@import url('variables.css');

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    font-size: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ===== LAYOUT ===== */
.app {
    display: flex;
    height: 100vh;
}

/* === Info slide-in panel (from right) === */
.info-slide-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.info-slide-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
/* Info slide panel — home card style (floating, rounded) */
.info-slide-panel {
    position: fixed;
    top: 20px; right: 20px; bottom: 20px;
    width: 400px;
    max-width: calc(100vw - 40px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(calc(100% + 40px));
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
.info-slide-panel.visible {
    transform: translateX(0);
}
.info-slide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 10px;
    flex-shrink: 0;
}
.info-slide-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: var(--color-text);
}
.info-slide-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
/* Preview = card cover style */
.info-slide-content .file-info-preview {
    width: 100%;
    aspect-ratio: 1.3;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-bottom: 0;
}
.info-slide-content .file-info-preview img,
.info-slide-content .file-info-preview video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.info-slide-content .file-info-preview svg {
    width: 72px;
    height: 72px;
}
/* Name block */
.info-slide-content .file-info-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    word-break: break-word;
    padding: 0 4px;
    margin: 0;
    line-height: 1.3;
}
/* Info rows — grouped in a card */
.info-slide-content .file-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    font-size: 13px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin-bottom: 0;
}
.info-slide-content .file-info-row + .file-info-row { margin-top: 4px; }
.info-slide-content .file-info-label {
    color: var(--color-text-tertiary);
    font-weight: 500;
}
@media (max-width: 480px) {
    .info-slide-panel {
        top: 12px; right: 12px; bottom: 12px;
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        transform: translateX(calc(100% + 24px));
    }
}

/* === No-sidebar layout (matches home-page visually) === */
body.no-sidebar-layout {
    overflow: auto !important;
    height: auto !important;
    min-height: 100vh;
}
html:has(body.no-sidebar-layout) {
    height: auto;
    overflow: auto;
}
.app-no-sidebar {
    display: block;
    width: 100%;
    min-height: 100vh;
    background: var(--color-bg);
}
.app-no-sidebar .main {
    width: 100%;
    height: auto;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    background: transparent;
    display: block;
    overflow: visible;
}
.app-no-sidebar .main-body {
    display: block;
    overflow: visible;
    min-height: 0;
    padding-top: 0; /* header is in normal flow now */
    background: transparent;
}
.no-sidebar-layout .sidebar,
.no-sidebar-layout .sidebar-overlay,
.no-sidebar-layout .file-info-panel {
    display: none !important;
}
.no-sidebar-layout .btn-sidebar-toggle {
    display: flex !important;
    color: var(--color-primary);
}
.no-sidebar-layout .header {
    padding-right: 180px; /* make room for global corner (theme + avatar + logout) */
}

/* Global logo — top center, visible on all pages */
.global-logo {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    z-index: 30;
    text-decoration: none;
    transition: transform 0.2s;
}
.global-logo:hover { transform: translateX(-50%) scale(1.08); text-decoration: none; }

/* On the home page (/), hide the global logo since it's already in the page */
body:has(.home-page) .global-logo { display: none; }

/* Global user corner (all pages) — not fixed, flows at top right of header */
.global-user-corner {
    position: absolute;
    top: 14px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 50;
}
.global-corner-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.global-corner-btn:hover {
    color: var(--color-text);
    transform: scale(1.05);
    text-decoration: none;
}
.global-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    border: 2px solid var(--color-surface);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-decoration: none;
}
.global-user-avatar:hover {
    transform: scale(1.05);
    text-decoration: none;
    color: white;
}

@media (max-width: 768px) {
    .global-user-corner {
        top: 8px;
        right: 8px;
        gap: 4px;
    }
    .global-corner-btn,
    .global-user-avatar {
        width: 32px;
        height: 32px;
    }
    .no-sidebar-layout .header {
        padding-right: 180px;
    }
}
@media (max-width: 480px) {
    .global-user-corner {
        gap: 3px;
    }
    .global-corner-btn,
    .global-user-avatar {
        width: 30px;
        height: 30px;
    }
    .no-sidebar-layout .header {
        padding-right: 140px;
    }
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    border: none !important;
    border-right: none !important;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s ease;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    pointer-events: none;
}

/* Prevent sidebar flash on page load when collapsed */
html.sidebar-start-collapsed .sidebar {
    width: 0;
    min-width: 0;
    opacity: 0;
    pointer-events: none;
    transition: none;
}

