/* ==========================================================================
   LUCIS EDU STUDIO — DESIGN TOKENS (single source of truth)
   --------------------------------------------------------------------------
   - Light tokens on :root, dark tokens on [data-theme="dark"] (set on <html>
     by the anti-FOUC script in _Layout before CSS renders).
   - Components must ONLY use these tokens. No hex/rgb outside this file.
   - Load order: adminlte.light.min.css → theme.css → theme-overrides.css → app CSS
   ========================================================================== */

:root {
    color-scheme: light;

    /* ---- Typography ---- */
    --font-sans: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

    --fs-xs: 12px;   --lh-xs: 16px;    /* badge, caption, table header */
    --fs-sm: 13px;   --lh-sm: 18px;    /* secondary text, subtitle */
    --fs-base: 14px; --lh-base: 20px;  /* body, table cell, input, button */
    --fs-md: 16px;   --lh-md: 24px;    /* card title */
    --fs-lg: 18px;   --lh-lg: 26px;    /* modal title */
    --fs-xl: 22px;   --lh-xl: 30px;    /* page title */
    --fs-2xl: 28px;  --lh-2xl: 36px;   /* KPI numbers */

    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* ---- Spacing / radius ---- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    --control-h: 36px;
    --control-h-sm: 32px;

    --transition-fast: .15s ease;
    --transition-normal: .25s ease;

    /* ---- Surfaces & text ---- */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --surface-input: var(--surface);
    --border: #e2e8f0;
    --border-strong: #7f8ea3;  /* spec #cbd5e1 → darkened to reach WCAG 1.4.11 (3:1) for control borders */
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --overlay: rgba(15, 23, 42, .5);

    /* ---- Brand ---- */
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-solid: #7c3aed;
    --primary-solid-hover: #6d28d9;
    --on-primary: #ffffff;
    --primary-soft: #ede9fe;
    --primary-border: rgba(124, 58, 237, .3);

    /* ---- Semantic ---- */
    --success: #15803d;
    --success-soft: #dcfce7;
    --success-solid: #15803d;
    --success-border: rgba(21, 128, 61, .3);
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --warning-solid: #b45309;
    --warning-border: rgba(180, 83, 9, .3);
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --danger-solid: #b91c1c;
    --danger-solid-hover: #991b1b;
    --danger-border: rgba(185, 28, 28, .3);
    --info: #1d4ed8;
    --info-soft: #dbeafe;
    --info-solid: #1d4ed8;
    --info-border: rgba(29, 78, 216, .3);
    --neutral: #475569;
    --neutral-soft: #f1f5f9;
    --neutral-border: rgba(71, 85, 105, .3);

    /* ---- Effects ---- */
    --focus-ring: 0 0 0 3px rgba(124, 58, 237, .25);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, .14);

    /* ---- Media stages (file previews). Intentionally theme-independent:
            video/image/code canvases stay dark in both modes. ---- */
    --media-stage: #000000;
    --image-stage: #1f2937;
    --code-stage: #1e1e1e;
    --code-stage-text: #d4d4d4;

    /* ---- Legacy aliases (kept for compatibility; prefer the tokens above) ---- */
    --color-primary: var(--primary);
    --color-primaryHover: var(--primary-hover);
    --color-primaryBorder: var(--primary);
    --color-textLink: var(--primary);
    --button-bg: var(--primary-solid);
    --button-color: var(--on-primary);
    --color-success: var(--success);
    --color-success-light: var(--success-soft);
    --color-warning: var(--warning);
    --color-warning-light: var(--warning-soft);
    --color-danger: var(--danger);
    --color-danger-light: var(--danger-soft);
    --color-info: var(--info);
    --color-info-light: var(--info-soft);
    --color-gray-50: var(--bg);
    --color-gray-100: var(--surface-2);
    --color-gray-200: var(--border);
    --color-gray-300: var(--border-strong);
    --color-gray-400: var(--text-muted);
    --color-gray-500: var(--text-muted);
    --color-gray-600: var(--text-secondary);
    --color-gray-700: var(--text-secondary);
    --color-gray-800: var(--text);
    --color-gray-900: var(--text);
    --spacing-xs: var(--space-1);
    --spacing-sm: var(--space-2);
    --spacing-md: var(--space-4);
    --spacing-lg: var(--space-5);
    --spacing-xl: var(--space-6);
    --radius-xl: var(--radius-lg);

    --lucis-primary: var(--primary);
    --lucis-primary-hover: var(--primary-hover);
    --lucis-primary-soft: var(--primary-soft);
    --lucis-bg: var(--bg);
    --lucis-surface: var(--surface);
    --lucis-surface-soft: var(--surface-2);
    --lucis-text: var(--text);
    --lucis-text-muted: var(--text-muted);
    --lucis-border: var(--border);
    --lucis-danger: var(--danger);
    --lucis-danger-soft: var(--danger-soft);
    --lucis-success: var(--success);
    --lucis-success-soft: var(--success-soft);
    --lucis-warning: var(--warning);
    --lucis-warning-soft: var(--warning-soft);
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1f2937;
    --surface-3: #273449;
    --surface-input: var(--surface-2);
    --border: #2b3a52;
    --border-strong: #5b6d8a;  /* spec #3b4b63 → lightened to reach 3:1 on --surface */
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --overlay: rgba(2, 6, 23, .72);

    --primary: #a78bfa;
    --primary-hover: #c4b5fd;
    --primary-solid: #7c3aed;
    --primary-solid-hover: #6d28d9;
    --on-primary: #ffffff;
    --primary-soft: rgba(167, 139, 250, .16);
    --primary-border: rgba(167, 139, 250, .3);

    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, .14);
    --success-solid: #15803d;
    --success-border: rgba(74, 222, 128, .3);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, .14);
    --warning-solid: #b45309;
    --warning-border: rgba(251, 191, 36, .3);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .14);
    --danger-solid: #b91c1c;
    --danger-solid-hover: #991b1b;
    --danger-border: rgba(248, 113, 113, .3);
    --info: #60a5fa;
    --info-soft: rgba(96, 165, 250, .14);
    --info-solid: #1d4ed8;
    --info-border: rgba(96, 165, 250, .3);
    --neutral: #cbd5e1;
    --neutral-soft: rgba(148, 163, 184, .14);
    --neutral-border: rgba(148, 163, 184, .3);

    --focus-ring: 0 0 0 3px rgba(167, 139, 250, .35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 1px var(--border);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .45), 0 0 0 1px var(--border);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, .6), 0 0 0 1px var(--border);
}

