/* ─────────────────────────────────────────────────────────────
   Design Tokens — Prime Gate HelpDesk
   Same family as the Tender CRM and the Performance platform:
   Prime Gate purple, IBM Plex Sans / IBM Plex Sans Arabic,
   12 px cards, 8 px controls, 1 px borders.
   Source: docs/redesign/design/tokens.css (sections A, B, C).
   All variable NAMES from the previous theme are kept so site.css
   and the views keep working. Admin → Branding can still override
   the brand-* block at runtime (BrandPalette.BuildCss).
   ───────────────────────────────────────────────────────────── */

/* ── Fonts (self-hosted, SIL Open Font License — fonts/plex/OFL.txt) ── */
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/plex/plex-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/plex/plex-sans-500.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/plex/plex-sans-600.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/plex/plex-sans-700.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/plex/plex-sans-arabic-400.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/plex/plex-sans-arabic-500.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/plex/plex-sans-arabic-600.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/plex/plex-sans-arabic-700.woff2') format('woff2'); }

/* ── A. Existing tokens, new values (light theme) ─────────────── */
:root {
  /* Brand: Prime Gate purple */
  --brand-50:  #F7F5FB;
  --brand-100: #EFECF6;   /* selected menu item, tints, progress track */
  --brand-200: #DCD7EA;
  --brand-300: #9A86E0;   /* chart series 2 only */
  --brand-400: #595999;   /* secondary: links, focus ring, progress, avatars */
  --brand-500: #312151;   /* primary: top bar, primary buttons, current step */
  --brand-600: #40306A;   /* primary hover */
  --brand-700: #261A40;   /* primary pressed */
  --brand-gradient:        #312151;
  --brand-gradient-soft:   rgba(49, 33, 81, 0.08);
  --brand-gradient-strong: #40306A;
  /* RGB triplet of brand-500 for rgba(); text colour readable on brand-500.
     Admin → Branding overrides the whole brand block at runtime
     (see BrandPalette.BuildCss), so keep these names in step with it. */
  --brand-rgb:      49, 33, 81;
  --brand-contrast: #FFFFFF;

  /* Bootstrap reads these, so pointing them at the tokens keeps
     utilities, tables and links on-palette in both themes. */
  --bs-primary:          var(--brand-500);
  --bs-primary-rgb:      var(--brand-rgb);
  --bs-link-color:       var(--brand-400);
  --bs-link-color-rgb:   89, 89, 153;
  --bs-link-hover-color: var(--brand-500);
  --bs-body-font-family: var(--font-sans);
  --bs-font-sans-serif:  var(--font-sans);
  --bs-body-bg:          var(--surface-1);
  --bs-body-color:       var(--text-primary);
  --bs-border-color:     var(--border-line);
  --bs-secondary-color:  var(--text-muted);
  --bs-tertiary-bg:      var(--surface-2);
  --bs-emphasis-color:   var(--text-primary);
  /* Bootstrap semantic colours (text-*, bg-* on bars) follow the status tokens */
  --bs-success-rgb: 23, 96, 60;
  --bs-warning-rgb: 138, 75, 0;
  --bs-danger-rgb:  161, 38, 27;
  --bs-info-rgb:    63, 63, 128;
  --bs-secondary-rgb: 94, 90, 107;

  /* Accent colours (buttons, KPI icons). Red, amber and green are for
     time and outcome only; priority uses the purple scale in section B. */
  --accent-cyan:    #3F3F80;
  --accent-pink:    #A1261B;
  --accent-emerald: #17603C;
  --accent-amber:   #8A4B00;
  --accent-rose:    #A1261B;
  --accent-violet:  #595999;

  /* Solid colour blocks (avatars, KPI icons) */
  --grad-orange:  #8A4B00;
  --grad-violet:  #595999;
  --grad-amber:   #6E4A12;
  --grad-emerald: #17603C;
  --grad-rose:    #A1261B;
  --grad-cyan:    #3F3F80;

  /* Soft pairs (background / ink) used by pills and banners */
  --soft-mint: #E6F4EC;     --soft-mint-ink: #17603C;
  --soft-sky: #ECECF6;      --soft-sky-ink: #3F3F80;
  --soft-sand: #FFF3DC;     --soft-sand-ink: #8A4B00;
  --soft-peach: #FFF3DC;    --soft-peach-ink: #8A4B00;
  --soft-rose: #FDECEA;     --soft-rose-ink: #A1261B;
  --soft-lavender: #EFECF6; --soft-lavender-ink: #312151;

  /* Surfaces and lines */
  --bg-app:        #F6F5F9;
  --bg-gradient:   none;
  --surface-1:     #FFFFFF;
  --surface-2:     #FAF9FC;   /* table headers, subtle panels */
  --surface-3:     #FFFFFF;
  --surface-inset: #F0EFF3;
  --border-soft:   #EFEDF3;   /* table row lines */
  --border-line:   #E4E1EA;   /* card and input borders */
  --border-strong: #CFCADB;   /* secondary button and input borders */

  /* Text */
  --text-primary:   #16131D;
  --text-secondary: #3A3644;
  --text-muted:     #5E5A6B;  /* 6.7:1 on white */
  --text-inverse:   #FFFFFF;

  /* Status: always with a word and an icon, never colour alone */
  --status-info:    #3F3F80;
  --status-success: #17603C;
  --status-warning: #8A4B00;
  --status-danger:  #A1261B;

  /* Shadows: flat design, depth comes from 1 px borders */
  --shadow-sm: 0 1px 2px rgba(22, 19, 29, .04);
  --shadow:    0 1px 2px rgba(22, 19, 29, .05), 0 1px 3px rgba(22, 19, 29, .04);
  --shadow-md: 0 4px 12px rgba(22, 19, 29, .08);
  --shadow-lg: 0 12px 32px rgba(22, 19, 29, .14);
  --shadow-brand: 0 1px 2px rgba(38, 26, 64, .18);

  /* Radius */
  --radius-sm:   4px;
  --radius:      8px;    /* = --radius-control */
  --radius-lg:   12px;   /* = --radius-card */
  --radius-xl:   16px;
  --radius-pill: 999px;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Layout */
  --topbar-height: 60px;
  --sidebar-width: 232px;

  /* Font */
  --font-display: var(--font-sans);
  --font-mono:    "IBM Plex Mono", "Cascadia Code", Consolas, ui-monospace, monospace;

  /* Focus ring (kept for older rules; new rules use --focus-ring) */
  --ring: 0 0 0 2px var(--brand-400);
}