.btn-sidebar-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--color-text-secondary);
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
}

.btn-sidebar-toggle:hover {
    color: var(--color-text);
    background: var(--color-hover);
    border-color: var(--color-border);
}

.btn-sidebar-toggle:active {
    transform: scale(0.92);
}

.btn-sidebar-toggle .sidebar-icon-bar {
    display: block;
    width: 16px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
}

.btn-sidebar-toggle .bar-1 { transform: translateY(-5px); width: 16px; }
.btn-sidebar-toggle .bar-2 { width: 12px; }
.btn-sidebar-toggle .bar-3 { transform: translateY(5px); width: 16px; }

.btn-sidebar-toggle:hover .bar-2 { width: 16px; }

/* Animate to X when sidebar is open (mobile) */
.btn-sidebar-toggle.is-open .bar-1 { transform: rotate(45deg); width: 16px; }
.btn-sidebar-toggle.is-open .bar-2 { opacity: 0; width: 0; }
.btn-sidebar-toggle.is-open .bar-3 { transform: rotate(-45deg); width: 16px; }

#info-toggle-btn.active {
    color: var(--color-primary);
    background: var(--color-primary-light);
    border-radius: var(--radius-sm);
}

.sidebar-logo {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}

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

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition-fast);
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.sidebar-nav-item:hover {
    background: var(--color-surface-hover);
    text-decoration: none;
}

.sidebar-nav-item.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.sidebar-nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 12px 6px;
}

/* Storage bar */
.sidebar-storage {
    padding: 20px;
    margin: 0 12px 8px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    text-align: center;
}

.storage-plan-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 4px;
}

.storage-upgrade-hint {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-primary);
    margin-top: 8px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.sidebar-storage:hover .storage-upgrade-hint {
    opacity: 1;
}

.storage-plan-quota {
    font-size: 32px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
    margin-bottom: 12px;
}

.storage-bar {
    height: 4px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.storage-bar-fill.warning {
    background: var(--color-warning);
}

.storage-bar-fill.danger {
    background: var(--color-danger);
}

.storage-text {
    font-size: 11px;
    color: var(--color-text-tertiary);
    margin-top: 8px;
}

/* User menu */
.sidebar-user {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--color-text-tertiary);
}

/* ===== MAIN CONTENT ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.main-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

.main-body > .content {
    flex: 1;
    min-width: 0;
}

/* Header — normal flow (scrolls with content), only pill is fixed */
.header {
    position: relative;
    height: auto;
    background: transparent;
    display: flex;
    align-items: center;
    padding: 14px 16px;
    gap: 12px;
    z-index: 5;
}
.header > .search-bar { display: none !important; }
.header > div[style*="flex:1"] { display: none !important; }
.header > .btn-sidebar-toggle {
    flex-shrink: 0;
    display: flex !important;
}
.header > .breadcrumb {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-weight: 700;
    font-size: 15px;
    margin-right: auto;
}
.header > .breadcrumb .breadcrumb-item {
    color: var(--color-text);
    font-weight: 700;
    font-size: 15px;
}

