@import 'tailwindcss';
@import 'tw-animate-css';

@custom-variant dark (&:is(.dark *));

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --font-sans:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
  --color-chart-5: var(--chart-5);
  --color-chart-4: var(--chart-4);
  --color-chart-3: var(--chart-3);
  --color-chart-2: var(--chart-2);
  --color-chart-1: var(--chart-1);
  --color-ring: var(--ring);
  --color-input: var(--input);
  --color-border: var(--border);
  --color-destructive: var(--destructive);
  --color-accent-foreground: var(--accent-foreground);
  --color-accent: var(--accent);
  --color-muted-foreground: var(--muted-foreground);
  --color-muted: var(--muted);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-secondary: var(--secondary);
  --color-primary-foreground: var(--primary-foreground);
  --color-primary: var(--primary);
  --color-popover-foreground: var(--popover-foreground);
  --color-popover: var(--popover);
  --color-card-foreground: var(--card-foreground);
  --color-card: var(--card);
  --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);
}

:root {
  --radius: 0.625rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.4 0.15 260);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.4 0.15 260);
  --chart-1: oklch(0.4 0.15 260);
  --chart-2: oklch(0.6 0.118 184.704);
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);
  /* Semantic status colors (token layer) — consumed by the --bl-* bridge below */
  --success: oklch(0.62 0.14 150);
  --warning: oklch(0.68 0.15 70);
  --info: oklch(0.55 0.13 240);
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.6 0.2 260);
  --primary-foreground: oklch(0.145 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.6 0.2 260);
  --chart-1: oklch(0.488 0.243 264.376);
  --chart-2: oklch(0.696 0.17 162.48);
  --chart-3: oklch(0.769 0.188 70.08);
  --chart-4: oklch(0.627 0.265 303.9);
  --chart-5: oklch(0.645 0.246 16.439);
  --success: oklch(0.7 0.15 155);
  --warning: oklch(0.75 0.15 75);
  --info: oklch(0.65 0.14 240);
}

/*
 * Token bridge: map the @bytelyst/* `--bl-*` token surface onto tracker's
 * shadcn-style OKLCH vars so every adopted shared component (ui, auth-ui,
 * notifications-ui, dashboard-components, charts) inherits the theme in both
 * light and dark automatically. Extends the UX-1.2 minimum set (UX-1.2 / CC.2).
 * Everything references tracker vars (or color-mix of them) so dark mode flips
 * for free; no standalone color literals here.
 */
:root,
.dark {
  /* Accent / primary / links */
  --bl-accent: var(--primary);
  --bl-accent-foreground: var(--primary-foreground);
  --bl-accent-muted: color-mix(in oklch, var(--primary) 12%, transparent);
  --bl-primary: var(--primary);
  --bl-link: var(--primary);

  /* Backgrounds & surfaces */
  --bl-bg-canvas: var(--background);
  --bl-page-bg: var(--background);
  --bl-bg-elevated: var(--card);
  --bl-surface: var(--card);
  --bl-surface-card: var(--card);
  --bl-surface-sidebar: var(--card);
  --bl-surface-highlight: var(--accent);
  --bl-surface-hover: var(--accent);
  --bl-surface-muted: var(--muted);

  /* Text */
  --bl-text: var(--foreground);
  --bl-text-primary: var(--foreground);
  --bl-text-secondary: var(--muted-foreground);
  --bl-text-tertiary: var(--muted-foreground);
  --bl-muted: var(--muted-foreground);

  /* Borders, inputs, focus */
  --bl-border: var(--border);
  --bl-border-strong: var(--border);
  --bl-border-subtle: var(--border);
  --bl-input: var(--input);
  --bl-focus-ring: var(--ring);
  --bl-focus-ring-muted: color-mix(in oklch, var(--ring) 40%, transparent);

  /* Danger / error */
  --bl-danger: var(--destructive);
  --bl-danger-foreground: var(--primary-foreground);
  --bl-danger-border: color-mix(in oklch, var(--destructive) 45%, transparent);
  --bl-danger-muted: color-mix(in oklch, var(--destructive) 12%, transparent);
  --bl-error: var(--destructive);

  /* Success / warning / info (semantic token layer flips per-theme) */
  --bl-success: var(--success);
  --bl-success-border: color-mix(in oklch, var(--success) 45%, transparent);
  --bl-success-muted: color-mix(in oklch, var(--success) 12%, transparent);
  --bl-warning: var(--warning);
  --bl-warning-border: color-mix(in oklch, var(--warning) 45%, transparent);
  --bl-warning-muted: color-mix(in oklch, var(--warning) 12%, transparent);
  --bl-info: var(--info);
  --bl-info-border: color-mix(in oklch, var(--info) 45%, transparent);
  --bl-info-muted: color-mix(in oklch, var(--info) 12%, transparent);

  /* Overlay scrim */
  --bl-overlay-scrim: color-mix(in oklch, var(--foreground) 40%, transparent);

  /* Radii */
  --bl-radius: var(--radius-md);
  --bl-radius-control: var(--radius-md);
  --bl-radius-card: var(--radius-lg);
  --bl-card-radius: var(--radius-lg);
  --bl-radius-pill: 9999px;

  /* Spacing */
  --bl-space-2: 0.5rem;
  --bl-space-3: 0.75rem;
  --bl-space-4: 1rem;

  /* Typography */
  --bl-font: var(--font-sans);
  --bl-font-display: var(--font-sans);

  /* Elevation / layout */
  --bl-card-shadow: 0 1px 2px 0 color-mix(in oklch, var(--foreground) 8%, transparent);
  --bl-app-sidebar-width: 16rem;

  /* Chart palette */
  --bl-chart-1: var(--chart-1);
  --bl-chart-2: var(--chart-2);
  --bl-chart-3: var(--chart-3);
  --bl-chart-4: var(--chart-4);
  --bl-chart-5: var(--chart-5);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    @apply bg-background text-foreground;
  }
}
