/*
 * styles.css — Console d'administration Devanture.
 * Aucune couleur litterale dans les regles : tout passe par les variables
 * ci-dessous. Le theme de la boutique connectee remplacera ces valeurs
 * neutres par les siennes a l'execution.
 */
:root {
  --fond: whitesmoke;
  --surface: white;
  --texte: darkslategray;
  --texte-doux: slategray;
  --bordure: gainsboro;
  --accent: darkslategray;
  --accent-texte: white;
  --alerte-fond: gainsboro;
  --alerte-texte: dimgray;
  --rayon: 16px;
  --rayon-petit: 10px;
  --espace: 20px;
  --police: system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--police);
  background: var(--fond);
  color: var(--texte);
  font-size: 18px;
  line-height: 1.5;
}

.bandeau {
  padding: calc(var(--espace) * 1.5) var(--espace);
  background: var(--surface);
  border-bottom: 2px solid var(--bordure);
}

.bandeau h1 {
  margin: 0;
  font-size: 2.2rem;
  line-height: 1.15;
}

.sous-titre {
  margin: 6px 0 var(--espace);
  color: var(--texte-doux);
  font-size: 1.15rem;
}

.champ-store {
  display: inline-grid;
  gap: 6px;
  font-weight: 700;
  /* Adaptation BCBT : un nom de boutique long ne doit pas faire
     déborder le sélecteur sur mobile (vu en capture 390 px). */
  max-width: 100%;
}

.champ-store select,
.formulaire-promo input {
  font: inherit;
  padding: 10px 14px;
  border: 2px solid var(--bordure);
  border-radius: var(--rayon-petit);
  background: var(--surface);
  color: var(--texte);
  min-height: 48px;
  max-width: 100%;
}

.statut {
  margin: var(--espace) 0 0;
  color: var(--texte-doux);
}

.statut-demo {
  background: var(--alerte-fond);
  color: var(--alerte-texte);
  border-radius: var(--rayon-petit);
  padding: 8px 12px;
  font-weight: 700;
}

main {
  display: grid;
  gap: var(--espace);
  padding: var(--espace);
  max-width: 960px;
  margin: 0 auto;
}

.carte {
  background: var(--surface);
  border: 2px solid var(--bordure);
  border-radius: var(--rayon);
  padding: var(--espace);
}

.carte h2 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.resume { color: var(--texte-doux); margin: 0 0 var(--espace); }

.liste { display: grid; gap: var(--espace); }

.bloc-produit h3 { margin: 0 0 8px; font-size: 1.25rem; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--bordure);
}
.stock-epuise { color: var(--texte-doux); font-style: italic; }

.ligne-commande {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--bordure);
}

.badge-etat {
  background: var(--accent);
  color: var(--accent-texte);
  border-radius: var(--rayon-petit);
  padding: 2px 10px;
  font-size: 0.9rem;
  font-weight: 700;
}

.formulaire-promo {
  display: flex;
  flex-wrap: wrap;
  gap: var(--espace);
  align-items: end;
}

.formulaire-promo label { display: grid; gap: 6px; font-weight: 700; }

.formulaire-promo button {
  font: inherit;
  font-weight: 700;
  min-height: 48px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--rayon-petit);
  background: var(--accent);
  color: var(--accent-texte);
  cursor: pointer;
}

.resultat { font-weight: 700; min-height: 1.5em; }

.graphique {
  background: var(--fond);
  border-radius: var(--rayon-petit);
  padding: 10px;
}

.ligne-serie {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.point-serie { fill: var(--accent); }
.axe { stroke: var(--bordure); stroke-width: 2; }
.etiquette { fill: var(--texte-doux); font-size: 13px; }

.pied {
  padding: var(--espace);
  color: var(--texte-doux);
  text-align: center;
}

/* ----- Écran de connexion (ajout BCBT) — variables existantes seulement ----- */
.ecran-connexion {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--fond);
  display: grid;
  place-items: center;
  padding: var(--espace);
  overflow: auto;
}

.ecran-connexion[hidden] { display: none; }

.carte-connexion {
  background: var(--surface);
  border: 2px solid var(--bordure);
  border-radius: var(--rayon);
  padding: calc(var(--espace) * 1.5);
  width: 100%;
  max-width: 480px;
  display: grid;
  gap: var(--espace);
}

.carte-connexion h1 {
  margin: 0;
  font-size: 1.9rem;
  line-height: 1.15;
}

.carte-connexion .sous-titre { margin: 0; }

.champ-jeton { display: grid; gap: 6px; font-weight: 700; }

.champ-jeton input {
  font: inherit;
  padding: 10px 14px;
  border: 2px solid var(--bordure);
  border-radius: var(--rayon-petit);
  background: var(--surface);
  color: var(--texte);
  min-height: 48px;
}

.bouton-connexion {
  font: inherit;
  font-weight: 700;
  min-height: 48px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--rayon-petit);
  background: var(--accent);
  color: var(--accent-texte);
  cursor: pointer;
}

.bouton-demo {
  font: inherit;
  min-height: 48px;
  padding: 10px 22px;
  border: 2px solid var(--bordure);
  border-radius: var(--rayon-petit);
  background: var(--surface);
  color: var(--texte);
  cursor: pointer;
}

.erreur-connexion {
  margin: 0;
  background: var(--alerte-fond);
  color: var(--alerte-texte);
  border-radius: var(--rayon-petit);
  padding: 8px 12px;
  font-weight: 700;
}

.note-connexion { margin: 0; color: var(--texte-doux); }

.bouton-deconnexion {
  font: inherit;
  font-weight: 700;
  margin-top: var(--espace);
  min-height: 44px;
  padding: 8px 18px;
  border: 2px solid var(--bordure);
  border-radius: var(--rayon-petit);
  background: var(--surface);
  color: var(--texte);
  cursor: pointer;
}

