/* =====================================================================
   MAIN A MAIN — Style
   Pensé pour un téléphone d'entrée de gamme, au guichet, en plein jour :
   gros contrastes, grandes zones à toucher, une seule couleur vive
   (le jaune de l'étiquette) réservée à la marque et à l'action principale.
   ===================================================================== */

:root {
  --encre: #1B2430;
  --encre-douce: #4F5B6A;
  --fond: #EEF1EC;
  --papier: #FFFFFF;
  --trait: #CDD5CC;
  --etiquette: #F2C230;
  --etiquette-fonce: #D9A814;
  --scelle: #0E7C5A;
  --alerte: #C8322B;
  --alerte-fond: #FBEAE8;

  --police: "Archivo", "Arial Narrow", Arial, sans-serif;
  --rayon: 10px;
  --toucher: 52px;
  --marge: clamp(16px, 4vw, 24px);

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--fond);
  color: var(--encre);
  font-family: var(--police);
  font-size: 17px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

h1, h2, h3 { margin: 0; line-height: 1.15; font-stretch: 85%; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }

:focus-visible { outline: 3px solid var(--encre); outline-offset: 2px; }

[hidden] { display: none !important; }

/* ---------- Marque : l'étiquette ----------------------------------- */

.etiquette {
  --h: 64px;
  position: relative;
  display: inline-flex;
  align-items: center;
  height: var(--h);
  padding: 0 22px 0 calc(var(--h) * 0.62);
  background: var(--etiquette);
  color: var(--encre);
  font-weight: 800;
  font-stretch: 70%;
  font-size: calc(var(--h) * 0.48);
  letter-spacing: 0.01em;
  white-space: nowrap;
  clip-path: polygon(calc(var(--h) * 0.32) 0, 100% 0, 100% 100%, calc(var(--h) * 0.32) 100%, 0 50%);
  border-radius: 0 6px 6px 0;
}
.etiquette::before {
  content: "";
  position: absolute;
  left: calc(var(--h) * 0.24);
  top: 50%;
  width: calc(var(--h) * 0.16);
  height: calc(var(--h) * 0.16);
  margin-top: calc(var(--h) * -0.08);
  border-radius: 50%;
  background: var(--fond);
}
.etiquette--petite { --h: 34px; padding-right: 12px; }
.entete .etiquette::before { background: var(--encre); }

/* ---------- En-tête ------------------------------------------------- */

.entete {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--marge) 10px;
  background: var(--encre);
  color: var(--papier);
}
.entete__lieu { flex: 1; min-width: 0; font-size: 0.85rem; line-height: 1.25; }
.entete__lieu strong { display: block; font-size: 0.95rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entete__lieu span { color: #B8C2CE; }
.entete button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #4F5B6A;
  border-radius: var(--rayon);
  background: transparent;
  color: var(--papier);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ---------- Mise en page -------------------------------------------- */

.vue {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px var(--marge) 48px;
  outline: none;
}
.pile > * + * { margin-top: 16px; }
.pile-serree > * + * { margin-top: 8px; }

.retour {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--encre-douce);
  font-weight: 600;
  text-decoration: none;
}

.doux { color: var(--encre-douce); }

/* ---------- Connexion ------------------------------------------------ */

.connexion {
  min-height: calc(100dvh - 68px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 32px;
}
.connexion__marque { display: grid; gap: 14px; }
.connexion__marque .etiquette { --h: 76px; justify-self: start; }
.connexion__marque p { max-width: 30ch; font-size: 1.1rem; color: var(--encre-douce); }

/* ---------- Formulaires ---------------------------------------------- */

.champ { display: grid; gap: 6px; }
.champ label { font-weight: 650; font-size: 0.95rem; }
.champ small { color: var(--encre-douce); font-size: 0.85rem; }

input, select, textarea {
  width: 100%;
  min-height: var(--toucher);
  padding: 0 14px;
  border: 1.5px solid var(--trait);
  border-radius: var(--rayon);
  background: var(--papier);
  color: var(--encre);
  font: inherit;
}
input:focus, select:focus { border-color: var(--encre); outline: none; box-shadow: 0 0 0 3px rgb(27 36 48 / 0.15); }
input[aria-invalid="true"] { border-color: var(--alerte); }

.code-pin { letter-spacing: 0.4em; font-size: 1.3rem; font-weight: 700; }

.rangee { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .rangee { grid-template-columns: 1fr; } }

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--toucher);
  padding: 0 18px;
  border: 0;
  border-radius: var(--rayon);
  background: var(--etiquette);
  color: var(--encre);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
.bouton:hover { background: var(--etiquette-fonce); }
.bouton:disabled { opacity: 0.55; cursor: wait; }
.bouton--sobre { background: var(--papier); border: 1.5px solid var(--trait); font-weight: 650; }
.bouton--sobre:hover { background: var(--fond); }
.bouton--lien { width: auto; min-height: 40px; padding: 0 8px; background: none; color: var(--encre-douce); font-weight: 600; text-decoration: underline; }
.bouton--lien:hover { background: none; color: var(--encre); }

.erreur {
  padding: 12px 14px;
  border-left: 4px solid var(--alerte);
  border-radius: 0 var(--rayon) var(--rayon) 0;
  background: var(--alerte-fond);
  color: #7A1B16;
  font-weight: 600;
}

/* ---------- Accueil : actions du rôle -------------------------------- */

.bonjour p { color: var(--encre-douce); margin-top: 4px; }

.actions { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--trait); }
.actions li { border-bottom: 1.5px solid var(--trait); }
.action {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  min-height: 76px;
  padding: 14px 4px;
  color: inherit;
  text-decoration: none;
}
.action strong { font-size: 1.1rem; font-weight: 700; }
.action span { grid-column: 1; color: var(--encre-douce); font-size: 0.92rem; }
.action::after { content: "›"; grid-row: 1 / span 2; grid-column: 2; font-size: 1.8rem; line-height: 1; color: var(--encre-douce); }
a.action:hover strong { text-decoration: underline; }
.action--bientot { opacity: 0.6; }
.action--bientot::after { content: none; }
.pastille {
  grid-row: 1 / span 2;
  grid-column: 2;
  padding: 3px 8px;
  border: 1.5px solid var(--trait);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--encre-douce);
  white-space: nowrap;
}