/* Actions pill — centered inside top header */
.header-actions {
    position: fixed;
    left: 50%;
    top: 14px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    z-index: 40;
}
.header-actions .btn-icon,
.header-actions .sort-dropdown,
.header-actions .view-toggle {
    position: relative;
    z-index: 1;
}
.header-actions .btn-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
}
.header-actions .btn-icon:hover {
    background: var(--color-hover);
    color: var(--color-text);
}
.header-actions .view-toggle {
    display: flex;
    gap: 2px;
    border-radius: 9px;
    background: transparent;
    padding: 0;
    border: none;
}
.header-actions .view-toggle button {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.header-actions .view-toggle button.active {
    background: var(--color-hover);
    color: var(--color-text);
}
.header-actions .view-toggle button:hover:not(.active) {
    background: var(--color-hover);
    color: var(--color-text);
}
/* Divider pseudo-element before Dossier button */
.header-actions .header-divider {
    width: 1px;
    height: 22px;
    background: var(--color-border);
    margin: 0 4px;
    align-self: center;
}
.header-actions .btn {
    border-radius: 10px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
}
.header-actions .btn-secondary {
    background: transparent;
    border: none;
    color: var(--color-text);
}
.header-actions .btn-secondary:hover {
    background: var(--color-hover);
}
.header-actions .btn-primary {
    background: var(--color-primary);
    color: white;
    border: none;
}
.header-actions .btn-primary:hover {
    background: #0066d6;
}

/* Responsive header */
@media (max-width: 900px) {
    .header {
        gap: 8px;
        padding: 10px 12px;
    }
    .header-actions {
        padding: 4px;
        gap: 1px;
    }
    .header-actions .btn-icon {
        width: 30px;
        height: 30px;
    }
    .header-actions .btn span {
        display: none;
    }
    .header-actions .btn svg {
        margin: 0 !important;
    }
    .header-actions .btn {
        padding: 6px 8px;
    }
}
@media (max-width: 600px) {
    .header-actions .view-toggle,
    .header-actions #theme-toggle,
    .header-actions #info-toggle-btn {
        display: none !important;
    }
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 1;
    min-width: 0;
    max-width: calc(50vw - 280px); /* stay clear of centered pill */
    overflow: hidden;
}
.breadcrumb .breadcrumb-item {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}
@media (max-width: 900px) {
    .breadcrumb { max-width: calc(100vw - 460px); }
    .breadcrumb .breadcrumb-item { max-width: 120px; }
}
@media (max-width: 600px) {
    .breadcrumb .breadcrumb-item:not(.current) { display: none; }
    .breadcrumb .breadcrumb-separator { display: none; }
}

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

.breadcrumb-item {
    font-size: 13px;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-xs);
    transition: background var(--transition-fast);
    white-space: nowrap;
}

.breadcrumb-item:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
}

.breadcrumb-item.current {
    color: var(--color-text);
    font-weight: 600;
    cursor: default;
}

.breadcrumb-item.current:hover {
    background: none;
}

.breadcrumb-separator {
    color: var(--color-text-tertiary);
    font-size: 12px;
}

/* Search */
.search-bar {
    flex: 1;
    max-width: 420px;
    min-width: 0;
    margin: 0 auto;
    z-index: 1;
}

.search-bar input {
    width: 100%;
    padding: 9px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    font-size: 13px;
    color: var(--color-text);
    transition: all var(--transition-fast);
    outline: none;
}

.search-bar input:focus {
    border-color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
    max-width: 480px;
}

.search-bar input::placeholder {
    color: var(--color-text-tertiary);
}

.search-bar > svg {
    display: none;
}

/* Header actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.header-actions .btn-icon {
    padding: 6px 8px;
    border-radius: 6px;
}

.header-actions .btn-sm {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
}

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

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

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

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

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

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

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

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

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
}

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

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

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

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

/* ===== FILE BROWSER ===== */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* View toggle */
.view-toggle {
    display: flex;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.view-toggle-btn {
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.view-toggle-btn.active {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-xs);
}

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

/* Grid view — HOME-STYLE CARDS */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.file-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 14px;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), box-shadow 0.3s, border-color 0.2s;
    text-align: center;
    overflow: hidden;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    will-change: transform;
}

.file-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.file-card.selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary);
}

/* Cover zone (light background, icon/thumbnail inside) */
.file-card-icon {
    width: 100%;
    aspect-ratio: 1.3;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f7;
    border-radius: 14px;
    overflow: hidden;
}
[data-theme="dark"] .file-card-icon {
    background: #1e1e20;
}

.file-card-icon svg {
    width: 56px;
    height: 56px;
    display: block;
}

/* Folder card */
.folder-card-icon {
    width: 100%;
    aspect-ratio: 1.3;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f7;
    border-radius: 14px;
    --folder-color: #3B82F6;
    transition: background 0.2s;
}
[data-theme="dark"] .folder-card-icon {
    background: #1e1e20;
}

.folder-card-icon svg {
    width: 72px;
    height: 60px;
    filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.25));
    transition: transform 0.2s;
}

.file-card:hover .folder-card-icon svg {
    transform: scale(1.08);
}
.file-card:hover .folder-card-icon {
    background: rgba(59,130,246,0.08);
}

/* Image thumbnail */
.file-card-thumb {
    width: 100%;
    aspect-ratio: 1.3;
    margin: 0;
    overflow: hidden;
    background: #f5f5f7;
    border-radius: 14px;
    position: relative;
}
[data-theme="dark"] .file-card-thumb {
    background: #1e1e20;
}

.file-card-thumb img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.file-card-thumb > svg {
    display: none;
}

