/* ==========================================================================
   SENTINEL-FX · Design Tokens & System Variables
   Calm, precise, institutional private-bank trading terminal palette.
   Automatic browser/OS light/dark theme switching via prefers-color-scheme.
   ========================================================================== */

:root {
  /* Color Scheme declaration for native browser widgets */
  color-scheme: light dark;

  /* Typography families */
  --font-display: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Type Scale */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.25rem;    /* 20px */
  --text-xl: 1.5rem;     /* 24px */
  --text-2xl: 1.75rem;   /* 28px */
  --text-3xl: 2.25rem;   /* 36px */
  --text-4xl: 2.5rem;    /* 40px */

  /* Spacing Grid */
  --space-1: 0.25rem; /* 4px */
  --space-2: 0.5rem;  /* 8px */
  --space-3: 0.75rem; /* 12px */
  --space-4: 1rem;    /* 16px */
  --space-5: 1.25rem; /* 20px */
  --space-6: 1.5rem;  /* 24px */
  --space-8: 2rem;    /* 32px */
  --space-10: 2.5rem; /* 40px */
  --space-12: 3rem;   /* 48px */

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Motion & Duration */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 220ms;
  --duration-slow: 350ms;

  /* Z-Index Hierarchy */
  --z-header: 40;
  --z-sidebar: 35;
  --z-bottom-nav: 50;
  --z-drawer: 60;
  --z-modal: 70;
  --z-toast: 90;

  /* ------------------------------------------------------------------------
     LIGHT THEME (Default :root)
     ------------------------------------------------------------------------ */
  --theme-name: "light";
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #f4f6fa;
  --bg-subtle: #f1f5f9;
  --bg-inset: #e2e8f0;

  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-medium: rgba(15, 23, 42, 0.14);
  --border-strong: rgba(15, 23, 42, 0.22);
  --border-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --text-inverse: #ffffff;

  --accent-primary: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-subtle: rgba(29, 78, 216, 0.08);
  --accent-text: #1d4ed8;

  --profit: #15803d;
  --profit-hover: #166534;
  --profit-subtle: rgba(21, 128, 61, 0.10);
  --profit-border: rgba(21, 128, 61, 0.25);
  --profit-text: #15803d;

  --loss: #b91c1c;
  --loss-hover: #991b1b;
  --loss-subtle: rgba(185, 28, 28, 0.10);
  --loss-border: rgba(185, 28, 28, 0.25);
  --loss-text: #b91c1c;

  --warning: #b45309;
  --warning-subtle: rgba(180, 83, 9, 0.10);
  --warning-border: rgba(180, 83, 9, 0.25);

  --demo-accent: #0284c7;
  --demo-subtle: rgba(2, 132, 199, 0.10);
  --real-accent: #c2410c;
  --real-subtle: rgba(194, 65, 12, 0.12);

  --shadow-subtle: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-card: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-modal: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);

  --chart-grid: rgba(15, 23, 42, 0.06);
  --chart-text: #64748b;
  --chart-crosshair: #475569;
  --chart-candle-up: #15803d;
  --chart-candle-down: #b91c1c;
  --chart-candle-up-border: #15803d;
  --chart-candle-down-border: #b91c1c;
}

