/*
 * Single source of design tokens (blueprint 30.1 rule 1). Components use only these variables via Tailwind.
 * Tenant branding overrides --primary / --accent / --radius / --font-sans at runtime (shared/lib/branding.ts).
 */
:root {
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --background: #f6f7fb;
  --surface: #ffffff;
  --surface-muted: #f1f3f9;
  --surface-raised: #ffffff;
  --border: #e4e7ef;
  --border-strong: #cdd2e0;
  --foreground: #121826;
  --foreground-muted: #5b6477;
  --foreground-subtle: #8a93a6;

  --primary: #4f46e5;
  --primary-foreground: #ffffff;
  --primary-soft: color-mix(in srgb, var(--primary) 10%, transparent);
  --primary-ring: color-mix(in srgb, var(--primary) 35%, transparent);
  --accent: #0ea5e9;
  --accent-foreground: #ffffff;
  --secondary: #64748b;
  /* categorical chart series (colour-blind safe); series 1 is the tenant primary */
  --chart-2: #e69f00;
  --chart-3: #009e73;
  --chart-4: #cc79a7;
  --chart-5: #56b4e9;
  --chart-6: #d55e00;
  --chart-7: #f0e442;
  --chart-8: #7c7c7c;

  --success: #16a34a;
  --success-soft: color-mix(in srgb, var(--success) 12%, transparent);
  --warning: #d97706;
  --warning-soft: color-mix(in srgb, var(--warning) 14%, transparent);
  --danger: #dc2626;
  --danger-soft: color-mix(in srgb, var(--danger) 11%, transparent);
  --info: #2563eb;
  --info-soft: color-mix(in srgb, var(--info) 11%, transparent);

  /* sidebar follows the theme: light here, dark in :root[data-theme='dark'] below; a tenant can force a style (data-sidebar) */
  --sidebar: var(--surface);
  --sidebar-foreground: var(--foreground-muted);
  --sidebar-muted: var(--foreground-subtle);
  --sidebar-active: var(--primary-soft);
  --sidebar-border: var(--border);
  --sidebar-hover: var(--surface-muted);
  --sidebar-active-foreground: var(--primary);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%);
  --shadow-md: 0 6px 20px -6px rgb(16 24 40 / 14%), 0 2px 6px rgb(16 24 40 / 6%);
  --shadow-lg: 0 24px 60px -16px rgb(16 24 40 / 28%);
  --header-height: 60px;
  --sidebar-width: 248px;
}

:root[data-theme='dark'] {
  --background: #0b0f1a;
  --surface: #121829;
  --surface-muted: #181f33;
  --surface-raised: #1a2238;
  --border: #232c45;
  --border-strong: #33405f;
  --foreground: #eef1fb;
  --foreground-muted: #a2abc4;
  --foreground-subtle: #727c97;
  --sidebar: #0f1424;
  --sidebar-foreground: #c8cde0;
  --sidebar-muted: #7d86a0;
  --sidebar-active: color-mix(in srgb, var(--primary) 22%, transparent);
  --sidebar-border: #1d2440;
  --sidebar-hover: color-mix(in srgb, white 6%, transparent);
  --sidebar-active-foreground: #ffffff;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-md: 0 8px 24px -8px rgb(0 0 0 / 55%);
  --shadow-lg: 0 28px 70px -16px rgb(0 0 0 / 70%);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Tenant-forced sidebar styles (branding.sidebarStyle). Placed last so they win over the theme defaults. */
:root[data-sidebar='dark'] {
  --sidebar: #0f1424;
  --sidebar-foreground: #c8cde0;
  --sidebar-muted: #7d86a0;
  --sidebar-active: color-mix(in srgb, var(--primary) 22%, transparent);
  --sidebar-border: #1d2440;
  --sidebar-hover: color-mix(in srgb, white 6%, transparent);
  --sidebar-active-foreground: #ffffff;
}

:root[data-sidebar='light'] {
  --sidebar: #ffffff;
  --sidebar-foreground: #5b6477;
  --sidebar-muted: #8a93a6;
  --sidebar-active: color-mix(in srgb, var(--primary) 10%, transparent);
  --sidebar-border: #e4e7ef;
  --sidebar-hover: #f1f3f9;
  --sidebar-active-foreground: var(--primary);
}

:root[data-sidebar='brand'] {
  --sidebar: color-mix(in srgb, var(--primary) 86%, black);
  --sidebar-foreground: rgb(255 255 255 / 88%);
  --sidebar-muted: rgb(255 255 255 / 62%);
  --sidebar-border: rgb(255 255 255 / 16%);
  --sidebar-hover: rgb(255 255 255 / 10%);
  --sidebar-active: rgb(255 255 255 / 20%);
  --sidebar-active-foreground: #ffffff;
}

/* Always-dark artwork panel (login screens): scopes the dark sidebar tokens to one element. */
.dark-panel {
  --sidebar: color-mix(in srgb, var(--primary) 16%, #0b0f1a); /* tinted by the tenant primary colour */
  --sidebar-foreground: #c8cde0;
  --sidebar-muted: #7d86a0;
  --sidebar-active: color-mix(in srgb, var(--primary) 22%, transparent);
  --sidebar-border: #1d2440;
  --sidebar-hover: color-mix(in srgb, white 6%, transparent);
  --sidebar-active-foreground: #ffffff;
}
