/* ============================================================
   Soirafa — Gestion de boutique
   Feuille de style unique (interface Gérant + interface Caissier)
   ============================================================ */
:root {
  --bleu: #2E5395;
  --bleu-clair: #3f6fc4;
  --bleu-fonce: #1e3a6b;
  --vert: #1f9d55;
  --vert-clair: #e6f6ec;
  --rouge: #d64545;
  --rouge-clair: #fbe9e9;
  --orange: #d98218;
  --orange-clair: #fdf1e0;
  --gris-bg: #f4f6fa;
  --gris-carte: #ffffff;
  --gris-bord: #e2e8f0;
  --texte: #1f2937;
  --texte-doux: #6b7280;
  --ombre: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --rayon: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--gris-bg);
  color: var(--texte);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--bleu); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: none; border-radius: 10px; padding: .6rem 1rem;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  background: var(--bleu); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--bleu-fonce); }
.btn-vert { background: var(--vert); }
.btn-vert:hover { background: #177d43; }
.btn-rouge { background: var(--rouge); }
.btn-rouge:hover { background: #b53434; }
.btn-clair { background: #eef2f8; color: var(--bleu-fonce); }
.btn-clair:hover { background: #dde6f3; }
.btn-bloc { width: 100%; }
.btn-lg { padding: 1rem 1.2rem; font-size: 1.2rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Formulaires ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin: .6rem 0 .25rem; color: var(--texte-doux); }
input, select, textarea {
  width: 100%; padding: .6rem .7rem; font-size: 1rem;
  border: 1px solid var(--gris-bord); border-radius: 10px; background: #fff;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--bleu-clair); border-color: var(--bleu-clair); }

/* ---------- Cartes / tableaux ---------- */
.carte {
  background: var(--gris-carte); border: 1px solid var(--gris-bord);
  border-radius: var(--rayon); box-shadow: var(--ombre); padding: 1.25rem;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .6rem; border-bottom: 1px solid var(--gris-bord); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--texte-doux); }
tbody tr:hover { background: #f9fbfe; }
.table-responsive { overflow-x: auto; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge-vert { background: var(--vert-clair); color: var(--vert); }
.badge-rouge { background: var(--rouge-clair); color: var(--rouge); }
.badge-orange { background: var(--orange-clair); color: var(--orange); }
.badge-bleu { background: #e7eefb; color: var(--bleu); }

/* ============================================================
   INTERFACE GÉRANT — layout avec menu latéral
   ============================================================ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--bleu-fonce); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar .marque { padding: 1.3rem 1.2rem; font-size: 1.3rem; font-weight: 800; letter-spacing: .02em; }
.sidebar .marque span { color: #9fc0ff; }
.sidebar nav { flex: 1; padding: .5rem; }
.sidebar nav a {
  display: flex; align-items: center; gap: .7rem; color: #cdd9f0;
  padding: .8rem 1rem; border-radius: 10px; font-weight: 600; margin-bottom: .15rem;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.actif { background: var(--bleu); color: #fff; }
.sidebar nav a .ico { font-size: 1.15rem; }
.sidebar .bas { padding: 1rem; border-top: 1px solid rgba(255,255,255,.12); font-size: .85rem; }
.sidebar .bas .nom { font-weight: 700; }
.sidebar .bas a { color: #9fc0ff; }

.contenu { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--gris-bord);
  padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 1.3rem; margin: 0; }
.page { padding: 1.5rem; max-width: 1200px; width: 100%; }

/* Grille de statistiques */
.grille-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: #fff; border: 1px solid var(--gris-bord); border-radius: var(--rayon); padding: 1.1rem 1.25rem; box-shadow: var(--ombre); }
.stat .libelle { color: var(--texte-doux); font-size: .85rem; font-weight: 600; }
.stat .valeur { font-size: 1.7rem; font-weight: 800; margin-top: .2rem; }
.stat .valeur.bleu { color: var(--bleu); }
.stat .valeur.vert { color: var(--vert); }
.stat .valeur.rouge { color: var(--rouge); }
.stat .valeur.orange { color: var(--orange); }

.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 900px) { .grille-2 { grid-template-columns: 1fr; } }

.section-titre { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

/* barres simples pour rapports */
.barre-ligne { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.barre-ligne .nom { width: 40%; font-size: .9rem; }
.barre-piste { flex: 1; background: #eef2f8; border-radius: 999px; height: 14px; overflow: hidden; }
.barre-remplie { height: 100%; background: var(--bleu); border-radius: 999px; }
.barre-ligne .val { font-size: .85rem; font-weight: 700; width: 90px; text-align: right; }

/* ---------- Menu mobile (gérant) ---------- */
.menu-toggle { display: none; background: none; border: none; font-size: 1.6rem; cursor: pointer; color: var(--bleu-fonce); }
@media (max-width: 768px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.ouvert { transform: translateX(0); }
  .menu-toggle { display: block; }
  .overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .overlay.actif { display: block; }
}

/* ============================================================
   INTERFACE CAISSIER — POS plein écran
   ============================================================ */
.pos { display: flex; flex-direction: column; height: 100vh; max-width: 560px; margin: 0 auto; background: #fff; }
.pos-header {
  background: var(--bleu-fonce); color: #fff; padding: .9rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
}
.pos-header .marque { font-weight: 800; font-size: 1.15rem; }
.pos-header a { color: #cdd9f0; font-size: .85rem; }

.pos-scan { padding: 1rem; }
.zone-scan { position: relative; background: #000; border-radius: var(--rayon); overflow: hidden; aspect-ratio: 4 / 3; display: none; }
.zone-scan video { width: 100%; height: 100%; object-fit: cover; }
.zone-scan .cible { position: absolute; inset: 15% 15%; border: 3px solid rgba(255,255,255,.8); border-radius: 12px; }

.pos-panier { flex: 1; overflow-y: auto; padding: 0 1rem; }
.ligne-panier { display: flex; align-items: center; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid var(--gris-bord); }
.ligne-panier .info { flex: 1; min-width: 0; }
.ligne-panier .info .nom { font-weight: 700; }
.ligne-panier .info .prix { color: var(--texte-doux); font-size: .85rem; }
.qte-ctrl { display: flex; align-items: center; gap: .3rem; }
.qte-ctrl button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--gris-bord); background: #f4f6fa; font-size: 1.3rem; font-weight: 700; cursor: pointer; }
.qte-ctrl .q { min-width: 28px; text-align: center; font-weight: 700; }
.ligne-panier .st { font-weight: 700; width: 90px; text-align: right; }
.panier-vide { text-align: center; color: var(--texte-doux); padding: 3rem 1rem; }

.pos-bas { border-top: 2px solid var(--gris-bord); padding: 1rem; background: #fff; }
.pos-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .8rem; }
.pos-total .lbl { font-size: 1.1rem; font-weight: 600; color: var(--texte-doux); }
.pos-total .montant { font-size: 2rem; font-weight: 800; color: var(--bleu); }
.pos-actions { display: grid; grid-template-columns: 1fr 2fr; gap: .6rem; }

/* modale */
.modale { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; align-items: center; justify-content: center; padding: 1rem; }
.modale.ouvert { display: flex; }
.modale-boite { background: #fff; border-radius: var(--rayon); padding: 1.25rem; width: 100%; max-width: 440px; max-height: 85vh; overflow-y: auto; }
.modale-boite h3 { margin-bottom: 1rem; }
.resultat-recherche { padding: .7rem; border: 1px solid var(--gris-bord); border-radius: 10px; margin-bottom: .5rem; cursor: pointer; display: flex; justify-content: space-between; }
.resultat-recherche:hover { background: #f4f6fa; }

.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--texte); color: #fff; padding: .7rem 1.2rem; border-radius: 10px; z-index: 200; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.err { background: var(--rouge); }
.toast.ok { background: var(--vert); }

/* ---------- Connexion ---------- */
.page-connexion { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.boite-connexion { background: #fff; border-radius: 16px; box-shadow: 0 10px 40px rgba(30,58,107,.15); padding: 2rem; width: 100%; max-width: 380px; }
.boite-connexion .marque { text-align: center; font-size: 1.8rem; font-weight: 800; color: var(--bleu-fonce); margin-bottom: .3rem; }
.boite-connexion .sous { text-align: center; color: var(--texte-doux); margin-bottom: 1.5rem; }
.erreur-msg { background: var(--rouge-clair); color: var(--rouge); padding: .7rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600; font-size: .9rem; }

/* QR affiché */
.qr-box { text-align: center; }
.qr-box img { width: 200px; height: 200px; border: 1px solid var(--gris-bord); border-radius: 10px; }
.qr-ref { font-family: monospace; font-weight: 700; font-size: 1.1rem; margin-top: .5rem; }

.aide { color: var(--texte-doux); font-size: .85rem; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.flex-entre { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* ---------- Administration plateforme ---------- */
.notice { background: var(--vert-clair); color: var(--vert); border: 1px solid var(--vert); padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600; font-size: .9rem; }
.barre-filtres { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; }
.fiche-liste { list-style: none; display: grid; gap: .5rem; }
.fiche-liste li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--gris-bord); }
.fiche-liste li:last-child { border-bottom: none; }

/* ---------- Champ mot de passe avec bascule de visibilité ---------- */
.champ-mdp { position: relative; }
.champ-mdp input { padding-right: 2.6rem; }
.bascule-mdp {
  position: absolute; top: 50%; right: .5rem; transform: translateY(-50%);
  width: auto; padding: .2rem .35rem; margin: 0; border: none; background: transparent;
  font-size: 1.15rem; line-height: 1; cursor: pointer; border-radius: 8px;
}
.bascule-mdp:hover { background: #eef2f8; }

/* ---------- Bandeau d'abonnement ---------- */
.bandeau-abo { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600; font-size: .9rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.bandeau-abo.orange { background: var(--orange-clair); color: var(--orange); border: 1px solid var(--orange); }
.bandeau-abo.rouge { background: var(--rouge-clair); color: var(--rouge); border: 1px solid var(--rouge); }
.bandeau-abo a { color: inherit; text-decoration: underline; }
