/* ============================================
   3D Catalog - Main Stylesheet
   Theme: Blue (from ZippyStarter)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================
   SHADCN/UI DESIGN TOKENS - Blue Theme
   Converted from oklch to hex
   ============================================ */
:root {
    --header-height: 64px;

    /* Background Scale */
    --background: #ffffff;
    --foreground: #09090b;
    --card: #ffffff;
    --card-foreground: #09090b;
    --popover: #ffffff;
    --popover-foreground: #09090b;
    
    /* Muted Scale */
    --muted: #f4f4f5;
    --muted-foreground: #71717a;
    --secondary: #f4f4f5;
    --secondary-foreground: #27272a;
    
    /* Accent - Blue Theme */
    --primary: #3b82f6;
    --primary-foreground: #f0f9ff;
    --accent: #eff6ff;
    --accent-foreground: #1e3a8a;
    
    /* Utility Colors */
    --destructive: #dc2626;
    --destructive-foreground: #ffffff;
    --success: #10b981;
    --success-foreground: #ffffff;
    --warning: #f59e0b;
    --warning-foreground: #09090b;
    
    /* Border & Input */
    --border: #e4e4e7;
    --input: #e4e4e7;
    --ring: #3b82f6;
    
    /* Radius Scale (from theme) */
    --radius-sm: 0.375rem;
    --radius-md: 0.625rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Legacy compatibility */
    --gray-50: #fafafa;
    --gray-100: #f4f4f5;
    --gray-200: #e5e5e5;
    --gray-300: #d4d4d4;
    --gray-400: #a3a3a3;
    --gray-500: #737373;
    --gray-600: #525252;
    --gray-700: #404040;
    --gray-800: #262626;
    --gray-900: #171717;
    --primary-dark: #2563eb;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--foreground);
    line-height: 1.6;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* Loading progress bar */
#loadingBar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 9999;
    background: transparent;
    transition: opacity 0.4s ease;
}

#loadingBar.done {
    opacity: 0;
    pointer-events: none;
}

#loadingBarFill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 8px rgb(59 130 246 / 0.6);
}

/* Header */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    color: var(--foreground);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
    /* Desktop: sticky */
    position: sticky;
    top: 0;
    z-index: 200;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.header-actions a {
    color: var(--primary-foreground);
    text-decoration: none;
    padding: 0.5rem 1rem;
    background: var(--primary);
    border-radius: var(--radius-md);
    margin-left: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 1px 2px 0 rgb(8 145 178 / 0.1);
}

.header-actions a:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 6px -1px rgb(8 145 178 / 0.2);
    transform: translateY(-1px);
}

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

/* Sidebar — sticky on desktop */
.sidebar {
    width: 280px;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 1.25rem;
    overflow-y: auto;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    align-self: flex-start;
}

.sidebar h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--muted-foreground);
    margin-bottom: 0.75rem;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.search-box {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    background: var(--background);
    transition: all 0.2s ease;
}

.search-box:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgb(8 145 178 / 0.1);
}

.folder-tree {
    font-size: 0.875rem;
}

.folder-tree ul {
    list-style: none;
}

.folder-tree li {
    margin: 0.25rem 0;
}

.folder-tree .folder-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.625rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

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

.folder-tree .folder-item.active {
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: 0 1px 3px 0 rgb(8 145 178 / 0.2);
}

.folder-tree .folder-icon {
    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
    opacity: 0.7;
}

.folder-tree .folder-toggle {
    width: 16px;
    height: 16px;
    margin-right: 0.25rem;
    cursor: pointer;
    text-align: center;
    font-size: 10px;
}

.folder-tree .folder-children {
    margin-left: 1rem;
    border-left: 1px solid var(--border);
    padding-left: 0.5rem;
}

.folder-tree .folder-icon {
    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
    opacity: 0.6;
    color: var(--muted-foreground);
}

.folder-tree .folder-toggle {
    width: 16px;
    height: 16px;
    margin-right: 0.25rem;
    cursor: pointer;
    text-align: center;
    font-size: 10px;
    color: var(--muted-foreground);
}

.folder-tree .folder-children.collapsed {
    display: none;
}

.folder-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.375rem;
    height: 1.375rem;
    padding: 0 0.35rem;
    background: var(--muted);
    color: var(--muted-foreground);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0;
    flex-shrink: 0;
    margin-left: auto;
    transition: all 0.15s ease;
}

.folder-item.active .folder-count-badge {
    background: rgb(255 255 255 / 0.2);
    color: var(--primary-foreground);
}

