/* =========================================================================
   Portail BDGEEK — design system « Mosaic » (Citadel-noir)
   CSS écrit à la main, mobile-first. Thème sombre par défaut + thème clair.
   Polices auto-hébergées (aucune dépendance externe — CSP stricte).
   ========================================================================= */

@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/spacegrotesk-600.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/spacegrotesk-700.woff2') format('woff2'); }
@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/outfit-400.woff2') format('woff2'); }
@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/outfit-600.woff2') format('woff2'); }

:root {
  --bp-tablet: 640px;
  --bp-desktop: 1024px;

  --font-head: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Outfit', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --radius-sm: 0.5rem;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  --sidebar-w: 264px;
  --topbar-h: 64px;
  --touch: 44px;
  --pad-card: 24px;
}

/* ---------------- Thème sombre (défaut = modèle Stitch) ---------------- */
:root, :root[data-theme="dark"] {
  --bg: #111415;
  --bg-elev: #1d2021;
  --bg-elev-2: #282a2b;
  --bg-elev-3: #323536;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: #514255;
  --text: #e1e3e4;
  --text-muted: #9d8ba0;
  --input-bg: #0c0f10;

  --accent: #ecb2ff;              /* violet électrique */
  --on-accent: #3a004f;
  --accent-strong: #bd00ff;
  --accent-glow: rgba(236, 178, 255, 0.28);
  --accent-soft: rgba(236, 178, 255, 0.12);

  --secondary: #00eefc;          /* cyan plasma (prix, totaux, jauges) */
  --secondary-soft: rgba(0, 238, 252, 0.14);

  --ok: #39ff14;
  --ok-soft: rgba(57, 255, 20, 0.14);
  --warn: #ff7a29;
  --warn-soft: rgba(255, 122, 41, 0.16);
  --danger: #ffb4ab;
  --danger-soft: rgba(255, 78, 0, 0.16);

  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
  --glass-bg: rgba(29, 32, 33, 0.72);
}

/* ---------------- Thème clair (déclinaison) ---------------- */
:root[data-theme="light"] {
  --bg: #f4f2f7;
  --bg-elev: #ffffff;
  --bg-elev-2: #eceaf2;
  --bg-elev-3: #e2def0;
  --border: #ddd7e6;
  --border-strong: #c9bfd8;
  --text: #191320;
  --text-muted: #6a6376;
  --input-bg: #ffffff;

  --accent: #8a00c2;
  --on-accent: #ffffff;
  --accent-strong: #6c009c;
  --accent-glow: rgba(138, 0, 194, 0.22);
  --accent-soft: rgba(138, 0, 194, 0.10);

  --secondary: #067b8b;
  --secondary-soft: rgba(6, 123, 139, 0.12);

  --ok: #1e9e2e;
  --ok-soft: rgba(30, 158, 46, 0.12);
  --warn: #cf4a09;
  --warn-soft: rgba(207, 74, 9, 0.12);
  --danger: #c62828;
  --danger-soft: rgba(198, 40, 40, 0.10);

  --shadow: 0 6px 18px rgba(50, 20, 70, 0.10);
  --shadow-lg: 0 20px 44px rgba(50, 20, 70, 0.16);
  --glass-bg: rgba(255, 255, 255, 0.75);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 700; }
h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 600; }

/* ============================ Barre du haut (espace quotidien) ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--glass-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1320px; margin: 0 auto; display: flex; align-items: center; gap: 18px;
  padding: 10px 5vw; min-height: var(--topbar-h);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: 0.02em; white-space: nowrap; }
.brand__logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: 14px; box-shadow: 0 0 22px var(--accent-glow); }
.topnav { display: flex; gap: 4px; align-items: center; }
.topnav a { color: var(--text-muted); padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.95rem; min-height: var(--touch); display: inline-flex; align-items: center; }
.topnav a:hover { color: var(--text); background: var(--bg-elev-2); text-decoration: none; }
.topnav a.active { color: var(--accent); position: relative; }
.topnav a.active::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px; background: var(--accent); border-radius: 2px; box-shadow: 0 0 10px var(--accent-glow); }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }

/* ============================ Console admin (sidebar) ==================== */
.admin-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 60;
  background: var(--bg-elev); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 16px; overflow-y: auto;
}
.admin-sidebar__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.admin-sidebar__title { font-family: var(--font-head); font-weight: 700; }
.admin-sidebar__title small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 0.72rem; color: var(--text-muted); letter-spacing: 0.04em; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 600; min-height: var(--touch); }
.admin-nav a:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
.admin-nav a.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.admin-sidebar__foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.admin-sidebar__foot .btn { width: 100%; }

