@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-2xl: calc(var(--radius) + 8px);
  --radius-full: 9999px;

  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;

  --background: oklch(0.145 0 0);           /* #1a1a1a - Page background */
  --foreground: oklch(0.985 0 0);           /* Near white - Primary text */

  --card: oklch(0.205 0 0);                 /* Elevated surface */
  --card-foreground: oklch(0.985 0 0);

  --muted: oklch(0.269 0 0);                /* Muted surface */
  --muted-foreground: oklch(0.708 0 0);     /* Subdued text */

  --primary: oklch(0.45 0.14 25);           /* AmSpec maroon, lifted for dark UI */
  --primary-foreground: oklch(0.98 0 0);
  --primary-hover: oklch(0.50 0.15 25);     /* Lighter on hover (dark UI) */

  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);

  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);

  --destructive: oklch(0.704 0.191 22.216); /* Red */
  --destructive-foreground: oklch(0.98 0 0);

  --success: oklch(0.65 0.19 145);          /* #22c55e equivalent */
  --success-foreground: oklch(0.98 0 0);

  --warning: oklch(0.75 0.15 85);           /* #f59e0b equivalent */
  --warning-foreground: oklch(0.15 0 0);

  --info: oklch(0.65 0.15 250);             /* Blue */
  --info-foreground: oklch(0.98 0 0);

  --border: oklch(1 0 0 / 10%);             /* Hairline */
  --border-light: oklch(1 0 0 / 15%);       /* Lighter border */
  --input: oklch(1 0 0 / 4.5%);             /* Input background */
  --input-border: oklch(1 0 0 / 15%);       /* Input border */
  --ring: oklch(0.556 0 0 / 50%);           /* Focus ring (3px halo) */
  --ring-strong: oklch(0.556 0 0);          /* Focused border */

  --sidebar: oklch(0.205 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.45 0.14 25);
  --sidebar-primary-foreground: oklch(0.98 0 0);
  --sidebar-accent: oklch(0.269 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-muted: oklch(0.55 0 0);

  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --popover-border: oklch(1 0 0 / 10%);

  --table-header: oklch(0.32 0.09 25);      /* Maroon tinted header */
  --table-header-foreground: oklch(0.98 0 0);
  --table-row-odd: oklch(1 0 0 / 2%);
  --table-row-hover: oklch(0.269 0 0 / 50%);
  --table-border: oklch(1 0 0 / 10%);

  --chart-1: oklch(0.45 0.14 25);           /* Primary maroon */
  --chart-2: oklch(0.65 0.19 145);          /* Success green */
  --chart-3: oklch(0.75 0.15 85);           /* Warning amber */
  --chart-4: oklch(0.65 0.15 250);          /* Info blue */
  --chart-5: oklch(0.6 0.18 330);           /* Purple accent */

  /* Categorical series (blend comparison rows + chart): distinct hues,
     lifted for the dark ground */
  --series-1: #60a5fa;  /* blue */
  --series-2: #fb923c;  /* orange */
  --series-3: #c084fc;  /* violet */
  --series-4: #2dd4bf;  /* teal */
  --series-5: #f472b6;  /* pink */
  --series-6: #facc15;  /* amber */
  --series-7: #a3a3a3;  /* grey */

  --shadow-xs: 0 1px 2px 0 oklch(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 oklch(0 0 0 / 0.1), 0 1px 2px -1px oklch(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px oklch(0 0 0 / 0.1), 0 2px 4px -2px oklch(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px oklch(0 0 0 / 0.25), 0 4px 6px -4px oklch(0 0 0 / 0.25);
  --shadow-xl: 0 20px 25px -5px oklch(0 0 0 / 0.35), 0 8px 10px -6px oklch(0 0 0 / 0.35);

  --transition-fast: 0.1s ease;
  --transition-base: 0.15s ease;
  --transition-slow: 0.25s ease;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;

  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;

  --line-height-tight: 1.25;
  --line-height-base: 1.5;
  --line-height-relaxed: 1.75;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --z-dropdown: 50;
  --z-sticky: 100;
  --z-fixed: 200;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;
  --z-toast: 800;
}

/* ===== LIGHT THEME =====
 * shadcn/ui "neutral" light values. Switched by data-theme on <html>
 * (assets/js/theme.js); dark above stays the default.
 */
html[data-theme="light"] {
  color-scheme: light;

  --background: oklch(0.955 0 0);          /* page: light grey */
  --foreground: oklch(0.145 0 0);

  --card: oklch(0.985 0 0);                /* cards: off-white */
  --card-foreground: oklch(0.145 0 0);

  --muted: oklch(0.935 0 0);               /* label cells, quiet areas */
  --muted-foreground: oklch(0.556 0 0);

  --primary: oklch(0.45 0.14 25);
  --primary-foreground: oklch(0.985 0 0);
  --primary-hover: oklch(0.40 0.13 25);

  --secondary: oklch(0.935 0 0);
  --secondary-foreground: oklch(0.205 0 0);

  --accent: oklch(0.925 0 0);
  --accent-foreground: oklch(0.205 0 0);

  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);

  --success: oklch(0.55 0.15 150);
  --warning: oklch(0.65 0.16 65);
  --warning-foreground: oklch(0.985 0 0);
  --info: oklch(0.55 0.18 255);

  --border: oklch(0.885 0 0);
  --border-light: oklch(0.87 0 0);
  --input: oklch(1 0 0);                   /* fields: pure white so they read as editable */
  --input-border: oklch(0.84 0 0);
  --ring: oklch(0.708 0 0 / 50%);
  --ring-strong: oklch(0.708 0 0);

  --sidebar: oklch(0.975 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.925 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-muted: oklch(0.556 0 0);

  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --popover-border: oklch(0.922 0 0);

  --table-row-odd: oklch(0 0 0 / 2.5%);
  --table-row-hover: oklch(0.935 0 0);
  --table-border: oklch(0.885 0 0);

  --series-1: #2563eb;
  --series-2: #ea580c;
  --series-3: #9333ea;
  --series-4: #0d9488;
  --series-5: #db2777;
  --series-6: #b45309;
  --series-7: #525252;

  --shadow-lg: 0 10px 15px -3px oklch(0 0 0 / 0.1), 0 4px 6px -4px oklch(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px oklch(0 0 0 / 0.1), 0 8px 10px -6px oklch(0 0 0 / 0.1);
}

/* ===== COLOUR-BLIND MODE =====
 * <html data-cvd="on"> (per user, dbo.app_user.colorblind_mode), over either theme.
 * Okabe-Ito hues: success blue, error vermillion, warning yellow, so no state
 * depends on telling red from green. --cvd-* exist only here: the stylesheets
 * use them as var(--cvd-ok, #10b981), keeping their own colour otherwise.
 */
html[data-cvd="on"] {
  --success: #3a93d6;
  --destructive: #e8731a;
  --warning: #f0e442;
  --warning-foreground: oklch(0.15 0 0);
  --info: #cc79a7;

  --chart-2: #3a93d6;
  --chart-3: #f0e442;
  --chart-4: #cc79a7;

  --series-1: #56b4e9;  /* sky blue */
  --series-2: #e69f00;  /* orange */
  --series-3: #cc79a7;  /* reddish purple */
  --series-4: #26b58c;  /* bluish green */
  --series-5: #f0e442;  /* yellow */
  --series-6: #e8731a;  /* vermillion */
  --series-7: #a3a3a3;  /* grey */

  --cvd-ok: #3a93d6;
  --cvd-ok-strong: #1f78bd;
  --cvd-ok-deep: #155f99;
  --cvd-ok-soft: #6cbcf0;
  --cvd-bad: #e8731a;
  --cvd-bad-strong: #d55e00;
  --cvd-bad-deep: #b34d00;
}

html[data-theme="light"][data-cvd="on"] {
  --success: #0072b2;
  --destructive: #d55e00;
  --warning: #a68a00;
  --warning-foreground: oklch(0.985 0 0);
  --info: #a8578a;

  --chart-2: #0072b2;
  --chart-3: #a68a00;
  --chart-4: #a8578a;

  --series-1: #0072b2;
  --series-2: #c98700;
  --series-3: #a8578a;
  --series-4: #007a59;
  --series-5: #8a7a00;
  --series-6: #d55e00;
  --series-7: #525252;

  --cvd-ok: #0072b2;
  --cvd-ok-strong: #005f94;
  --cvd-ok-deep: #004b75;
  --cvd-ok-soft: #3a93d6;
  --cvd-bad: #d55e00;
  --cvd-bad-strong: #b84f00;
  --cvd-bad-deep: #963f00;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--foreground);
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

:focus:not(:focus-visible) {
  outline: none;
}

::selection {
  background-color: var(--primary);
  color: var(--primary-foreground);
}
