/* ============================================================
   Kit maquette AdoptIA — SYSTÈME DE COMPOSANTS (brand-agnostic)
   ------------------------------------------------------------
   Ne dépend que des tokens définis dans theme.css. Ne RIEN
   coder en dur ici : toute couleur/police vient des variables.
   Charger après theme.css :
     <link rel="stylesheet" href="theme.css">
     <link rel="stylesheet" href="assets/components.css">
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-weight: 400; font-size: 15px; line-height: 1.55;
  color: var(--text); background: var(--surface-1);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img, svg { display: block; }
ul { list-style: none; }

/* ── Typo utilitaires ────────────────────────────── */
.caps { text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; font-size: 11px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.num { font-variant-numeric: tabular-nums; }

/* ── Badges de catégorie ─────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 10px;
  border-radius: var(--r-pill); background: var(--surface-2);
  color: var(--text-muted); border: 1px solid var(--line); white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: var(--r-pill); flex: none; }
.dot-1{background:var(--cat-1)} .dot-2{background:var(--cat-2)}
.dot-3{background:var(--cat-3)} .dot-4{background:var(--cat-4)}
.dot-5{background:var(--cat-5)} .dot-6{background:var(--cat-6)}
.dot-7{background:var(--cat-7)} .dot-8{background:var(--cat-8)}

/* ── Boutons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 14px; padding: 11px 20px;
  border-radius: var(--r-md); border: 1px solid transparent;
  background: var(--surface-2); color: var(--text);
  transition: transform .18s cubic-bezier(.4,0,.2,1), background .18s, box-shadow .18s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-700); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 16px; }
.btn-xl { padding: 22px 24px; font-size: 19px; font-weight: 700; }

/* ── Cartes ──────────────────────────────────────── */
.card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s-6); box-shadow: var(--shadow-sm);
}

/* ── Shell appli (sidebar + main) ────────────────── */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--primary); color: #fff; display: flex; flex-direction: column;
  padding: var(--s-5) var(--s-4); position: sticky; top: 0; height: 100vh;
}
.sidebar .logo-wrap { background: var(--primary-700); border-radius: var(--r-md); padding: 16px 18px; margin-bottom: var(--s-6); }
.sidebar .logo-wrap img { width: 128px; max-width: 100%; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px;
  border-radius: var(--r-md); color: rgba(255,255,255,0.78);
  font-weight: 500; font-size: 14px; transition: background .16s, color .16s;
}
.nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav a.active { background: #fff; color: var(--primary); font-weight: 700; }
.nav a.active svg { stroke: var(--primary); }
.nav a svg { width: 19px; height: 19px; flex: none; stroke: currentColor; }
.nav .group-label { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255,255,255,0.45); font-weight: 700; padding: 0 13px; margin: var(--s-5) 0 var(--s-2); }
.sidebar .me { margin-top: auto; padding-top: var(--s-5); border-top: 1px solid rgba(255,255,255,0.12); display: flex; align-items: center; gap: 11px; }
.sidebar .me .avatar { width: 36px; height: 36px; border-radius: var(--r-pill); background: #fff; color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.sidebar .me .info { line-height: 1.25; min-width: 0; }
.sidebar .me .info .n { font-weight: 700; font-size: 13px; }
.sidebar .me .info .r { font-size: 11px; color: rgba(255,255,255,0.6); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-5) var(--s-8); background: var(--bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.topbar .sub { font-size: 13px; color: var(--text-muted); margin-top: 1px; }
.topbar .spacer { flex: 1; }
.search { display: flex; align-items: center; gap: 9px; background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 9px 14px; min-width: 280px; }
.search input { border: none; background: none; outline: none; font: inherit; flex: 1; color: var(--text); }
.content { padding: var(--s-8); display: flex; flex-direction: column; gap: var(--s-6); }

/* ── KPI ─────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
.kpi { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi .k-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.kpi .k-value { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin-top: 6px; }
.kpi .k-value small { font-size: 16px; font-weight: 600; color: var(--text-faint); }
.kpi .k-trend { font-size: 12px; font-weight: 600; margin-top: 4px; display: inline-flex; gap: 5px; align-items: center; }
.kpi .k-trend.up { color: var(--ok); }
.kpi .k-trend.down { color: var(--accent); }
.kpi.alert { border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.kpi.alert .k-value { color: var(--accent); }
.kpi .k-icon { position: absolute; top: 18px; right: 18px; color: var(--surface-3); }
.kpi .k-icon svg { width: 26px; height: 26px; stroke: currentColor; }

/* ── Sections ────────────────────────────────────── */
.section-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.section-head h2 { font-size: 17px; font-weight: 700; }
.section-head .count { font-size: 12px; color: var(--text-faint); }
.section-head .spacer { flex: 1; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--s-6); align-items: start; }

/* ── Tableaux ────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover, .table tr.row:hover { background: var(--surface-1); }
.table .right { text-align: right; }
.table .strong { font-weight: 700; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: var(--r-pill); text-transform: uppercase; letter-spacing: 0.04em; }
.tag.primary { background: color-mix(in srgb, var(--primary) 8%, transparent); color: var(--primary); }
.tag.ok      { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.tag.accent  { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.tag.neutral { background: var(--surface-2); color: var(--text-muted); }

/* Barres de progression / niveau */
.bar { height: 7px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; min-width: 90px; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: var(--r-pill); }
.bar.low > span { background: var(--accent); }
.bar.mid > span { background: var(--warn); }

/* Lignes d'alerte */
.alert-row { display: flex; align-items: center; gap: var(--s-3); padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--bg); }
.alert-row + .alert-row { margin-top: 8px; }
.alert-row.crit { border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 3%, transparent); }
.alert-row .ico { width: 34px; height: 34px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; }
.alert-row.crit .ico { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.alert-row.warn .ico { background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--warn); }
.alert-row .body { flex: 1; min-width: 0; }
.alert-row .body .t { font-weight: 700; font-size: 14px; }
.alert-row .body .d { font-size: 12px; color: var(--text-muted); }
.alert-row .qty { font-weight: 800; font-size: 15px; }