/* ---------- Listes (agences, équipe) --------------------------------- */

.liste { list-style: none; margin: 0; padding: 0; background: var(--papier); border: 1.5px solid var(--trait); border-radius: var(--rayon); }
.liste li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--trait); }
.liste li:first-child { border-top: 0; }
.liste__texte { flex: 1; min-width: 0; }
.liste__texte strong { display: block; font-weight: 700; }
.liste__texte span { display: block; color: var(--encre-douce); font-size: 0.9rem; }
.liste__inactif { opacity: 0.5; }
.liste__vide { padding: 20px 14px; color: var(--encre-douce); }

.code-agence {
  flex: none;
  min-width: 52px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--encre);
  color: var(--etiquette);
  font-weight: 800;
  font-stretch: 75%;
  text-align: center;
  letter-spacing: 0.05em;
}

.role { flex: none; font-size: 0.8rem; font-weight: 650; padding: 3px 8px; border-radius: 999px; background: var(--fond); }

details.ajout { background: var(--papier); border: 1.5px solid var(--trait); border-radius: var(--rayon); }
details.ajout summary { min-height: var(--toucher); display: flex; align-items: center; padding: 0 14px; font-weight: 700; cursor: pointer; list-style: none; }
details.ajout summary::before { content: "+"; width: 1.4em; font-size: 1.3rem; }
details.ajout[open] summary::before { content: "−"; }
details.ajout form { padding: 4px 14px 16px; }

/* PIN affiché une seule fois après création */
.pin-cree {
  padding: 16px;
  border: 2px dashed var(--scelle);
  border-radius: var(--rayon);
  background: #E6F3EE;
}
.pin-cree strong { display: block; font-size: 2rem; letter-spacing: 0.3em; font-weight: 800; color: var(--scelle); }

/* ---------- Messages éphémères --------------------------------------- */

.messages { position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; justify-items: center; gap: 8px; pointer-events: none; z-index: 20; padding: 0 16px; }
.message {
  max-width: 560px;
  padding: 12px 16px;
  border-radius: var(--rayon);
  background: var(--encre);
  color: var(--papier);
  font-weight: 600;
  box-shadow: 0 6px 20px rgb(27 36 48 / 0.25);
}
.message--erreur { background: var(--alerte); }
.message--ok { background: var(--scelle); }

@media (prefers-reduced-motion: no-preference) {
  .message { animation: monter 180ms ease-out; }
  @keyframes monter { from { transform: translateY(8px); opacity: 0; } }
}

/* =====================================================================
   Étape 2 — Guichet
   ===================================================================== */

fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: 12px; }
legend {
  width: 100%;
  margin-bottom: 4px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--encre);
  font-size: 1.1rem;
  font-weight: 800;
  font-stretch: 85%;
}
.formulaire-colis > * + * { margin-top: 28px; }

