/* ==========================================================================
   DESIGN SYSTEM — Portail Métier AMO (marque blanche)
   Tokens, thèmes light/dark, typographie, fond.
   Les couleurs --brand-primary / --brand-secondary sont réécrites à chaud
   par js/brand-config.js : tout le reste en dérive via color-mix().
   ========================================================================== */

:root {
  /* ---- Marque (surchargées dynamiquement) ---- */
  --brand-primary: #1e3a8a;
  --brand-secondary: #0d9488;

  /* ---- Dérivées de marque ---- */
  --primary: var(--brand-primary);
  --secondary: var(--brand-secondary);
  --primary-soft: color-mix(in srgb, var(--primary) 10%, transparent);
  --primary-softer: color-mix(in srgb, var(--primary) 5%, transparent);
  --secondary-soft: color-mix(in srgb, var(--secondary) 12%, transparent);
  --primary-text: var(--primary);
  --secondary-text: color-mix(in srgb, var(--secondary) 85%, black);
  --gradient-brand: linear-gradient(135deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 55%, var(--secondary)) 60%, var(--secondary) 100%);

  /* ---- Sémantique ---- */
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --success-text: #15803d;
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.13);
  --warning-text: #b45309;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.11);
  --danger-text: #b91c1c;
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.11);
  --info-text: #1d4ed8;
  --neutral-soft: rgba(100, 116, 139, 0.12);

  /* ---- Surfaces (light) ---- */
  --bg: #f3f5fa;
  --bg-mesh-1: color-mix(in srgb, var(--primary) 9%, transparent);
  --bg-mesh-2: color-mix(in srgb, var(--secondary) 9%, transparent);
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef1f7;
  --surface-hover: rgba(15, 23, 42, 0.035);
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.15);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --subtle: #94a3b8;
  --overlay: rgba(15, 23, 42, 0.45);
  --sidebar-bg: rgba(255, 255, 255, 0.72);
  --glass-blur: saturate(160%) blur(16px);

  /* ---- Ombres ---- */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 18px -6px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 24px 48px -16px rgba(15, 23, 42, 0.25), 0 6px 14px rgba(15, 23, 42, 0.06);
  --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);

  /* ---- Typo ---- */
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-title: 'Outfit', 'Inter', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --fs-xs: 0.72rem;
  --fs-sm: 0.82rem;
  --fs-md: 0.92rem;
  --fs-lg: 1.05rem;
  --fs-xl: 1.3rem;
  --fs-2xl: 1.7rem;
  --fs-3xl: 2.2rem;

  /* ---- Espacements & rayons ---- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* ---- Layout ---- */
  --sidebar-w: 268px;
  --topbar-h: 64px;

  /* ---- Mouvement ---- */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 140ms;
  --t: 240ms;

  color-scheme: light;
}

/* ---- Thème sombre ---- */
:root[data-theme="dark"] {
  --primary-text: color-mix(in srgb, var(--primary) 45%, #dbeafe);
  --secondary-text: color-mix(in srgb, var(--secondary) 70%, white);
  --primary-soft: color-mix(in srgb, var(--primary) 30%, transparent);
  --primary-softer: color-mix(in srgb, var(--primary) 16%, transparent);
  --secondary-soft: color-mix(in srgb, var(--secondary) 20%, transparent);
  --success-text: #4ade80;
  --warning-text: #fbbf24;
  --danger-text: #f87171;
  --info-text: #60a5fa;
  --success-soft: rgba(74, 222, 128, 0.13);
  --warning-soft: rgba(251, 191, 36, 0.13);
  --danger-soft: rgba(248, 113, 113, 0.14);
  --info-soft: rgba(96, 165, 250, 0.14);
  --neutral-soft: rgba(148, 163, 184, 0.14);

  --bg: #080d1a;
  --bg-mesh-1: color-mix(in srgb, var(--primary) 26%, transparent);
  --bg-mesh-2: color-mix(in srgb, var(--secondary) 14%, transparent);
  --surface: rgba(17, 24, 39, 0.72);
  --surface-solid: #111827;
  --surface-2: #0f1626;
  --surface-3: #172033;
  --surface-hover: rgba(148, 163, 184, 0.06);
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.24);
  --text: #e5e9f2;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --subtle: #64748b;
  --overlay: rgba(2, 6, 17, 0.66);
  --sidebar-bg: rgba(11, 17, 32, 0.78);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 22px -8px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 28px 60px -18px rgba(0, 0, 0, 0.7);
  --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent);
  color-scheme: dark;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 600px at 100% -10%, var(--bg-mesh-1), transparent 60%),
    radial-gradient(900px 520px at -10% 110%, var(--bg-mesh-2), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}
h1, h2, h3, h4, h5 { font-family: var(--font-title); margin: 0; line-height: 1.2; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: var(--fs-2xl); font-weight: 600; }
h2 { font-size: var(--fs-xl); font-weight: 600; }
h3 { font-size: var(--fs-lg); font-weight: 600; }
h4 { font-size: var(--fs-md); font-weight: 600; }
p { margin: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
/* Icônes Lucide : en ligne par défaut (les composants fixent leur propre taille) */
.lucide { display: inline-block; vertical-align: -0.18em; width: 1.15em; height: 1.15em; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: color-mix(in srgb, var(--primary) 25%, transparent); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* Scrollbars discrètes */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }

/* ---- Utilitaires ---- */
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mono { font-family: var(--font-mono); font-size: 0.85em; }
.title-font { font-family: var(--font-title); }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.text-danger { color: var(--danger-text); }
.text-primary { color: var(--primary-text); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---- Animations ---- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }

.anim-in > * { animation: fadeUp 420ms var(--ease) both; }
.anim-in > *:nth-child(2) { animation-delay: 40ms; }
.anim-in > *:nth-child(3) { animation-delay: 80ms; }
.anim-in > *:nth-child(4) { animation-delay: 120ms; }
.anim-in > *:nth-child(5) { animation-delay: 160ms; }
.anim-in > *:nth-child(n+6) { animation-delay: 200ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