/* Bandeau haut mobile (console admin) */
.admin-topbar { display: none; position: sticky; top: 0; z-index: 55; background: var(--glass-bg); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); align-items: center; gap: 12px; padding: 8px 16px; min-height: 56px; }

body.admin-console .container { margin-left: var(--sidebar-w); }
.sidebar-scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 58; }

@media (max-width: 1023px) {
  body.admin-console .container { margin-left: 0; }
  .admin-topbar { display: flex; }
  .admin-sidebar { transform: translateX(-105%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg); }
  .admin-sidebar.open { transform: translateX(0); }
  .sidebar-scrim.open { display: block; }
}

/* Menu hamburger barre du haut (mobile) */
.nav-toggle { display: none; }
@media (max-width: 1023px) {
  .nav-toggle { display: inline-grid; }
  .topnav {
    position: fixed; inset: var(--topbar-h) 0 auto 0; flex-direction: column; align-items: stretch;
    background: var(--bg-elev); border-bottom: 1px solid var(--border); padding: 8px 12px 16px; gap: 2px;
    transform: translateY(-120%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg);
    max-height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  }
  .topnav.open { transform: translateY(0); }
  .topnav a { padding: 12px 14px; font-size: 1rem; }
}

.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  width: var(--touch); height: var(--touch); border-radius: var(--radius-sm);
  cursor: pointer; display: inline-grid; place-items: center; font-size: 1.1rem;
}
.icon-btn:hover { background: var(--bg-elev-2); }

/* ============================ Layout ==================================== */
.container { max-width: 1320px; margin: 0 auto; padding: 28px 5vw 80px; }
.container--narrow { max-width: 620px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: var(--pad-card); box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.grid { display: grid; gap: 24px; }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid--stats { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.hr { height: 1px; background: var(--border); border: 0; margin: 16px 0; }
.hidden { display: none !important; }
.tag { display: inline-block; padding: 3px 10px; border-radius: var(--radius-full); background: var(--bg-elev-2); font-size: 0.74rem; font-weight: 600; color: var(--text-muted); }

/* ============================ Boutons =================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); padding: 10px 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-elev-2); color: var(--text);
  font-family: var(--font-body); font-weight: 700; font-size: 0.92rem; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { background: var(--bg-elev-3); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; box-shadow: 0 0 26px var(--accent-glow); }
.btn--ghost { background: transparent; border-color: var(--secondary); color: var(--secondary); }
.btn--ghost:hover { background: var(--secondary-soft); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { min-height: 34px; padding: 6px 12px; font-size: 0.82rem; }
.btn--block { width: 100%; }

/* ============================ Formulaires ============================== */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; min-height: var(--touch); padding: 11px 14px;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: inherit;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.checkbox-row { display: flex; align-items: center; gap: 10px; min-height: var(--touch); }
.checkbox-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } }

/* Champ mot de passe avec bouton afficher/masquer */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; border-radius: var(--radius-sm); font-size: 1.05rem; display: grid; place-items: center; }
.pw-toggle:hover { background: var(--bg-elev-2); color: var(--text); }
.pw-toggle.on { color: var(--accent); }

