/* =====================================================================
   Cockpit FBA — Maquette interactive
   style.css : jetons de design (couleurs, typo, espacements) + layout
   ===================================================================== */

:root {
  color-scheme: light;
  /* Plans */
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef0f5;
  --border: #e3e6ee;
  --border-strong: #cfd4df;
  /* Encre */
  --text: #141a2e;
  --text-2: #4a5268;
  --muted: #868ea3;
  /* Marque */
  --primary: #3d40c4;          /* indigo / bleu nuit */
  --primary-hover: #3235a8;
  --primary-soft: #ecedfc;
  --primary-ink: #ffffff;
  --accent: #0f8f8a;           /* turquoise */
  --accent-soft: #e2f5f4;
  /* Statuts (réservés aux états, jamais aux séries) */
  --good: #12804a;  --good-soft: #e3f4ea;
  --warn: #b86e00;  --warn-soft: #fdf1dc;
  --crit: #c93636;  --crit-soft: #fbe7e7;
  --info: #2f6fb8;  --info-soft: #e5eff9;
  /* Séries graphiques (palette validée daltonisme, voir README) */
  --s1: #4f52d9; --s2: #0f9f9a; --s3: #eb6834; --s4: #c24f93; --s5: #e0a100; --s6: #2a7fc4;
  --grid: #eceef3;
  --axis: #c9cedb;
  /* Barre latérale */
  --side-bg: #12163a;
  --side-bg-2: #1b2050;
  --side-text: #c6cae6;
  --side-muted: #7f86b5;
  --side-active: #ffffff;
  /* Forme */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 26, 46, .06);
  --shadow: 0 1px 2px rgba(20, 26, 46, .05), 0 4px 14px rgba(20, 26, 46, .06);
  --shadow-lg: 0 10px 40px rgba(20, 26, 46, .18);
  --ring: 0 0 0 3px rgba(61, 64, 196, .25);
  /* Dimensions */
  --side-w: 248px;
  --side-w-collapsed: 68px;
  --top-h: 60px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1018;
  --surface: #151a26;
  --surface-2: #1a2030;
  --surface-3: #222839;
  --border: #262d3f;
  --border-strong: #353d53;
  --text: #eceef5;
  --text-2: #b3bacb;
  --muted: #7c859b;
  --primary: #8b8ef5;
  --primary-hover: #a1a4f8;
  --primary-soft: #23264a;
  --primary-ink: #0d1018;
  --accent: #2bb8ae;
  --accent-soft: #12302f;
  --good: #3cc47c;  --good-soft: #13301f;
  --warn: #f0a42a;  --warn-soft: #33270f;
  --crit: #f06b6b;  --crit-soft: #3a1818;
  --info: #6aa7ee;  --info-soft: #172a40;
  --s1: #7d80f0; --s2: #159a8a; --s3: #d8622f; --s4: #c9579a; --s5: #b58000; --s6: #3a8bd0;
  --grid: #222838;
  --axis: #353d53;
  --side-bg: #0a0d1c;
  --side-bg-2: #151a36;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(139, 142, 245, .35);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
