/* ═══════════════════════════════════════════════════════════════
   Theme System — Dark & Light Mode Variables
   ═══════════════════════════════════════════════════════════════
   All color tokens live here. Other CSS files reference these
   variables so both themes "just work" via [data-theme].
   ═══════════════════════════════════════════════════════════════ */

/* ── Default / Dark Mode ────────────────────────────────────── */
:root,
[data-theme="dark"] {
    /* Brand (unchanged across themes) */
    --primary: #dc2626;
    --primary-light: #ef4444;
    --primary-dark: #991b1b;
    --primary-rgb: 220, 38, 38;
    --accent: #facc15;
    --neon-blue: #3b82f6;
    --neon-blue-rgb: 59, 130, 246;

    /* Backgrounds — layered surfaces */
    --bg: #050505;
    --surface-1: #0d0d0d;
    --surface-2: #121212;
    --surface-3: #1a1a1a;
    --surface-4: #222222;
    --surface-5: #262626;
    --surface-6: #333333;

    /* Text */
    --text: #ffffff;
    --text-secondary: #e2e2ea;
    --text-dim: #b4b4be;
    --text-muted: #78808c;
    --text-faint: #52596a;
    --text-subtle: #a8a8b8;
    --text-dark: #0f0f0f;

    /* Borders */
    --glass-border: rgba(255, 255, 255, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.04);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.2);

    /* Glass / translucent surfaces */
    --glass-bg: rgba(255, 255, 255, 0.02);
    --glass-bg-hover: rgba(255, 255, 255, 0.06);
    --glass-bg-active: rgba(255, 255, 255, 0.08);
    --glass-bg-input: rgba(0, 0, 0, 0.2);
    --glass-bg-strong: rgba(255, 255, 255, 0.05);

    /* Overlays */
    --overlay-bg: rgba(0, 0, 0, 0.85);
    --overlay-light: rgba(0, 0, 0, 0.5);

    /* Scrollbars */
    --scrollbar-thumb: rgba(255, 255, 255, 0.15);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
    --scrollbar-track: rgba(255, 255, 255, 0.02);
    --scrollbar-thin-thumb: rgba(255, 255, 255, 0.08);

    /* Skeletons / Shimmers */
    --skeleton-from: #1f2937;
    --skeleton-via: #374151;
    --skel-from: rgba(255, 255, 255, 0.03);
    --skel-via: rgba(255, 255, 255, 0.06);

    /* Inputs */
    --input-bg: rgba(0, 0, 0, 0.3);
    --input-option-bg: #111;
    --select-bg: #1a1a1a;
    --select-hover-bg: #222222;
    --select-option-bg: #1a1a1a;
    --select-option-active-bg: #2a2a2a;
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a1a1aa' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

    /* Code / markdown */
    --code-bg: rgba(0, 0, 0, 0.4);
    --code-inline-bg: rgba(255, 255, 255, 0.1);

    /* Nav */
    --nav-bg: rgba(5, 5, 5, 0.95);
    --nav-badge-border: #1a1a1a;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
    --shadow-card-hover: 0 20px 40px rgba(220, 38, 38, 0.1);

    /* Miscellaneous */
    --divider: rgba(255, 255, 255, 0.1);
    --divider-subtle: rgba(255, 255, 255, 0.05);
    --ticker-marquee-bg: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.2) 100%);
    --marquee-fade-color: var(--bg);
    --dashed-border: rgba(255, 255, 255, 0.1);

    /* Theme toggle icon */
    --theme-icon-color: var(--text-dim);
}

