/* ========================================================================
   Design tokens — port du CRM V1 (Monday × Apple, indigo #4F46E5, Figtree)
   ======================================================================== */
:root {
  /* --- Typographie --- */
  --font-sans: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.25rem;      /* 20px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 1.875rem;    /* 30px */
  --text-4xl: 2.25rem;     /* 36px */

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

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

  /* --- Espacements --- */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* --- Rayons --- */
  --radius-sm: 0.375rem;   /* badges */
  --radius: 0.5rem;        /* inputs, small cards */
  --radius-lg: 0.75rem;    /* boutons, cards standard (base CRM V1) */
  --radius-xl: 1rem;       /* cards principales */
  --radius-2xl: 1.5rem;    /* hero cards, images produit */
  --radius-full: 9999px;

  /* --- Couleurs de base (neutres) --- */
  --white: #ffffff;
  --black: #000000;

  /* Palette Slate (utilisée partout pour text/bg neutres) */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* --- Accents (Indigo — brand principal) --- */
  --indigo-50:  #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;   /* --primary */
  --indigo-700: #4338ca;

  /* Palette statuts (Apple-style feutré) */
  --sky-50: #f0f9ff;    --sky-700: #0369a1;
  --violet-50: #f5f3ff; --violet-700: #6d28d9;
  --amber-50: #fffbeb;  --amber-700: #b45309;
  --emerald-50: #ecfdf5; --emerald-700: #047857;
  --rose-50: #fff1f2;   --rose-700: #be123c;
  --blue-50: #eff6ff;   --blue-700: #1d4ed8;
  --green-50: #f0fdf4;  --green-700: #15803d;
  --yellow-50: #fefce8; --yellow-700: #a16207;
  --red-50: #fef2f2;    --red-700: #b91c1c;
  --pink-50: #fdf2f8;   --pink-700: #be185d;
  --orange-50: #fff7ed; --orange-700: #c2410c;

  /* --- Sémantique app (light) --- */
  --bg-app: #f3f6fb;                       /* canvas admin (slate teinté, contraste net avec les cards blanches) */
  --bg-card: var(--white);                 /* cards restent pures — pop sur le canvas */
  --bg-elevated: var(--white);
  --bg-muted: var(--slate-100);            /* zones neutres (thead tables, chips) */
  --bg-subtle: var(--slate-50);            /* sections internes d'une card (rail fiche client, panels chat) */
  --bg-hover: rgba(15, 23, 42, 0.05);      /* +2pt vs avant pour être visible sur canvas teinté */

  --border: #e2e7ee;                       /* bordure légèrement plus soutenue que slate-200 */
  --border-strong: var(--slate-300);
  --border-subtle: var(--slate-100);       /* séparateurs internes (rows table, footer card) */

  --text-primary: var(--slate-900);
  --text-secondary: var(--slate-600);
  --text-muted: var(--slate-500);
  --text-inverted: var(--white);

  --primary: var(--indigo-600);
  --primary-hover: var(--indigo-700);
  --primary-fg: var(--white);
  --ring: rgba(79, 70, 229, 0.3);

  /* --- Sidebar admin — sombre, teintée par la couleur de thème (--primary),
     suit donc automatiquement la couleur choisie dans les Réglages --- */
  --sidebar-bg: linear-gradient(180deg,
    color-mix(in oklch, var(--primary) 32%, #0b1220) 0%,
    color-mix(in oklch, var(--primary) 12%, #0b1220) 55%,
    #0b1220 100%);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-fg: rgba(255, 255, 255, 0.78);
  --sidebar-muted: rgba(255, 255, 255, 0.5);
  --sidebar-accent-bg: rgba(255, 255, 255, 0.12);
  --sidebar-accent-fg: #ffffff;
  --sidebar-primary: color-mix(in oklch, var(--primary) 45%, white);
  --sidebar-width: 232px;

  /* --- Zone client (paramétrable via CrmSettings, override en JS au boot) --- */
  --client-primary: var(--indigo-600);
  --client-icon-color: var(--indigo-600);
  --client-icon-soft: rgba(79, 70, 229, 0.12);
  --client-icon-faint: rgba(79, 70, 229, 0.06);
  --client-chart-color: var(--indigo-600);
  --client-topbar-bg: var(--white);
  --client-topbar-fg: var(--slate-900);
  --client-topbar-fg-muted: rgba(15, 23, 42, 0.65);
  --client-sidebar-bg: var(--slate-50);
  --client-sidebar-fg: var(--slate-900);
  --client-sidebar-fg-muted: rgba(15, 23, 42, 0.65);

  /* --- Ombres --- */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

  /* --- Transitions --- */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* --- Z-index --- */
  --z-sticky: 30;
  --z-dropdown: 40;
  --z-modal-backdrop: 100;
  --z-modal: 110;
  --z-toast: 200;
  --z-preview-banner: 250;
}

/* Dark mode — activable via [data-theme="dark"] sur html (V1.9 : off côté client, mais utile côté admin plus tard) */
[data-theme="dark"] {
  --bg-app: var(--slate-950);
  --bg-card: var(--slate-900);
  --bg-elevated: var(--slate-800);
  --bg-muted: var(--slate-800);
  --bg-subtle: rgba(255, 255, 255, 0.03);
  --bg-hover: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --text-primary: var(--slate-50);
  --text-secondary: var(--slate-300);
  --text-muted: var(--slate-400);
  --primary: #a5b4fc;
  --primary-hover: #c7d2fe;
  --sidebar-bg: var(--slate-900);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-fg: var(--slate-300);
  --sidebar-accent-bg: rgba(255, 255, 255, 0.06);
  --sidebar-accent-fg: var(--slate-50);
}
