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

:root {
    /* ─── Cute Palette ─────────────────────────────── */
    --pink: #f472b6;
    --pink-hover: #ec4899;
    --pink-light: #fce7f3;
    --pink-subtle: #fdf2f8;
    --lavender: #a78bfa;
    --lavender-light: #ede9fe;
    --lavender-subtle: #f5f3ff;
    --amber: #fbbf24;
    --amber-light: #fef3c7;
    --mint: #34d399;
    --mint-light: #d1fae5;
    --rose: #fb7185;
    --rose-light: #ffe4e6;
    --sky: #60a5fa;
    --sky-light: #dbeafe;

    --primary: var(--pink);
    --primary-hover: var(--pink-hover);
    --primary-light: var(--pink-light);
    --primary-subtle: var(--pink-subtle);
    --danger: var(--rose);
    --danger-hover: #f43f5e;
    --danger-light: var(--rose-light);
    --success: var(--mint);
    --success-light: var(--mint-light);
    --warning: var(--amber);
    --warning-light: var(--amber-light);
    --info: var(--sky);
    --info-light: var(--sky-light);

    --bg: #fef9f0;
    --card-bg: #ffffff;
    --text: #374151;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #f3e8ff;
    --border-light: #fdf2f8;

    /* ─── Spacing Scale ─────────────────────────────── */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* ─── Type Scale Tokens ──────────────────────────── */
    --font-xs: 11px;
    --font-sm: 12px;
    --font-base: 13px;
    --font-md: 14px;
    --font-lg: 15px;
    --font-xl: 17px;
    --font-2xl: 18px;
    --font-3xl: 24px;
    --font-4xl: 26px;

    /* ─── Radius Tokens ─────────────────────────────── */
    --radius: 20px;
    --radius-sm: 12px;
    --radius-xs: 8px;

    /* ─── Shadow Tokens ─────────────────────────────── */
    --shadow: 0 1px 3px rgba(244, 114, 182, 0.08), 0 1px 2px rgba(244, 114, 182, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(244, 114, 182, 0.08), 0 2px 4px -1px rgba(244, 114, 182, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(244, 114, 182, 0.08), 0 4px 6px -2px rgba(244, 114, 182, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(244, 114, 182, 0.1), 0 10px 10px -5px rgba(244, 114, 182, 0.04);

    /* ─── Layout Tokens ─────────────────────────────── */
    --nav-height: 60px;
    --container-max: 1200px;
    --sidebar-width: 220px;
    --sidebar-collapsed: 56px;
}

html { font-size: var(--font-lg); }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; font-weight: 500; }
a:hover { color: var(--primary-hover); }

/* ─── Focus & Accessibility ──────────────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--pink);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: 8px;
    padding: 8px 16px;
    background: var(--pink);
    color: white;
    border-radius: var(--radius-xs);
    z-index: 10000;
    font-weight: 600;
    font-size: var(--font-md);
    text-decoration: none;
    transition: top 0.15s ease;
}
.skip-link:focus {
    top: 8px;
    outline: 2px solid white;
    outline-offset: 2px;
}

.btn:disabled,
.btn-outline:disabled,
.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ─── Auth Pages ──────────────────────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #fef9f0 0%, #fdf2f8 100%);
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    position: relative;
    animation: fadeUp 0.5s ease;
    z-index: 1;
}

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

.auth-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--space-2xl) var(--space-xl);
    box-shadow: 0 4px 6px -1px rgba(244, 114, 182, 0.05), 0 10px 40px -4px rgba(244, 114, 182, 0.1);
    border: 1px solid var(--border);
    position: relative;
}

.auth-header { text-align: center; margin-bottom: var(--space-xl); }
.auth-header .logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
}
.auth-header .logo-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: linear-gradient(135deg, #f472b6, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(244, 114, 182, 0.25);
}
.auth-header .logo-icon svg {
    width: 28px;
    height: 28px;
    fill: white;
}
.auth-header h1 { font-size: var(--font-3xl); font-weight: 700; color: var(--text); margin-bottom: 2px; letter-spacing: -0.3px; }
.auth-header p { color: var(--text-secondary); font-size: var(--font-md); }

.auth-form .form-group { margin-bottom: var(--space-lg); }

.auth-form label {
    display: block;
    font-size: var(--font-base);
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-xs);
}

.auth-form input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--font-md);
    transition: all 0.25s ease;
    outline: none;
    background: #fefdfb;
    color: var(--text);
}

.auth-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(244, 114, 182, 0.1), 0 0 0 1px rgba(244, 114, 182, 0.2);
}

.auth-form input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-form input::placeholder { color: var(--text-muted); }

.auth-form .input-group {
    display: flex;
    gap: var(--space-sm);
}
.auth-form .input-group input { flex: 1; }
.auth-form .input-group .btn { flex-shrink: 0; }
.auth-links { text-align: center; margin-top: var(--space-sm); }
.forgot-link { font-size: var(--font-base); color: var(--text-secondary); }
.forgot-link:hover { color: var(--primary); }
.required-mark { color: var(--rose); }
.optional-mark { color: var(--text-secondary); font-weight: 400; font-size: var(--font-sm); }

.auth-footer {
    text-align: center;
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: var(--font-md);
}
.auth-footer a { color: var(--primary); }
.auth-footer a:hover { color: var(--primary-hover); }

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    font-size: var(--font-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none !important;
    line-height: 1.4;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    color: white;
    border: none;
    transition: all 0.2s ease;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(244, 114, 182, 0.35);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-danger {
    background: transparent;
    color: var(--rose);
    border-color: var(--border);
}
.btn-danger:hover {
    background: var(--rose-light);
    border-color: var(--rose);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-outline:hover {
    background: var(--primary-subtle);
    color: var(--primary);
    border-color: var(--primary-light);
}

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: var(--font-sm); border-radius: var(--radius-xs); }

/* ─── Alerts ──────────────────────────────────────────────────────────── */
.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: var(--font-base);
    font-weight: 500;
    line-height: 1.5;
    word-break: break-all;
}
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--danger-light); color: #9f1239; border: 1px solid #fecdd3; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--info-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* ─── Toast Notification ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: var(--font-md);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 380px;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.toast-success { background: var(--mint-light); color: #065f46; border: 1px solid #6ee7b7; }
.toast-error   { background: var(--rose-light); color: #9f1239; border: 1px solid #fecdd3; }

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

/* ─── Navbar ──────────────────────────────────────────────────────────── */
.navbar {
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 var(--space-lg);
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand { display: flex; align-items: center; gap: var(--space-sm); }
.nav-brand .logo { font-size: 22px; }
.brand-text { font-size: var(--font-2xl); font-weight: 700; color: var(--text); letter-spacing: -0.3px; }

.nav-right { display: flex; align-items: center; gap: var(--space-sm); }
.nav-user { color: var(--text-secondary); font-size: var(--font-base); font-weight: 500; }

/* ─── Layout ──────────────────────────────────────────────────────────── */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: var(--space-lg) var(--space-lg);
    animation: fadeUp 0.3s ease;
}

/* ─── Cards ───────────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: var(--space-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.card h2 { font-size: var(--font-xl); font-weight: 700; margin-bottom: var(--space-md); letter-spacing: -0.2px; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) var(--space-lg) 0;
}
.card-header h2 { margin-bottom: 0; }
.card-body { padding: var(--space-lg); }
.file-count { color: var(--text-secondary); font-size: var(--font-base); font-weight: 500; }

/* ─── Upload ──────────────────────────────────────────────────────────── */
.upload-card { padding: var(--space-lg); }

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: #fefdfb;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--pink);
    background: var(--pink-subtle);
    transform: scale(1.01);
}

