/*
 * Design tokens
 * ------------------------------------------------------------------
 * Two layers:
 *   1. Primitives  — raw colour scales (--gray-500, --teal-600…).
 *                    Never use these directly in components.
 *   2. Semantic    — what a colour is FOR (--color-text, --color-primary…).
 *                    Components only use these, so switching theme is just
 *                    a matter of re-pointing the semantic tokens.
 *
 * Light mode is the default. Dark mode is defined below under
 * [data-theme="dark"] but is not switched on anywhere yet. To try it,
 * add data-theme="dark" to the <html> tag in the layout.
 */

:root {
  /* ================================================================
   * 1. PRIMITIVES
   * ================================================================ */

  --white: #ffffff;
  --black: #000000;

  /* Neutral gray, slightly cool so it sits well next to teal */
  --gray-25: #fcfcfd;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --gray-950: #020617;

  /* Brand — teal */
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;
  --teal-950: #042f2e;

  /* Status: success */
  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-200: #bbf7d0;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-900: #14532d;

  /* Status: warning */
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --amber-900: #78350f;

  /* Status: danger */
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-200: #fecaca;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --red-900: #7f1d1d;

  /* Status: info */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-900: #1e3a8a;

  /* ================================================================
   * 2. SEMANTIC COLOURS — LIGHT MODE (default)
   * ================================================================ */

  color-scheme: light;

  /* Surfaces (back to front) */
  --color-bg: var(--gray-50);              /* page background */
  --color-surface: var(--white);           /* cards, sidebar, inputs */
  --color-surface-sunken: var(--gray-100); /* wells, table headers */
  --color-surface-hover: var(--gray-100);
  --color-surface-active: var(--gray-200);
  --color-overlay: rgb(15 23 42 / 0.4);

  /* Borders */
  --color-border: var(--gray-200);
  --color-border-strong: var(--gray-300);

  /* Text */
  --color-text: var(--gray-900);
  --color-text-muted: var(--gray-600);
  --color-text-subtle: var(--gray-500);   /* placeholders, meta */
  --color-text-disabled: var(--gray-400);
  --color-text-inverse: var(--white);

  /* Brand / primary action */
  --color-primary: var(--teal-600);
  --color-primary-hover: var(--teal-700);
  --color-primary-active: var(--teal-800);
  --color-primary-subtle: var(--teal-50);
  --color-primary-subtle-hover: var(--teal-100);
  --color-primary-border: var(--teal-200);
  --color-primary-text: var(--teal-700);  /* teal text on light bg */
  --color-on-primary: var(--white);       /* text on solid primary */

  /* Status — each has: solid, subtle background, border, text */
  --color-success: var(--green-600);
  --color-success-subtle: var(--green-50);
  --color-success-border: var(--green-200);
  --color-success-text: var(--green-700);

  --color-warning: var(--amber-500);
  --color-warning-subtle: var(--amber-50);
  --color-warning-border: var(--amber-200);
  --color-warning-text: var(--amber-700);

  --color-danger: var(--red-600);
  --color-danger-hover: var(--red-700);
  --color-danger-subtle: var(--red-50);
  --color-danger-border: var(--red-200);
  --color-danger-text: var(--red-700);

  --color-info: var(--blue-600);
  --color-info-subtle: var(--blue-50);
  --color-info-border: var(--blue-200);
  --color-info-text: var(--blue-700);

  /* Focus ring */
  --color-focus: var(--teal-500);
  --focus-ring: 0 0 0 3px rgb(20 184 166 / 0.3);

  /* Chat bubbles */
  --color-bubble-incoming: var(--white);
  --color-bubble-incoming-text: var(--color-text);
  --color-bubble-admin: var(--teal-600);
  --color-bubble-admin-text: var(--white);
  --color-bubble-bot: var(--teal-50);
  --color-bubble-bot-text: var(--teal-900);
  --color-chat-bg: var(--gray-50);

  /* ================================================================
   * 3. TYPOGRAPHY
   * ================================================================ */

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    monospace;

  /* Font sizes (rem, so they respect the user's browser setting) */
  --text-xs: 0.75rem;    /* 12px — meta, badges */
  --text-sm: 0.875rem;   /* 14px — default UI text */
  --text-md: 1rem;       /* 16px — emphasised body */
  --text-lg: 1.125rem;   /* 18px — card titles */
  --text-xl: 1.25rem;    /* 20px — section titles */
  --text-2xl: 1.5rem;    /* 24px — page titles */
  --text-3xl: 1.875rem;  /* 30px — hero */

  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

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

  --tracking-tight: -0.015em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;

  /* ================================================================
   * 4. SPACING — 4px base grid (--space-N = N × 4px)
   * ================================================================ */

  --space-0: 0;
  --space-0-5: 0.125rem; /* 2px  */
  --space-1: 0.25rem;    /* 4px  */
  --space-1-5: 0.375rem; /* 6px  */
  --space-2: 0.5rem;     /* 8px  */
  --space-3: 0.75rem;    /* 12px */
  --space-4: 1rem;       /* 16px */
  --space-5: 1.25rem;    /* 20px */
  --space-6: 1.5rem;     /* 24px */
  --space-8: 2rem;       /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */

  /* ================================================================
   * 5. RADII, BORDERS, SHADOWS
   * ================================================================ */

  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;     /* buttons, inputs */
  --radius-lg: 8px;     /* cards */
  --radius-xl: 12px;    /* large panels, modals */
  --radius-2xl: 16px;   /* chat bubbles */
  --radius-full: 9999px;

  --border-width: 1px;
  --border: var(--border-width) solid var(--color-border);
  --border-strong: var(--border-width) solid var(--color-border-strong);

  --shadow-xs: 0 1px 2px rgb(15 23 42 / 0.05);
  --shadow-sm: 0 1px 3px rgb(15 23 42 / 0.08), 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-md: 0 4px 8px -2px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.04);
  --shadow-lg: 0 12px 24px -6px rgb(15 23 42 / 0.12), 0 4px 8px -4px rgb(15 23 42 / 0.06);

  /* ================================================================
   * 6. SIZES, LAYOUT, MOTION, LAYERS
   * ================================================================ */

  --control-height-sm: 2rem;    /* 32px */
  --control-height-md: 2.25rem; /* 36px */
  --control-height-lg: 2.75rem; /* 44px */

  --sidebar-width: 15rem;       /* 240px */
  --content-max-width: 72rem;   /* 1152px */
  --auth-card-width: 24rem;     /* 384px */

  --icon-sm: 1rem;
  --icon-md: 1.25rem;
  --avatar-sm: 2rem;
  --avatar-md: 2.5rem;
  --avatar-lg: 3.5rem;
  --avatar-xl: 6rem;

  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --z-base: 0;
  --z-sticky: 10;
  --z-dropdown: 20;
  --z-overlay: 40;
  --z-modal: 50;
  --z-toast: 60;
  /* Category colours (see Colorable::COLORS). Each has a "colour" (pill text and
     picker swatch) and a "highlight" (pill background) */
  --category-red: #b91c1c;        --category-red-highlight: #fee2e2;
  --category-orange: #c2410c;     --category-orange-highlight: #ffedd5;
  --category-amber: #b45309;      --category-amber-highlight: #fef3c7;
  --category-green: #15803d;      --category-green-highlight: #dcfce7;
  --category-teal: #0f766e;       --category-teal-highlight: #ccfbf1;
  --category-blue: #1d4ed8;       --category-blue-highlight: #dbeafe;
  --category-indigo: #4338ca;     --category-indigo-highlight: #e0e7ff;
  --category-purple: #7e22ce;     --category-purple-highlight: #f3e8ff;
  --category-pink: #be185d;       --category-pink-highlight: #fce7f3;
  --category-gray: #475569;       --category-gray-highlight: #e2e8f0;
}