/* --------------------------------------------------------------------------
   DARK THEME (OS Preference)
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --theme-name: "dark";
    --bg-page: #080c14;
    --bg-surface: #0f172a;
    --bg-surface-elevated: #162238;
    --bg-surface-hover: #1c2b47;
    --bg-subtle: #121c2f;
    --bg-inset: #090f1d;

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.22);
    --border-focus: #3b82f6;

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --text-inverse: #0f172a;

    --accent-primary: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-subtle: rgba(59, 130, 246, 0.14);
    --accent-text: #60a5fa;

    --profit: #22c55e;
    --profit-hover: #4ade80;
    --profit-subtle: rgba(34, 197, 94, 0.14);
    --profit-border: rgba(34, 197, 94, 0.3);
    --profit-text: #4ade80;

    --loss: #ef4444;
    --loss-hover: #f87171;
    --loss-subtle: rgba(239, 68, 68, 0.14);
    --loss-border: rgba(239, 68, 68, 0.3);
    --loss-text: #f87171;

    --warning: #f59e0b;
    --warning-subtle: rgba(245, 158, 11, 0.14);
    --warning-border: rgba(245, 158, 11, 0.3);

    --demo-accent: #38bdf8;
    --demo-subtle: rgba(56, 189, 248, 0.14);
    --real-accent: #fb923c;
    --real-subtle: rgba(251, 146, 60, 0.16);

    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-modal: 0 25px 40px rgba(0, 0, 0, 0.6);

    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-text: #94a3b8;
    --chart-crosshair: #cbd5e1;
    --chart-candle-up: #22c55e;
    --chart-candle-down: #ef4444;
    --chart-candle-up-border: #22c55e;
    --chart-candle-down-border: #ef4444;
  }
}

/* Explicit Dark Theme override */
:root[data-theme="dark"] {
  --theme-name: "dark";
  --bg-page: #080c14;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #162238;
  --bg-surface-hover: #1c2b47;
  --bg-subtle: #121c2f;
  --bg-inset: #090f1d;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.22);
  --border-focus: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --text-inverse: #0f172a;

  --accent-primary: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-subtle: rgba(59, 130, 246, 0.14);
  --accent-text: #60a5fa;

  --profit: #22c55e;
  --profit-hover: #4ade80;
  --profit-subtle: rgba(34, 197, 94, 0.14);
  --profit-border: rgba(34, 197, 94, 0.3);
  --profit-text: #4ade80;

  --loss: #ef4444;
  --loss-hover: #f87171;
  --loss-subtle: rgba(239, 68, 68, 0.14);
  --loss-border: rgba(239, 68, 68, 0.3);
  --loss-text: #f87171;

  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.14);
  --warning-border: rgba(245, 158, 11, 0.3);

  --demo-accent: #38bdf8;
  --demo-subtle: rgba(56, 189, 248, 0.14);
  --real-accent: #fb923c;
  --real-subtle: rgba(251, 146, 60, 0.16);

  --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-modal: 0 25px 40px rgba(0, 0, 0, 0.6);

  --chart-grid: rgba(255, 255, 255, 0.06);
  --chart-text: #94a3b8;
  --chart-crosshair: #cbd5e1;
  --chart-candle-up: #22c55e;
  --chart-candle-down: #ef4444;
  --chart-candle-up-border: #22c55e;
  --chart-candle-down-border: #ef4444;
}

/* Explicit Light Theme override */
:root[data-theme="light"] {
  --theme-name: "light";
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #f4f6fa;
  --bg-subtle: #f1f5f9;
  --bg-inset: #e2e8f0;

  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-medium: rgba(15, 23, 42, 0.14);
  --border-strong: rgba(15, 23, 42, 0.22);
  --border-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --text-inverse: #ffffff;

  --accent-primary: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-subtle: rgba(29, 78, 216, 0.08);
  --accent-text: #1d4ed8;

  --profit: #15803d;
  --profit-hover: #166534;
  --profit-subtle: rgba(21, 128, 61, 0.10);
  --profit-border: rgba(21, 128, 61, 0.25);
  --profit-text: #15803d;

  --loss: #b91c1c;
  --loss-hover: #991b1b;
  --loss-subtle: rgba(185, 28, 28, 0.10);
  --loss-border: rgba(185, 28, 28, 0.25);
  --loss-text: #b91c1c;

  --warning: #b45309;
  --warning-subtle: rgba(180, 83, 9, 0.10);
  --warning-border: rgba(180, 83, 9, 0.25);

  --demo-accent: #0284c7;
  --demo-subtle: rgba(2, 132, 199, 0.10);
  --real-accent: #c2410c;
  --real-subtle: rgba(194, 65, 12, 0.12);

  --shadow-subtle: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-card: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-modal: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);

  --chart-grid: rgba(15, 23, 42, 0.06);
  --chart-text: #64748b;
  --chart-crosshair: #475569;
  --chart-candle-up: #15803d;
  --chart-candle-down: #b91c1c;
  --chart-candle-up-border: #15803d;
  --chart-candle-down-border: #b91c1c;
}
