/* ============================================================
   Suivi Nacelle — mobile-first.
   Palette : bleu nuit (marque) + orange chantier (action/route).
   ============================================================ */

:root {
  --bleu:        #0F2740;
  --bleu-clair:  #1E4067;
  --orange:      #E8710A;
  --orange-fonce:#C75F05;
  --fond:        #F3F5F8;
  --carte:       #FFFFFF;
  --texte:       #17222E;
  --texte-doux:  #64748B;
  --bord:        #DCE3EC;
  --vert:        #15803D;
  --vert-fond:   #DCFCE7;
  --rouge:       #B91C1C;
  --rouge-fond:  #FEE2E2;
  --info-fond:   #E0ECFB;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
.centre { text-align: center; }
.note { color: var(--texte-doux); font-size: 13px; }
.optionnel { color: var(--texte-doux); font-weight: 400; font-size: 12px; }

/* ---------- entete ---------- */

.entete {
  background: var(--bleu);
  color: #fff;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1100;
}

.entete-titre { font-weight: 700; font-size: 17px; }
.entete-droite { display: flex; align-items: center; gap: 10px; font-size: 13px; }

.conteneur {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 12px calc(30px + env(safe-area-inset-bottom));
}

/* ---------- connexion ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--bleu) 0%, var(--bleu-clair) 100%);
  padding: 20px;
}

.login-card {
  background: var(--carte);
  border-radius: 16px;
  padding: 30px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.login-logo { text-align: center; margin-bottom: 24px; }
.brand { font-size: 24px; font-weight: 800; color: var(--bleu); }
.tagline { font-size: 13px; color: var(--texte-doux); margin-top: 4px; }
.login-note { text-align: center; margin-top: 22px; font-size: 12px; color: var(--texte-doux); line-height: 1.6; }

/* ---------- formulaires ---------- */

.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--bleu);
}

input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--bord);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--texte);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232, 113, 10, .15);
}

/* ---------- boutons ---------- */

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter .15s;
}
.btn:active { filter: brightness(.9); }
.btn:disabled { opacity: .55; cursor: wait; }

