/* =========================================================
   CHARTE GRAPHIQUE MVW — Ma Vitrine Web
   Base commune à toutes les applications MVW.
   - Violet MVW  #35119F : couleur principale (boutons, titres, actifs)
   - Gris MVW    #BDBEBF : traits, éléments neutres
   - Orange      #E07A1F : couleur secondaire, complémentaire du violet
                           (ici : la liste Drive)
   - Titres : Poppins / Texte : police du téléphone
   Pour une nouvelle appli MVW : copier ce bloc tel quel.
   ========================================================= */
:root {
  --mvw-violet: #35119f;
  --mvw-violet-fonce: #240a70;
  --mvw-violet-clair: #ece8fa;
  --mvw-gris: #bdbebf;
  --mvw-orange: #e07a1f;

  --fond: #f4f3f8;
  --carte: #ffffff;
  --texte: #1c1633;
  --gris: #6c6a78;
  --trait: #e3e2ea;
  --primaire: var(--mvw-violet);
  --primaire-clair: var(--mvw-violet-clair);
  --second: var(--mvw-orange);
  --second-clair: #fcefe2;
  --rouge: #c62f3c;
  --ombre: 0 1px 2px rgba(53, 17, 159, .06), 0 4px 14px rgba(53, 17, 159, .06);
  --rayon: 18px;
  --police-titre: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bas: env(safe-area-inset-bottom, 0px);
  --haut: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #12101b;
    --carte: #1d1a2b;
    --texte: #eceaf5;
    --gris: #a19fb0;
    --trait: #2e2a40;
    --primaire: #8b6ff2;
    --primaire-clair: #2a2250;
    --second: #f0953f;
    --second-clair: #3a2a1a;
    --rouge: #f06b74;
    --ombre: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
  font-size: 17px;
  line-height: 1.35;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; font-size: 17px; color: var(--texte); }
[hidden] { display: none !important; }

/* ---------- Démarrage / connexion ---------- */
.demarrage { position: fixed; inset: 0; display: grid; place-items: center; background: var(--mvw-violet); }
.demarrage img { border-radius: 18px; }
.login { min-height: 100%; display: grid; place-content: center; justify-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--mvw-violet) 0%, var(--mvw-violet-fonce) 100%); }
.login .signature-mvw { color: rgba(255,255,255,.75); }
.login .signature-mvw { margin-top: 26px; }
.login-carte {
  width: 100%; max-width: 380px; background: var(--carte); border-radius: 22px;
  padding: 28px 22px; box-shadow: var(--ombre); text-align: center;
}
.login-carte img { border-radius: 16px; }
.login-carte h1 { margin: 10px 0 2px; font-size: 26px; color: var(--primaire); }
.login-carte p { margin: 0 0 18px; color: var(--gris); }
.login-carte label { display: block; text-align: left; font-weight: 600; font-size: 15px; margin: 12px 0 6px; }
.erreur { color: var(--rouge) !important; margin-top: 12px !important; min-height: 1.3em; }

.champ {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--trait); border-radius: 12px;
  background: var(--fond); outline: none;
}
.login-carte input { width: 100%; padding: 13px 14px; border: 1.5px solid var(--trait); border-radius: 12px; background: var(--fond); outline: none; }
.champ:focus, .login-carte input:focus { border-color: var(--primaire); background: var(--carte); }

.btn-principal {
  display: block; width: 100%; margin-top: 20px; padding: 15px; border: 0; border-radius: 14px;
  background: var(--primaire); color: #fff; font-weight: 700; font-size: 17px;
}
.btn-principal:active { transform: scale(.98); }
.btn-secondaire {
  display: block; width: 100%; padding: 14px; border: 1.5px solid var(--trait); border-radius: 14px;
  background: var(--carte); font-weight: 600; text-align: center; text-decoration: none; color: var(--texte);
}
.btn-danger { color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 35%, var(--trait)); }

