/* Colle — carte collaborative de l'affichage libre.
   Conçu pour le terrain : gros boutons, contrastes élevés, priorité au mobile. */

:root {
  --fond: #f6f5f2;
  --carte: #ffffff;
  --encre: #1c1b19;
  --encre-douce: #5f5a52;
  --trait: #ded9d0;
  --accent: #1f6feb;
  --accent-fonce: #14538f;
  --recent: #1a9d5a;
  --moyen: #d98a00;
  --vieux: #8d8880;
  --danger: #b4232a;
  --rayon: 10px;
  --ombre: 0 2px 10px rgba(28, 27, 25, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--encre);
  background: var(--fond);
  -webkit-text-size-adjust: 100%;
}

body { display: flex; flex-direction: column; }

/* ------------------------------------------------------------------ entête */

.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  background: var(--carte);
  border-bottom: 1px solid var(--trait);
  z-index: 500;
}

.entete h1 { margin: 0; font-size: 1.05rem; letter-spacing: -0.01em; }
.sous-titre { margin: 0.1rem 0 0; font-size: 0.78rem; color: var(--encre-douce); }

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

.bouton {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  background: var(--carte);
  color: var(--encre);
  cursor: pointer;
  min-height: 40px;
}
.bouton:hover { background: #f0eee9; }
.bouton:disabled { opacity: 0.5; cursor: not-allowed; }

.bouton-principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.bouton-principal:hover { background: var(--accent-fonce); }

.bouton-confirmer { background: var(--recent); border-color: var(--recent); color: #fff; }
.bouton-confirmer:hover { background: #157a45; }

.bouton-danger { color: var(--danger); border-color: #e8c9cb; }

.bouton-icone {
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--rayon);
  background: transparent;
  cursor: pointer;
}
.bouton-icone:hover { background: #f0eee9; }

.lien {
  font: inherit;
  font-size: 0.78rem;
  background: none;
  border: none;
  color: var(--encre-douce);
  text-decoration: underline;
  cursor: pointer;
}

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

.conteneur { position: relative; flex: 1; min-height: 0; }

#carte { position: absolute; inset: 0; background: #e8e6e0; }

.leaflet-container { font: inherit; }

/* Icônes de points : pastille colorée plutôt que l'épingle par défaut,
   plus lisible quand 48 points se superposent. */
.pastille {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.pastille-chaud { animation: pulsation 2s ease-in-out infinite; }
@keyframes pulsation {
  0%, 100% { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(26, 157, 90, 0.5); }
  50%      { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), 0 0 0 9px rgba(26, 157, 90, 0); }
}

.pastille-selectionnee { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Point jamais vérifié ou périmé : contour en tirets, lisible en survol de carte. */
.pastille-a-revoir { border-style: dashed; border-color: #6b665e; }

/* Légende de fraîcheur (contrôle Leaflet, en bas à gauche). */
.legende {
  background: rgba(255, 255, 255, 0.94);
  padding: 0.5rem 0.65rem;
  border-radius: var(--rayon);
  border: 1px solid var(--trait);
  box-shadow: var(--ombre);
  font-size: 0.74rem;
  line-height: 1.5;
  max-width: 240px;
}
.legende strong { display: block; margin-bottom: 0.3rem; font-size: 0.76rem; }
.legende-ligne { display: flex; align-items: center; gap: 0.4rem; }
.legende-pastille {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
}
.legende-note {
  margin-top: 0.35rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--trait);
  color: var(--encre-douce);
  font-size: 0.7rem;
}

/* Compteur dans le bouton de filtre. */
.compteur {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.3em;
  border-radius: 999px;
  background: #e8e4dc;
  font-size: 0.78em;
}
.bouton.actif { background: var(--encre); border-color: var(--encre); color: #fff; }
.bouton.actif .compteur { background: rgba(255, 255, 255, 0.25); }

/* Phrase de fraîcheur dans le panneau, colorée selon le niveau. */
.fraicheur.niveau-recent { color: var(--recent); }
.fraicheur.niveau-frais { color: #5f8f10; }
.fraicheur.niveau-ancien { color: var(--moyen); }
.fraicheur.niveau-perime,
.fraicheur.niveau-jamais_verifie { color: var(--vieux); }

/* ------------------------------------------------------------------ panneau */

.panneau {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  padding: 0.9rem 1rem 2rem;
  background: var(--carte);
  border-left: 1px solid var(--trait);
  box-shadow: var(--ombre);
  overflow-y: auto;
  z-index: 400;
  transition: transform 0.18s ease;
}
.panneau.ferme { transform: translateX(102%); }

.panneau-entete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.panneau h2 { margin: 0; font-size: 1.05rem; }

.adresse { margin: 0.2rem 0 0.4rem; color: var(--encre-douce); font-size: 0.85rem; }
.fraicheur { margin: 0 0 0.9rem; font-size: 0.82rem; font-weight: 600; }

.champ { display: block; margin: 0.8rem 0; }
.champ > span { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.3rem; }
.champ em { font-weight: 400; color: var(--encre-douce); font-style: normal; }

textarea, input[type="text"] {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  background: #fdfcfa;
  resize: vertical;
}
textarea:focus, input[type="text"]:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* -------------------------------------------------------------- états */

.etats { border: none; padding: 0; margin: 0.8rem 0; }
.etats legend { font-size: 0.82rem; font-weight: 600; padding: 0; }
.puces { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.puces label { cursor: pointer; }
.puces input { position: absolute; opacity: 0; width: 0; height: 0; }
.puces span {
  display: inline-block;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--trait);
  border-radius: 999px;
  font-size: 0.82rem;
  background: var(--carte);
  min-height: 36px;
  line-height: 1.25;
}
.puces input:checked + span { background: var(--encre); color: #fff; border-color: var(--encre); }
.puces input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------- photos */

.photos { margin: 1rem 0; }
.galerie { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.galerie figure { margin: 0; position: relative; }
.galerie img {
  width: 84px; height: 84px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--trait);
  display: block;
}
.galerie button {
  position: absolute; top: -6px; right: -6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--trait);
  background: var(--carte);
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
}

.champ-fichier { display: block; margin-bottom: 0.4rem; }
.champ-fichier input { position: absolute; opacity: 0; width: 0; height: 0; }
.champ-fichier span {
  display: block;
  padding: 0.55rem 0.7rem;
  border: 1px dashed var(--trait);
  border-radius: var(--rayon);
  text-align: center;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 44px;
}
.champ-fichier span:hover { background: #f7f6f3; }
.champ-fichier input:focus-visible + span { outline: 2px solid var(--accent); }

/* ------------------------------------------------------------ actions */

.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; }
.actions .bouton { flex: 1 1 auto; }

.aide { font-size: 0.76rem; color: var(--encre-douce); line-height: 1.4; }
.meta { font-size: 0.74rem; color: var(--encre-douce); margin-top: 1rem; }

.historique { margin-top: 1rem; font-size: 0.82rem; }
.historique summary { cursor: pointer; font-weight: 600; }
.historique ul { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.historique li {
  padding: 0.35rem 0;
  border-top: 1px solid var(--trait);
  color: var(--encre-douce);
}
.historique li strong { color: var(--encre); font-weight: 600; }
.historique .annulee { text-decoration: line-through; opacity: 0.6; }

/* ------------------------------------------------------- panneau tournées */

.panneau-gauche {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--trait);
}
.panneau-gauche.ferme { transform: translateX(-102%); }

.liste-tournees { list-style: none; padding: 0; margin: 0.8rem 0 0; }
.liste-tournees > button { width: 100%; margin-bottom: 0.6rem; }

.carte-tournee { padding: 0.6rem 0; border-top: 1px solid var(--trait); }
.carte-tournee strong { display: block; font-size: 0.9rem; }
.carte-tournee .aide { display: block; margin: 0.15rem 0 0.45rem; }
.carte-tournee-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.carte-tournee-actions .bouton { flex: 1 1 auto; font-size: 0.82rem; padding: 0.4rem 0.6rem; }

/* --------------------------------------------------------- mode terrain */

.terrain {
  position: fixed;
  inset: 0;
  background: var(--fond);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.terrain.ferme { display: none; }

.terrain-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.7rem 0.9rem;
  background: var(--carte);
  border-bottom: 1px solid var(--trait);
}
.terrain-entete h2 { margin: 0; font-size: 1rem; }
.terrain-progression { margin: 0.1rem 0 0; font-size: 0.8rem; color: var(--encre-douce); }
.terrain-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.terrain-distance {
  margin: 0;
  padding: 0.5rem 0.9rem;
  background: #eef4ff;
  color: var(--accent-fonce);
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom: 1px solid #d6e2f7;
}
.terrain-distance:empty { display: none; }

.terrain-liste {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.arret {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
}
.arret-fait { opacity: 0.65; border-color: var(--recent); }
.arret-fait .arret-numero { background: var(--recent); }

.arret-numero {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--encre);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.arret-corps { flex: 1; min-width: 0; }
.arret-corps strong { display: block; font-size: 0.92rem; }
.arret-corps .aide { display: block; margin: 0.15rem 0 0.45rem; }
.arret-etats { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.bouton-etat { font-size: 0.8rem; padding: 0.4rem 0.6rem; }
.bouton-etat.actif { background: var(--encre); border-color: var(--encre); color: #fff; }

@media (min-width: 701px) {
  .terrain-liste { max-width: 720px; width: 100%; margin: 0 auto; }
}

/* ------------------------------------------------------------- bandeau */

.bandeau {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%) translateY(150%);
  max-width: min(90vw, 460px);
  padding: 0.6rem 0.9rem;
  border-radius: var(--rayon);
  background: var(--encre);
  color: #fff;
  font-size: 0.85rem;
  box-shadow: var(--ombre);
  transition: transform 0.2s ease;
  z-index: 1000;
}
.bandeau.visible { transform: translateX(-50%) translateY(0); }
.bandeau.erreur { background: var(--danger); }
.bandeau.succes { background: var(--recent); }

/* ---------------------------------------------------------------- pied */

.pied {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0.9rem;
  font-size: 0.72rem;
  color: var(--encre-douce);
  background: var(--carte);
  border-top: 1px solid var(--trait);
}

/* --------------------------------------------------------------- dialog */

dialog {
  border: none;
  border-radius: var(--rayon);
  max-width: min(560px, 92vw);
  padding: 1.2rem 1.4rem;
  box-shadow: var(--ombre);
}
dialog::backdrop { background: rgba(28, 27, 25, 0.45); }
dialog h2 { margin-top: 0; font-size: 1.05rem; }
dialog ul { padding-left: 1.1rem; }
dialog li { margin-bottom: 0.35rem; font-size: 0.9rem; }

/* -------------------------------------------------------------- mobile */

@media (max-width: 700px) {
  .entete { padding: 0.5rem 0.6rem; }
  .entete h1 { font-size: 0.95rem; }
  .sous-titre { display: none; }

  .panneau {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 78vh;
    border-left: none;
    border-top: 1px solid var(--trait);
    border-radius: 14px 14px 0 0;
  }
  .panneau.ferme { transform: translateY(105%); }

  .actions { position: sticky; bottom: 0; background: var(--carte); padding-bottom: 0.5rem; }
}