.drop-icon { font-size: 42px; margin-bottom: 10px; }
.drop-text { font-size: var(--font-lg); font-weight: 600; color: var(--text); margin-bottom: 3px; }
.drop-hint { font-size: var(--font-base); color: var(--text-secondary); }

.file-input { display: none; }

.selected-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    background: var(--pink-subtle);
    border-radius: var(--radius-sm);
    border: 1px solid var(--pink-light);
    font-size: var(--font-base);
    font-weight: 500;
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ec4899, #8b5cf6);
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

.progress-text { font-size: var(--font-sm); font-weight: 600; color: var(--pink); min-width: 36px; text-align: right; }

/* ─── File Grid ───────────────────────────────────────────────────────── */
.file-grid {
    padding: var(--space-sm) var(--space-lg) var(--space-lg);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-sm);
}

.file-card {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    cursor: default;
    background: var(--card-bg);
}

.file-card:hover {
    border-color: var(--pink-light);
    box-shadow: 0 4px 12px rgba(244, 114, 182, 0.1);
    transform: translateY(-2px);
}

.file-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    background: var(--pink-subtle);
}

.file-icon.type-image { background: var(--sky-light); }
.file-icon.type-video { background: var(--lavender-light); }
.file-icon.type-audio { background: var(--mint-light); }
.file-icon.type-pdf   { background: var(--rose-light); }
.file-icon.type-archive { background: var(--amber-light); }
.file-icon.type-code  { background: var(--pink-light); }

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

