/* ==========================================================================================
   Design tokens — the one place colour, type, spacing, radius, elevation and motion are decided.
   (DECISION-015.) Everything else in /design reads these; nothing else names a hex value.

   Layering: these sheets are linked AFTER the vendored template (/admindek/css/style.css), which
   stays byte-identical. Section 3 maps the tokens onto the template's own `--bs-*` / `--pc-*`
   variables, so every Bootstrap rule the pages still use picks the new palette up by itself.

   Contrast is computed, not judged by eye: every text/background pair below was checked with the
   WCAG 2.x formula; the ratios are noted beside the values they belong to.
   ========================================================================================== */

/* ---- 1. Primitives ---------------------------------------------------------------------- */
:root {
  /* Ink — the blue-green black of the sidebar and of dark surfaces. */
  --ink-950: #071318;
  --ink-900: #0b1f26;
  --ink-850: #0f272f;
  --ink-800: #122a32;
  --ink-750: #16313a;
  --ink-700: #21434e;

  /* Brand — one deep electric teal-blue. 500 is the solid; white on it is 5.12:1. */
  --brand-50: #e5f3f6;
  --brand-100: #cbe7ec;
  --brand-200: #a0d3dc;
  --brand-300: #62b5c4;
  --brand-400: #2a96aa;
  --brand-500: #0a7890;
  --brand-600: #096a7f;
  --brand-700: #075a6c;
  --brand-800: #064857;
  --brand-900: #063843;

  /* Volt — a spark, on ink only (13.2:1 there). Never text on a light surface. */
  --volt: #c6f432;

  /* Type. Latin and digits come from IBM Plex Sans, Arabic from IBM Plex Sans Arabic: the two are
     one design, so a mixed line keeps one colour and one x-height. */
  --font-sans: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", Tahoma, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs: 0.75rem;     /* 12 — captions, table heads, pills */
  --fs-sm: 0.8125rem;   /* 13 — hints, secondary lines */
  --fs-base: 0.875rem;  /* 14 — body, controls, table cells */
  --fs-md: 1rem;        /* 16 — card and section titles */
  --fs-lg: 1.125rem;    /* 18 */
  --fs-xl: 1.5rem;      /* 24 — page title */
  --fs-2xl: 1.75rem;    /* 28 — stat value */
  --fs-3xl: 2.25rem;    /* 36 — sign-in headline */
  --lh-tight: 1.25;
  --lh-body: 1.5;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* Spacing — a 4/8 scale. */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* Radius. */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* Motion — hover and focus only, and only this fast. */
  --t-fast: 120ms;
  --t-med: 160ms;
  --ease: cubic-bezier(0.2, 0, 0.2, 1);

  /* Layout. */
  --sidebar-w: 264px;
  --header-h: 64px;
  --content-max: 1320px;
  --gutter: 32px;
  --control-h: 40px;
  --control-h-sm: 32px;
}

/* Arabic is set a little larger and with more leading: its letters carry marks above and below
   the line that Latin does not, and at 14px they close up. One step on the root scales every
   rem-sized thing together, so the two languages keep the same proportions. */
html:lang(ar) {
  font-size: 106.25%;
  --lh-body: 1.7;
  --lh-tight: 1.45;
}

