/* ════════════════════════════════════════════════════════════════════
   Ambolt design tokens — the single source of truth for colour, type
   and elevation across the ev- design system.

   Loaded FIRST of the app stylesheets (see App.razor). Everything else
   (entity-view.css, css/ev/components.css, scoped *.razor.css) consumes
   these variables and must not re-define them.

   White-labelling: App.razor injects per-brand values for the
   --brand-* variables into the document head (server-side, resolved
   from the request host — see the Login.razor precedent). Every
   primary/CTA token below derives from those two inputs, so a brand
   swap re-themes the whole app without touching component CSS.

   Dark mode: keyed on html[data-theme="dark"], stamped pre-paint by the
   inline boot script in App.razor <head> and toggled at runtime by
   js/ev-theme.js. (The old .mud-theme-dark hook was never applied by
   MudBlazor — every rule scoped to it was dead code.)
   ════════════════════════════════════════════════════════════════════ */

:root {
    color-scheme: light;

    /* ── Brand inputs (overridden per-brand from App.razor) ─────────── */
    --brand-primary: #1e3a8a;
    --brand-secondary: #00897b;

    /* ── Typography / shape ─────────────────────────────────────────── */
    --ev-font: "Plus Jakarta Sans", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --ev-radius: 12px;
    --ev-radius-sm: 8px;

    /* ── Z-scale (document any new layer here) ──────────────────────────
       app header 100 · dev toolbox 1100 · impersonation 1200 ·
       search box 1299/1300 · dropdown 1310 · dialog 1400 · toast 1500 ·
       reconnect modal 99999 */
    --ev-z-dropdown: 1310;
    --ev-z-dialog: 1400;
    --ev-z-toast: 1500;

    /* ── Neutrals ────────────────────────────────────────────────────── */
    --ev-surface: #ffffff;
    --ev-surface-2: #f8fafc;
    --ev-bg: #f9fafb;
    --ev-border: #e8ebf0;
    --ev-border-strong: #d6dae2;
    --ev-text: #1f2937;
    --ev-text-muted: #6b7280;
    --ev-text-soft: #9ca3af;

    /* ── Brand-derived ───────────────────────────────────────────────── */
    --ev-primary: var(--brand-primary);
    --ev-primary-hover: color-mix(in srgb, var(--brand-primary) 82%, black);
    --ev-primary-soft: color-mix(in srgb, var(--brand-primary) 7%, white);
    --ev-primary-ring: color-mix(in srgb, var(--brand-primary) 14%, transparent);
    --ev-cta: var(--brand-secondary);
    --ev-cta-hover: color-mix(in srgb, var(--brand-secondary) 85%, black);

    /* ── Status ──────────────────────────────────────────────────────── */
    --ev-danger: #dc2626;
    --ev-danger-soft: rgba(239, 68, 68, 0.1);
    --ev-warn: #b45309;
    --ev-warn-soft: rgba(245, 158, 11, 0.13);
    --ev-success: #047857;
    --ev-success-soft: rgba(0, 137, 123, 0.12);
    --ev-violet: #7c3aed;
    --ev-violet-soft: rgba(124, 58, 237, 0.12);

    /* ── Elevation ───────────────────────────────────────────────────── */
    --ev-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.05);
    --ev-shadow-pop: 0 12px 34px rgba(15, 23, 42, 0.16);

    /* ── MudBlazor palette bridge ─────────────────────────────────────
       While MudThemeProvider is still rendered its own inline <style>
       wins over these (it sits later in the DOM). The moment the
       provider is removed, these fallbacks keep every var(--mud-palette-*)
       consumer (AppHeader, SearchBox, DevToolbox, feature CSS) themed.
       Delete this block when the last consumer is migrated. */
    --mud-palette-primary: var(--ev-primary);
    --mud-palette-surface: var(--ev-surface);
    --mud-palette-background: var(--ev-bg);
    --mud-palette-divider: var(--ev-border);
    --mud-palette-lines-default: var(--ev-border);
    --mud-palette-text-primary: var(--ev-text);
    --mud-palette-text-secondary: var(--ev-text-muted);
    --mud-palette-action-default: var(--ev-primary);
    --mud-palette-error: var(--ev-danger);
    --mud-palette-success: var(--ev-success);
    --mud-palette-warning: var(--ev-warn);
    --mud-palette-info: #3b82f6;
    --mud-palette-dark: #111827;
}

html[data-theme="dark"] {
    color-scheme: dark;

    /* ── Neutrals ────────────────────────────────────────────────────── */
    --ev-surface: #1e293b;
    --ev-surface-2: #18233a;
    --ev-bg: #0f172a;
    --ev-border: #2c3a52;
    --ev-border-strong: #3a4a66;
    --ev-text: #f1f5f9;
    --ev-text-muted: #94a3b8;
    --ev-text-soft: #6b7c96;

    /* ── Brand-derived ───────────────────────────────────────────────
       Dark primaries lighten the brand hue so it reads on dark
       surfaces. A brand can pin exact dark values by injecting
       --brand-primary-dark / --brand-secondary-dark (App.razor does
       this for the default Fidelity navy to preserve #60a5fa). */
    --ev-primary: var(--brand-primary-dark, color-mix(in oklch, var(--brand-primary) 55%, white));
    --ev-primary-hover: color-mix(in oklch, var(--ev-primary) 80%, white);
    --ev-primary-soft: color-mix(in srgb, var(--ev-primary) 14%, transparent);
    --ev-primary-ring: color-mix(in srgb, var(--ev-primary) 25%, transparent);
    --ev-cta: var(--brand-secondary-dark, color-mix(in oklch, var(--brand-secondary) 70%, white));
    --ev-cta-hover: color-mix(in oklch, var(--ev-cta) 82%, black);

    /* ── Status ──────────────────────────────────────────────────────── */
    --ev-danger: #fca5a5;
    --ev-danger-soft: rgba(239, 68, 68, 0.16);
    --ev-warn: #fcd34d;
    --ev-warn-soft: rgba(245, 158, 11, 0.16);
    --ev-success: #6ee7b7;
    --ev-success-soft: rgba(16, 185, 129, 0.18);
    --ev-violet: #c4b5fd;
    --ev-violet-soft: rgba(124, 58, 237, 0.22);

    /* ── Elevation ───────────────────────────────────────────────────── */
    --ev-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.32);
    --ev-shadow-pop: 0 12px 34px rgba(0, 0, 0, 0.5);

    /* ── MudBlazor palette bridge (dark) ─────────────────────────────── */
    --mud-palette-primary: var(--ev-primary);
    --mud-palette-surface: var(--ev-surface);
    --mud-palette-background: var(--ev-bg);
    --mud-palette-divider: var(--ev-border);
    --mud-palette-lines-default: var(--ev-border);
    --mud-palette-text-primary: var(--ev-text);
    --mud-palette-text-secondary: var(--ev-text-muted);
    --mud-palette-action-default: var(--ev-primary);
    --mud-palette-error: var(--ev-danger);
    --mud-palette-success: var(--ev-success);
    --mud-palette-warning: var(--ev-warn);
    --mud-palette-info: #60a5fa;
    --mud-palette-dark: #f1f5f9;
}