.file-card-name {
    font-size: 13px;
    font-weight: 700;
    word-break: break-word;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--color-text);
    padding: 0 4px;
}

.file-card-meta {
    font-size: 11px;
    color: var(--color-text-tertiary);
    padding: 0 4px 2px;
}

/* List view */
.file-list {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.file-list-header {
    display: grid;
    grid-template-columns: 1fr 100px 140px 60px;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
}

.file-list-header span:hover {
    color: var(--color-text-secondary);
}

.file-list-row {
    display: grid;
    grid-template-columns: 1fr 100px 140px 60px;
    padding: 10px 16px;
    align-items: center;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--color-border-light);
}

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

.file-list-row:hover {
    background: var(--color-bg);
}

.file-list-row.selected {
    background: var(--color-primary-light);
}

.file-list-name {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.file-list-name svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.file-list-name span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}

.file-list-size, .file-list-date {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.file-list-actions {
    display: flex;
    justify-content: flex-end;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--color-text-tertiary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.empty-state-text {
    font-size: 13px;
}

/* ===== DRAG & DROP OVERLAY ===== */
.drop-zone {
    position: relative;
}

.drop-zone.drag-over::after {
    content: 'Glissez vos fichiers ici';
    position: absolute;
    inset: 0;
    background: rgba(0, 122, 255, 0.08);
    border: 2px dashed var(--color-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
    color: var(--color-primary);
    z-index: 10;
    pointer-events: none;
}

/* ===== UPLOAD PROGRESS ===== */
.upload-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 360px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: var(--z-modal);
    display: none;
}

.upload-panel.visible {
    display: block;
}

.upload-panel-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 13px;
    font-weight: 600;
}

.upload-panel-list {
    max-height: 240px;
    overflow-y: auto;
}

.upload-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--color-border-light);
}

.upload-item:last-child {
    border-bottom: none;
}

.upload-item-name {
    flex: 1;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-item-progress {
    width: 60px;
    height: 3px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.upload-item-progress-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: width 0.1s linear;
}

.upload-item-status {
    font-size: 11px;
    color: var(--color-text-tertiary);
    width: 40px;
    text-align: right;
}

.upload-item-status.success {
    color: var(--color-success);
}

.upload-item-status.error {
    color: var(--color-danger);
}

/* ===== MODAL ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    will-change: opacity;
    transform: translateZ(0);
}

.modal-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-normal);
    will-change: transform;
}

.modal-backdrop.visible .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 20px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.modal-close {
    color: var(--color-text-tertiary);
    padding: 4px;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
}

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

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 0 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--color-text);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.form-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--color-text);
    outline: none;
    cursor: pointer;
}

/* ===== CONTEXT MENU ===== */
.context-menu {
    position: fixed;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 200px;
    z-index: var(--z-context-menu);
    display: none;
}

.context-menu.visible {
    display: block;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--color-text);
    width: 100%;
    text-align: left;
    transition: background var(--transition-fast);
}

.context-menu-item:hover {
    background: var(--color-bg);
}

.context-menu-item.danger {
    color: var(--color-danger);
}

.context-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.context-menu-separator {
    height: 1px;
    background: var(--color-border-light);
    margin: 4px 6px;
}

/* ===== PREVIEW OVERLAY ===== */
.preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: var(--z-modal);
    display: none;
    flex-direction: column;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.preview-overlay.visible {
    display: flex;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    color: white;
}

.preview-filename {
    font-size: 14px;
    font-weight: 500;
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.preview-actions button {
    color: rgba(255,255,255,0.7);
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.08);
    transition: all var(--transition-fast);
}

.preview-actions button:hover {
    color: white;
    background: rgba(255,255,255,0.15);
}

.preview-actions button svg {
    width: 20px;
    height: 20px;
}

.preview-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: auto;
}

.preview-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.preview-content video {
    max-width: 90%;
    max-height: 85%;
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.preview-content audio {
    max-width: 100%;
    max-height: 100%;
}

.preview-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    border-radius: var(--radius-sm);
}