/* ==================================================================
 * DARK MODE (not active yet)
 * Only the semantic tokens change — components need no edits.
 * To enable it later, either:
 *   - set <html data-theme="dark"> (e.g. from a user preference), or
 *   - also wrap this block in @media (prefers-color-scheme: dark)
 *     to follow the OS setting.
 * ================================================================== */
[data-theme="dark"] {
  color-scheme: dark;

  --color-bg: var(--gray-950);
  --color-surface: var(--gray-900);
  --color-surface-sunken: #0b1324;
  --color-surface-hover: var(--gray-800);
  --color-surface-active: var(--gray-700);
  --color-overlay: rgb(2 6 23 / 0.7);

  --color-border: var(--gray-800);
  --color-border-strong: var(--gray-700);

  --color-text: var(--gray-100);
  --color-text-muted: var(--gray-400);
  --color-text-subtle: var(--gray-500);
  --color-text-disabled: var(--gray-600);
  --color-text-inverse: var(--gray-950);

  --color-primary: var(--teal-500);
  --color-primary-hover: var(--teal-400);
  --color-primary-active: var(--teal-300);
  --color-primary-subtle: rgb(20 184 166 / 0.12);
  --color-primary-subtle-hover: rgb(20 184 166 / 0.2);
  --color-primary-border: rgb(20 184 166 / 0.35);
  --color-primary-text: var(--teal-300);
  --color-on-primary: var(--gray-950);

  --color-success: var(--green-500);
  --color-success-subtle: rgb(34 197 94 / 0.12);
  --color-success-border: rgb(34 197 94 / 0.3);
  --color-success-text: var(--green-200);

  --color-warning: var(--amber-500);
  --color-warning-subtle: rgb(245 158 11 / 0.12);
  --color-warning-border: rgb(245 158 11 / 0.3);
  --color-warning-text: var(--amber-200);

  --color-danger: var(--red-500);
  --color-danger-hover: var(--red-600);
  --color-danger-subtle: rgb(239 68 68 / 0.12);
  --color-danger-border: rgb(239 68 68 / 0.3);
  --color-danger-text: var(--red-200);

  --color-info: var(--blue-500);
  --color-info-subtle: rgb(59 130 246 / 0.12);
  --color-info-border: rgb(59 130 246 / 0.3);
  --color-info-text: var(--blue-200);

  --color-focus: var(--teal-400);
  --focus-ring: 0 0 0 3px rgb(45 212 191 / 0.35);

  --color-bubble-incoming: var(--gray-800);
  --color-bubble-incoming-text: var(--gray-100);
  --color-bubble-admin: var(--teal-700);
  --color-bubble-admin-text: var(--white);
  --color-bubble-bot: rgb(20 184 166 / 0.15);
  --color-bubble-bot-text: var(--teal-100);
  --color-chat-bg: var(--gray-950);

  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 8px -2px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 12px 24px -6px rgb(0 0 0 / 0.6);
  /* Category colours: lighter text on a translucent highlight */
  --category-red: #fca5a5;        --category-red-highlight: rgb(239 68 68 / 0.15);
  --category-orange: #fdba74;     --category-orange-highlight: rgb(249 115 22 / 0.15);
  --category-amber: #fcd34d;      --category-amber-highlight: rgb(245 158 11 / 0.15);
  --category-green: #86efac;      --category-green-highlight: rgb(34 197 94 / 0.15);
  --category-teal: #5eead4;       --category-teal-highlight: rgb(20 184 166 / 0.15);
  --category-blue: #93c5fd;       --category-blue-highlight: rgb(59 130 246 / 0.15);
  --category-indigo: #a5b4fc;     --category-indigo-highlight: rgb(99 102 241 / 0.15);
  --category-purple: #d8b4fe;     --category-purple-highlight: rgb(168 85 247 / 0.15);
  --category-pink: #f9a8d4;       --category-pink-highlight: rgb(236 72 153 / 0.15);
  --category-gray: #cbd5e1;       --category-gray-highlight: rgb(100 116 139 / 0.2);
}