/* ── Login split-screen ──────────────────────────── */
.split { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.split .left { background: var(--primary); color: #fff; padding: 64px 72px; display: flex; flex-direction: column; justify-content: space-between; }
.split .left .logo-block { background: var(--primary-700); align-self: flex-start; padding: 26px 30px; border-radius: var(--r-lg); }
.split .left .logo-block img { width: 170px; max-width: 100%; }
.split .left .tag { font-size: 42px; font-weight: 800; line-height: 1.06; letter-spacing: -0.02em; max-width: 18ch; }
.split .left .tag em { color: var(--accent); font-style: normal; }
.split .left p { margin-top: 16px; color: rgba(255,255,255,0.7); font-size: 15px; max-width: 40ch; }
.split .left .foot { font-size: 12px; color: rgba(255,255,255,0.5); }
.split .left .foot strong { color: rgba(255,255,255,0.8); font-weight: 700; }
.split .right { background: var(--bg); display: grid; place-items: center; padding: 40px; }
.barcode { display: flex; gap: 3px; align-items: flex-end; height: 34px; margin-bottom: 22px; }
.barcode i { width: 3px; background: rgba(255,255,255,0.85); border-radius: 1px; }
.barcode i.red { background: var(--accent); width: 5px; }
.form-card { width: 100%; max-width: 380px; }
.form-card h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.form-card .eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.form-card .lead { color: var(--text-muted); margin-top: 6px; margin-bottom: 30px; font-size: 14px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 7px; }
.field input { width: 100%; font: inherit; font-size: 15px; padding: 13px 15px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface-1); color: var(--text); transition: border-color .16s, box-shadow .16s, background .16s; }
.field input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); }
.err { color: var(--accent); font-size: 13px; font-weight: 600; margin-bottom: 16px; min-height: 18px; }

/* ── Cadre téléphone (écran mobile) ──────────────── */
.phone { width: 372px; height: 760px; background: #000; border-radius: 46px; padding: 12px; box-shadow: var(--shadow-lg); position: relative; flex: none; }
.phone .notch { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 120px; height: 26px; background: #000; border-radius: var(--r-pill); z-index: 20; }
.phone .screen { width: 100%; height: 100%; background: var(--bg); border-radius: 36px; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.m-head { background: var(--primary); color: #fff; padding: 42px 20px 16px; display: flex; align-items: center; gap: 12px; }
.m-head img { width: 96px; }
.m-head .who { margin-left: auto; text-align: right; line-height: 1.2; }
.m-head .who b { font-size: 13px; font-weight: 700; }
.m-head .who span { font-size: 11px; color: rgba(255,255,255,0.6); }
.toast { position: absolute; left: 16px; right: 16px; bottom: 24px; z-index: 30; background: var(--ok); color: #fff; border-radius: var(--r-lg); padding: 16px 18px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow-md); transform: translateY(140%); transition: transform .32s cubic-bezier(.2,.8,.2,1); }
.toast.show { transform: translateY(0); }
.toast .ck { width: 30px; height: 30px; border-radius: var(--r-pill); background: rgba(255,255,255,0.2); display: grid; place-items: center; flex: none; }
.toast b { font-weight: 700; }
.toast small { display: block; opacity: 0.85; font-size: 12px; }

/* ── Aperçu tableur (export) ─────────────────────── */
.xls { border: 1px solid var(--line-strong); border-radius: var(--r-lg); overflow: hidden; }
.xls-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #1D6F42; color: #fff; font-size: 13px; font-weight: 700; }
.xls-bar .file { margin-left: auto; font-weight: 500; opacity: 0.85; font-size: 12px; }
.xls table { width: 100%; border-collapse: collapse; font-size: 13px; }
.xls th { background: var(--surface-2); font-size: 12px; color: var(--text-muted); border: 1px solid var(--line); padding: 9px 12px; text-align: left; font-weight: 700; }
.xls td { border: 1px solid var(--line); padding: 9px 12px; }
.xls tr:nth-child(even) td { background: var(--surface-1); }
.xls .right { text-align: right; font-variant-numeric: tabular-nums; }
.xls tfoot td { font-weight: 800; background: var(--surface-2); }
.xls td.colidx, .xls th.cidx { color: var(--text-faint); font-weight: 700; text-align: center; width: 34px; background: var(--surface-2); }

/* ── Crédit + bandeau démo ───────────────────────── */
.credit { text-align: center; font-size: 12px; color: var(--text-faint); padding: var(--s-6); border-top: 1px solid var(--line); }
.credit a { color: var(--text-muted); font-weight: 600; }
.demo-banner { position: fixed; bottom: 16px; right: 16px; z-index: 50; background: var(--primary); color: #fff; font-size: 12px; font-weight: 600; padding: 9px 15px; border-radius: var(--r-pill); box-shadow: var(--shadow-md); display: inline-flex; gap: 8px; align-items: center; }
.demo-banner .d { width: 7px; height: 7px; border-radius: var(--r-pill); background: var(--accent); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .content { padding: var(--s-4); }
  .topbar { padding: var(--s-4); }
}
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .split .left { display: none; }
}