/* Content Area */
.content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: var(--background);
}

.content-header {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
}

.content-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.content-header .breadcrumb {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Gallery Controls */
.gallery-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

/* Sort Controls */
.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-controls label {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    font-weight: 500;
}

.sort-controls select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--card);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23737373' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    transition: all 0.2s ease;
}

.sort-controls select:hover {
    border-color: var(--gray-400);
}

.sort-controls select:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgb(8 145 178 / 0.1);
}

/* Grid Controls */
.grid-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.grid-controls label {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-right: 0.25rem;
    font-weight: 500;
}

.grid-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--input);
    background: var(--card);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.15s ease;
    color: var(--foreground);
}

.grid-btn:hover {
    background: var(--muted);
    border-color: var(--gray-400);
}

.grid-btn.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
    box-shadow: 0 1px 3px 0 rgb(8 145 178 / 0.2);
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* Empty State */
.gallery-grid:empty::before {
    content: 'Aucun fichier trouvé';
    grid-column: 1 / -1;
    padding: 3rem;
    text-align: center;
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

/* Grid sizes */
.gallery-grid.grid-small {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.gallery-grid.grid-small .file-card .info h4 {
    font-size: 0.75rem;
}

.gallery-grid.grid-small .file-card .info .path {
    font-size: 0.625rem;
}

.gallery-grid.grid-medium {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.gallery-grid.grid-large {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.25rem;
}

.gallery-grid.grid-large .file-card .info h4 {
    font-size: 0.9375rem;
}

.file-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
    transition: all 0.2s ease;
}

.file-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    border-color: var(--gray-300);
}

.file-card .preview {
    aspect-ratio: 1 / 1;
    background: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.file-card .preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-card .preview .no-preview {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    text-align: center;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

.file-card .preview .ref-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: rgb(0 0 0 / 0.55);
    color: #ffffff;
    backdrop-filter: blur(4px);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.2);
    font-family: 'Inter', monospace;
}

.file-card .preview .status-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.1);
}

.status-badge.preview_missing { 
    background: var(--warning); 
    color: var(--warning-foreground); 
}
.status-badge.preview_added { 
    background: var(--success); 
    color: var(--success-foreground); 
}
.status-badge.missing_from_scan { 
    background: var(--destructive); 
    color: var(--destructive-foreground); 
}
.status-badge.to_verify { 
    background: var(--primary); 
    color: var(--primary-foreground); 
}

.file-card .info {
    padding: 1rem;
    background: var(--card);
}

.file-card .info h4 {
    font-size: 0.9375rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    word-break: break-word;
    color: var(--foreground);
}

.file-card .info .path {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-bottom: 0.5rem;
}

.file-card .info .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.file-card .info .tag {
    background: var(--secondary);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    color: var(--secondary-foreground);
    font-weight: 500;
}

/* Gallery loading spinner */
.gallery-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6rem 0;
    grid-column: 1 / -1;
}

.spinner-svg {
    width: 48px;
    height: 48px;
    animation: spin 0.9s linear infinite;
}

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

/* Search highlight */
.search-highlight {
    background: #fef08a;
    color: #713f12;
    border-radius: 2px;
    padding: 0 1px;
    font-style: normal;
}

/* Lazy loading: placeholder while image not yet loaded */
img.lazy {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--muted);
    opacity: 0;
    display: block;
}

img.lazy-loaded {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Model Card Styles (Public Viewer) */
.model-card .model-name {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--foreground);
    line-height: 1.3;
}