.preview-content pre {
    background: var(--color-surface);
    color: #d4d4d4;
    padding: 24px;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 13px;
    max-width: 900px;
    width: 100%;
    max-height: 100%;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.video-thumb {
    position: relative;
    background: linear-gradient(135deg, #1e1e20 0%, #2a2a2e 100%);
}
[data-theme="light"] .video-thumb {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
}

.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 50%;
    backdrop-filter: blur(4px);
    height: 48px;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: all var(--transition-fast);
}

.file-card:hover .video-play-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.video-play-icon svg {
    margin-left: 3px;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: var(--z-toast);
}

.toast {
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 400px;
    animation: toastIn 0.3s ease forwards;
    border-left: 3px solid var(--color-primary);
}

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

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

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

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

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

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

/* ===== LOGIN PAGE ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg);
    overflow: auto;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    margin: 20px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo svg {
    width: 48px;
    height: 48px;
    color: var(--color-primary);
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 600;
    margin-top: 12px;
}

.login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--color-danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form .btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
}

/* ===== SHARE PUBLIC PAGE ===== */
.share-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg);
    overflow: auto;
}

.share-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    margin: 20px;
    text-align: center;
}

.share-card-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-light);
    border-radius: var(--radius-lg);
}

.share-card-icon svg {
    width: 36px;
    height: 36px;
    color: var(--color-primary);
}

.share-card-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-word;
}

.share-card-meta {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.share-card-owner {
    font-size: 12px;
    color: var(--color-text-tertiary);
    margin-bottom: 24px;
}

/* ===== ADMIN ===== */
.admin-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    padding: 0 24px;
    background: var(--color-surface);
}

.admin-tab {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.admin-tab:hover {
    color: var(--color-text);
}

.admin-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-xs);
}

.stat-card-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-border);
}

.data-table td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--color-border-light);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--color-bg);
}

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
}

.badge-admin {
    background: #fef3c7;
    color: #92400e;
}

.badge-user {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.badge-active {
    background: #d1fae5;
    color: #065f46;
}

.badge-suspended {
    background: #fef2f2;
    color: #991b1b;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px;
}

.pagination-btn {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

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

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

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 100;
        transition: left var(--transition-normal);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 99;
        display: none;
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .header {
        padding: 0 16px;
    }

    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }

    .content {
        padding: 16px;
    }

    .upload-panel {
        width: calc(100% - 32px);
        left: 16px;
        right: 16px;
    }

    .modal {
        margin: 16px;
    }

    .btn-mobile-menu {
        display: flex;
    }
}

@media (min-width: 769px) {
    .btn-mobile-menu {
        display: none;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* ===== FOLDER TREE (for move dialog) ===== */
.folder-tree {
    max-height: 300px;
    overflow-y: auto;
}

.folder-tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition-fast);
}

.folder-tree-item:hover {
    background: var(--color-bg);
}

.folder-tree-item.selected {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.folder-tree-item svg {
    width: 18px;
    height: 18px;
    color: var(--color-warning);
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}

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

/* ===== LOADING ===== */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.loading-center {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

/* ===== ANIMATIONS ===== */
.file-card {
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
}

.file-list-row {
    animation: fadeInUp 0.2s ease forwards;
    opacity: 0;
}

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

.file-grid .file-card:nth-child(1) { animation-delay: 0.02s; }
.file-grid .file-card:nth-child(2) { animation-delay: 0.04s; }
.file-grid .file-card:nth-child(3) { animation-delay: 0.06s; }
.file-grid .file-card:nth-child(4) { animation-delay: 0.08s; }
.file-grid .file-card:nth-child(5) { animation-delay: 0.10s; }
.file-grid .file-card:nth-child(6) { animation-delay: 0.12s; }
.file-grid .file-card:nth-child(7) { animation-delay: 0.14s; }
.file-grid .file-card:nth-child(8) { animation-delay: 0.16s; }
.file-grid .file-card:nth-child(n+9) { animation-delay: 0.18s; }

/* ===== BATCH ACTIONS BAR ===== */
.batch-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-xl);
    z-index: var(--z-modal);
    white-space: nowrap;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.batch-bar-count {
    font-size: 13px;
    font-weight: 600;
    padding-right: 12px;
    border-right: 1px solid rgba(255,255,255,0.2);
}

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

.batch-bar .btn {
    color: rgba(255,255,255,0.9);
    border-color: rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
}

.batch-bar .btn:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.batch-bar .btn-danger {
    border-color: var(--color-danger);
    color: var(--color-danger);
    background: rgba(255,59,48,0.1);
}

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

.batch-bar .btn svg {
    width: 15px;
    height: 15px;
}

.batch-bar .btn-icon {
    color: rgba(255,255,255,0.5);
}

.batch-bar .btn-icon:hover {
    color: white;
    background: rgba(255,255,255,0.15);
}

/* ===== FAVORITES ===== */
.favorite-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    color: white;
    opacity: 0;
    transition: all var(--transition-fast);
    z-index: 2;
}