@media (max-width: 640px) {
  body { font-size: 17px; }
  .bandeau h1 { font-size: 1.8rem; }
  main { padding: 12px; }
  /* Adaptation BCBT : le sélecteur de boutique passe en pleine largeur —
     un nom long (« BCBT — Friperie (Ben Chill Ben Tranquille) ») faisait
     déborder la page de 35 px à 390 px de large. */
  .champ-store { display: grid; }
  .champ-store select { width: 100%; }
}

/* ----- Admin unifiée : navigation par sections ----- */
.nav-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--espace);
}
.nav-sections button {
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--bordure);
  border-radius: var(--rayon-petit);
  background: var(--surface);
  color: var(--texte);
  cursor: pointer;
}
.nav-sections button[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-texte);
  border-color: var(--accent);
}

.note-boutique {
  margin: var(--espace) 0 0;
  background: var(--alerte-fond);
  color: var(--alerte-texte);
  border-radius: var(--rayon-petit);
  padding: 10px 14px;
  font-weight: 700;
}

/* ----- Grilles et cartes du tableau de bord ----- */
.grille-cartes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--espace);
  margin-bottom: var(--espace);
}
.carte-stat {
  background: var(--fond);
  border-radius: var(--rayon-petit);
  padding: 14px 16px;
}
.carte-stat .stat-nom { margin: 0; color: var(--texte-doux); font-size: 0.95rem; }
.carte-stat .stat-valeur { margin: 2px 0 0; font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.carte-stat .stat-detail { margin: 2px 0 0; color: var(--texte-doux); font-size: 0.9rem; }

/* ----- Formulaires ----- */
.formulaire {
  display: flex;
  flex-wrap: wrap;
  gap: var(--espace);
  align-items: end;
  margin-bottom: var(--espace);
}
.formulaire label { display: grid; gap: 6px; font-weight: 700; }
.formulaire input,
.formulaire select,
.champ-recherche input,
.editeur input,
.editeur select {
  font: inherit;
  padding: 10px 14px;
  border: 2px solid var(--bordure);
  border-radius: var(--rayon-petit);
  background: var(--surface);
  color: var(--texte);
  min-height: 48px;
  max-width: 100%;
}
.formulaire button,
.bouton {
  font: inherit;
  font-weight: 700;
  min-height: 48px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--rayon-petit);
  background: var(--accent);
  color: var(--accent-texte);
  cursor: pointer;
}
.bouton-secondaire {
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  padding: 8px 18px;
  border: 2px solid var(--bordure);
  border-radius: var(--rayon-petit);
  background: var(--surface);
  color: var(--texte);
  cursor: pointer;
}
button:disabled, .bouton:disabled, .bouton-secondaire:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.champ-recherche { display: grid; gap: 6px; font-weight: 700; margin-bottom: var(--espace); }

.message { font-weight: 700; min-height: 1.5em; margin: 0 0 var(--espace); }
.message-erreur { color: var(--alerte-texte); }

.etat-vide, .etat-verrouille {
  background: var(--fond);
  border-radius: var(--rayon-petit);
  padding: 14px 16px;
  color: var(--texte-doux);
  margin: 0;
}
.etat-verrouille { font-weight: 700; }

/* ----- Détails / éditeurs ----- */
details.detail { border-bottom: 1px solid var(--bordure); padding: 10px 0; }
details.detail summary { cursor: pointer; font-weight: 700; }
.editeur { display: grid; gap: 12px; margin-top: 12px; }
.editeur .rangee { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.editeur label { display: grid; gap: 6px; font-weight: 700; }
.ligne-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ----- Complétude (fiches) ----- */
.jauge {
  height: 14px;
  background: var(--fond);
  border: 2px solid var(--bordure);
  border-radius: var(--rayon-petit);
  overflow: hidden;
}
.jauge-remplissage { height: 100%; background: var(--accent); }
.liste-manquants { margin: 8px 0; color: var(--texte-doux); }
.bloc-texte {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--fond);
  border-radius: var(--rayon-petit);
  padding: 14px 16px;
  font-size: 0.92rem;
  max-height: 320px;
  overflow: auto;
}

/* ----- Divers ----- */
.petit { font-size: 0.9rem; color: var(--texte-doux); }
.en-ligne { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.badge-info {
  background: var(--fond);
  color: var(--texte);
  border: 2px solid var(--bordure);
  border-radius: var(--rayon-petit);
  padding: 2px 10px;
  font-size: 0.9rem;
  font-weight: 700;
}
.badge-alerte {
  background: var(--alerte-fond);
  color: var(--alerte-texte);
  border-radius: var(--rayon-petit);
  padding: 2px 10px;
  font-size: 0.9rem;
  font-weight: 700;
}
section.carte { display: block; }
section.carte[hidden] { display: none; }

@media (max-width: 640px) {
  .nav-sections button { flex: 1 1 40%; }
  .formulaire label, .formulaire button { width: 100%; }
  table { font-size: 0.95rem; }
  th, td { padding: 6px 6px; }
  /* Les tableaux larges (commandes, notifications, journal) défilent
     dans leur carte au lieu de faire déborder la page — mesuré :
     commandes +278 px, notifications +269 px, journal +162 px à 390 px
     avant ce correctif. */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Les <select> se dimensionnent sur leur plus longue option (titres
     de produits ~600 px) : sans min-width:0, l'étiquette flex déborde
     de la page — c'était le vrai fautif de la section Commandes. */
  .formulaire label { min-width: 0; }
  .formulaire input, .formulaire select { width: 100%; min-width: 0; }
}