/* ---------- Structure ---------- */
.app { min-height: 100%; padding-bottom: calc(76px + var(--bas)); }
.entete {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--haut)) 18px 14px;
  background: linear-gradient(135deg, var(--mvw-violet) 0%, var(--mvw-violet-fonce) 100%);
  box-shadow: 0 2px 12px rgba(36, 10, 112, .25);
}
.entete-gauche { display: flex; align-items: center; gap: 10px; }
.marque { display: block; height: 18px; width: auto; opacity: .95; }
.entete h1 { margin: 0; font-family: var(--police-titre); font-size: 26px; font-weight: 700; letter-spacing: -.01em; color: #fff; }
.synchro { width: 11px; height: 11px; border-radius: 50%; background: #5ee39b; box-shadow: 0 0 0 3px rgba(255,255,255,.18); transition: background .3s; }
.synchro.hors-ligne { background: #ff6b6b; }
.synchro.envoi { background: #ffc94a; }

main { padding: 0 14px 20px; max-width: 640px; margin: 0 auto; }

/* ---------- Barre d'onglets ---------- */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--carte); border-top: 1px solid var(--trait);
  padding: 6px 4px calc(6px + var(--bas));
}
.onglet {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: 6px 0; font-size: 11.5px; color: var(--gris); border-radius: 12px;
}
.onglet .ico { font-size: 23px; line-height: 1; filter: grayscale(1); opacity: .7; }
.onglet.actif { color: var(--primaire); font-weight: 700; }
.onglet.actif .ico { filter: none; opacity: 1; }
.pastille {
  position: absolute; top: 2px; left: calc(50% + 8px);
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--primaire); color: #fff; font-size: 12px; line-height: 20px; font-weight: 700;
}
.pastille:empty { display: none; }
.onglet[data-vue="drive"] .pastille { background: var(--second); }

/* ---------- Barre d'ajout ---------- */
.ajout { position: sticky; top: calc(62px + var(--haut)); z-index: 15; padding: 14px 0 10px; background: var(--fond); }
.ajout form { display: flex; gap: 8px; }
.ajout input {
  flex: 1; min-width: 0; padding: 14px 16px; border: 1.5px solid var(--trait); border-radius: 14px;
  background: var(--carte); outline: none; box-shadow: var(--ombre);
}
.ajout input:focus { border-color: var(--accent, var(--primaire)); }
.ajout button {
  flex: 0 0 54px; border: 0; border-radius: 14px; background: var(--accent, var(--primaire)); color: #fff;
  font-size: 28px; font-weight: 600; line-height: 1;
}
.suggestions {
  margin-top: 6px; background: var(--carte); border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.14);
  overflow: hidden;
}
.suggestions button {
  display: flex; width: 100%; align-items: center; gap: 10px; text-align: left;
  border: 0; background: none; padding: 13px 16px; border-bottom: 1px solid var(--trait);
}
.suggestions button:last-child { border-bottom: 0; }
.suggestions button:active { background: var(--fond); }
.suggestions .deja { margin-left: auto; font-size: 13px; color: var(--gris); }

.vue-drive { --accent: var(--second); }

/* ---------- Bandeau d'aide (Drive) ---------- */
.bandeau {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 12px;
  border-radius: var(--rayon); background: var(--second-clair); font-size: 14.5px;
}
.bandeau a {
  flex: 0 0 auto; padding: 9px 12px; border-radius: 10px; background: var(--second); color: #fff;
  font-weight: 700; text-decoration: none; font-size: 14px;
}

/* ---------- Groupes par rayon ---------- */
.groupe { margin-bottom: 14px; }
.groupe h2 {
  display: flex; align-items: center; gap: 8px; margin: 14px 4px 8px;
  font-family: var(--police-titre); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--primaire);
}
.groupe h2 .nb { margin-left: auto; font-weight: 600; color: var(--gris); }
.carte-liste { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); overflow: hidden; }