.file-card:hover .favorite-btn {
    opacity: 1;
}

.favorite-btn.active {
    opacity: 1;
    color: #fbbf24;
    background: rgba(0,0,0,0.5);
}

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

/* file-card needs relative for favorites */
.file-card {
    position: relative;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    width: 40px;
    height: 22px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    position: relative;
    transition: background var(--transition-fast);
    border: none;
    padding: 0;
    flex-shrink: 0;
}

.theme-toggle::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .theme-toggle {
    background: var(--color-primary);
}

[data-theme="dark"] .theme-toggle::after {
    transform: translateX(18px);
}

/* ===== RECENT FILES SECTION ===== */
.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-title svg {
    width: 16px;
    height: 16px;
}

.recent-files-bar {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 20px;
}

.recent-file-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    cursor: pointer;
    white-space: nowrap;
    font-size: 12px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.recent-file-chip:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.recent-file-chip svg {
    width: 16px;
    height: 16px;
}

/* ===== UPLOAD DROPDOWN ===== */
.upload-dropdown {
    position: relative;
}

.upload-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 160px;
    z-index: var(--z-dropdown);
    display: none;
}

.upload-dropdown-menu.visible {
    display: block;
}

.upload-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 13px;
    width: 100%;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.upload-dropdown-item:hover {
    background: var(--color-surface-hover);
}

.upload-dropdown-item svg {
    flex-shrink: 0;
}

/* ===== SORT DROPDOWN ===== */
.sort-dropdown {
    position: relative;
}

.sort-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 180px;
    z-index: var(--z-dropdown);
    display: none;
}

.sort-dropdown-menu.visible {
    display: block;
}

.sort-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--color-text);
    cursor: pointer;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    transition: background var(--transition-fast);
}

.sort-option:hover {
    background: var(--color-bg);
}

.sort-option.active {
    color: var(--color-primary);
    font-weight: 600;
}

.sort-arrow {
    font-size: 11px;
    color: var(--color-text-tertiary);
}

/* ===== FILE INFO PANEL ===== */
.file-info-panel {
    width: 320px;
    background: var(--color-bg);
    overflow-y: auto;
    padding: 20px;
    flex-shrink: 0;
    display: none;
    flex-direction: column;
    transition: width var(--transition-normal), opacity var(--transition-normal);
    will-change: width, opacity;
    transform: translateZ(0);
}

.file-info-panel.visible {
    display: flex;
}

.file-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.file-info-preview {
    width: 100%;
    height: 200px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-bg);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-info-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.file-info-preview svg {
    width: 64px;
    height: 64px;
    color: var(--color-text-tertiary);
}

.file-info-name {
    font-size: 16px;
    font-weight: 600;
    word-break: break-word;
    margin-bottom: 16px;
}

.file-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--color-border-light);
}

.file-info-label {
    color: var(--color-text-secondary);
}

/* ===== DRAG & DROP ===== */
.file-card.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}

.file-card.drag-over-folder,
.sidebar-nav-item.drag-over-folder {
    outline: 2px dashed var(--color-primary);
    outline-offset: -2px;
    background: var(--color-primary-light);
    transform: scale(1.02);
    transition: all var(--transition-fast);
}

/* ===== PROFILE PAGE ===== */
.profile-container {
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--color-border);
}

.profile-hero {
    text-align: center;
    padding: 32px 24px;
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    margin: 0 auto 16px;
}

.profile-hero-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.profile-hero-email {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.profile-stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    border: 1px solid var(--color-border);
    text-align: center;
}

.profile-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.profile-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.profile-stat-label {
    font-size: 12px;
    color: var(--color-text-tertiary);
}

.profile-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 16px;
}

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

/* ===== ADMIN IMPROVEMENTS ===== */
.admin-section-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.admin-section-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.admin-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.table-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.data-table-wrap {
    overflow-x: auto;
}

.activity-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.pagination-dots {
    padding: 6px 4px;
    color: var(--color-text-tertiary);
    font-size: 12px;
}

/* ===== SETTINGS PAGE ===== */
.settings-container {
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--color-border);
}

.settings-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.settings-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

.settings-row {
    display: flex;
    gap: 16px;
}