.photo { display: grid; gap: 10px; }
.photo__bouton { position: relative; min-height: 64px; border-style: dashed; }
.photo__fichier { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo__apercu { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--rayon); border: 1.5px solid var(--trait); }

.bouton--whatsapp { background: var(--scelle); color: var(--papier); text-decoration: none; text-align: center; }
.bouton--whatsapp:hover { background: #0B6549; }
a.bouton { text-decoration: none; }

.confirmation {
  padding: 22px 18px;
  border-radius: var(--rayon);
  background: var(--encre);
  color: var(--papier);
  text-align: center;
}
.confirmation .doux { color: #B8C2CE; }
.confirmation__code {
  margin: 6px 0;
  color: var(--etiquette);
  font-size: clamp(1.6rem, 8vw, 2.2rem);
  font-weight: 800;
  font-stretch: 75%;
  letter-spacing: 0.04em;
}

.resume { display: flex; flex-wrap: wrap; gap: 10px; }
.resume > div { flex: 1 1 140px; padding: 12px 14px; border-radius: var(--rayon); background: var(--papier); border: 1.5px solid var(--trait); }
.resume strong { display: block; font-size: 1.3rem; font-weight: 800; font-stretch: 85%; }
.resume span { color: var(--encre-douce); font-size: 0.9rem; }

/* =====================================================================
   Suivi public
   ===================================================================== */

.suivi { padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
.suivi__code { font-stretch: 75%; letter-spacing: 0.03em; overflow-wrap: anywhere; }
.suivi__trajet { font-size: 1.2rem; font-weight: 700; }

.frise { list-style: none; margin: 0; padding: 0; }
.frise li {
  position: relative;
  padding: 0 0 18px 34px;
  color: var(--encre-douce);
}
.frise li::before {
  content: "";
  position: absolute;
  left: 6px; top: 5px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--trait);
  background: var(--fond);
}
.frise li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13px; top: 22px; bottom: 0;
  width: 2px;
  background: var(--trait);
}
.frise li.fait { color: var(--encre); }
.frise li.fait::before { border-color: var(--scelle); background: var(--scelle); }
.frise li.fait::after { background: var(--scelle); }
.frise li.actuel { color: var(--encre); font-weight: 800; }
.frise li.actuel::before { width: 20px; height: 20px; left: 3px; top: 2px; border: 4px solid var(--etiquette); background: var(--encre); }

.historique { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--trait); }
.historique li { display: grid; padding: 10px 0; border-bottom: 1.5px solid var(--trait); }
.historique span { color: var(--encre-douce); font-size: 0.9rem; }

.carte-agence { padding: 14px; border-radius: var(--rayon); background: var(--papier); border: 1.5px solid var(--trait); }
.carte-agence a { color: var(--encre); font-weight: 700; font-size: 1.1rem; }

/* =====================================================================
   Impression 58 mm : étiquettes et reçu
   ===================================================================== */

#impression { display: none; }

@media print {
  @page { size: 58mm auto; margin: 2mm; }
  body { background: #fff; min-height: 0; padding: 0; }
  body > *:not(#impression) { display: none !important; }
  #impression { display: block; }

  .ticket {
    width: 54mm;
    color: #000;
    font-family: Arial, sans-serif;
    font-size: 9pt;
    line-height: 1.3;
    text-align: center;
    break-after: page;
    page-break-after: always;
  }
  .ticket:last-child { break-after: auto; page-break-after: auto; }
  .ticket p { margin: 0 0 1.5mm; }
  .ticket .qr { width: 34mm; margin: 0 auto 2mm; }
  .ticket .qr svg { display: block; width: 100%; height: auto; }
  .ticket__code { font-size: 13pt; font-weight: 800; letter-spacing: 0.5pt; }
  .ticket__trajet { font-size: 15pt; font-weight: 800; text-transform: uppercase; }
  .ticket__pied { display: flex; justify-content: space-between; font-size: 7.5pt; border-top: 0.3mm solid #000; padding-top: 1mm; }
  .ticket__entete { font-size: 11pt; font-weight: 800; }
  .ticket--recu dl { display: grid; grid-template-columns: auto 1fr; gap: 0.6mm 2mm; margin: 2mm 0; text-align: left; }
  .ticket--recu dt { font-weight: 700; }
  .ticket--recu dd { margin: 0; overflow-wrap: anywhere; }
  .ticket__montant { font-weight: 800; }
  .ticket__pied-texte { font-size: 7.5pt; }
}