/* ── Light Mode ─────────────────────────────────────────────── */
[data-theme="light"] {
    /* Brand (same) */
    --primary: #dc2626;
    --primary-light: #b91c1c;
    --primary-dark: #991b1b;
    --primary-rgb: 220, 38, 38;
    --accent: #ca8a04;
    --neon-blue: #2563eb;
    --neon-blue-rgb: 37, 99, 235;

    /* Backgrounds */
    --bg: #f0f1f3;
    --surface-1: #ffffff;
    --surface-2: #f7f8fa;
    --surface-3: #eef0f2;
    --surface-4: #e2e4e8;
    --surface-5: #d1d5db;
    --surface-6: #9ca3af;

    /* Text */
    --text: #111827;
    --text-secondary: #1f2937;
    --text-dim: #374151;
    --text-muted: #5a6472;
    --text-faint: #8a919e;
    --text-subtle: #374151;
    --text-dark: #ffffff;

    /* Borders */
    --glass-border: rgba(0, 0, 0, 0.12);
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.15);
    --border-strong: rgba(0, 0, 0, 0.25);

    /* Glass / translucent surfaces */
    --glass-bg: rgba(0, 0, 0, 0.03);
    --glass-bg-hover: rgba(0, 0, 0, 0.06);
    --glass-bg-active: rgba(0, 0, 0, 0.08);
    --glass-bg-input: rgba(0, 0, 0, 0.04);
    --glass-bg-strong: rgba(0, 0, 0, 0.06);

    /* Overlays */
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --overlay-light: rgba(0, 0, 0, 0.2);

    /* Scrollbars */
    --scrollbar-thumb: rgba(0, 0, 0, 0.2);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.35);
    --scrollbar-track: rgba(0, 0, 0, 0.03);
    --scrollbar-thin-thumb: rgba(0, 0, 0, 0.12);

    /* Skeletons / Shimmers */
    --skeleton-from: #e5e7eb;
    --skeleton-via: #d1d5db;
    --skel-from: rgba(0, 0, 0, 0.05);
    --skel-via: rgba(0, 0, 0, 0.10);

    /* Inputs */
    --input-bg: rgba(0, 0, 0, 0.04);
    --input-option-bg: #ffffff;
    --select-bg: #ffffff;
    --select-hover-bg: #f3f4f6;
    --select-option-bg: #ffffff;
    --select-option-active-bg: #f3f4f6;
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

    /* Code / markdown */
    --code-bg: rgba(0, 0, 0, 0.06);
    --code-inline-bg: rgba(0, 0, 0, 0.08);

    /* Nav */
    --nav-bg: rgba(255, 255, 255, 0.95);
    --nav-badge-border: #ffffff;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --shadow-card-hover: 0 12px 32px rgba(0, 0, 0, 0.12);

    /* Miscellaneous */
    --divider: rgba(0, 0, 0, 0.12);
    --divider-subtle: rgba(0, 0, 0, 0.08);
    --ticker-marquee-bg: linear-gradient(180deg, rgba(0,0,0,0.04) 0%, rgba(0,0,0,0.02) 100%);
    --marquee-fade-color: var(--bg);
    --dashed-border: rgba(0, 0, 0, 0.15);

    /* Theme toggle icon */
    --theme-icon-color: var(--text-dim);
}

/* ── Theme Toggle Button ────────────────────────────────────── */
.theme-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--divider-subtle);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    transition: background 0.2s;
    text-align: left;
}

.theme-toggle-item:hover {
    background-color: var(--glass-bg-hover);
    color: var(--primary-light);
}

.theme-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--theme-icon-color);
    transition: transform 0.3s ease, color 0.2s;
}

/* Sun icon (shown in dark mode) */
[data-theme="dark"] .theme-icon-sun { display: inline-block; }
[data-theme="dark"] .theme-icon-moon { display: none; }
/* Moon icon (shown in light mode) */
[data-theme="light"] .theme-icon-sun { display: none; }
[data-theme="light"] .theme-icon-moon { display: inline-block; }

.theme-toggle-state {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mobile theme toggle (in mobile user menu) */
.theme-toggle-mobile {
    width: 100%;
    padding: 0.6rem 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s, border-color 0.2s;
}

.theme-toggle-mobile:hover {
    background: var(--glass-bg-hover);
    border-color: var(--border-medium);
}

/* ── Smooth Theme Transition ────────────────────────────────── */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color 0.3s ease, color 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}
