/* ==========================================================
   STOCKO — Démo gestion de stock
   ========================================================== */
:root {
  --bg: #FAF6EE;
  --surface: #FFFFFF;
  --surface-2: #F3EDE2;
  --line: #E5E0D8;
  --ink: #1A1A1A;
  --ink-soft: #5C5C5C;
  --ink-mute: #8A8371;
  --accent: #243156;
  --accent-ink: #FFFFFF;

  --t-blue: #DCE3F0;
  --t-peach: #F3E3D3;
  --t-lav: #E6DDF0;
  --t-mint: #DDEBE3;
  --t-cream: #F3E9D2;
  --t-pink: #F3DDE5;

  --ok: #2F7A55;
  --warn: #B26A12;
  --danger: #B3372F;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(26,26,26,.04), 0 8px 24px -12px rgba(36,49,86,.18);
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.5 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.main { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); }
#view { padding: 16px; max-width: 1200px; margin: 0 auto; outline: none; }

.sidebar { display: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; }
.topbar .btn-add { display: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 24px; }
.brand-name { font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em; }
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: #fff;
}
.brand-mark.sm { width: 30px; height: 30px; border-radius: 8px; }
.brand-mark svg { width: 18px; height: 18px; }

/* ---------- Bottom nav (téléphone) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 44px;
  color: var(--ink-mute);
  font-size: .72rem; font-weight: 700;
  text-decoration: none;
  position: relative;
}
.nav-link .nav-ic {
  display: grid; place-items: center;
  width: 44px; height: 28px; border-radius: 999px;
  transition: background .2s ease;
}
.nav-link[aria-current="page"] { color: var(--accent); }
.nav-link[aria-current="page"] .nav-ic { background: var(--t-blue); }
.nav-badge {
  position: absolute; top: 8px; left: calc(50% + 8px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 800; line-height: 18px; text-align: center;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 16px; z-index: 31;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  display: grid; place-items: center;
  width: 56px; height: 56px; border: 0; border-radius: 18px;
  background: var(--accent); color: #fff;
  box-shadow: 0 10px 24px -6px rgba(36,49,86,.5);
  cursor: pointer;
}
.fab svg { width: 24px; height: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px;
  font-weight: 700; font-size: .9rem;
  cursor: pointer; white-space: nowrap;
  transition: opacity .2s ease, background .2s ease;
}
.btn:hover { opacity: .9; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: transparent; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- Cards / sections ---------- */
.section { margin-top: 24px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 1.05rem; font-weight: 800; }
.link { color: var(--accent); font-weight: 700; font-size: .85rem; text-decoration: none; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hello { margin: 4px 0 4px; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.hello-sub { margin: 0; color: var(--ink-soft); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.kpi { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.tile {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  color: var(--ink);
}
.tile svg { width: 20px; height: 20px; }
.tile.blue { background: var(--t-blue); }
.tile.peach { background: var(--t-peach); }
.tile.lav { background: var(--t-lav); }
.tile.mint { background: var(--t-mint); }
.tile.cream { background: var(--t-cream); }
.tile.pink { background: var(--t-pink); }
.kpi-label { color: var(--ink-soft); font-size: .8rem; font-weight: 600; }
.kpi-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--ink-mute); font-size: .8rem; }
.row-end { text-align: right; font-weight: 700; white-space: nowrap; }
.empty { padding: 32px 16px; text-align: center; color: var(--ink-mute); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge.low { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.badge.out { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.mv-in { color: var(--ok); }
.mv-out { color: var(--danger); }

/* ---------- Chart ---------- */
.chart { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 56px; align-items: center; gap: 10px; font-size: .82rem; }
.bar-label { color: var(--ink-soft); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .5s ease; }
.bar-val { text-align: right; font-weight: 700; }

/* ---------- Toolbar (recherche + filtres) ---------- */
.toolbar { display: flex; flex-direction: column; gap: 10px; }
.search {
  position: relative; display: flex; align-items: center;
}
.search svg { position: absolute; left: 14px; color: var(--ink-mute); pointer-events: none; }
.search input {
  width: 100%; min-height: 46px; padding: 0 14px 0 42px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); outline: none;
}
.search input:focus, .field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-soft);
  font-size: .82rem; font-weight: 700; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Produits ---------- */
.products { margin-top: 16px; display: grid; gap: 10px; }
.product {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "info stepper" "meta meta";
  gap: 10px 12px;
  padding: 14px 16px;
}
.p-info { grid-area: info; min-width: 0; cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.p-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-sku { color: var(--ink-mute); font-size: .78rem; }
.p-meta { grid-area: meta; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--ink-soft); font-size: .8rem; }
.p-cat { padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-weight: 600; }
.p-price { margin-left: auto; font-weight: 700; color: var(--ink); }

.stepper {
  grid-area: stepper;
  display: flex; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  align-self: start;
}
.stepper button {
  width: 40px; height: 40px; border: 0; background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
}
.stepper button:hover { background: var(--surface-2); }
.stepper button svg { width: 16px; height: 16px; }
.stepper output { min-width: 40px; text-align: center; font-weight: 800; }

.table-head { display: none; }

/* ---------- Réglages ---------- */
.settings { display: grid; gap: 12px; margin-top: 16px; }
.setting { padding: 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.setting .row-main { min-width: 180px; }

/* ---------- Dialog (bottom sheet) ---------- */
.sheet {
  width: 100%; max-width: 100%; margin: auto 0 0; padding: 0;
  border: 0; border-radius: 22px 22px 0 0;
  background: var(--surface); color: var(--ink);
  max-height: 92vh;
}
.sheet::backdrop { background: rgba(26,26,26,.4); backdrop-filter: blur(2px); }
.sheet[open] { animation: sheetUp .25s ease; }
.sheet form { padding: 20px 16px calc(20px + var(--safe-b)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h2 { font-size: 1.15rem; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.field.full { grid-column: 1 / -1; }
.field { min-width: 0; }
.field input, .field select { width: 100%; min-width: 0; }
.field input, .field select {
  min-height: 46px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink); font-weight: 600; font-size: 1rem;
  outline: none;
}
.sheet-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.spacer { display: none; }
.sheet-actions .btn { flex: 1 1 0; padding: 0 12px; }

@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; z-index: 50;
  bottom: calc(var(--nav-h) + var(--safe-b) + 88px);
  transform: translate(-50%, 20px);
  padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: #fff;
  font-weight: 600; font-size: .88rem;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================
   TABLETTE
   ========================================================== */
@media (min-width: 640px) {
  #view { padding: 24px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .toolbar { flex-direction: row; align-items: center; }
  .search { flex: 0 0 320px; }
  .sheet { width: min(520px, calc(100% - 48px)); margin: auto; border-radius: 22px; }
  .sheet form { padding: 24px; }
  .spacer { display: block; flex: 1; }
  .sheet-actions .btn { flex: 0 0 auto; padding: 0 18px; }
}

/* ==========================================================
   PC — sidebar + tableau
   ========================================================== */
@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 248px 1fr; }
  .main { padding-bottom: 40px; min-width: 0; }
  .bottom-nav, .fab { display: none; }
  .toast { bottom: 32px; }

  .sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    padding: 24px 16px;
    background: var(--surface);
    border-right: 1px solid var(--line);
  }
  .side-nav { display: flex; flex-direction: column; gap: 4px; }
  .side-nav .nav-link {
    flex-direction: row; justify-content: flex-start; gap: 10px;
    padding: 6px 10px; border-radius: 12px;
    font-size: .9rem; color: var(--ink-soft);
  }
  .side-nav .nav-link:hover { background: var(--surface-2); }
  .side-nav .nav-link .nav-ic { width: 32px; height: 32px; border-radius: 9px; }
  .side-nav .nav-link[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
  .side-nav .nav-badge { position: static; margin-left: auto; }
  .side-foot { margin-top: auto; padding: 14px; border-radius: 14px; background: var(--bg); font-size: .78rem; color: var(--ink-soft); }
  .side-foot p { margin: 8px 0 0; }
  .demo-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--t-cream); color: var(--ink); font-weight: 700; }

  .topbar { padding: 20px 32px; }
  .topbar .brand-mark { display: none; }
  .topbar h1 { font-size: 1.5rem; }
  .topbar .btn-add { display: inline-flex; }
  #view { padding: 28px 32px; }

  .dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
  .dash-grid .section { margin-top: 24px; }

  /* Tableau produits */
  .products { gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
  .table-head, .product {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) 1fr 1fr 110px 150px;
    grid-template-areas: none;
    align-items: center; gap: 16px;
    padding: 12px 20px;
  }
  .table-head { color: var(--ink-mute); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
  .product { border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; }
  .product:hover { background: #FDFBF7; }
  .p-info, .stepper { grid-area: auto; }
  .p-meta { display: contents; }
  .p-price { margin: 0; }
  .p-cat { justify-self: start; }
  .stepper { justify-self: start; }
}