.ligne {
  display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 8px 10px 8px 8px;
  border-bottom: 1px solid var(--trait);
}
.ligne:last-child { border-bottom: 0; }
.coche {
  flex: 0 0 44px; height: 44px; border-radius: 50%; border: 2.5px solid var(--trait); background: none;
  display: grid; place-items: center; font-size: 20px; color: transparent; font-weight: 800;
}
.ligne.fait .coche { background: var(--accent, var(--primaire)); border-color: var(--accent, var(--primaire)); color: #fff; }
.texte { flex: 1; min-width: 0; padding: 4px 0; background: none; border: 0; text-align: left; }
.texte .nom { font-weight: 600; overflow-wrap: anywhere; }
.texte .info { font-size: 13px; color: var(--gris); margin-top: 1px; }
.ligne.fait .nom { text-decoration: line-through; color: var(--gris); font-weight: 500; }
.lien-drive {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--second-clair); text-decoration: none; font-size: 18px;
}
.qte { flex: 0 0 auto; display: flex; align-items: center; background: var(--fond); border-radius: 12px; }
.qte button { width: 38px; height: 42px; border: 0; background: none; font-size: 22px; font-weight: 600; color: var(--gris); }
.qte button:disabled { opacity: .25; }
.qte span { min-width: 22px; text-align: center; font-weight: 700; }
.qte-texte { padding: 0 12px; height: 42px; display: grid; place-items: center; font-weight: 600; font-size: 14px; border: 0; background: var(--fond); border-radius: 12px; }

.section-faits h2 { color: var(--accent, var(--primaire)); }
.btn-terminer {
  display: block; width: 100%; margin: 12px 0 4px; padding: 15px; border: 0; border-radius: 14px;
  background: var(--accent, var(--primaire)); color: #fff; font-weight: 700;
}

.vide { text-align: center; color: var(--gris); padding: 48px 20px; }
.vide .grand { font-size: 46px; display: block; margin-bottom: 8px; }

/* ---------- Habituels ---------- */
.choix-liste {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 0 0 10px;
  background: var(--trait); border-radius: 13px;
}
.choix-liste button { border: 0; background: none; padding: 10px; border-radius: 10px; font-weight: 600; color: var(--gris); }
.choix-liste button.actif { background: var(--carte); color: var(--texte); box-shadow: var(--ombre); }
.btn-ajouter {
  flex: 0 0 48px; height: 44px; border-radius: 12px; border: 0;
  background: var(--accent, var(--primaire)); color: #fff; font-size: 24px; font-weight: 600;
}
.btn-ajouter.dans-liste { background: var(--primaire-clair); color: var(--primaire); font-size: 15px; font-weight: 700; }
.vue-habituels.lieu-drive .btn-ajouter.dans-liste { background: var(--second-clair); color: var(--second); }
.btn-icone {
  flex: 0 0 40px; height: 40px; border-radius: 12px; border: 0; background: var(--fond); font-size: 16px;
}

/* ---------- Réglages ---------- */
.bloc { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; margin-bottom: 14px; }
.bloc h2 { margin: 0 0 10px; font-size: 18px; }
.bloc p { margin: 6px 0; color: var(--gris); font-size: 15px; }
.bloc ol { margin: 6px 0; padding-left: 20px; color: var(--gris); font-size: 15px; }
.rayon-ligne { display: flex; align-items: center; gap: 6px; padding: 7px 0; border-bottom: 1px solid var(--trait); }
.rayon-ligne:last-of-type { border-bottom: 0; }
.rayon-ligne .emoji { width: 30px; text-align: center; font-size: 20px; }
.rayon-ligne .nom { flex: 1; font-weight: 600; min-width: 0; }
.ajout-rayon { display: flex; gap: 8px; margin-top: 12px; }
.ajout-rayon .champ:first-child { flex: 0 0 64px; text-align: center; }

/* ---------- Feuille de modification ---------- */
.voile { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); animation: apparait .2s; }
.feuille {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  max-height: 92vh; overflow-y: auto; max-width: 640px; margin: 0 auto;
  background: var(--carte); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(20px + var(--bas)); animation: monte .25s ease-out;
}
.feuille::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--trait); margin: 0 auto 12px; }
.feuille h3 { margin: 0 0 8px; font-size: 21px; }
.feuille label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; color: var(--gris); }
.feuille .aide { font-size: 13px; color: var(--gris); margin: 6px 0 0; }
.feuille .actions { display: grid; gap: 10px; margin-top: 20px; }
.feuille .deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feuille .choix-liste { margin: 0; }
@keyframes monte { from { transform: translateY(100%); } to { transform: none; } }
@keyframes apparait { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Message ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--bas)); z-index: 60;
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: #1d2521; color: #fff; font-size: 15px; font-weight: 500; text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.visible { opacity: 1; transform: translateX(-50%); }
.toast.erreur-toast { background: var(--rouge); }

