/* ==========================================================================
   AlDerhamy HCAG — Design tokens, theme, reset, typography, utilities
   A front-end prototype. All values are illustrative demo data.
   ========================================================================== */

:root {
  /* --- Brand palette --- */
  --navy-900: #061424;
  --navy-800: #0a2138;
  --navy-700: #10314f;
  --navy-600: #17456f;
  --emerald-900: #062e26;
  --emerald-800: #0a3f34;
  --emerald-700: #0d5a49;
  --emerald-600: #12836a;
  --emerald-500: #1a9d80;
  --gold-600: #9d7a2c;
  --gold-500: #c9a24d;
  --gold-400: #d9b96b;
  --gold-300: #e7cd8b;

  /* --- Semantic status --- */
  --success: #1a7f5a;
  --success-bg: #e5f5ec;
  --warning: #a86a12;
  --warning-bg: #fdf1dd;
  --danger: #b42318;
  --danger-bg: #fdeceb;
  --info: #175cd3;
  --info-bg: #e8f0fe;
  --neutral-500: #6b7280;
  --neutral-bg: #eef0f3;

  /* --- Surfaces (light) --- */
  --bg: #f5f4f0;
  --bg-alt: #ecebe4;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #f2f1ec;
  --border: #e2e0d7;
  --border-strong: #cfccbf;
  --text: #16202e;
  --text-soft: #4d5a6b;
  --text-muted: #7b8798;
  --text-inverse: #ffffff;
  --sidebar-bg: linear-gradient(180deg, #0a2138 0%, #061424 60%, #061424 100%);
  --sidebar-text: #c8d4e2;
  --sidebar-text-strong: #ffffff;
  --sidebar-active: rgba(201, 162, 77, 0.16);
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --chart-grid: #e6e4dc;
  --focus: #175cd3;

  /* --- Spacing scale --- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 56px;

  /* --- Radii --- */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* --- Typography --- */
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-base: 14px;
  --fs-md: 15.5px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-3xl: 34px;
  --lh-tight: 1.2;
  --lh-normal: 1.5;
  --lh-loose: 1.7;

  /* --- Shadows --- */
  --shadow-xs: 0 1px 2px rgba(6, 20, 36, 0.06);
  --shadow-sm: 0 2px 6px rgba(6, 20, 36, 0.07);
  --shadow-md: 0 8px 22px rgba(6, 20, 36, 0.09);
  --shadow-lg: 0 18px 48px rgba(6, 20, 36, 0.16);
  --shadow-gold: 0 6px 20px rgba(157, 122, 44, 0.24);

  /* --- Layout --- */
  --sidebar-w: 268px;
  --sidebar-w-collapsed: 74px;
  --topbar-h: 66px;
  --content-max: 1520px;

  /* --- Motion --- */
  --t-fast: 120ms ease;
  --t-base: 200ms cubic-bezier(0.4, 0.1, 0.2, 1);
  --t-slow: 320ms cubic-bezier(0.4, 0.1, 0.2, 1);
}

/* =====================  DARK THEME  ===================== */
[data-theme="dark"] {
  --bg: #060e18;
  --bg-alt: #0a1622;
  --surface: #0d1b2a;
  --surface-2: #101f30;
  --surface-3: #16273a;
  --border: #1e3348;
  --border-strong: #2c4761;
  --text: #e8eef6;
  --text-soft: #b3c2d3;
  --text-muted: #8698ac;
  --text-inverse: #061424;
  --sidebar-bg: linear-gradient(180deg, #08182a 0%, #050d17 70%, #050d17 100%);
  --sidebar-text: #9fb2c7;
  --sidebar-text-strong: #ffffff;
  --sidebar-active: rgba(201, 162, 77, 0.22);
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --chart-grid: #1c2f44;

  --success: #4ecb9b;
  --success-bg: rgba(78, 203, 155, 0.14);
  --warning: #e6b45f;
  --warning-bg: rgba(230, 180, 95, 0.14);
  --danger: #f3867d;
  --danger-bg: rgba(243, 134, 125, 0.14);
  --info: #7aabf7;
  --info-bg: rgba(122, 171, 247, 0.14);
  --neutral-bg: rgba(255, 255, 255, 0.07);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 26px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 22px 54px rgba(0, 0, 0, 0.6);
}

/* =====================  RESET  ===================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
h1, h2, h3, h4, h5 { margin: 0; font-weight: 650; line-height: var(--lh-tight); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--emerald-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
ul, ol { margin: 0; padding-left: 1.15rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-5) 0; }
code, kbd, samp { font-family: var(--font-mono); font-size: 0.92em; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* =====================  TYPOGRAPHY HELPERS  ===================== */
.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--gold-600);
}
[data-theme="dark"] .eyebrow { color: var(--gold-400); }
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fs-sm { font-size: var(--fs-sm); }
.fs-xs { font-size: var(--fs-xs); }
.fs-lg { font-size: var(--fs-lg); }
.strong { font-weight: 650; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.strike { text-decoration: line-through; }
.arabic {
  font-family: "Traditional Arabic", "Amiri", "Scheherazade New", serif;
  font-size: 1.35em;
  color: var(--gold-600);
}

/* =====================  LAYOUT UTILITIES  ===================== */
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.row--top { align-items: flex-start; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack--sm { gap: var(--sp-2); }
.stack--lg { gap: var(--sp-5); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.grid { display: grid; gap: var(--sp-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid--split { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.grid--split-left { grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.w-100 { width: 100%; }
.hide-mobile { display: initial; }

/* =====================  ACCESSIBILITY  ===================== */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 50%; transform: translate(-50%, -140%);
  top: 0; z-index: 200; background: var(--surface); color: var(--text);
  padding: var(--sp-3) var(--sp-5); border-radius: 0 0 var(--r-md) var(--r-md);
  box-shadow: var(--shadow-md); font-weight: 600; transition: transform var(--t-base);
}
.skip-link:focus { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* =====================  SCROLLBARS  ===================== */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }

/* =====================  CHART + PROGRESS PRIMITIVES  ===================== */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-5); margin-top: var(--sp-4); }
.chart-legend__item { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-soft); }
.chart-legend__swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.chart-legend__value { color: var(--text); font-weight: 620; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-3); font-size: var(--fs-sm); }
.bar-track { height: 9px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; margin-top: 5px; }
.bar-fill { height: 100%; border-radius: var(--r-pill); transition: width var(--t-slow); }
.chart-svg .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart-svg .axis-label { fill: var(--text-muted); font-size: 10.5px; font-family: var(--font-sans); }
.chart-svg .series-area { opacity: 0.16; }
.chart-svg .point { transition: r var(--t-fast); }
.chart-svg [data-tip]:hover .point, .chart-svg [data-tip]:focus .point { r: 5.5; }
.chart-empty { display: grid; place-items: center; min-height: 180px; color: var(--text-muted); font-size: var(--fs-sm); }
.donut-center { font-family: var(--font-sans); }
.tooltip-note { cursor: help; border-bottom: 1px dotted var(--border-strong); }