/* ── B. New tokens ─────────────────────────────────────────────── */
:root {
  --font-sans:   'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-arabic: 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, sans-serif;

  --radius-control: 8px;  /* buttons, inputs */
  --radius-card: 12px;
  --touch: 44px;          /* minimum touch target on mobile */
  --content-max: 1280px;

  /* Priority: ordinal purple scale for the five live levels */
  --priority-critical-bg: #312151;      --priority-critical-fg: #FFFFFF;
  --priority-high-bg: #595999;          --priority-high-fg: #FFFFFF;
  --priority-medium-bg: #C9C5E3;        --priority-medium-fg: #16131D;
  --priority-low-bg: #ECECF6;           --priority-low-fg: #3F3F80;
  --priority-informational-bg: #FFFFFF; --priority-informational-fg: #4A4656; --priority-informational-border: 1px dashed #8C8799;

  /* SLA chip */
  --sla-ok-bg: #E6F4EC;     --sla-ok-fg: #17603C;      /* running */
  --sla-warn-bg: #FFF3DC;   --sla-warn-fg: #8A4B00;    /* under 25% of the target left */
  --sla-bad-bg: #FDECEA;    --sla-bad-fg: #A1261B;     /* overdue */
  --sla-paused-bg: #F0EFF3; --sla-paused-fg: #4A4656;  /* waiting */

  /* Internal note */
  --note-internal-bg: #FFF8E8; --note-internal-border: #F0D9A8;

  /* Charts (validated pair) */
  --chart-1: #595999; --chart-2: #9A86E0;

  --focus-ring: 0 0 0 2px #FFFFFF, 0 0 0 4px #595999;
}