.vue-drive .groupe h2 { color: var(--second); }

/* ---------- Signature MVW ---------- */
.signature-mvw {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 22px 0 8px; color: var(--gris); font-size: 12.5px; line-height: 1.3; text-align: right; text-decoration: none;
}
.signature-mvw img { display: block; height: 40px; width: auto; }
.bloc h2, .feuille h3, .login-carte h1 { font-family: var(--police-titre); }

.vue-reglages { padding-top: 14px; }

/* ---------- Idées cadeaux ---------- */
.bandeau-cadeaux { background: var(--primaire-clair); }
.vue-cadeaux .texte .badge-secret,
.vue-cadeaux .texte .badge-achete {
  display: inline-block; margin-top: 5px; margin-right: 6px; padding: 3px 9px; border-radius: 8px;
  font-size: 12.5px; font-weight: 700;
}
.badge-secret { background: var(--second-clair); color: var(--second); }
.badge-achete { background: var(--primaire-clair); color: var(--primaire); }
.feuille .interrupteur {
  display: flex; align-items: center; gap: 14px; margin: 18px 0 0; padding: 14px;
  border-radius: 14px; background: var(--second-clair); color: var(--texte); font-size: 15px; cursor: pointer;
}
.interrupteur input {
  -webkit-appearance: none; appearance: none; flex: 0 0 50px; height: 30px; margin: 0;
  border-radius: 15px; background: var(--trait); position: relative; transition: background .2s; cursor: pointer;
}
.interrupteur input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.interrupteur input:checked { background: var(--second); }
.interrupteur input:checked::after { transform: translateX(20px); }
.interrupteur b { display: block; }
.interrupteur small { display: block; color: var(--gris); font-size: 13px; font-weight: 400; margin-top: 2px; }

.bloc .etiquette { display: block; font-weight: 600; font-size: 14px; color: var(--gris); margin: 12px 0 6px; }
.bloc .aide-petite { font-size: 13px; margin-top: 8px; }

/* ---------- Scanner 📷 ---------- */
.ajout .btn-scan {
  background: var(--carte); color: var(--texte); font-size: 24px;
  border: 1.5px solid var(--trait); box-shadow: var(--ombre);
}
.scanner {
  position: fixed; inset: 0; z-index: 70; background: #0b0816; color: #fff;
  display: flex; flex-direction: column; padding: calc(10px + var(--haut)) 0 calc(16px + var(--bas));
}
.scanner-haut { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 12px; }
.scanner-haut b { font-family: var(--police-titre); font-size: 19px; }
.scanner-fermer {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 20px;
}
/* La vidéo garde ses proportions : la zone affichée correspond
   exactement à la zone analysée par le lecteur */
.scanner-cadre { flex: 1; min-height: 0; display: flex; align-items: center; background: #000; overflow: hidden; }
#scanner-video { width: 100%; }
.scanner-aide { text-align: center; margin: 14px 20px 8px; font-size: 15px; color: rgba(255,255,255,.85); }
.scanner-manuel {
  align-self: center; border: 0; background: none; color: rgba(255,255,255,.7);
  text-decoration: underline; font-size: 14px; padding: 8px;
}
.scan-entete { display: flex; gap: 14px; align-items: center; margin: 4px 0 6px; }
.scan-photo { flex: 0 0 72px; width: 72px; height: 72px; object-fit: contain; border-radius: 14px; background: #fff; border: 1px solid var(--trait); }
.scan-photo-vide { display: grid; place-items: center; font-size: 32px; background: var(--fond); }
.scan-code { margin: 4px 0 0; font-size: 12.5px; color: var(--gris); font-variant-numeric: tabular-nums; }
