/* =========================================================================
   OmniConnect PBX · Design Tokens
   Light theme  → Cognitive Enterprise
   Dark  theme  → Sovereign Voice
   ========================================================================= */

:root {
  /* Type scale */
  --font-en: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, "Tajawal", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-icon: "Material Symbols Rounded";

  --fs-display-lg: 36px;
  --fs-headline-lg: 30px;
  --fs-headline-md: 24px;
  --fs-headline-sm: 20px;
  --fs-body-lg: 16px;
  --fs-body-md: 14px;
  --fs-label-md: 13px;
  --fs-label-sm: 12px;
  --fs-mono: 13px;

  --lh-tight: 1.2;
  --lh-snug: 1.3;
  --lh-normal: 1.5;
  --lh-relaxed: 1.6;
  --lh-arabic: 1.75;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Spacing scale (4px baseline) */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;
  --space-11: 80px;
  --space-12: 96px;

  /* Radius */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Shell metrics */
  --sidebar-width: 272px;
  --sidebar-width-collapsed: 72px;
  --header-height: 64px;
  --content-max: 1600px;
  --gutter: 24px;
  --gutter-sm: 16px;

  /* Z layers */
  --z-base: 0;
  --z-sticky: 50;
  --z-header: 60;
  --z-drawer: 80;
  --z-modal: 90;
  --z-toast: 95;
  --z-palette: 100;

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur-normal: 200ms;
  --dur-slow: 320ms;
}

/* -------------------------------------------------------------------------
   LIGHT — Cognitive Enterprise
   ------------------------------------------------------------------------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  /* Primitives (Cognitive Enterprise) */
  --ce-surface: #faf8ff;
  --ce-surface-white: #ffffff;
  --ce-surface-low: #f2f3ff;
  --ce-surface: #eaedff;
  --ce-surface-high: #e2e7ff;
  --ce-surface-highest: #dae2fd;
  --ce-on-surface: #131b2e;
  --ce-on-surface-variant: #434655;
  --ce-outline: #c3c6d7;
  --ce-primary: #004ac6;
  --ce-primary-strong: #2563eb;
  --ce-secondary: #57dffe;
  --ce-accent: #7c3aed;
  --ce-success: #10b981;
  --ce-warning: #bc4800;
  --ce-error: #ba1a1a;

  /* Surfaces */
  --bg: #faf8ff;
  --surface: #ffffff;
  --surface-1: #ffffff;
  --surface-2: #f2f3ff;
  --surface-3: #eaedff;
  --surface-4: #e2e7ff;
  --surface-5: #dae2fd;
  --surface-inverse: #131b2e;

  /* Text */
  --text-primary: #131b2e;
  --text-secondary: #434655;
  --text-muted: #6b6f80;
  --text-on-accent: #ffffff;
  --text-on-inverse: #faf8ff;
  --text-link: #004ac6;

  /* Borders */
  --border: #dae2fd;
  --border-strong: #c3c6d7;
  --border-subtle: rgba(19, 27, 46, 0.06);
  --divider: rgba(19, 27, 46, 0.08);

  /* Brand / Accents */
  --accent: #004ac6;
  --accent-hover: #2563eb;
  --accent-active: #003ea8;
  --accent-soft: rgba(0, 74, 198, 0.08);
  --accent-soft-hover: rgba(0, 74, 198, 0.12);
  --accent-ring: rgba(37, 99, 235, 0.25);
  --accent-secondary: #57dffe;
  --accent-tertiary: #7c3aed;

  /* Status */
  --status-success: #10b981;
  --status-success-bg: rgba(16, 185, 129, 0.10);
  --status-success-fg: #047857;
  --status-warning: #bc4800;
  --status-warning-bg: rgba(188, 72, 0, 0.10);
  --status-warning-fg: #8a3500;
  --status-error: #ba1a1a;
  --status-error-bg: rgba(186, 26, 26, 0.10);
  --status-error-fg: #93000a;
  --status-info: #2563eb;
  --status-info-bg: rgba(37, 99, 235, 0.10);
  --status-info-fg: #1d4ed8;
  --status-neutral: #6b6f80;
  --status-neutral-bg: rgba(67, 70, 85, 0.08);
  --status-neutral-fg: #434655;

  /* Field tokens */
  --field-bg: #ffffff;
  --field-border: #dae2fd;
  --field-border-hover: #b4c5ff;
  --field-focus: #004ac6;
  --field-focus-ring: rgba(0, 74, 198, 0.20);
  --field-placeholder: #8a8fa3;
  --field-disabled-bg: #f2f3ff;

  /* Sidebar */
  --sidebar-bg: #ffffff;
  --sidebar-fg: #434655;
  --sidebar-fg-strong: #131b2e;
  --sidebar-group-fg: #6b6f80;
  --sidebar-item-hover: #f2f3ff;
  --sidebar-item-active-bg: rgba(0, 74, 198, 0.08);
  --sidebar-item-active-fg: #004ac6;
  --sidebar-indicator: #004ac6;
  --sidebar-border: #eaedff;

  /* Topbar */
  --topbar-bg: #ffffff;
  --topbar-fg: #131b2e;
  --topbar-border: #eaedff;

  /* Cards / Surfaces */
  --card-bg: #ffffff;
  --card-border: #eaedff;
  --card-hover-bg: #faf8ff;

  /* Modals / Overlays */
  --modal-bg: #ffffff;
  --modal-backdrop: rgba(19, 27, 46, 0.40);
  --drawer-bg: #ffffff;
  --overlay-scrim: rgba(19, 27, 46, 0.32);

  /* Shadows — tinted with text-primary */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.10);
  --shadow-xl: 0 20px 40px rgba(15, 23, 42, 0.14);
  --shadow-focus: 0 0 0 3px var(--field-focus-ring);

  /* Glows — disabled in light */
  --glow-primary: none;
  --glow-secondary: none;
  --glow-accent: none;

  /* Scrollbar */
  --scrollbar-thumb: #c3c6d7;
  --scrollbar-track: transparent;

  /* Chart palette */
  --chart-1: #004ac6;
  --chart-2: #7c3aed;
  --chart-3: #10b981;
  --chart-4: #2563eb;
  --chart-5: #57dffe;
  --chart-6: #bc4800;
  --chart-grid: rgba(19, 27, 46, 0.08);
}