/* ---- 2. Semantic tokens ----------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Surfaces */
  --c-page: #f4f7f8;
  --c-surface: #ffffff;
  --c-surface-2: #f7f9fa;          /* table head, quiet insets */
  --c-surface-3: #eef2f4;          /* row hover, neutral fills */
  --c-border: #e1e7ea;             /* hairlines between things */
  --c-border-strong: #c9d3d8;      /* secondary button outline */
  --c-control-border: #7f8f97;     /* input outline — 3.34:1 on white (WCAG 1.4.11) */
  --c-input-bg: #ffffff;

  /* Text */
  --c-text: #0f1f26;               /* 16.9:1 on surface, 15.7:1 on page */
  --c-text-2: #46565e;             /* 7.6:1 */
  --c-muted: #5c6c74;              /* 5.45:1 on surface, 5.06:1 on page, 4.84:1 on row hover */
  --c-placeholder: #66757d;        /* 4.77:1 */

  /* Brand */
  --c-brand: var(--brand-500);     /* solid fills; white text 5.12:1 */
  --c-brand-hover: var(--brand-600);
  --c-brand-active: var(--brand-700);
  --c-on-brand: #ffffff;
  --c-brand-text: var(--brand-600);/* links and brand-coloured text: 6.21:1 on surface */
  --c-brand-text-hover: var(--brand-800);
  --c-brand-tint: var(--brand-50);
  --c-brand-tint-border: var(--brand-200);
  --c-focus: var(--brand-500);
  --c-focus-halo: rgba(10, 120, 144, 0.22);

  /* Status — reserved for state, never decoration. mark = dots, bars, icons; text = on its tint. */
  --c-ok: #2a9d55;        --c-ok-text: #1b6b3a;        --c-ok-tint: #e3f4e8;        --c-ok-border: #b4dfc1;
  --c-warn: #e8a70a;      --c-warn-text: #7a4d00;      --c-warn-tint: #fff3d6;      --c-warn-border: #f1d489;
  --c-bad: #b8261f;       --c-bad-text: #9e2019;       --c-bad-tint: #fce9e7;       --c-bad-border: #f1bcb7;
  --c-uncertain: #6b40c9; --c-uncertain-text: #53309f; --c-uncertain-tint: #f0ebfb; --c-uncertain-border: #a98fe2;
  --c-pending: #4f91f2;   --c-pending-text: #1f4e9e;   --c-pending-tint: #e8f0fd;   --c-pending-border: #b9d1f8;
  --c-neutral: #74858d;   --c-neutral-text: #46565e;   --c-neutral-tint: #eef2f4;   --c-neutral-border: #d3dce0;
  --c-danger-solid: #b8261f;       /* destructive button; white text 6.30:1 */
  --c-danger-solid-hover: #9e2019;

  /* Sidebar (ink in both themes) */
  --c-side-bg: var(--ink-900);
  --c-side-border: transparent;
  --c-side-text: #c2d0d5;          /* 10.7:1 */
  --c-side-caption: #8499a1;       /* 5.7:1 */
  --c-side-icon: #8fa4ac;
  --c-side-hover: var(--ink-800);
  --c-side-active: var(--ink-750);
  --c-side-active-text: #ffffff;

  /* Elevation — three steps, tinted with ink so shadows never go grey-brown. */
  --e-1: 0 1px 2px rgba(11, 31, 38, 0.05);
  --e-2: 0 4px 12px -2px rgba(11, 31, 38, 0.1), 0 1px 2px rgba(11, 31, 38, 0.06);
  --e-3: 0 16px 40px -8px rgba(11, 31, 38, 0.2), 0 2px 6px rgba(11, 31, 38, 0.06);

  --c-scrim: rgba(7, 19, 24, 0.55);
  --c-skeleton: #e6ecef;
  --c-skeleton-shine: rgba(255, 255, 255, 0.7);
}

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

  --c-page: #0a181d;
  --c-surface: #10242b;
  --c-surface-2: #152c34;
  --c-surface-3: #1b353e;
  --c-border: #233d46;
  --c-border-strong: #35525c;
  --c-control-border: #5c7882;     /* 3.2:1 on the input fill */
  --c-input-bg: #0c1d23;

  --c-text: #e6eef0;               /* 13.6:1 on surface */
  --c-text-2: #b4c4ca;
  --c-muted: #8ea3ab;              /* 6.1:1 on surface */
  --c-placeholder: #8399a1;

  --c-brand-text: #5ccad4;         /* 8.3:1 on surface */
  --c-brand-text-hover: #8adde5;
  --c-brand-tint: #0f3540;
  --c-brand-tint-border: #1b5564;
  --c-focus: #3fb8c3;
  --c-focus-halo: rgba(63, 184, 195, 0.28);

  --c-ok: #33d977;        --c-ok-text: #7fe0a2;        --c-ok-tint: #12301f;        --c-ok-border: #1f4d33;
  --c-warn: #f5af20;      --c-warn-text: #f7cb6b;      --c-warn-tint: #33290f;      --c-warn-border: #5a481b;
  --c-bad: #e2484f;       --c-bad-text: #ffa198;       --c-bad-tint: #3a1a18;       --c-bad-border: #662d29;
  --c-uncertain: #8259e0; --c-uncertain-text: #c9b8fb; --c-uncertain-tint: #271f47; --c-uncertain-border: #6b4fc0;
  --c-pending: #6f96e8;   --c-pending-text: #a9c4fa;   --c-pending-tint: #172a4a;   --c-pending-border: #29477c;
  --c-neutral: #7f959d;   --c-neutral-text: #b4c4ca;   --c-neutral-tint: #1b353e;   --c-neutral-border: #2f4c56;
  --c-danger-solid: #c2352e;       /* white text 5.5:1 */
  --c-danger-solid-hover: #a82a24;

  --c-side-bg: var(--ink-950);
  --c-side-border: #14292f;

  --e-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --e-2: 0 6px 16px -4px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --e-3: 0 20px 44px -10px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.35);

  --c-scrim: rgba(2, 8, 10, 0.7);
  --c-skeleton: #1b353e;
  --c-skeleton-shine: rgba(255, 255, 255, 0.07);
}