.file-name {
    font-weight: 600;
    font-size: var(--font-md);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.file-meta {
    display: flex;
    gap: var(--space-md);
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-top: 2px;
}

.file-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .file-actions .btn-label {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip: rect(0,0,0,0);
        white-space: nowrap;
    }
}

/* ─── Empty State ─────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-secondary);
}

.empty-icon { font-size: 52px; margin-bottom: 10px; }
.empty-state p { font-size: var(--font-lg); font-weight: 600; }
.empty-hint { font-size: var(--font-base); color: var(--text-secondary); font-weight: 400 !important; margin-top: 3px; }

/* ─── Preview Page ────────────────────────────────────────────────────── */
.preview-info-card { padding: 22px; }
.preview-header h2 { font-size: var(--font-2xl); margin-bottom: 6px; word-break: break-all; }
.preview-meta { display: flex; gap: 20px; font-size: var(--font-base); color: var(--text-secondary); }

.preview-content-card { padding: 0; }

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--pink-subtle);
}

.preview-badge {
    font-size: var(--font-xs);
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    background: var(--card-bg);
    color: var(--pink);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* Text Preview */
.preview-text {
    padding: 18px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: var(--font-base);
    line-height: 1.7;
    max-height: 70vh;
    overflow-y: auto;
    white-space: pre;
    tab-size: 4;
}

.preview-text.wrap { white-space: pre-wrap; word-break: break-all; }
.preview-text .comment { color: #6b7280; font-style: italic; }
.preview-text .keyword { color: #7c3aed; font-weight: 600; }
.preview-text .string  { color: #059669; }
.preview-text .literal { color: #dc2626; }

/* Image Preview */
.preview-image-container {
    padding: 18px;
    text-align: center;
    background: var(--pink-subtle);
}
.preview-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

/* Video */
.preview-media { padding: 18px; }
.preview-video { width: 100%; max-height: 70vh; border-radius: var(--radius-sm); }

/* Audio */
.audio-player { text-align: center; padding: 24px 18px; }
.audio-icon { font-size: 52px; margin-bottom: 6px; }
.audio-name { font-size: var(--font-lg); font-weight: 600; margin-bottom: 16px; color: var(--text); }
.preview-audio { width: 100%; max-width: 480px; }

/* PDF */
.preview-pdf { height: 80vh; }
.pdf-iframe { width: 100%; height: 100%; border: none; }

/* Preview Unavailable */
.preview-unavailable { text-align: center; padding: 50px 20px; }
.unavailable-icon { font-size: 52px; margin-bottom: 10px; }
.preview-unavailable h3 { font-size: var(--font-2xl); margin-bottom: 6px; color: var(--text); }
.preview-unavailable p { color: var(--text-secondary); margin-bottom: 18px; font-size: var(--font-md); }

/* ─── Admin Layout ─────────────────────────────────────────────────────── */
.admin-body { margin: 0; min-height: 100vh; background: var(--bg); }
.admin-wrapper { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #fdf2f8 0%, #f5f3ff 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.sidebar-nav { flex: 1; padding: 10px 0; display: flex; flex-direction: column; gap: 1px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-md);
    font-weight: 500;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    border-radius: 0 20px 20px 0;
    margin-right: 10px;
}

.sidebar-link:hover {
    background: rgba(244, 114, 182, 0.08);
    color: var(--primary);
}

.sidebar-link.active {
    background: rgba(244, 114, 182, 0.12);
    color: var(--primary-hover);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-footer { padding: 10px 0; border-top: 1px solid var(--border); }

.admin-main { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; }

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-topbar-title { font-size: var(--font-2xl); font-weight: 700; margin: 0; color: var(--text); letter-spacing: -0.3px; }
.admin-topbar-right { display: flex; align-items: center; gap: var(--space-sm); }

.flash-container { padding: var(--space-md) var(--space-xl) 0; }
.admin-content { padding: var(--space-lg) var(--space-xl); animation: fadeUp 0.3s ease; }

/* ─── Stats Grid ───────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-lg);
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
    font-size: var(--font-4xl);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.stat-icon-users { background: var(--lavender-light); }
.stat-icon-files { background: var(--sky-light); }
.stat-icon-storage { background: var(--mint-light); }
.stat-icon-today { background: var(--amber-light); }

.stat-info { display: flex; flex-direction: column; }
.stat-number { font-size: var(--font-4xl); font-weight: 800; color: var(--text); line-height: 1.1; letter-spacing: -0.5px; }
.stat-label { font-size: var(--font-sm); color: var(--text-secondary); font-weight: 500; }

/* ─── Dashboard Grid ───────────────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }

/* ─── Admin Table ──────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: var(--font-md); }

.admin-table thead th {
    text-align: left;
    padding: 10px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--pink-subtle);
    border-bottom: 1px solid var(--border);
}

.admin-table tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border-light); color: var(--text); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--pink-subtle); }

.admin-table .cell-id { color: var(--text-secondary); font-family: monospace; font-size: var(--font-sm); }
.admin-table .cell-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-table .cell-time { color: var(--text-secondary); font-size: var(--font-base); white-space: nowrap; }
.admin-table .cell-actions { white-space: nowrap; text-align: right; }
.admin-table .cell-detail { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }

/* ─── Badges ───────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: var(--font-xs); font-weight: 600; white-space: nowrap; }
.badge-admin { background: var(--lavender-light); color: #7c3aed; }
.badge-user { background: var(--pink-subtle); color: var(--pink); }

/* ─── Filter Form ──────────────────────────────────────────────────────── */
.filter-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-form label { font-size: var(--font-base); font-weight: 500; color: var(--text-secondary); }
.filter-form select {
    padding: 6px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: var(--font-base);
    background: white;
    color: var(--text);
    font-family: inherit;
}

/* ─── Admin Config Form ────────────────────────────────────────────────── */
.admin-config-form { max-width: 460px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: var(--font-base); font-weight: 600; color: var(--text); margin-bottom: 5px; }

.form-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--font-md);
    background: #fefdfb;
    transition: all 0.2s;
    box-sizing: border-box;
    color: var(--text);
}

.form-input:focus {
    outline: none;
    border-color: var(--pink);
    box-shadow: 0 0 0 3px rgba(244, 114, 182, 0.1);
}

.checkbox-label { display: flex !important; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--pink); }
.form-actions { padding-top: 6px; }

/* ─── Pagination ───────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--space-sm); margin-top: var(--space-md); }
.page-info { font-size: var(--font-base); color: var(--text-secondary); }
.text-muted { color: var(--text-secondary); font-size: var(--font-sm); }

/* ─── Utility Classes ────────────────────────────────────────────────── */
.hidden { display: none !important; }
.inline { display: inline !important; }
.inline-form { display: inline; }
.icon-lg { font-size: 48px; display: block; }
.p-0 { padding: 0 !important; }
.ml-sm { margin-left: var(--space-sm); }

/* ─── Responsive ───────────────────────────────────────────────────────── */

/* ─── Mobile table wrapper ────────────────────────────────────────────── */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-wrap table { min-width: 560px; }

@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .file-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── Admin: hamburger toggle (visible on mobile only) ────────────────── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 6px;
    color: var(--text);
    line-height: 1;
    border-radius: var(--radius-xs);
    transition: background 0.15s;
}
.sidebar-toggle:hover { background: var(--pink-subtle); }
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
    /* ─── Mobile admin sidebar: overlay drawer ───────────────────────── */
    .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }

    .admin-sidebar {
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }
    .admin-sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.12); }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.3);
        z-index: 199;
    }
    .sidebar-overlay.visible { display: block; }

    .admin-main { margin-left: 0; }
    .admin-content { padding: var(--space-md); }
    .admin-topbar { padding: 10px var(--space-md); }
    .flash-container { padding: 10px var(--space-md) 0; }
    .file-grid { grid-template-columns: 1fr; }

    .admin-topbar-title { font-size: var(--font-xl); }
}

