/* =========================================================================
   Back-office Boutique — Feuille de styles
   Interface sobre, responsive (desktop d'abord), en français.
   Aucune dépendance externe. Variables CSS pour la charte.
   ========================================================================= */

:root {
  --bleu: #1e40af;
  --bleu-clair: #3b82f6;
  --bleu-fonce: #1e3a8a;
  --fond: #f4f6fb;
  --carte: #ffffff;
  --texte: #1f2937;
  --texte-doux: #6b7280;
  --bordure: #e5e7eb;
  --vert: #16a34a;
  --rouge: #dc2626;
  --orange: #ea580c;
  --jaune: #ca8a04;
  --ombre: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --rayon: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fond);
  color: var(--texte);
  font-size: 14px;
  line-height: 1.5;
}

/* Cacher les éléments */
.cache { display: none !important; }

/* =========================================================================
   ÉCRAN DE CONNEXION
   ========================================================================= */
#ecran-connexion {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.boite-connexion {
  background: var(--carte);
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.12);
  width: 100%;
  max-width: 400px;
}

.boite-connexion h1 {
  margin: 0 0 4px;
  font-size: 24px;
  color: var(--bleu);
  text-align: center;
}

.boite-connexion .sous-titre {
  text-align: center;
  color: var(--texte-doux);
  margin: 0 0 28px;
  font-size: 13px;
}

/* =========================================================================
   FORMULAIRES
   ========================================================================= */
.champ { margin-bottom: 16px; }

.champ label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 13px;
}

