/* =============================================================
   styles.css — Interface K-Manager Pro
   Conçue pour : petit écran Android d'entrée de gamme d'abord,
   PC de comptoir ensuite. Aucune police ni image chargée depuis
   internet (§3.2 : interface légère, 100 % hors-ligne).
   ============================================================= */

:root {
  --vert: #1f5b4d;
  --vert-clair: #2e7d68;
  --vert-pale: #e8f2ef;
  --or: #d99b28;
  --rouge: #b3261e;
  --rouge-pale: #fdecea;
  --texte: #16211f;
  --texte-doux: #5d6b68;
  --bord: #dde5e2;
  --fond: #f4f7f6;
  --blanc: #ffffff;
  --rayon: 14px;
  --ombre: 0 1px 2px rgba(16, 40, 34, .06), 0 4px 14px rgba(16, 40, 34, .06);
  --nav-h: 66px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }
body.verrouille { padding-bottom: 0; overflow: hidden; }

/* ------------------ En-tête ------------------ */
.entete {
  position: sticky; top: 0; z-index: 30;
  background: var(--vert); color: #fff;
  padding: 12px 16px calc(12px + env(safe-area-inset-top, 0px));
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.entete h1 { font-size: 1.05rem; margin: 0; font-weight: 650; flex: 1; }
.entete .sous { font-size: .74rem; opacity: .85; font-weight: 400; display: block; }
.entete button {
  background: rgba(255, 255, 255, .16); color: #fff; border: 0;
  border-radius: 10px; padding: 8px 12px; font-size: .85rem; cursor: pointer;
}
.badge-hors-ligne {
  font-size: .68rem; background: rgba(255, 255, 255, .18);
  padding: 3px 8px; border-radius: 20px; white-space: nowrap;
}
.badge-hors-ligne.actif { background: var(--or); color: #241a05; font-weight: 600; }

/* ------------------ Contenu ------------------ */
main { padding: 14px 14px 24px; max-width: 900px; margin: 0 auto; }
h2.titre-ecran { font-size: 1.15rem; margin: 4px 0 14px; }
h3 { font-size: .95rem; margin: 20px 0 8px; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .04em; }

.carte {
  background: var(--blanc); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 14px; margin-bottom: 12px;
}
.carte.compacte { padding: 10px 12px; }
.carte-titre { font-weight: 650; font-size: .95rem; margin-bottom: 8px; }

/* ------------------ Chiffres clés ------------------ */
.grille-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--blanc); border-radius: var(--rayon); padding: 12px 14px; box-shadow: var(--ombre); }
.stat .libelle { font-size: .72rem; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .04em; }
.stat .valeur { font-size: 1.32rem; font-weight: 700; margin-top: 2px; color: var(--vert); word-break: break-word; }
.stat .detail { font-size: .76rem; color: var(--texte-doux); }
.stat.pleine { grid-column: 1 / -1; }