.num, td.num, th.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.crit { color: var(--crit); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.ic.sm { width: 15px; height: 15px; }
svg.ic.lg { width: 22px; height: 22px; }

/* ---------- Layout général ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--side-w);
  background: var(--side-bg);
  color: var(--side-text);
  display: flex; flex-direction: column;
  transition: width .25s var(--ease), transform .25s var(--ease);
}
.side-brand {
  height: var(--top-h); display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid rgba(255,255,255,.06);
  color: #fff; font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; white-space: nowrap;
}
.side-brand img { width: 30px; height: 30px; flex: none; }
.side-brand small { display: block; font-weight: 500; font-size: 11px; color: var(--side-muted); letter-spacing: .02em; }
.side-nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; scrollbar-width: thin; scrollbar-color: #2a3070 transparent; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 4px; }
.nav-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 650;
  color: var(--side-muted); padding: 0 10px 6px; white-space: nowrap;
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 10px; margin: 1px 0; border-radius: 8px;
  color: var(--side-text); font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--side-bg-2); color: var(--side-active); }
.nav-link.active::before {
  content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0;
  background: #2bd3c6;
}
.nav-link .ic { opacity: .85; }
.nav-link .nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 20px;
  background: rgba(240,107,107,.18); color: #ff9c9c;
}
.nav-link .nav-tag {
  margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px;
  background: rgba(43,211,198,.14); color: #6fe3d8;
}
.side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.side-collapse {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--side-muted); cursor: pointer; white-space: nowrap;
}
.side-collapse:hover { background: rgba(255,255,255,.06); color: #fff; }

.main { flex: 1; min-width: 0; margin-left: var(--side-w); transition: margin-left .25s var(--ease); display: flex; flex-direction: column; }

/* Barre latérale rétractée */
.side-collapsed .sidebar { width: var(--side-w-collapsed); }
.side-collapsed .main { margin-left: var(--side-w-collapsed); }
.side-collapsed .side-brand span,
.side-collapsed .nav-title,
.side-collapsed .nav-link span,
.side-collapsed .nav-link .nav-badge,
.side-collapsed .nav-link .nav-tag,
.side-collapsed .side-collapse span { display: none; }
.side-collapsed .nav-title { height: 1px; background: rgba(255,255,255,.07); margin: 6px 10px; padding: 0; }
.side-collapsed .nav-link { justify-content: center; padding: 9px 0; }
.side-collapsed .side-collapse { justify-content: center; }
.side-collapsed .side-collapse .ic { transform: rotate(180deg); }
.side-collapsed .side-brand { justify-content: center; padding: 0; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .top-burger { display: none; }
.top-search {
  flex: 1; max-width: 460px;
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 12px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
  color: var(--muted); cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s;
}
.top-search:hover { border-color: var(--border-strong); background: var(--surface); }
.top-search span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd {
  font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface);
}
.top-spacer { flex: 1; }
.demo-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 750; letter-spacing: .06em;
  padding: 4px 10px; border-radius: 20px;
  color: #8a4b00; background: #fff1d6; border: 1px solid #f6d79a;
  white-space: nowrap; cursor: help;
}
:root[data-theme="dark"] .demo-badge { color: #ffcf7a; background: #3a2a0e; border-color: #5c4313; }
.demo-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #e89a00; box-shadow: 0 0 0 3px rgba(232,154,0,.2); }

.page-wrap { padding: 22px 26px 40px; max-width: 1560px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.page-head .crumbs a { color: var(--muted); }
.page-head p.sub { color: var(--text-2); margin: 4px 0 0; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Grilles */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-main-r { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.span-2 { grid-column: span 2; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 22px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

/* Animation d'entrée discrète */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-wrap > * { animation: rise .35s var(--ease) both; }
.page-wrap > *:nth-child(2) { animation-delay: .03s; }
.page-wrap > *:nth-child(3) { animation-delay: .06s; }
.page-wrap > *:nth-child(4) { animation-delay: .09s; }
.page-wrap > *:nth-child(n+5) { animation-delay: .12s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Espaces de travail : Cockpit / Opportunités ---------- */
.space-switch { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); flex: none; }
.space-switch a { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.space-switch a:hover { color: var(--text); text-decoration: none; }
.space-switch a.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.space-strip { display: flex; align-items: center; gap: 8px; padding: 7px 26px; font-size: 12.5px; color: var(--text-2); background: var(--accent-soft); border-bottom: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); }
.space-strip .ic { color: var(--accent); }
.nav-link .nav-count { margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 20px; background: rgba(255,255,255,.12); color: #fff; font-style: normal; }
.nav-link em { font-style: normal; }
/* Accent turquoise dans l'espace Opportunités : on sait toujours où l'on est */
:root[data-space="opp"] { --primary: #0d7f7a; --primary-hover: #0a6b67; --primary-soft: #dff3f1; --ring: 0 0 0 3px rgba(13,127,122,.25); --side-bg: #0b2a33; --side-bg-2: #12404a; --side-text: #c2dedd; --side-muted: #79a3a5; }
:root[data-space="opp"][data-theme="dark"] { --primary: #3cc4b8; --primary-hover: #5fd3c9; --primary-soft: #113533; --primary-ink: #0d1018; --ring: 0 0 0 3px rgba(60,196,184,.35); --side-bg: #071b21; --side-bg-2: #0f333b; }

/* ---- Cycle de vie d'une niche (espace Opportunités) ---- */
.lifecycle { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin-top: 10px; }
.lifecycle .lc { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); white-space: nowrap; }
.lifecycle .lc + .lc { margin-left: 18px; position: relative; }
.lifecycle .lc + .lc::before { content: ""; position: absolute; left: -14px; top: 50%; width: 10px; height: 1px; background: var(--border-strong); }
.lifecycle .lc.done { color: var(--text-2); background: var(--surface-2, var(--surface)); border-color: var(--border-strong); }
.lifecycle .lc.cur { color: var(--primary-ink); background: var(--primary); border-color: var(--primary); }