@media (max-width: 640px) {
    .auth-card { padding: var(--space-xl) var(--space-lg); border-radius: var(--radius-sm); }
    .auth-page { padding: 12px; }
    .auth-container { max-width: 100%; }

    .container { padding: var(--space-md) var(--space-sm); }
    .navbar { padding: 0 var(--space-sm); height: 52px; }
    .brand-text { font-size: var(--font-xl); }

    .file-card { flex-wrap: wrap; padding: var(--space-sm); }
    .file-actions { width: 100%; justify-content: flex-end; padding-top: var(--space-sm); border-top: 1px solid var(--border-light); }
    .file-actions .btn { flex: 1; max-width: 44%; justify-content: center; }
    .file-icon { width: 34px; height: 34px; font-size: 16px; }

    .preview-meta { flex-direction: column; gap: 3px; }
    .preview-info-card { padding: var(--space-md); }
    .preview-header h2 { font-size: var(--font-xl); }
    .preview-toolbar { flex-wrap: wrap; gap: 6px; padding: 10px 14px; }
    .preview-text { padding: 12px; font-size: var(--font-sm); }
    .preview-image-container { padding: 10px; }

    .nav-user { display: none; }
    .navbar .btn-sm { padding: 5px 10px; font-size: var(--font-sm); }
    .nav-right { gap: 4px; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: var(--space-sm); }
    .stat-card { padding: var(--space-md); }
    .stat-icon { width: 40px; height: 40px; font-size: var(--font-3xl); }
    .stat-number { font-size: var(--font-2xl); }

    .drop-zone { padding: var(--space-xl) var(--space-md); }
    .drop-icon { font-size: 32px; }
    .drop-text { font-size: var(--font-md); }
    .drop-hint { font-size: var(--font-sm); }

    .toast-container { top: 10px; right: 10px; left: 10px; }
    .toast { max-width: 100%; font-size: var(--font-base); padding: 10px 14px; }

    .dashboard-grid .card-header { flex-direction: column; align-items: flex-start; gap: var(--space-sm); }

    .pagination { flex-wrap: wrap; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .filter-form select { width: 100%; }

    .admin-config-form { max-width: 100%; }

    /* Auth pages: input group stacking */
    .auth-form .input-group { flex-direction: column; }
    .auth-form .input-group .btn { width: 100%; }

    .empty-state { padding: 30px 16px; }
    .empty-icon { font-size: 40px; }
}

@media (max-width: 480px) {
    :root {
        --space-lg: 16px;
        --space-xl: 20px;
        --space-2xl: 28px;
        --space-3xl: 40px;
    }

    .card { border-radius: var(--radius-sm); }
    .card-header { padding: var(--space-md) var(--space-md) 0; }
    .card-body { padding: var(--space-md); }
    .auth-header h1 { font-size: var(--font-2xl); }
    .stat-number { font-size: var(--font-xl); }
    .stat-label { font-size: var(--font-xs); }
    .file-grid { gap: 4px; }
    .file-card { gap: 6px; }
    .file-name { font-size: var(--font-base); }
    .file-meta { font-size: var(--font-xs); gap: var(--space-sm); }
    .file-actions .btn { padding: 5px 8px; font-size: var(--font-xs); }
    .card-header h2 { font-size: var(--font-lg); }
    .page-info { font-size: var(--font-sm); }
    .preview-pdf { height: 60vh; }
    .selected-file { flex-wrap: wrap; gap: 6px; }
}

@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr; }
    .navbar .btn-sm .btn-label { display: none; }
    .navbar .btn-sm .btn-icon { display: inline; }
    .file-actions .btn-label { display: none; }
}

@media (min-width: 381px) {
    .navbar .btn-sm .btn-icon { display: none; }
}