/* ------------------ Boutons ------------------ */
button, .bouton {
  font-family: inherit; font-size: 1rem; cursor: pointer;
  border-radius: 12px; border: 1px solid transparent; padding: 12px 16px;
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; text-decoration: none;
}
.bouton-principal { background: var(--vert); color: #fff; width: 100%; font-weight: 600; }
.bouton-principal:active { background: var(--vert-clair); }
.bouton-secondaire { background: var(--blanc); color: var(--vert); border-color: var(--bord); }
.bouton-danger { background: var(--rouge-pale); color: var(--rouge); border-color: #f3c9c5; }
.bouton-petit { min-height: 38px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.rangee-boutons { display: flex; gap: 8px; flex-wrap: wrap; }
.rangee-boutons > * { flex: 1; min-width: 130px; }

/* ------------------ Formulaires ------------------ */
label { display: block; font-size: .82rem; color: var(--texte-doux); margin: 10px 0 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; font-family: inherit; font-size: 1rem; padding: 12px;
  border: 1px solid var(--bord); border-radius: 12px; background: var(--blanc);
  color: var(--texte); min-height: 48px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--vert-clair); outline-offset: -1px; }
.champs-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.aide { font-size: .76rem; color: var(--texte-doux); margin-top: 4px; }
.erreur-champ { color: var(--rouge); font-size: .8rem; margin-top: 6px; white-space: pre-line; }

.segments { display: flex; background: var(--vert-pale); border-radius: 12px; padding: 4px; gap: 4px; }
.segments button {
  flex: 1; min-height: 40px; background: transparent; border: 0; border-radius: 9px;
  font-size: .9rem; color: var(--vert); font-weight: 600; padding: 6px;
}
.segments button.actif { background: var(--blanc); box-shadow: var(--ombre); }

/* ------------------ Listes ------------------ */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li {
  background: var(--blanc); border-radius: var(--rayon); padding: 12px 14px;
  margin-bottom: 8px; box-shadow: var(--ombre); display: flex; align-items: center; gap: 12px;
}
.liste li .principal { flex: 1; min-width: 0; }
.liste li .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste li .meta { font-size: .78rem; color: var(--texte-doux); }
.liste li .droite { text-align: right; white-space: nowrap; }
.liste li.cliquable { cursor: pointer; }
.liste li.cliquable:active { background: var(--vert-pale); }

.puce { display: inline-block; font-size: .7rem; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.puce-alerte { background: #fdf1dd; color: #8a5a06; }
.puce-rupture { background: var(--rouge-pale); color: var(--rouge); }
.puce-ok { background: var(--vert-pale); color: var(--vert); }
.puce-annulee { background: var(--rouge-pale); color: var(--rouge); }

.vide { text-align: center; color: var(--texte-doux); padding: 34px 16px; font-size: .92rem; }
.vide .grand { font-size: 2rem; display: block; margin-bottom: 6px; }

/* ------------------ Barre de navigation ------------------ */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--blanc); border-top: 1px solid var(--bord);
  display: flex; padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav button {
  flex: 1; background: none; border: 0; padding: 8px 2px; min-height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: .68rem; color: var(--texte-doux); border-radius: 0;
}
.nav button .ico { font-size: 1.28rem; line-height: 1; }
.nav button.actif { color: var(--vert); font-weight: 650; }
.nav button.centrale .ico {
  background: var(--vert); color: #fff; width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin-top: -14px;
  box-shadow: 0 4px 12px rgba(31, 91, 77, .35); font-size: 1.5rem;
}

/* ------------------ Fenêtres modales ------------------ */
.voile {
  position: fixed; inset: 0; background: rgba(12, 24, 21, .5); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.modale {
  background: var(--blanc); border-radius: 20px 20px 0 0; width: 100%; max-width: 620px;
  max-height: 92vh; overflow-y: auto; padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: monter .18s ease-out;
}
@keyframes monter { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modale h3 { margin: 0 0 12px; font-size: 1.05rem; color: var(--texte); text-transform: none; letter-spacing: 0; }
.modale .poignee { width: 42px; height: 4px; background: var(--bord); border-radius: 4px; margin: 0 auto 12px; }

/* ------------------ Messages ------------------ */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px); z-index: 80;
  background: #16211f; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: .9rem; max-width: 90vw; text-align: center; box-shadow: var(--ombre);
}
.toast.erreur { background: var(--rouge); }
.toast.attention { background: #8a5a06; }
.toast.succes { background: var(--vert); }

/* ------------------ Écran de verrouillage ------------------ */
.verrou {
  position: fixed; inset: 0; z-index: 100; background: var(--vert);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; padding: 24px;
}
.verrou .logo { font-size: 2.6rem; margin-bottom: 6px; }
.verrou h1 { font-size: 1.3rem; margin: 0 0 4px; }
.verrou p { opacity: .85; margin: 0 0 22px; font-size: .9rem; }
.verrou .points { display: flex; gap: 12px; margin-bottom: 22px; }
.verrou .point { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); }
.verrou .point.plein { background: #fff; }
.clavier { display: grid; grid-template-columns: repeat(3, 74px); gap: 12px; }
.clavier button {
  height: 66px; border-radius: 50%; background: rgba(255,255,255,.14);
  color: #fff; border: 0; font-size: 1.5rem; font-weight: 500;
}
.clavier button:active { background: rgba(255,255,255,.3); }
.clavier button.vide { background: none; }
.verrou .msg { min-height: 22px; margin-top: 16px; font-size: .88rem; color: #ffd7d3; }

/* ------------------ Écran d'activation de licence ------------------ */
.verrou.activation { justify-content: flex-start; overflow-y: auto; padding: 0; }
.activation-boite {
  width: 100%; max-width: 460px; margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top, 0px)) 22px calc(32px + env(safe-area-inset-bottom, 0px));
  text-align: left;
}
.activation-boite .logo { font-size: 2.4rem; text-align: center; }
.activation-boite h1 { font-size: 1.28rem; margin: 6px 0 8px; text-align: center; }
.activation-boite > .logo + h1 { margin-top: 4px; }
.activation-boite p { opacity: .88; font-size: .92rem; margin: 0 0 20px; text-align: center; }
.activation-boite label {
  color: #cfe6df; font-size: .8rem; margin: 14px 0 5px; display: block; font-weight: 600;
}
.activation-boite input[type="text"], .activation-boite textarea {
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .3);
  color: #fff; border-radius: 12px; width: 100%; font-size: 1rem; padding: 13px;
}
.activation-boite input::placeholder, .activation-boite textarea::placeholder { color: rgba(255,255,255,.5); }
.activation-boite input:focus, .activation-boite textarea:focus {
  outline: 2px solid var(--or); outline-offset: 1px;
}
.activation-boite #cle-licence {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .06em; text-transform: uppercase; font-size: 1.02rem;
}
.activation-boite .bouton-principal { background: var(--or); color: #241a05; margin-top: 18px; }
.activation-boite .bouton-secondaire { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.28); }
.activation-boite .msg { min-height: 22px; margin-top: 12px; font-size: .88rem; color: #ffd7d3; text-align: center; }
.activation-boite .msg.attente { color: #cfe6df; }
.activation-boite .rangee-boutons { margin-top: 12px; }

.tarif-activation {
  background: rgba(0, 0, 0, .2); border-radius: 14px; padding: 14px;
  text-align: center; margin: 0 0 8px;
}
.insecable { white-space: nowrap; }
.tarif-montant { display: block; font-size: 1.5rem; font-weight: 800; color: var(--or); }
.tarif-detail { display: block; font-size: .8rem; color: #cfe6df; margin-top: 2px; }

.repli { margin-top: 26px; border-top: 1px solid rgba(255,255,255,.18); padding-top: 14px; }
.repli summary { cursor: pointer; font-size: .9rem; color: #cfe6df; padding: 6px 0; }
.repli-texte { text-align: left !important; font-size: .86rem; margin: 8px 0 14px !important; }
.code-appareil {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0, 0, 0, .22); border-radius: 12px; padding: 12px 14px;
}
.code-appareil span {
  flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.02rem; letter-spacing: .05em; word-break: break-all;
}
.aide-sombre { font-size: .78rem; color: #a9ccc2; margin-top: 6px; }
.pied-activation {
  margin-top: 26px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.18);
  font-size: .84rem; color: #a9ccc2; text-align: center; line-height: 1.6;
}
.badge-essai {
  font-size: .68rem; background: var(--or); color: #241a05;
  padding: 3px 9px; border-radius: 20px; font-weight: 700; white-space: nowrap;
}
.badge-essai.badge-urgent { background: #ffdad6; color: var(--rouge); }
a.bouton { text-decoration: none; }
a.bouton-principal { background: var(--vert); color: #fff; }

/* ------------------ Facture en cours ------------------ */
.ligne-panier { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--bord); }
.ligne-panier:last-child { border-bottom: 0; }
.ligne-panier .info { flex: 1; min-width: 0; }
.ligne-panier .nom { font-weight: 600; font-size: .95rem; }
.ligne-panier .pu { font-size: .78rem; color: var(--texte-doux); }
.compteur { display: flex; align-items: center; gap: 6px; }
.compteur button { width: 36px; min-height: 36px; padding: 0; border-radius: 9px; background: var(--vert-pale); color: var(--vert); font-size: 1.2rem; font-weight: 700; }
.compteur input { width: 52px; text-align: center; padding: 6px; min-height: 36px; }
.total-ligne { display: flex; justify-content: space-between; padding: 5px 0; font-size: .95rem; }
.total-ligne.grand { font-size: 1.22rem; font-weight: 700; color: var(--vert); border-top: 2px solid var(--vert-pale); margin-top: 8px; padding-top: 10px; }
.total-ligne .conv { font-size: .8rem; color: var(--texte-doux); font-weight: 400; }

.barre-validation {
  position: sticky; z-index: 20;
  bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom, 0px));
  background: var(--fond); padding: 10px 0 6px; margin-top: 10px;
}
.barre-validation::before {
  content: ''; position: absolute; left: -14px; right: -14px; top: -14px; bottom: 0;
  background: linear-gradient(to bottom, rgba(244,247,246,0), var(--fond) 45%);
  z-index: -1; pointer-events: none;
}

.resultats-recherche { max-height: 46vh; overflow-y: auto; }

/* Avertissement « stock dépassé » : jamais bloquant, toujours visible */
.alerte-stock { font-size: .76rem; color: #8a5a06; font-weight: 600; margin-top: 2px; }
.bandeau-alerte {
  background: #fdf1dd; color: #6d4708; border: 1px solid #f0d9a8;
  box-shadow: none; font-size: .86rem; line-height: 1.4;
}
.bandeau-alerte b { color: #5a3a06; }

/* ------------------ Détail facture ------------------ */
.tableau { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tableau th { text-align: left; font-size: .72rem; text-transform: uppercase; color: var(--texte-doux); padding: 6px 4px; border-bottom: 1px solid var(--bord); }
.tableau td { padding: 8px 4px; border-bottom: 1px solid var(--bord); }
.tableau td.num, .tableau th.num { text-align: right; white-space: nowrap; }

/* ------------------ Grand écran (PC de comptoir) ------------------ */
@media (min-width: 780px) {
  body { padding-bottom: 0; padding-left: 210px; }
  main { padding: 22px; }
  .nav {
    top: 0; bottom: 0; right: auto; width: 210px; flex-direction: column;
    border-top: 0; border-right: 1px solid var(--bord); padding-top: 76px; justify-content: flex-start;
  }
  .nav button { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 14px 20px; font-size: .95rem; min-height: 54px; }
  .nav button .ico { font-size: 1.2rem; }
  .nav button.centrale .ico { width: 34px; height: 34px; margin-top: 0; font-size: 1.2rem; }
  .nav button.actif { background: var(--vert-pale); }
  .entete { padding-left: 226px; }
  .grille-stats { grid-template-columns: repeat(4, 1fr); }
  .barre-validation { bottom: 10px; }
  .voile { align-items: center; }
  .modale { border-radius: 20px; }
  .toast { bottom: 24px; }
}

@media print {
  .nav, .entete, .barre-validation, .rangee-boutons { display: none !important; }
  body { padding: 0; background: #fff; }
}
