/* ===========================================================================
   Design tokens + shared components.
   Brand colors are constant; semantic tokens switch with [data-theme].
   =========================================================================== */

:root {
    /* Brand (constant across themes) */
    --blue:           #4355B9;  /* indigo-600 — mirrors Android Indigo40 */
    --purple:         #6366F1;  /* indigo-500 */
    --blue-light:     #818CF8;  /* indigo-400 — dark-mode accent */
    --red:            #EF4444;
    --green:          #10B981;
    --amber:          #F59E0B;
    --accent-gradient: linear-gradient(135deg, var(--blue), var(--purple));

    /* File-category chip backgrounds */
    --cat-folder:   rgba(245,158,11,  0.14);
    --cat-image:    rgba(139,92,246,  0.14);
    --cat-video:    rgba(239,68,68,   0.14);
    --cat-audio:    rgba(16,185,129,  0.14);
    --cat-pdf:      rgba(234,88,12,   0.14);
    --cat-doc:      rgba(59,130,246,  0.14);
    --cat-sheet:    rgba(22,163,74,   0.14);
    --cat-slides:   rgba(249,115,22,  0.14);
    --cat-archive:  rgba(99,102,241,  0.14);
    --cat-text:     rgba(100,116,139, 0.14);

    /* Semantic — light theme */
    --bg:             #F4F4FF;
    --surface:        #FFFFFF;
    --surface-2:      #F8F8FF;
    --surface-3:      #EDEDFB;
    --border:         #E3E1F0;
    --border-strong:  #C8C5D8;
    --text:           #1B1B22;
    --text-muted:     #46465B;
    --text-subtle:    #777790;
    --accent:         var(--blue);
    --accent-soft:    rgba(67,85,185, 0.12);
    --danger-bg:      #FFF5F5;
    --danger-fg:      #C92A2A;
    --danger-border:  #FFC9C9;
    --info-bg:        #EEF2FF;
    --info-fg:        #3730A3;
    --info-border:    #C7D2FE;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(67,85,185, 0.10);
    --shadow-lg: 0 8px 32px rgba(67,85,185, 0.14);
    --radius:    14px;
    --radius-sm: 9px;

    /* Layout — app shell */
    --sidebar-w:      248px;
    --sidebar-rail-w: 76px;
    --topbar-h:       60px;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
}

[data-theme="dark"] {
    --bg:             #0F1117;
    --surface:        #181922;
    --surface-2:      #1E1F2E;
    --surface-3:      #252638;
    --border:         #2A2B3D;
    --border-strong:  #363748;
    --text:           #E3E2EC;
    --text-muted:     #B0AECA;
    --text-subtle:    #7A798E;
    --accent:         var(--blue-light);
    --accent-soft:    rgba(129,140,248, 0.16);
    --danger-bg:      #3A1D1F;
    --danger-fg:      #FF8787;
    --danger-border:  #5A2A2D;
    --info-bg:        #1E1F3A;
    --info-fg:        #A5B4FC;
    --info-border:    #312E7A;

    /* Category chips — slightly more saturated in dark */
    --cat-folder:   rgba(245,158,11,  0.18);
    --cat-image:    rgba(139,92,246,  0.18);
    --cat-video:    rgba(239,68,68,   0.18);
    --cat-audio:    rgba(16,185,129,  0.18);
    --cat-pdf:      rgba(234,88,12,   0.18);
    --cat-doc:      rgba(59,130,246,  0.18);
    --cat-sheet:    rgba(22,163,74,   0.18);
    --cat-slides:   rgba(249,115,22,  0.18);
    --cat-archive:  rgba(99,102,241,  0.18);
    --cat-text:     rgba(100,116,139, 0.18);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.40);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.55);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 2rem 1rem;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    transition: background 0.2s ease, color 0.2s ease;
}

/* App-shell pages fill the whole viewport — no outer gutter. */
body.app-shell {
    padding: 0;
    min-height: 100vh;
}

/* ── Theme toggle button ───────────────────────────────── */
.theme-toggle {
    background: rgba(255,255,255,0.18);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    transition: background 0.2s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.28); }

/* ── Toasts ───────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}
.toast {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-sm);
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    max-width: 320px;
    animation: toast-in 0.25s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 900;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 1.5rem;
}
.modal h2 { margin: 0 0 1rem; font-size: 1.1rem; }

/* ── Shared buttons ─────────────────────────────────────────── */
.btn-primary {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(67,85,185, 0.3);
    transition: opacity 0.2s, transform 0.15s;
}
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-ghost {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-ghost:hover { background: var(--surface-3); }