/* -------------------------------------------------------------------------
   DARK — Sovereign Voice
   ------------------------------------------------------------------------- */
[data-theme="dark"] {
  color-scheme: dark;

  /* Primitives (Sovereign Voice) */
  --sv-surface: #051424;
  --sv-surface-lowest: #010f1f;
  --sv-surface-low: #0d1c2d;
  --sv-surface: #122131;
  --sv-surface-high: #1c2b3c;
  --sv-surface-highest: #273647;
  --sv-on-surface: #d4e4fa;
  --sv-on-surface-variant: #c6c6cd;
  --sv-outline: #45464d;
  --sv-primary: #bec6e0;
  --sv-secondary: #d2bbff;
  --sv-tertiary: #89ceff;
  --sv-success: #34d399;
  --sv-warning: #fbbf24;
  --sv-error: #ffb4ab;

  /* Surfaces */
  --bg: #051424;
  --surface: #0d1c2d;
  --surface-1: #0d1c2d;
  --surface-2: #122131;
  --surface-3: #1c2b3c;
  --surface-4: #273647;
  --surface-5: #2c3a4c;
  --surface-inverse: #d4e4fa;

  /* Text */
  --text-primary: #d4e4fa;
  --text-secondary: #c6c6cd;
  --text-muted: #909097;
  --text-on-accent: #25005a;
  --text-on-inverse: #131b2e;
  --text-link: #89ceff;

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --divider: rgba(255, 255, 255, 0.08);

  /* Brand / Accents */
  --accent: #d2bbff;
  --accent-hover: #c9aeff;
  --accent-active: #b89aff;
  --accent-soft: rgba(210, 187, 255, 0.12);
  --accent-soft-hover: rgba(210, 187, 255, 0.18);
  --accent-ring: rgba(210, 187, 255, 0.35);
  --accent-secondary: #89ceff;
  --accent-tertiary: #bec6e0;

  /* Status */
  --status-success: #34d399;
  --status-success-bg: rgba(52, 211, 153, 0.12);
  --status-success-fg: #34d399;
  --status-warning: #fbbf24;
  --status-warning-bg: rgba(251, 191, 36, 0.12);
  --status-warning-fg: #fbbf24;
  --status-error: #ffb4ab;
  --status-error-bg: rgba(255, 180, 171, 0.12);
  --status-error-fg: #ffb4ab;
  --status-info: #89ceff;
  --status-info-bg: rgba(137, 206, 255, 0.12);
  --status-info-fg: #89ceff;
  --status-neutral: #909097;
  --status-neutral-bg: rgba(144, 144, 151, 0.12);
  --status-neutral-fg: #c6c6cd;

  /* Field */
  --field-bg: #0d1c2d;
  --field-border: #273647;
  --field-border-hover: #3f465c;
  --field-focus: #d2bbff;
  --field-focus-ring: rgba(210, 187, 255, 0.25);
  --field-placeholder: #909097;
  --field-disabled-bg: #122131;

  /* Sidebar */
  --sidebar-bg: #0d1c2d;
  --sidebar-fg: #c6c6cd;
  --sidebar-fg-strong: #d4e4fa;
  --sidebar-group-fg: #909097;
  --sidebar-item-hover: rgba(255, 255, 255, 0.04);
  --sidebar-item-active-bg: rgba(210, 187, 255, 0.10);
  --sidebar-item-active-fg: #d2bbff;
  --sidebar-indicator: #d2bbff;
  --sidebar-border: rgba(255, 255, 255, 0.06);

  /* Topbar */
  --topbar-bg: #051424;
  --topbar-fg: #d4e4fa;
  --topbar-border: rgba(255, 255, 255, 0.06);

  /* Cards */
  --card-bg: #122131;
  --card-border: rgba(255, 255, 255, 0.06);
  --card-hover-bg: #1c2b3c;

  /* Modals / Overlays */
  --modal-bg: #122131;
  --modal-backdrop: rgba(1, 15, 31, 0.72);
  --drawer-bg: #0d1c2d;
  --overlay-scrim: rgba(1, 15, 31, 0.60);

  /* Shadows — softer in dark, used for overlays only */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.50);
  --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.55);
  --shadow-focus: 0 0 0 3px var(--field-focus-ring);

  /* Glows — Sovereign Voice signature */
  --glow-primary: 0 0 0 1px rgba(210, 187, 255, 0.18), 0 8px 24px rgba(210, 187, 255, 0.12);
  --glow-secondary: 0 0 0 1px rgba(137, 206, 255, 0.18), 0 8px 24px rgba(137, 206, 255, 0.10);
  --glow-accent: 0 0 0 1px rgba(190, 198, 224, 0.18), 0 8px 24px rgba(190, 198, 224, 0.08);
  --glow-success: 0 0 0 1px rgba(52, 211, 153, 0.18), 0 8px 24px rgba(52, 211, 153, 0.10);
  --glow-error: 0 0 0 1px rgba(255, 180, 171, 0.18), 0 8px 24px rgba(255, 180, 171, 0.10);

  /* Scrollbar */
  --scrollbar-thumb: rgba(255, 255, 255, 0.12);
  --scrollbar-track: transparent;

  /* Chart palette */
  --chart-1: #d2bbff;
  --chart-2: #89ceff;
  --chart-3: #34d399;
  --chart-4: #bec6e0;
  --chart-5: #fbbf24;
  --chart-6: #ffb4ab;
  --chart-grid: rgba(255, 255, 255, 0.08);
}