/* ============================ Badges / chips =========================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: var(--radius-full); font-size: 0.74rem; font-weight: 700;
  white-space: nowrap; letter-spacing: 0.02em;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--draft, .badge--closed, .badge--user { color: var(--text-muted); background: var(--bg-elev-3); }
.badge--confirmed, .badge--ordered, .badge--shop { color: var(--secondary); background: var(--secondary-soft); }
.badge--to_pay, .badge--warn { color: var(--warn); background: var(--warn-soft); }
.badge--paid, .badge--received, .badge--ok, .badge--open { color: var(--ok); background: var(--ok-soft); }
.badge--cancelled, .badge--danger { color: var(--danger); background: var(--danger-soft); }
.badge--admin { color: var(--accent); background: var(--accent-soft); }

/* ============================ Tables responsives ====================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { color: var(--text-muted); font-weight: 700; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; }
table.data tbody tr:hover { background: var(--bg-elev-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 639px) {
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 12px; padding: 6px 4px; box-shadow: var(--shadow); }
  table.data td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); text-align: right; padding: 10px 14px; }
  table.data td:last-child { border-bottom: none; }
  table.data td::before { content: attr(data-label); font-weight: 700; color: var(--text-muted); font-size: 0.74rem; text-transform: uppercase; text-align: left; flex-shrink: 0; }
}

/* ============================ Cartes produit ========================== */
.product-card { position: relative; display: flex; flex-direction: column; overflow: hidden; padding: 0; border-radius: var(--radius-xl); }
.product-card__img { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; background: var(--bg-elev-2); }
.product-card__img--placeholder { display: grid; place-items: center; color: var(--text-muted); font-size: 2.4rem; }
.product-card__body { padding: 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card__title { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; }
.product-card__prices { display: flex; align-items: baseline; gap: 8px; margin-top: auto; padding-top: 8px; }
.price-gw { color: var(--text-muted); text-decoration: line-through; font-size: 0.85rem; }
.price-member { color: var(--secondary); font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; }
.product-card__foot { display: flex; align-items: center; gap: 8px; padding: 0 18px 18px; }
.qty-input { width: 66px; text-align: center; }
/* badge PROMO overlay */
.product-card .badge--danger, .product-card .promo-flag {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  background: var(--warn); color: #1a0a00; box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.product-card .badge--danger::before { display: none; }
.deadline { font-size: 0.8rem; color: var(--warn); font-weight: 600; }

/* ============================ Tuiles KPI ============================== */
.stat { text-align: left; border-radius: var(--radius-lg); }
.stat__value { font-family: var(--font-head); font-size: 2rem; font-weight: 700; line-height: 1; }
.stat__label { color: var(--text-muted); font-size: 0.82rem; margin-top: 8px; }
.stat__value--accent { color: var(--secondary); }

/* ============================ Jauge « power-cell » ==================== */
.progress { height: 8px; border-radius: var(--radius-full); background: var(--bg-elev-3); overflow: hidden; }
.progress__fill { height: 100%; border-radius: var(--radius-full); background: linear-gradient(90deg, color-mix(in srgb, var(--secondary) 60%, transparent), var(--secondary)); box-shadow: 0 0 12px var(--secondary-soft); }

/* ============================ Auth ==================================== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(60% 50% at 50% 0%, var(--accent-soft), transparent 70%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; margin-bottom: 18px; font-size: 1.4rem; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; font-size: 0.88rem; }

/* ============================ Toast =================================== */
#toast-root { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--glass-bg); backdrop-filter: blur(16px); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--secondary); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow-lg); font-size: 0.9rem; animation: toast-in .2s ease; }
.toast--ok { border-left-color: var(--ok); }
.toast--error { border-left-color: var(--danger); }
.toast--warn { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ============================ Modal (glass) ========================== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--glass-bg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid var(--border); border-radius: var(--radius-xl); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal__head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal__head h3 { margin: 0; }
.modal__body { padding: 22px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px; border-top: 1px solid var(--border); }

/* ============================ Divers ================================= */
.empty-state { text-align: center; padding: 56px 16px; color: var(--text-muted); }
.empty-state__icon { font-size: 2.8rem; margin-bottom: 10px; }
