/* ==================== Reset & Base ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #4f6ef7;
    --primary-hover: #3b5de7;
    --primary-light: #eef1ff;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --success: #27ae60;
    --warning: #f39c12;
    --bg: #f5f6fa;
    --surface: #ffffff;
    --border: #e2e5ee;
    --text: #2c3e50;
    --text-secondary: #7f8c9b;
    --text-muted: #b0b8c4;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 0.2s ease;
    --sidebar-width: 260px;
    --header-height: 56px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== Header ==================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.storage-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== Layout ==================== */
.main-container {
    display: flex;
    padding-top: var(--header-height);
    min-height: 100vh;
}

/* ==================== Sidebar ==================== */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 16px;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-section {
    margin-bottom: 16px;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* Storage Bar */
.storage-bar-container {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.storage-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #8b9cf7);
    border-radius: 3px;
    transition: width 0.5s ease;
    max-width: 100%;
}

.storage-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.storage-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

.storage-row span:last-child {
    font-weight: 500;
    color: var(--text);
}

/* ==================== Content ==================== */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-width: 0;
}

/* ==================== Toolbar ==================== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    font-size: 14px;
}

.breadcrumb-item {
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
}

.breadcrumb-item:hover {
    background: var(--primary-light);
}

.breadcrumb-separator {
    color: var(--text-muted);
    margin: 0 2px;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    gap: 8px;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

.search-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: var(--text);
    width: 180px;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
    text-decoration: none;
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 110, 247, 0.3);
}

.btn-primary:disabled {
    background: #a0b0f8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn-icon {
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
}

.btn-icon:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* ==================== File List ==================== */
.file-list-container {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.file-row {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 48px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.file-row:not(.file-header):hover {
    background: #f8f9fd;
}

.file-row:last-child {
    border-bottom: none;
}

.file-header {
    background: #fafbfc;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
}

.file-col {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.file-col-name {
    flex: 1;
    min-width: 0;
}

.file-col-size {
    width: 110px;
    justify-content: flex-end;
    text-align: right;
}

.file-col-date {
    width: 170px;
    justify-content: flex-end;
    text-align: right;
}

.file-col-actions {
    width: 100px;
    justify-content: flex-end;
    gap: 4px;
}

.file-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.file-name {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    color: var(--text);
    font-weight: 500;
}

.file-name:hover {
    color: var(--primary);
}

.file-name.folder {
    color: var(--primary);
    font-weight: 600;
}

.file-row .file-col-size,
.file-row .file-col-date {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Action buttons in rows */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    color: var(--text-secondary);
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

.action-btn:hover {
    background: var(--bg);
}

.action-btn.download:hover {
    color: var(--primary);
}

.action-btn.delete:hover {
    color: var(--danger);
}

.action-btn.preview:hover {
    color: var(--success);
}

/* ==================== Loading & States ==================== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state, .error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon, .error-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-title, .error-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.empty-desc, .error-desc {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ==================== Modal ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s ease;
}

.modal-small {
    max-width: 400px;
}

.modal-large {
    max-width: 700px;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    transition: var(--transition);
    background: #fafbfc;
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.drop-zone-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.drop-zone-text {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.drop-zone-divider {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Upload List */
.upload-list {
    margin-top: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.upload-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    margin-bottom: 6px;
    font-size: 13px;
}

.upload-file-item .file-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-file-item .file-size {
    color: var(--text-secondary);
    margin-left: 12px;
    flex-shrink: 0;
}

.upload-file-item .remove-file {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 16px;
    border-radius: var(--radius-sm);
}

.upload-file-item .remove-file:hover {
    color: var(--danger);
    background: rgba(231,76,60,0.1);
}

/* Progress Bar */
.upload-progress {
    margin-top: 16px;
}

.progress-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #63b3ed);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Confirm Modal */
.confirm-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 12px;
}

.confirm-text {
    text-align: center;
    font-size: 15px;
    margin-bottom: 6px;
}

.confirm-warning {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* Preview */
.preview-body {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-body img {
    max-width: 100%;
    max-height: 60vh;
    border-radius: var(--radius-sm);
}

.preview-body pre {
    width: 100%;
    max-height: 60vh;
    overflow: auto;
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.preview-body .unsupported {
    text-align: center;
    color: var(--text-secondary);
}

.preview-body .unsupported-icon {
    font-size: 64px;
    margin-bottom: 12px;
}

/* ==================== Toast ==================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: 14px;
    min-width: 280px;
    max-width: 420px;
    animation: toastIn 0.3s ease;
    border-left: 4px solid var(--border);
}

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    padding: 2px;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .content {
        margin-left: 0;
        padding: 16px;
    }

    .file-col-size,
    .file-col-date {
        display: none;
    }

    .file-header .file-col-size,
    .file-header .file-col-date {
        display: none;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions {
        flex-wrap: wrap;
    }

    .search-box input {
        width: 120px;
    }

    .header {
        padding: 0 16px;
    }

    .modal {
        width: 95%;
        max-height: 90vh;
    }
}

/* ==================== Drag & Drop Overlay ==================== */
body.drag-over::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(79, 110, 247, 0.08);
    border: 3px dashed var(--primary);
    z-index: 999;
    pointer-events: none;
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