.form-hint {
    display: block;
    font-size: 11px;
    color: var(--color-text-tertiary);
    margin-top: 4px;
}

/* ===== LOGIN ERROR FLEX ===== */
.login-error {
    display: flex;
    align-items: center;
}

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 768px) {
    .header {
        padding: 10px 12px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .header-actions {
        gap: 6px;
    }

    .header-actions .btn span,
    .header-actions .btn:not(.btn-icon) {
        font-size: 0;
        padding: 8px;
    }

    .header-actions .btn svg {
        margin: 0;
    }

    .search-bar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 56px;
        z-index: 150;
        background: var(--color-bg);
        padding: 8px 16px;
        align-items: center;
        margin: 0;
    }

    .search-bar.mobile-active {
        display: flex;
    }

    .breadcrumb {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

    .file-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        padding: 10px !important;
    }

    .file-card {
        padding: 8px !important;
    }

    .file-card-name {
        font-size: 11px !important;
    }

    .file-card-meta {
        font-size: 10px !important;
    }

    .file-card-thumb {
        height: 90px !important;
    }

    .file-card-icon svg {
        width: 32px !important;
        height: 32px !important;
    }

    .file-list-row {
        font-size: 12px;
    }

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

    .batch-bar {
        padding: 8px 12px;
        gap: 8px;
        font-size: 12px;
    }

    .batch-bar .btn {
        font-size: 0;
        padding: 8px;
    }

    .batch-bar .btn svg {
        margin: 0;
    }

    .preview-content video {
        max-width: 100%;
        max-height: 80%;
        border-radius: 12px;
    }

    .preview-header {
        padding: 12px 16px;
    }

    .profile-container {
        padding: 0 !important;
    }

    .profile-stats {
        grid-template-columns: 1fr;
    }

    .settings-row {
        flex-direction: column;
        gap: 0;
    }

    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .file-info-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100% !important;
        z-index: var(--z-modal);
    }

    .sort-dropdown-menu {
        right: -40px;
    }

    /* Login mobile */
    .login-card {
        padding: 32px 24px;
        margin: 16px;
    }

    /* Sidebar toggle hamburger */
    .btn-sidebar-toggle {
        display: flex;
    }

    /* Workspaces grid */
    .ws-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .ws-card { padding: 16px; }
    .ws-card-icon { width: 38px; height: 38px; border-radius: 10px; font-size: 15px; }
    .ws-card-footer { flex-wrap: wrap; gap: 8px; }

    /* Shared page */
    .shared-tabs {
        max-width: 100%;
    }
    .shared-tab {
        padding: 8px 12px;
        font-size: 12px;
        gap: 6px;
    }
    .shared-tab svg { display: none; }
    .shared-ws-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .shared-ws-card { padding: 14px; gap: 12px; }
    .shared-ws-icon { width: 40px; height: 40px; border-radius: 10px; font-size: 15px; }
    .shared-ws-name { font-size: 14px; }
    .shared-file-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .shared-file-card { padding: 14px 12px 12px; }
    .shared-card-icon { width: 44px; height: 44px; border-radius: 10px; margin-bottom: 8px; }
    .shared-card-name { font-size: 12px; }
    .shared-file-row { padding: 10px 12px; gap: 10px; }
    .shared-file-name { font-size: 13px; }
    .shared-file-detail span:nth-child(n+3) { display: none; }
    .shared-file-badges { gap: 4px; }

    /* Admin */
    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .stat-card { padding: 16px; }
    .stat-card-value { font-size: 24px; }

    /* Data table responsive */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .data-table th,
    .data-table td {
        padding: 10px 12px;
        font-size: 12px;
        white-space: nowrap;
    }

    /* Profile */
    .profile-container {
        padding: 0 !important;
    }
    .profile-stats {
        grid-template-columns: 1fr;
    }
    .profile-card { padding: 20px; }

    /* Modal */
    .modal {
        margin: 12px;
        max-height: calc(100vh - 24px);
    }
    .modal-body { padding: 16px; }
    .modal-footer { padding: 12px 16px; }

    /* Toast */
    .toast {
        left: 12px !important;
        right: 12px !important;
        max-width: none !important;
    }

    /* Context menu */
    .context-menu {
        min-width: 180px;
    }

    /* Upload panel */
    .upload-panel {
        width: calc(100% - 24px);
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    /* Breadcrumb */
    .breadcrumb-item:not(.current) {
        display: none;
    }
    .breadcrumb-separator {
        display: none;
    }
    .breadcrumb-item.current {
        font-size: 14px;
    }

    /* Settings admin */
    .settings-card {
        padding: 16px;
    }
    .settings-row {
        flex-direction: column;
        gap: 8px;
    }
    .settings-row label {
        min-width: auto;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 4px;
    }
    .pagination-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .file-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .view-toggle {
        display: none;
    }

    .header-actions .sort-dropdown,
    .header-actions #theme-toggle {
        display: none;
    }

    /* Login */
    .login-card {
        padding: 28px 20px;
        margin: 12px;
        border-radius: 16px;
    }
    .login-logo h1 { font-size: 20px; }
    .login-logo p { font-size: 12px; }
    .login-bg-1 { width: 250px; height: 250px; }
    .login-bg-2 { width: 180px; height: 180px; }

    /* Profile */
    .profile-container { gap: 12px; }
    .profile-card { padding: 16px; }
    .profile-hero { padding: 20px 16px; }
    .profile-avatar-large { width: 60px; height: 60px; font-size: 24px; }
    .profile-hero-name { font-size: 18px; }
    .profile-hero-email { font-size: 12px; }
    .profile-stats { grid-template-columns: 1fr !important; }
    .profile-stat-value { font-size: 20px; }

    /* Admin */
    .admin-stats { grid-template-columns: 1fr !important; }
    .stat-card { padding: 14px; }
    .stat-card-value { font-size: 22px; }

    /* Shared */
    .shared-tabs { flex-direction: column; max-width: 100%; }
    .shared-tab { padding: 8px 12px; font-size: 12px; }
    .shared-ws-grid { grid-template-columns: 1fr !important; }
    .shared-file-grid { grid-template-columns: 1fr !important; }
    .shared-file-row { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
    .shared-file-badges { width: 100%; justify-content: flex-start; }
    .shared-file-actions { width: 100%; justify-content: flex-end; }

    /* Workspaces */
    .ws-grid { grid-template-columns: 1fr !important; }
    .ws-card { padding: 16px; }
    .ws-card-name { font-size: 14px; }
    .ws-card-desc { font-size: 11px; }
    .ws-card-actions { display: flex !important; }

    /* Sidebar */
    .sidebar-logo span { display: none; }
    .sidebar-user-info { display: none; }
}