.model-card .model-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.model-card .model-color {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.model-card .model-qty {
    background: var(--primary);
    color: var(--primary-foreground);
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.model-card .model-time {
    background: var(--secondary);
    color: var(--secondary-foreground);
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 500;
}

.model-card .full-path {
    font-size: 0.625rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
    word-break: break-all;
    line-height: 1.3;
}

/* Admin specific styles */
.admin-table {
    width: 100%;
    background: var(--card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

.admin-table table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    background: var(--muted);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    font-size: 0.75rem;
}

.admin-table td {
    font-size: 0.875rem;
    color: var(--foreground);
}

.admin-table tr:hover td {
    background: var(--muted);
}

/* Buttons - Shadcn/UI Style */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary { 
    background: var(--primary); 
    color: var(--primary-foreground);
    box-shadow: 0 1px 2px 0 rgb(8 145 178 / 0.1);
}
.btn-primary:hover { 
    background: var(--primary-dark); 
    box-shadow: 0 4px 6px -1px rgb(8 145 178 / 0.2);
}

.btn-success { 
    background: var(--success); 
    color: var(--success-foreground);
    box-shadow: 0 1px 2px 0 rgb(16 185 129 / 0.1);
}

.btn-danger { 
    background: var(--destructive); 
    color: var(--destructive-foreground);
    box-shadow: 0 1px 2px 0 rgb(239 68 68 / 0.1);
}

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

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--card);
    color: var(--foreground);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgb(8 145 178 / 0.1);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgb(0 0 0 / 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Login page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    padding: 1rem;
}

.login-box {
    background: var(--card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--foreground);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid;
}

.alert-error { 
    background: #fef2f2; 
    color: var(--destructive); 
    border-color: #fecaca; 
}
.alert-success { 
    background: #f0fdf4; 
    color: var(--success); 
    border-color: #bbf7d0; 
}

/* Import section */
.import-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    background: var(--card);
    transition: all 0.2s ease;
}

.import-area.dragover {
    border-color: var(--primary);
    background: var(--primary-foreground);
    background-color: rgb(8 145 178 / 0.05);
}

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

.stat-card {
    background: var(--card);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

.stat-card .number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.025em;
}

.stat-card .label {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Footer admin link (discrete) */
.site-footer {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--card);
}

.footer-admin-link {
    color: var(--border);
    text-decoration: none;
    font-size: 1rem;
    line-height: 1;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: color 0.2s ease;
    user-select: none;
}

.footer-admin-link:hover {
    color: var(--muted-foreground);
}

/* Mobile Sidebar Toggle */
#sidebarToggle {
    display: none;
}

.mobile-only {
    display: none;
}

.sidebar-content {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }

    /* Mobile: header fixed at top, slides out on scroll down */
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 200;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
    }

    /* Sidebar fixed just below header, slides with it */
    .sidebar {
        width: 100%;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        z-index: 199;
        height: auto;
        align-self: auto;
        border-bottom: 1px solid transparent;
        border-right: none;
        padding: 0;
        background: var(--card);
        box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
        max-height: 0;
        overflow: hidden;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    top 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    border-bottom-color 0.35s ease;
        will-change: transform;
    }

    .sidebar.collapsed {
        max-height: 0;
        border-bottom-color: transparent;
        box-shadow: none;
    }

    .sidebar.expanded {
        max-height: 70vh;
        border-bottom-color: var(--border);
    }

    /* When scrolling down: slide header up out of view */
    body.scrolled-down .header {
        transform: translateY(-100%);
    }

    /* Sidebar must move up by its own top offset (header height) + its own height.
       Since max-height:0 when collapsed, translateY(-100%) = 0px — useless.
       Instead move it up by the header height so it hides behind/above the viewport. */
    body.scrolled-down .sidebar {
        top: 0;
        transform: translateY(-100%);
    }

    /* Offset content below fixed header */
    body {
        padding-top: var(--header-height);
    }
    
    /* Show mobile toggle in header */
    .mobile-only {
        display: flex;
    }
    
    #sidebarToggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.375rem;
        padding: 0.5rem 0.875rem;
        background: var(--primary);
        color: var(--primary-foreground);
        border: none;
        border-radius: var(--radius-md);
        cursor: pointer;
        font-size: 0.875rem;
        font-weight: 500;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        transition: all 0.2s ease;
        box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.08);
        letter-spacing: 0.01em;
    }
    
    #sidebarToggle:hover {
        background: var(--primary-dark);
        box-shadow: 0 4px 6px -1px rgb(59 130 246 / 0.2);
    }
    
    #sidebarToggle.active {
        background: var(--foreground);
        color: var(--background);
    }
    
    #sidebarToggle svg {
        flex-shrink: 0;
    }
    
    /* Mobile header actions adjustment */
    .header-actions {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .sidebar-content {
        display: none;
        padding: 1rem;
        overflow-y: auto;
        max-height: calc(70vh - 50px);
    }
    
    .sidebar.expanded .sidebar-content {
        display: block;
    }
    
    .sidebar h3 {
        display: block;
        margin-top: 0;
        margin-bottom: 0.75rem;
    }
    
    .folder-tree {
        max-height: none;
    }
    
    .content {
        padding: 1rem;
        min-height: calc(100vh - 64px);
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .gallery-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        width: 100%;
    }
    
    .sort-controls select {
        flex: 1;
        min-width: 200px;
    }
    
    .grid-controls {
        margin-top: 0;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }
    
    .header {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.125rem;
    }
}

/* Note: do NOT add a global .hidden rule — it breaks CSS transitions */