.btn-primary   { background: var(--orange); color: #fff; }
.btn-secondaire{ background: var(--bleu);   color: #fff; }
.btn-danger    { background: var(--rouge);  color: #fff; }
.btn-bloc      { display: block; width: 100%; }
.btn-petit     { padding: 8px 12px; font-size: 13px; border-radius: 8px; }

.btn-lien {
  background: none;
  color: inherit;
  text-decoration: underline;
  padding: 4px;
  font-size: 13px;
  font-weight: 400;
}

/* ---------- messages ---------- */

.msg {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 14px;
}
.msg-erreur { background: var(--rouge-fond); color: var(--rouge); }
.msg-ok     { background: var(--vert-fond);  color: var(--vert); }
.msg-info   { background: var(--info-fond);  color: var(--bleu-clair); }

/* ---------- blocs ---------- */

.carte-bloc {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.titre-bloc { font-weight: 700; color: var(--bleu); margin-bottom: 10px; font-size: 15px; }

details.carte-bloc summary { cursor: pointer; margin-bottom: 0; }
details.carte-bloc[open] summary { margin-bottom: 10px; }
.sous-details { margin: 10px 0; }
.sous-details summary { font-size: 13px; color: var(--texte-doux); cursor: pointer; margin-bottom: 8px; }

/* ---------- tournee (nacelliste) ---------- */

.entete-tournee {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tournee-date { font-weight: 700; text-transform: capitalize; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--bord);
  color: var(--texte-doux);
  margin-top: 4px;
}
.badge-preparee { background: var(--info-fond); color: var(--bleu-clair); }
.badge-en_cours { background: #FEF3C7; color: #92400E; }
.badge-terminee { background: var(--vert-fond); color: var(--vert); }
.badge-inactif  { background: var(--rouge-fond); color: var(--rouge); font-size: 11px; }

.suivi-actif {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--vert);
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: right;
}

.point-vert {
  width: 9px; height: 9px;
  background: var(--vert);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(21, 128, 61, .5); }
  70%  { box-shadow: 0 0 0 8px rgba(21, 128, 61, 0); }
  100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); }
}

.actions-tournee {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

/* ---------- modale « Partager ta position » ---------- */
/* Affichee AVANT la demande GPS du navigateur, pour expliquer la
   popup systeme qui va suivre. */

.voile {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 39, 64, .58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modale {
  background: var(--carte);
  border-radius: 18px;
  padding: 22px 20px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.modale-emoji { font-size: 44px; }
.modale-titre { margin: 6px 0 8px; font-size: 20px; color: var(--bleu); }
.modale-texte { font-size: 14.5px; margin: 0 0 14px; }

/* Petite maquette de la popup systeme, pour que le nacelliste la
   reconnaisse quand elle apparait. */
.faux-popup {
  border: 1.5px solid var(--bord);
  border-radius: 12px;
  background: var(--fond);
  padding: 10px 12px;
  font-size: 13px;
  text-align: left;
}

.faux-popup-boutons {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 8px;
  font-weight: 700;
  color: var(--texte-doux);
}
.faux-popup-ok { color: var(--vert); }

.modale-consigne { font-size: 13px; color: var(--texte-doux); margin: 8px 0 16px; }

.modale .btn-lien { margin-top: 8px; color: var(--texte-doux); }

/* ---------- bandeau « tu es visible » (partage actif) ---------- */

.bandeau-visible {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1500;
  background: var(--vert);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .25);
}

.bandeau-textes { min-width: 0; }
.bandeau-titre { font-weight: 800; font-size: 14px; line-height: 1.3; }
.bandeau-sous { font-size: 12px; opacity: .92; }

.bandeau-visible .btn {
  flex-shrink: 0;
  white-space: nowrap;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, .55);
}

/* Le bandeau ne doit rien cacher en bas de page. */
body.bandeau-actif .conteneur {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* ---------- carte Leaflet ---------- */

.carte-leaflet {
  height: 300px;
  border-radius: 14px;
  border: 1px solid var(--bord);
  margin-bottom: 12px;
  z-index: 1;
}
.carte-haute { height: 380px; }

.marqueur {
  width: 30px; height: 30px;
  background: var(--orange);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
.marqueur-fait { background: var(--vert); }
.marqueur-encours { animation: pulse-orange 1.6s infinite; }
.marqueur-maison { background: var(--bleu); font-size: 15px; }

.marqueur-moi {
  width: 34px; height: 34px;
  background: #fff;
  border: 3px solid var(--orange);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
}

/* ---------- liste des interventions ---------- */

.intervention-entete {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pastille {
  flex-shrink: 0;
  width: 30px; height: 30px;
  background: var(--orange);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.pastille-faite { background: var(--vert); }
.pastille-encours { background: var(--orange); animation: pulse-orange 1.6s infinite; }
.pastille-petite { width: 22px; height: 22px; font-size: 12px; }

@keyframes pulse-orange {
  0%   { box-shadow: 0 0 0 0 rgba(232, 113, 10, .5); }
  70%  { box-shadow: 0 0 0 8px rgba(232, 113, 10, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 113, 10, 0); }
}

.intervention-infos { flex: 1; min-width: 0; }
.intervention-nom { font-weight: 700; }
.intervention-adresse { font-size: 13px; color: var(--texte-doux); overflow-wrap: anywhere; }
.intervention-eta { font-size: 13px; font-weight: 700; color: var(--orange-fonce); white-space: nowrap; }

.intervention-faite { opacity: .72; }
.intervention-encours { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange); }

/* Reordonnancement manuel (fleches + glisser-deposer) */

.note-reordonner { margin: 0 2px 10px; }

.reordonner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.btn-fleche {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 1.5px solid var(--bord);
  border-radius: 8px;
  background: var(--carte);
  color: var(--bleu);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.btn-fleche:active { background: var(--fond); }
.btn-fleche:disabled { opacity: .3; cursor: default; }

.intervention[draggable="true"] { cursor: grab; }
.intervention.en-deplacement {
  opacity: .45;
  border-style: dashed;
  border-color: var(--orange);
}

.intervention-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

/* ---------- admin ---------- */

.onglets {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.onglet {
  border: 1.5px solid var(--bord);
  background: var(--carte);
  color: var(--texte-doux);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.onglet.actif { background: var(--bleu); border-color: var(--bleu); color: #fff; }

.admin-itv {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0 0;
  font-size: 13px;
}
.admin-itv-adresse { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ============================================================
   Page client — carte plein ecran + bandeau bas (bottom sheet),
   facon appli de livraison. Mobile-first, gros textes.
   ============================================================ */

.gros-emoji { font-size: 52px; margin: 8px 0; }

.page-client { background: var(--bleu); }

/* Ecrans centres (chargement, lien invalide, termine) */

.ecran-centre {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--bleu) 0%, var(--bleu-clair) 100%);
}

.ecran-carte {
  background: var(--carte);
  border-radius: 20px;
  padding: 30px 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.bloc-telephone { margin-top: 16px; font-weight: 600; }
.bloc-telephone .btn { margin-top: 10px; font-size: 17px; text-decoration: none; }

/* Carte plein ecran */

#carte-client {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.barre-haut {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  background: rgba(15, 39, 64, .92);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}

/* Camion anime */

.marqueur-camion {
  width: 38px; height: 38px;
  background: #fff;
  border: 3px solid var(--orange);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .4);
}

/* Bandeau bas */

.feuille {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  margin: 0 auto;
  max-width: 560px;
  background: var(--carte);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 34px rgba(0, 0, 0, .22);
}

.feuille-poignee {
  width: 42px; height: 4px;
  border-radius: 999px;
  background: var(--bord);
  margin: 4px auto 10px;
}

.feuille-statut {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.statut-icone {
  flex-shrink: 0;
  width: 46px; height: 46px;
  background: var(--fond);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.statut-titre { font-weight: 800; font-size: 17px; line-height: 1.25; }
.statut-sous { font-size: 13.5px; color: var(--texte-doux); margin-top: 2px; }

.barre-progression {
  height: 6px;
  background: var(--bord);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progression-remplie {
  height: 100%;
  width: 4%;
  background: linear-gradient(90deg, var(--orange), var(--orange-fonce));
  border-radius: 999px;
  transition: width .8s ease;
}

.feuille-eta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: var(--fond);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.eta-libelle { font-size: 13px; color: var(--texte-doux); font-weight: 600; }
.eta-heure { font-size: 24px; font-weight: 800; color: var(--orange-fonce); }

.bloc-retard {
  background: #FEF3C7;
  border: 1px solid #FDE68A;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
  color: #92400E;
  font-weight: 600;
  font-size: 14px;
}
.bloc-retard a { color: #92400E; font-weight: 800; }

.feuille-boutons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-clair {
  background: var(--fond);
  color: var(--bleu);
  border: 1.5px solid var(--bord);
}

.panneau-feuille {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--bord);
}

.contact-ligne {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-weight: 600;
}
.contact-ligne .btn { text-decoration: none; white-space: nowrap; }

/* ---------- ecran un peu plus large ---------- */

@media (min-width: 560px) {
  .carte-leaflet { height: 380px; }
  .carte-haute { height: 480px; }
}