input[type="text"],
input[type="password"],
input[type="tel"],
input[type="date"],
input[type="search"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--texte);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--bleu-clair);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* =========================================================================
   BOUTONS
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bleu);
  color: #fff;
  transition: background .15s;
}
.btn:hover { background: var(--bleu-fonce); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-bloc { width: 100%; }
.btn-secondaire { background: #fff; color: var(--texte); border: 1px solid var(--bordure); }
.btn-secondaire:hover { background: #f9fafb; }
.btn-danger { background: var(--rouge); }
.btn-danger:hover { background: #b91c1c; }

/* =========================================================================
   MESSAGES / ALERTES
   ========================================================================= */
.message-erreur {
  background: #fef2f2;
  color: var(--rouge);
  border: 1px solid #fecaca;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.message-info {
  background: #eff6ff;
  color: var(--bleu);
  border: 1px solid #bfdbfe;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

/* Bandeau permanent de l'écran de connexion : URL d'API différente du défaut.
   Discret mais toujours visible (anti-exfiltration / hameçonnage). */
.avert-api {
  background: #fff7ed;
  color: var(--orange);
  border: 1px solid #fed7aa;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
  margin-bottom: 16px;
  word-break: break-all;
}
.avert-api a {
  color: var(--orange);
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}

/* =========================================================================
   MISE EN PAGE APPLICATION (barre latérale + contenu)
   ========================================================================= */
#app { display: flex; min-height: 100vh; }

.barre-laterale {
  width: 230px;
  background: var(--bleu-fonce);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.barre-laterale .logo {
  padding: 20px 20px 16px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.barre-laterale .logo small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  opacity: .7;
  margin-top: 2px;
}

.menu { flex: 1; padding: 12px 0; }
.menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.menu a:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu a.actif {
  background: rgba(255,255,255,.10);
  color: #fff;
  border-left-color: var(--bleu-clair);
  font-weight: 600;
}
.menu a .ico { width: 18px; text-align: center; }

.bas-barre {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 12px;
}
.bas-barre .utilisateur { margin-bottom: 10px; opacity: .85; }
.bas-barre .utilisateur strong { display: block; font-size: 13px; opacity: 1; }

/* Zone de contenu principale */
.contenu {
  flex: 1;
  padding: 24px 32px;
  overflow-x: auto;
  max-width: 100%;
}

.entete-page {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.entete-page h2 { margin: 0; font-size: 22px; }

/* =========================================================================
   CARTES INDICATEURS (tableau de bord)
   ========================================================================= */
.grille-cartes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.carte {
  background: var(--carte);
  border-radius: var(--rayon);
  padding: 18px 20px;
  box-shadow: var(--ombre);
  border: 1px solid var(--bordure);
}
.carte .titre-carte {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--texte-doux);
  margin-bottom: 8px;
}
.carte .valeur-carte {
  font-size: 26px;
  font-weight: 700;
  color: var(--texte);
}
.carte.alerte .valeur-carte { color: var(--orange); }
.carte.danger .valeur-carte { color: var(--rouge); }

/* =========================================================================
   TABLEAUX
   ========================================================================= */
.boite-tableau {
  background: var(--carte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  border: 1px solid var(--bordure);
  overflow: hidden;
  margin-top: 8px;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f9fafb;
  text-align: left;
  padding: 12px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--texte-doux);
  border-bottom: 1px solid var(--bordure);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bordure);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

.vignette {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  background: #f3f4f6;
  border: 1px solid var(--bordure);
}
.vignette-vide {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: #f3f4f6;
  border: 1px solid var(--bordure);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--texte-doux);
  font-size: 16px;
}

/* =========================================================================
   BADGES
   ========================================================================= */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-rouge   { background: #fef2f2; color: var(--rouge); border: 1px solid #fecaca; }
.badge-orange  { background: #fff7ed; color: var(--orange); border: 1px solid #fed7aa; }
.badge-jaune   { background: #fefce8; color: var(--jaune); border: 1px solid #fde68a; }
.badge-vert    { background: #f0fdf4; color: var(--vert); border: 1px solid #bbf7d0; }
.badge-gris    { background: #f3f4f6; color: var(--texte-doux); border: 1px solid var(--bordure); }
.badge-bleu    { background: #eff6ff; color: var(--bleu); border: 1px solid #bfdbfe; }

/* =========================================================================
   BARRES D'OUTILS / FILTRES
   ========================================================================= */
.barre-filtres {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
  background: var(--carte);
  padding: 16px;
  border-radius: var(--rayon);
  border: 1px solid var(--bordure);
  box-shadow: var(--ombre);
}
.barre-filtres .champ { margin-bottom: 0; }
.barre-filtres .champ-large { flex: 1; min-width: 180px; }
.barre-filtres label { font-size: 12px; }

.checkbox-ligne {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

/* =========================================================================
   ÉTATS (chargement / vide)
   ========================================================================= */
.etat-vide, .etat-chargement {
  text-align: center;
  padding: 40px 20px;
  color: var(--texte-doux);
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--bordure);
  border-top-color: var(--bleu);
  border-radius: 50%;
  animation: tourner .8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes tourner { to { transform: rotate(360deg); } }

/* Rapports : mise en page en deux colonnes */
.grille-rapport {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.section-titre {
  font-size: 16px;
  font-weight: 700;
  margin: 24px 0 12px;
}

.reglages-api {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--texte-doux);
}
.reglages-api input { width: 240px; padding: 6px 10px; font-size: 12px; }

/* =========================================================================
   RESPONSIVE (tablette / mobile de secours)
   ========================================================================= */
@media (max-width: 820px) {
  #app { flex-direction: column; }
  .barre-laterale {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .barre-laterale .logo { flex: 1 0 100%; }
  .menu { display: flex; flex-wrap: wrap; padding: 6px; }
  .menu a { border-left: none; padding: 8px 12px; }
  .menu a.actif { border-radius: 6px; }
  .bas-barre { flex: 1 0 100%; }
  .contenu { padding: 16px; }
}

/* =========================================================================
   IMPRESSION (rapports -> PDF navigateur)
   ========================================================================= */
@media print {
  .barre-laterale, .barre-filtres, .btn, .no-print, .reglages-api, .entete-page .btn { display: none !important; }
  #app { display: block; }
  .contenu { padding: 0; }
  body { background: #fff; }
  .carte, .boite-tableau { box-shadow: none; border: 1px solid #ccc; }
  .entete-page { margin-bottom: 10px; }
}

/* ---- Grille de produits façon Zobaze (cartes) ---- */
.grille-produits {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.carte-produit {
  background: #fff;
  border: 1px solid #e6e8ee;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  transition: box-shadow .15s, transform .15s;
}
.carte-produit:hover {
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  transform: translateY(-2px);
}
/* Conteneur de la photo : sert d'ancrage au badge de quantité superposé. */
.carte-produit-media {
  position: relative;
  width: 100%;
}
.carte-produit-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  background: #f2f4f8;
}
.carte-produit-img.vide {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #b9c0cc;
}
/* Badge « x N » de stock, en haut à gauche de la photo (comme sur le mobile). */
.carte-produit-qte {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.carte-produit-qte.rupture {
  background: var(--rouge, #c0392b);
}
.carte-produit-nom {
  font-weight: 700;
  font-size: 14px;
  margin-top: 8px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.carte-produit-prix {
  color: var(--bleu, #1f4e79);
  font-weight: 700;
  margin-top: 4px;
}
.carte-produit-stock {
  color: var(--texte-doux, #6b7280);
  font-size: 12px;
  margin-top: 2px;
}
.carte-produit-stock.rupture {
  color: var(--rouge, #c0392b);
  font-weight: 700;
}
.carte-produit-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-start;
  margin-top: 6px;
}

/* =========================================================================
   COMPLÉMENTS v2 — coquille de l'application (socle core.js)
   Menu par groupes, sélecteur de boutique, modales, notifications.
   ========================================================================= */

/* ---- Écran de connexion (v2) ---- */
.ecran-connexion {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--fond);
}
.carte-connexion {
  width: 100%; max-width: 400px; background: var(--carte); padding: 32px;
  border-radius: var(--rayon); box-shadow: var(--ombre);
}
.carte-connexion h1 { margin: 0 0 4px; text-align: center; color: var(--bleu); font-size: 26px; }
.carte-connexion .sous-titre { margin: 0 0 20px; text-align: center; color: var(--texte-doux); font-size: 13px; }
.carte-connexion label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 13px; }
.carte-connexion input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--bordure);
  border-radius: 8px; font-size: 15px;
}
.carte-connexion .btn-bloc { margin-top: 20px; }
.lien-discret {
  display: block; margin-top: 16px; text-align: center; font-size: 12px;
  color: var(--texte-doux); text-decoration: underline; cursor: pointer;
}
.bloc-api { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--bordure); }
.avert-api {
  margin-bottom: 12px; padding: 8px 10px; border-radius: 8px;
  background: #fff7ed; color: #9a3412; font-size: 12px; border: 1px solid #fed7aa;
}

/* ---- Coquille application ---- */
.app { display: flex; min-height: 100vh; }
.marque {
  display: flex; align-items: center; gap: 8px; padding: 18px 16px 10px;
  font-weight: 700; font-size: 17px; color: #fff;
}
.marque .logo { font-size: 20px; }
.bloc-boutique { padding: 0 16px 12px; border-bottom: 1px solid rgba(255,255,255,.12); }
.bloc-boutique label { display: block; font-size: 11px; color: rgba(255,255,255,.65); margin-bottom: 4px; }
.bloc-boutique select {
  width: 100%; padding: 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.10); color: #fff; font-size: 13px;
}
.bloc-boutique select option { color: #111; }
.boutique-unique { color: rgba(255,255,255,.85); font-size: 13px; font-weight: 600; }
.menu-groupe {
  padding: 14px 16px 4px; font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(255,255,255,.45);
}
.badge-role {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 10px;
  background: rgba(255,255,255,.18); font-size: 11px;
}
.entete-contenu { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.entete-contenu h2 { margin: 0; font-size: 21px; }
.btn-menu {
  display: none; background: var(--carte); border: 1px solid var(--bordure);
  border-radius: 8px; font-size: 18px; padding: 6px 11px; cursor: pointer;
}
.zone-vue { padding-bottom: 40px; }

/* ---- Modales ---- */
.modale-fond {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 900;
}
.modale {
  background: var(--carte); border-radius: 12px; width: 100%; max-width: 520px;
  max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modale-large { max-width: 900px; }
.modale-entete {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--bordure);
}
.modale-entete h3 { margin: 0; font-size: 17px; }
.modale-fermer { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--texte-doux); line-height: 1; }
.modale-corps { padding: 18px; overflow: auto; }
.modale-corps label { display: block; margin: 12px 0 5px; font-weight: 600; font-size: 13px; }
.modale-corps label:first-child { margin-top: 0; }
.modale-corps input, .modale-corps select, .modale-corps textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--bordure); border-radius: 8px; font-size: 14px;
}
.modale-pied {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--bordure);
}
.texte-confirmation { margin: 0; font-size: 15px; }

/* ---- Notifications ---- */
#zone-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 11px 16px; border-radius: 8px; color: #fff; font-size: 14px; max-width: 380px;
  box-shadow: 0 6px 20px rgba(0,0,0,.20); animation: toast-entree .18s ease-out;
}
.toast-ok { background: var(--vert); }
.toast-erreur { background: var(--rouge); }
.toast-info { background: var(--bleu); }
.toast.sortie { opacity: 0; transition: opacity .5s; }
@keyframes toast-entree { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Écrans étroits (tablette / téléphone) ---- */
@media (max-width: 900px) {
  .btn-menu { display: inline-block; }
  /* Tiroir latéral coulissant (remplace l'ancienne barre horizontale du bloc
     @media 820px plus haut : ces règles, placées après, ont la priorité). */
  .barre-laterale {
    position: fixed; inset: 0 auto 0 0; z-index: 800; width: 250px;
    height: 100vh; flex-direction: column; flex-wrap: nowrap; align-items: stretch;
    overflow-y: auto; transform: translateX(-100%); transition: transform .2s ease-out;
  }
  .menu { display: block; }
  .menu a { border-left: 3px solid transparent; padding: 10px 16px; }
  body.menu-ouvert .barre-laterale { transform: none; }
  .contenu { width: 100%; }
}

/* =========================================================================
   CORRECTIF — DÉFILEMENT DE LA BARRE LATÉRALE
   Avec 23 écrans répartis en groupes, la liste dépasse la hauteur de l'écran
   sur un ordinateur portable : sans défilement, les derniers groupes
   (Équipe, Retraits, Compte) étaient purement invisibles et donc
   inaccessibles. `min-height: 0` est indispensable : sans lui, un enfant
   flex refuse de rétrécir sous la taille de son contenu et le débordement
   n'est jamais scrollable.
   ========================================================================= */
.barre-laterale { min-height: 0; }
.menu {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Barre de défilement discrète sur fond sombre */
.menu::-webkit-scrollbar { width: 8px; }
.menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 4px; }
.menu::-webkit-scrollbar-track { background: transparent; }
/* La marque, le sélecteur de boutique et le bloc utilisateur restent fixes */
.marque, .bloc-boutique, .bas-barre { flex: 0 0 auto; }

/* Logo au-dessus du formulaire de connexion. Version complète (carré bleu) :
   le fond de l'écran de connexion est clair. */
.carte-connexion .logo-connexion {
  display: block;
  margin: 0 auto 14px;
  width: 64px;
  height: 64px;
}

/* Logo dans la barre latérale. Variante sans carré de fond : la barre est
   déjà bleue, un carré bleu ne s'y verrait pas. */
.marque .marque-logo {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}