/* Auto mode follows OS preference */
[data-theme="auto"] {
  color-scheme: light dark;
}

/* -------------------------------------------------------------------------
   AUTO — inherit full dark token set when OS is in dark mode
   ------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    color-scheme: dark;

    --bg: #051424;
    --surface: #0d1c2d;
    --surface-1: #0d1c2d;
    --surface-2: #122131;
    --surface-3: #1c2b3c;
    --surface-4: #273647;
    --surface-5: #2c3a4c;
    --surface-inverse: #d4e4fa;

    --text-primary: #d4e4fa;
    --text-secondary: #c6c6cd;
    --text-muted: #909097;
    --text-on-accent: #25005a;
    --text-on-inverse: #131b2e;
    --text-link: #89ceff;

    --border: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.12);
    --border-subtle: rgba(255, 255, 255, 0.04);
    --divider: rgba(255, 255, 255, 0.08);

    --accent: #d2bbff;
    --accent-hover: #c9aeff;
    --accent-active: #b89aff;
    --accent-soft: rgba(210, 187, 255, 0.12);
    --accent-soft-hover: rgba(210, 187, 255, 0.18);
    --accent-ring: rgba(210, 187, 255, 0.35);
    --accent-secondary: #89ceff;
    --accent-tertiary: #bec6e0;

    --status-success: #34d399;
    --status-success-bg: rgba(52, 211, 153, 0.12);
    --status-success-fg: #34d399;
    --status-warning: #fbbf24;
    --status-warning-bg: rgba(251, 191, 36, 0.12);
    --status-warning-fg: #fbbf24;
    --status-error: #ffb4ab;
    --status-error-bg: rgba(255, 180, 171, 0.12);
    --status-error-fg: #ffb4ab;
    --status-info: #89ceff;
    --status-info-bg: rgba(137, 206, 255, 0.12);
    --status-info-fg: #89ceff;
    --status-neutral: #909097;
    --status-neutral-bg: rgba(144, 144, 151, 0.12);
    --status-neutral-fg: #c6c6cd;

    --field-bg: #0d1c2d;
    --field-border: #273647;
    --field-border-hover: #3f465c;
    --field-focus: #d2bbff;
    --field-focus-ring: rgba(210, 187, 255, 0.25);
    --field-placeholder: #909097;
    --field-disabled-bg: #122131;

    --sidebar-bg: #0d1c2d;
    --sidebar-fg: #c6c6cd;
    --sidebar-fg-strong: #d4e4fa;
    --sidebar-group-fg: #909097;
    --sidebar-item-hover: rgba(255, 255, 255, 0.04);
    --sidebar-item-active-bg: rgba(210, 187, 255, 0.10);
    --sidebar-item-active-fg: #d2bbff;
    --sidebar-indicator: #d2bbff;
    --sidebar-border: rgba(255, 255, 255, 0.06);

    --topbar-bg: #051424;
    --topbar-fg: #d4e4fa;
    --topbar-border: rgba(255, 255, 255, 0.06);

    --card-bg: #122131;
    --card-border: rgba(255, 255, 255, 0.06);
    --card-hover-bg: #1c2b3c;

    --modal-bg: #122131;
    --modal-backdrop: rgba(1, 15, 31, 0.72);
    --drawer-bg: #0d1c2d;
    --overlay-scrim: rgba(1, 15, 31, 0.60);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.40);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.50);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.55);
    --shadow-focus: 0 0 0 3px var(--field-focus-ring);

    --glow-primary: 0 0 0 1px rgba(210, 187, 255, 0.18), 0 8px 24px rgba(210, 187, 255, 0.12);
    --glow-secondary: 0 0 0 1px rgba(137, 206, 255, 0.18), 0 8px 24px rgba(137, 206, 255, 0.10);
    --glow-accent: 0 0 0 1px rgba(190, 198, 224, 0.18), 0 8px 24px rgba(190, 198, 224, 0.08);

    --scrollbar-thumb: rgba(255, 255, 255, 0.12);

    --chart-1: #d2bbff;
    --chart-2: #89ceff;
    --chart-3: #34d399;
    --chart-4: #bec6e0;
    --chart-5: #fbbf24;
    --chart-6: #ffb4ab;
    --chart-grid: rgba(255, 255, 255, 0.08);
  }
}