/* ==========================================================================
   BASE
   ========================================================================== */
html {
    background-color: var(--bg);
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    font-weight: var(--fw-regular);
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-sans);
    color: var(--text);
}

h1, .h1 { font-size: var(--fs-xl); line-height: var(--lh-xl); font-weight: var(--fw-bold); }
h2, .h2 { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: var(--fw-bold); }
h3, .h3 { font-size: var(--fs-md); line-height: var(--lh-md); font-weight: var(--fw-semibold); }
h4, .h4 { font-size: var(--fs-md); line-height: var(--lh-md); font-weight: var(--fw-semibold); }
h5, .h5 { font-size: var(--fs-base); line-height: var(--lh-base); font-weight: var(--fw-semibold); }
h6, .h6 { font-size: var(--fs-sm); line-height: var(--lh-sm); font-weight: var(--fw-semibold); }

small, .small { font-size: var(--fs-sm); }

input, button, select, optgroup, textarea,
.btn, .form-control, .custom-select, .dropdown-menu, .popover, .tooltip,
.main-sidebar, .brand-link, .brand-text, .nav-sidebar,
.select2-container, .select2-dropdown,
.swal2-popup, .swal2-title, .swal2-html-container, .swal2-styled,
#toast-container, .toast,
.note-editor, .note-editable, .note-toolbar, .note-popover,
.air-datepicker, .jstree, .daterangepicker {
    font-family: var(--font-sans);
}

code, kbd, pre, samp,
.font-mono, .font-monospace, .text-monospace {
    font-family: var(--font-mono) !important; /* Bootstrap uses !important on .text-monospace */
}

::selection {
    background: var(--primary-solid);
    color: var(--on-primary);
}

/* Typography utilities */
.fs-xs { font-size: var(--fs-xs) !important; line-height: var(--lh-xs) !important; }
.fs-sm { font-size: var(--fs-sm) !important; line-height: var(--lh-sm) !important; }
.fs-base { font-size: var(--fs-base) !important; line-height: var(--lh-base) !important; }
.fs-md { font-size: var(--fs-md) !important; line-height: var(--lh-md) !important; }
.fs-lg { font-size: var(--fs-lg) !important; line-height: var(--lh-lg) !important; }
.fs-xl { font-size: var(--fs-xl) !important; line-height: var(--lh-xl) !important; }
.fs-2xl { font-size: var(--fs-2xl) !important; line-height: var(--lh-2xl) !important; }

.text-secondary-token { color: var(--text-secondary) !important; }

/* Applied for one frame while the theme flips so components switch together */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
    transition: none !important;
}