/* ---- 3. The tokens, in the template's own variables ---------------------------------------- */
:root,
[data-pc-theme="dark"],
[data-pc-theme="light"] {
  --bs-font-sans-serif: var(--font-sans);
  --bs-font-monospace: var(--font-mono);
  --bs-body-font-family: var(--font-sans);
  --bs-body-font-size: var(--fs-base);
  --bs-body-font-weight: 400;
  --bs-body-line-height: var(--lh-body);

  --bs-body-color: var(--c-text);
  --bs-body-bg: var(--c-page);
  --bs-emphasis-color: var(--c-text);
  --bs-secondary-color: var(--c-muted);
  --bs-tertiary-color: var(--c-placeholder);
  --bs-secondary-bg: var(--c-surface-3);
  --bs-tertiary-bg: var(--c-surface-2);
  --bs-heading-color: var(--c-text);
  --pc-heading-color: var(--c-text);
  --bs-code-color: var(--c-text-2);
  --bs-highlight-bg: var(--c-warn-tint);
  --bs-highlight-color: var(--c-text);

  --bs-link-color: var(--c-brand-text);
  --bs-link-hover-color: var(--c-brand-text-hover);
  --bs-link-decoration: none;

  --bs-primary: var(--c-brand);
  --bs-secondary: var(--c-neutral);
  --bs-success: var(--c-ok);
  --bs-info: var(--c-pending);
  --bs-warning: var(--c-warn);
  --bs-danger: var(--c-bad);

  --bs-primary-text-emphasis: var(--c-brand-text);
  --bs-secondary-text-emphasis: var(--c-neutral-text);
  --bs-success-text-emphasis: var(--c-ok-text);
  --bs-info-text-emphasis: var(--c-pending-text);
  --bs-warning-text-emphasis: var(--c-warn-text);
  --bs-danger-text-emphasis: var(--c-bad-text);

  --bs-primary-bg-subtle: var(--c-brand-tint);
  --bs-secondary-bg-subtle: var(--c-neutral-tint);
  --bs-success-bg-subtle: var(--c-ok-tint);
  --bs-info-bg-subtle: var(--c-pending-tint);
  --bs-warning-bg-subtle: var(--c-warn-tint);
  --bs-danger-bg-subtle: var(--c-bad-tint);

  --bs-primary-border-subtle: var(--c-brand-tint-border);
  --bs-secondary-border-subtle: var(--c-neutral-border);
  --bs-success-border-subtle: var(--c-ok-border);
  --bs-info-border-subtle: var(--c-pending-border);
  --bs-warning-border-subtle: var(--c-warn-border);
  --bs-danger-border-subtle: var(--c-bad-border);

  --bs-border-color: var(--c-border);
  --bs-border-color-translucent: var(--c-border);
  --bs-border-radius: var(--r-md);
  --bs-border-radius-sm: var(--r-sm);
  --bs-border-radius-lg: var(--r-lg);
  --bs-border-radius-xl: var(--r-xl);
  --bs-border-radius-pill: var(--r-pill);

  --bs-box-shadow-sm: var(--e-1);
  --bs-box-shadow: var(--e-2);
  --bs-box-shadow-lg: var(--e-3);
  --bs-focus-ring-color: var(--c-focus-halo);
  --bs-form-valid-color: var(--c-ok-text);
  --bs-form-valid-border-color: var(--c-ok);
  --bs-form-invalid-color: var(--c-bad-text);
  --bs-form-invalid-border-color: var(--c-bad);

  --pc-card-box-shadow: var(--e-1);
  --pc-active-background: var(--c-surface-3);
  --pc-header-background: var(--c-surface);
  --pc-header-color: var(--c-text-2);
  --pc-header-submenu-background: var(--c-surface);
  --pc-header-submenu-color: var(--c-text);
  --pc-sidebar-background: var(--c-side-bg);
  --pc-sidebar-color: var(--c-side-text);
}

/* The template's utilities read `rgba(var(--bs-*-rgb), α)`, which a hex token cannot feed. */
:root,
[data-pc-theme="light"] {
  --bs-body-color-rgb: 15, 31, 38;
  --bs-body-bg-rgb: 244, 247, 248;
  --bs-emphasis-color-rgb: 15, 31, 38;
  --bs-secondary-color-rgb: 92, 108, 116;
  --bs-secondary-bg-rgb: 238, 242, 244;
  --bs-tertiary-bg-rgb: 247, 249, 250;
  --bs-link-color-rgb: 9, 106, 127;
  --bs-link-hover-color-rgb: 6, 72, 87;
  --bs-primary-rgb: 10, 120, 144;
  --bs-secondary-rgb: 116, 133, 141;
  --bs-success-rgb: 42, 157, 85;
  --bs-info-rgb: 79, 145, 242;
  --bs-warning-rgb: 232, 167, 10;
  --bs-danger-rgb: 184, 38, 31;
  --bs-light-rgb: 247, 249, 250;
  --bs-dark-rgb: 11, 31, 38;
}
[data-pc-theme="dark"] {
  --bs-body-color-rgb: 230, 238, 240;
  --bs-body-bg-rgb: 10, 24, 29;
  --bs-emphasis-color-rgb: 230, 238, 240;
  --bs-secondary-color-rgb: 142, 163, 171;
  --bs-secondary-bg-rgb: 27, 53, 62;
  --bs-tertiary-bg-rgb: 21, 44, 52;
  --bs-link-color-rgb: 92, 202, 212;
  --bs-link-hover-color-rgb: 138, 221, 229;
  --bs-primary-rgb: 10, 120, 144;
  --bs-secondary-rgb: 127, 149, 157;
  --bs-success-rgb: 51, 217, 119;
  --bs-info-rgb: 111, 150, 232;
  --bs-warning-rgb: 245, 175, 32;
  --bs-danger-rgb: 226, 72, 79;
  --bs-light-rgb: 21, 44, 52;
  --bs-dark-rgb: 7, 19, 24;
}
