/* ClientBase — design tokens */
:root {
  /* Color — neutrals (warm-tinted, very low chroma) */
  --bg: #FFFFFF;
  --bg-alt: oklch(97.5% 0.003 260);
  --warn-soft:   oklch(96% 0.025 55);
  --warn-soft-2: oklch(90% 0.05 55);
  --warn-ink:    oklch(45% 0.14 55);
  --bg-section: oklch(98% 0.004 260);
  --surface: #ffffff;
  --ink: oklch(18% 0.012 260);
  --ink-2: oklch(32% 0.015 260);
  --ink-3: oklch(48% 0.012 260);
  --ink-4: oklch(65% 0.01 260);
  --line: oklch(91% 0.005 80);
  --line-strong: oklch(84% 0.007 80);

  /* Accent — ClientBase indigo (matches logo #5A50E6) */
  --accent: oklch(55% 0.22 278);
  --accent-ink: oklch(42% 0.22 278);
  --accent-soft: oklch(96% 0.035 278);
  --accent-soft-2: oklch(92% 0.06 278);

  /* Supporting */
  --sage: oklch(72% 0.07 160);
  --sage-soft: oklch(96% 0.02 160);
  --warn: oklch(70% 0.13 55);
  --warn-soft: oklch(96% 0.03 55);

  /* Type scale — Geist (Vercel's premium sans, Apple-feel) */
  --ff-display: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --ff-text: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --ff-mono: "Geist Mono", "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Space */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --s-9: 96px; --s-10: 128px;

  /* Radius */
  --r-1: 6px; --r-2: 10px; --r-3: 14px; --r-4: 20px;

  /* Shadow — barely-there */
  --sh-1: 0 1px 2px rgba(15, 18, 30, 0.04), 0 1px 1px rgba(15, 18, 30, 0.02);
  --sh-2: 0 6px 18px -6px rgba(15, 18, 30, 0.10), 0 2px 4px rgba(15, 18, 30, 0.04);
  --sh-3: 0 24px 48px -18px rgba(15, 18, 30, 0.18), 0 6px 14px rgba(15, 18, 30, 0.05);

  --container: 1200px;
}

/* Warm theme variant */
:root[data-theme="warm"] {
  --bg: oklch(98.2% 0.012 70);
  --bg-alt: oklch(95.8% 0.02 70);
  --bg-section: oklch(96.8% 0.015 70);
  --accent: oklch(58% 0.13 40);
  --accent-ink: oklch(42% 0.13 40);
  --accent-soft: oklch(96% 0.035 40);
  --accent-soft-2: oklch(92% 0.06 40);
}

/* Dark theme variant */
:root[data-theme="dark"] {
  --bg: oklch(16% 0.012 260);
  --bg-alt: oklch(20% 0.014 260);
  --bg-section: oklch(18% 0.013 260);
  --surface: oklch(22% 0.015 260);
  --ink: oklch(98% 0.005 80);
  --ink-2: oklch(88% 0.006 80);
  --ink-3: oklch(70% 0.008 80);
  --ink-4: oklch(55% 0.01 80);
  --line: oklch(28% 0.015 260);
  --line-strong: oklch(38% 0.02 260);
  --accent: oklch(72% 0.16 268);
  --accent-ink: oklch(82% 0.14 268);
  --accent-soft: oklch(28% 0.08 268);
  --accent-soft-2: oklch(34% 0.12 268);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
/* Touch feedback without the grey rectangle flash */
button, a, [role="button"], .btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ff-text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
}

h1, h2, h3, h4 {
  font-family: var(--ff-display);
  font-weight: 560;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(44px, 5.2vw, 72px); line-height: 1.02; letter-spacing: -0.035em; font-weight: 580; }
h2 { font-size: clamp(32px, 3.4vw, 46px); line-height: 1.05; letter-spacing: -0.028em; }
h3 { font-size: 22px; line-height: 1.25; letter-spacing: -0.018em; }
h4 { font-size: 17px; line-height: 1.3; letter-spacing: -0.01em; font-weight: 560; }
p  { margin: 0; color: var(--ink-2); text-wrap: pretty; }
a  { color: inherit; text-decoration: none; }