html[lang="ar"] body { font-family: var(--font-arabic); line-height: 1.7; }
html[lang="en"] body { font-family: var(--font-sans);   line-height: 1.5; }
.num, td.num, th.num, .tabular { font-variant-numeric: tabular-nums; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px; }

/* ── C. Dark theme — same selector the dark-mode toggle sets on <html> ── */
[data-theme="dark"] {
  --bg-app: #14111B;
  --surface-1: #1D1926; --surface-2: #241F2F; --surface-3: #1D1926; --surface-inset: #2A2340;
  --border-soft: #2E2839; --border-line: #3A3446; --border-strong: #4B4459;

  --text-primary:   #F2F0F7;   /* 15.2:1 on surface-1 */
  --text-secondary: #D6D1E2;
  --text-muted:     #B5AFC4;   /* 8.1:1 */
  --text-inverse:   #14111B;

  --brand-50:  #1D1926;
  --brand-100: #2A2340;
  --brand-200: #3A3446;
  --brand-400: #B9AEF0;
  --brand-500: #5E4DB8;        /* white on #5E4DB8: 6.5:1 */
  --brand-600: #6A58C9;
  --brand-700: #C9C2F2;        /* used as "active" ink on dark surfaces */
  --brand-rgb: 94, 77, 184;
  --brand-gradient: #5E4DB8;
  --brand-gradient-soft: rgba(185, 174, 240, 0.12);
  --brand-gradient-strong: #6A58C9;
  --bs-link-color-rgb: 185, 174, 240;
  --bs-link-hover-color: #C9C2F2;

  --status-success: #7FD3A0; --status-warning: #F5B969; --status-danger: #F59B92; --status-info: #C9C2F2;
  --bs-success-rgb: 127, 211, 160;
  --bs-warning-rgb: 245, 185, 105;
  --bs-danger-rgb:  245, 155, 146;
  --bs-info-rgb:    201, 194, 242;
  --bs-secondary-rgb: 181, 175, 196;

  --soft-mint: #183326;     --soft-mint-ink: #7FD3A0;
  --soft-sky: #2A2340;      --soft-sky-ink: #C9C2F2;
  --soft-sand: #3A2A12;     --soft-sand-ink: #F5B969;
  --soft-peach: #3A2A12;    --soft-peach-ink: #F5B969;
  --soft-rose: #3D1E1C;     --soft-rose-ink: #F59B92;
  --soft-lavender: #2A2340; --soft-lavender-ink: #C9C2F2;

  --priority-critical-bg: #B9AEF0; --priority-critical-fg: #14111B;
  --priority-high-bg: #8F84D6;     --priority-high-fg: #14111B;
  --priority-medium-bg: #4B4459;   --priority-medium-fg: #F2F0F7;
  --priority-low-bg: #2A2340;      --priority-low-fg: #C9C2F2;
  --priority-informational-bg: #1D1926; --priority-informational-fg: #B5AFC4; --priority-informational-border: 1px dashed #6E6780;

  --sla-ok-bg: #183326;     --sla-ok-fg: #7FD3A0;
  --sla-warn-bg: #3A2A12;   --sla-warn-fg: #F5B969;
  --sla-bad-bg: #3D1E1C;    --sla-bad-fg: #F59B92;
  --sla-paused-bg: #2A2340; --sla-paused-fg: #B5AFC4;

  --note-internal-bg: #2E2414; --note-internal-border: #5C4420;
  --chart-1: #B9AEF0; --chart-2: #8F84D6;

  --focus-ring: 0 0 0 2px #14111B, 0 0 0 4px #B9AEF0;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .40);
  --shadow:    0 1px 3px rgba(0, 0, 0, .45);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .50);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .60);
}