/* ===== TABLET (1024px) ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
        min-width: 200px;
    }
    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .shared-file-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* ===== TOUCH-FRIENDLY ===== */
@media (hover: none) and (pointer: coarse) {
    .btn-icon { min-width: 40px; min-height: 40px; }
    .sidebar-nav-item { padding: 10px 14px; }
    .file-list-row { padding: 12px 14px; }
    .ws-card-actions { display: flex !important; }
    .shared-card-actions { display: flex !important; }
    .context-menu-item { padding: 10px 16px; }
}

/* ===== DARK MODE ADJUSTMENTS ===== */
[data-theme="dark"] .login-card,
[data-theme="dark"] .share-card {
    background: var(--color-surface);
}

[data-theme="dark"] .login-error {
    background: #3b1a1a;
    border-color: #7f1d1d;
}

[data-theme="dark"] .badge-admin {
    background: #78350f;
    color: #fef3c7;
}

[data-theme="dark"] .badge-active {
    background: #064e3b;
    color: #d1fae5;
}

[data-theme="dark"] .badge-suspended {
    background: #7f1d1d;
    color: #fef2f2;
}

[data-theme="dark"] .batch-bar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

[data-theme="dark"] .stat-card-icon[style*="background:#dbeafe"] {
    background: #1e3a5f !important;
}

[data-theme="dark"] .settings-card-icon[style*="background:#d1fae5"] {
    background: #064e3b !important;
}

[data-theme="dark"] .profile-stat-icon[style*="background:#d1fae5"] {
    background: #064e3b !important;
}

[data-theme="dark"] .preview-content pre {
    background: #111;
}

/* ===== MOBILE SEARCH TOGGLE ===== */
.btn-mobile-search {
    display: none !important;
    padding: 6px 8px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.btn-mobile-search:hover {
    background: var(--color-hover);
    color: var(--color-text);
}

@media (max-width: 768px) {
    .btn-mobile-search {
        display: flex !important;
    }
    .header .search-bar {
        display: none;
    }
    .header .search-bar.mobile-active {
        display: flex;
    }
}