/* Prevent iOS Safari from zooming into focused form fields.
   iOS triggers the zoom when the input's computed font-size is < 16px. */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

.eyebrow {
  font-size: 13px;
  color: var(--accent-ink);
  font-weight: 580;
  letter-spacing: -0.005em;
}
.muted { color: var(--ink-3); }
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* Global smooth scroll + focus ring */
html { scroll-behavior: smooth; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
  transition: outline-offset .15s ease;
}

/* Liens cliquables dans le texte */
a { transition: color .15s ease, opacity .15s ease; }
a:hover { opacity: 0.82; }

/* Inputs — focus animé */
input, select, textarea {
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: 10px;
  font-family: var(--ff-text);
  font-size: 14.5px; font-weight: 520;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .22s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow .22s cubic-bezier(0.22, 1, 0.36, 1),
              background-color .18s ease,
              border-color .18s ease,
              color .18s ease,
              opacity .18s ease;
  white-space: nowrap;
  will-change: transform;
}
.btn:active { transform: translateY(1px) scale(0.98); transition-duration: .08s; }
.btn:disabled { cursor: not-allowed; opacity: 0.6; }
.btn-primary {
  background: var(--ink);
  color: var(--bg);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover { transform: translateY(-2px); box-shadow: 0 14px 32px -10px var(--accent); }
.btn-ghost {
  background: transparent; color: var(--ink);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--bg-alt); border-color: var(--ink-4); transform: translateY(-1px); }
.cb-btn-destructive { color: oklch(55% 0.18 25); border-color: oklch(86% 0.06 25); margin-right: auto; }
.cb-btn-destructive:hover { background: oklch(97% 0.025 25); border-color: oklch(70% 0.16 25); color: oklch(48% 0.20 25); transform: translateY(-1px); }
.btn-lg { height: 50px; padding: 0 22px; font-size: 15.5px; border-radius: 12px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }

/* Utility */
.hstack { display: flex; align-items: center; gap: var(--s-3); }
.vstack { display: flex; flex-direction: column; gap: var(--s-3); }
.grid   { display: grid; gap: var(--s-5); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: transform .3s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow .3s cubic-bezier(0.22, 1, 0.36, 1),
              border-color .2s ease;
}

/* Liens de navigation — l'état actif est géré en JSX (pill background) */

/* Transition de page — fade-in léger au changement de route */
@keyframes cbPageIn {
  from { opacity: 0; transform: translateY(6px) scale(0.995); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
main[data-screen-label] {
  animation: cbPageIn .32s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Mobile — press feedback sur tous les éléments tactiles */
@media (hover: none) and (pointer: coarse) {
  .btn:active,
  button:active,
  [role="button"]:active {
    transform: scale(0.97);
    transition-duration: 0.08s;
  }
}

/* Respecter la préférence système "reduce motion" */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.section { padding: var(--s-10) 0; }
.section-sm { padding: var(--s-8) 0; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--accent-soft-2);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.kbd {
  font-family: var(--ff-mono);
  font-size: 11.5px;
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-2);
}

/* Divider line */
.hr { height: 1px; background: var(--line); border: 0; margin: 0; }

/* Focus */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Scrollbar light touch */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Print — nimprimer que la facture
   Active : un parent ajoute la classe .cb-print-invoice à <body>,
   ou on cible directement #cb-invoice-print quand lutilisateur lance window.print().
   ============================================================ */
@media print {
  /* Cache toute lapp */
  body * { visibility: hidden !important; }
  /* Affiche uniquement la facture imprimable et ses descendants */
  #cb-invoice-print, #cb-invoice-print * { visibility: visible !important; }
  /* Sort la facture du flux modal/overlay et laffiche en pleine page */
  #cb-invoice-print {
    position: absolute !important;
    top: 0; left: 0;
    width: 100%;
    margin: 0 !important;
    padding: 24mm 18mm !important;
    border: none !important;
    border-radius: 0 !important;
    background: white !important;
    color: #111 !important;
    box-shadow: none !important;
  }
  /* Marges papier A4 raisonnables */
  @page { size: A4; margin: 12mm; }
  /* Retire les overlays/modale autour */
  .cb-modal-overlay, .cb-modal-shell { background: transparent !important; box-shadow: none !important; padding: 0 !important; }
}
