/* CalendArc - application de tournée
   Pensée pour le dehors : gros boutons, fort contraste, une main libre. */

:root {
  --beton: #F1F2EF;
  --papier: #FFFFFF;
  --marine: #1B2638;
  --marine-2: #2A3850;
  --rouge: #C8102E;
  --rouge-fonce: #A00D25;
  --jaune: #F2C230;
  --trait: #D3D7DC;
  --gris: #5E6673;
  --vert: #2E7D4F;

  --s-a_faire: #8A93A0;
  --s-donne: #2E7D4F;
  --s-deja_donne: #6BAF7F;
  --s-absent: #E0A100;
  --s-repasser: #D9822B;
  --s-refus: #C8102E;

  --rayon: 10px;
  --titre: "Barlow Condensed", "Arial Narrow", sans-serif;
  --texte: "Barlow", system-ui, sans-serif;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 400 17px/1.45 var(--texte);
  color: var(--marine);
  background: var(--beton);
  min-height: 100vh;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--titre); font-weight: 700; line-height: 1.1; margin: 0; }
:focus-visible { outline: 3px solid var(--jaune); outline-offset: 2px; }
.visuel-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.livree {
  height: 8px;
  background: repeating-linear-gradient(-45deg, var(--rouge) 0 12px, var(--jaune) 12px 24px);
}

/* ---------- En-tête ---------- */
.entete {
  position: sticky; top: 0; z-index: 1000;
  background: var(--marine); color: #fff;
  padding-top: var(--haut);
}
.entete-ligne { display: flex; align-items: center; gap: .5rem; padding: .6rem 1rem; min-height: 3.4rem; }
.entete-titre { font-size: 1.7rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete-retour {
  font: 400 2.2rem/1 var(--texte); color: #fff; background: none; border: 0;
  width: 2.6rem; height: 2.6rem; margin-left: -.6rem; cursor: pointer;
}
.pastille-sync {
  font: 600 .85rem var(--texte); border: 0; border-radius: 999px;
  padding: .4rem .8rem; cursor: pointer; white-space: nowrap;
  background: var(--jaune); color: var(--marine);
}
.pastille-sync.hors-ligne { background: var(--marine-2); color: #fff; box-shadow: inset 0 0 0 1px #8A93A0; }
.pastille-sync.erreur { background: var(--rouge); color: #fff; }

.ecran { padding: 1rem 1rem calc(2rem + var(--bas)); max-width: 40rem; margin: 0 auto; }

/* ---------- Boutons et champs ---------- */
.btn {
  font: 600 1rem/1 var(--texte); padding: .85rem 1.1rem; min-height: 3rem;
  border-radius: var(--rayon); border: 1px solid var(--trait);
  background: var(--papier); color: var(--marine); cursor: pointer;
}
.btn-rouge { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.btn-rouge:active { background: var(--rouge-fonce); }
.btn-large { width: 100%; font-size: 1.1rem; min-height: 3.5rem; }
.btn-lien { font: 500 1rem var(--texte); background: none; border: 0; padding: .5rem 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.btn:disabled { opacity: .5; }

label { display: block; font-weight: 500; margin-bottom: 1rem; }
input[type=email], input[type=password], input[type=text] {
  display: block; width: 100%; margin-top: .35rem;
  font: 400 1.1rem var(--texte); color: var(--marine);
  padding: .8rem .9rem; border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--papier);
}
.erreur { color: var(--rouge); font-weight: 600; min-height: 1.4em; margin: .3rem 0 .8rem; }

/* ---------- Connexion ---------- */
.connexion { padding-top: 8vh; }
.connexion h2 { font-size: 2.6rem; }
.connexion .sous { color: var(--gris); margin: .3rem 0 2rem; }

/* ---------- Accueil ---------- */
.bonjour { font-size: 2rem; margin: .5rem 0 .2rem; }
.sous { color: var(--gris); margin: 0 0 1.4rem; }
.bandeau {
  border-left: 4px solid var(--jaune); background: #FFF6D6;
  padding: .9rem 1rem; margin-bottom: 1.2rem; border-radius: 0 var(--rayon) var(--rayon) 0;
}
.bandeau.rouge { border-left-color: var(--rouge); background: #FBE7EA; }
.bandeau.vert { border-left-color: var(--vert); background: #E5F2EA; }
.bandeau p { margin: 0 0 .5rem; }
.bandeau p:last-child { margin-bottom: 0; }
.bandeau ul { margin: .3rem 0 .6rem; padding-left: 1.2rem; }

.equipe-titre { font-size: 1.5rem; margin: 1.6rem 0 .2rem; }
.coequipiers { color: var(--gris); margin: 0 0 .8rem; }

.secteur-carte {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--papier); border: 1px solid var(--trait); border-left: 8px solid var(--couleur, var(--marine));
  border-radius: var(--rayon); padding: 1rem 1.1rem; margin-bottom: .8rem;
  font: inherit; color: inherit;
}
.secteur-carte h3 { font-size: 1.5rem; margin-bottom: .3rem; }
.secteur-carte .meta { color: var(--gris); font-size: .95rem; }
.barre-avancement { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #E3E6EA; margin: .6rem 0 .4rem; }
.barre-avancement span { display: block; height: 100%; }

.liens-bas { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; margin-top: 2rem; }

/* ---------- Écran secteur ---------- */
.resume { display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin: 0 0 .9rem; font-size: .95rem; }
.resume span { display: flex; align-items: center; gap: .35rem; }
.point { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; flex: none; }

.onglets { display: grid; grid-template-columns: 1fr 1fr; background: #E3E6EA; border-radius: var(--rayon); padding: 4px; margin-bottom: .9rem; }
.onglets button { font: 600 1rem var(--texte); border: 0; background: none; padding: .65rem; border-radius: 7px; color: var(--marine); cursor: pointer; }
.onglets button[aria-pressed="true"] { background: var(--papier); box-shadow: 0 1px 2px rgba(27,38,56,.2); }

.filtres { display: flex; gap: .5rem; overflow-x: auto; margin-bottom: .9rem; padding-bottom: .2rem; }
.filtres button {
  font: 500 .95rem var(--texte); white-space: nowrap; cursor: pointer;
  border: 1px solid var(--trait); background: var(--papier); color: var(--marine);
  border-radius: 999px; padding: .5rem .9rem;
}
.filtres button[aria-pressed="true"] { background: var(--marine); border-color: var(--marine); color: #fff; }

.rue { margin-bottom: 1.1rem; }
.rue h3 { font-family: var(--texte); font-weight: 600; font-size: 1rem; color: var(--gris); margin: 0 0 .4rem; }
.adresses { list-style: none; padding: 0; margin: 0; background: var(--papier); border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; }
.adresses li + li { border-top: 1px solid var(--trait); }
.adresse {
  display: flex; align-items: center; gap: .8rem; width: 100%;
  font: inherit; color: inherit; text-align: left; background: none; border: 0;
  padding: .85rem 1rem; min-height: 3.4rem; cursor: pointer;
}
.adresse .num { font-family: var(--titre); font-weight: 700; font-size: 1.4rem; min-width: 2.6rem; }
.adresse .lib { flex: 1; min-width: 0; }
.adresse .lib small { display: block; color: var(--gris); }
.etiquette { font-size: .85rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; color: #fff; white-space: nowrap; }
.etiquette.attente::after { content: " •"; }
.e-a_faire { background: none; color: var(--gris); border: 1px solid var(--trait); }
.e-donne { background: var(--s-donne); }
.e-deja_donne { background: var(--s-deja_donne); }
.e-absent { background: var(--s-absent); color: var(--marine); }
.e-repasser { background: var(--s-repasser); }
.e-refus { background: var(--s-refus); }
.vide { text-align: center; color: var(--gris); padding: 2rem 1rem; }

.carte-terrain { height: calc(100vh - 15rem - var(--haut) - var(--bas)); min-height: 18rem; border-radius: var(--rayon); border: 1px solid var(--trait); }
.btn-position {
  position: absolute; z-index: 800; right: 10px; bottom: 24px;
  font: 600 .95rem var(--texte); background: var(--papier); color: var(--marine);
  border: 1px solid var(--trait); border-radius: var(--rayon); padding: .65rem .9rem;
  box-shadow: 0 1px 4px rgba(27,38,56,.25); cursor: pointer;
}
.btn-position[aria-pressed="true"] { background: var(--marine); color: #fff; }
.carte-cadre { position: relative; }

/* ---------- Fiche de passage (feuille du bas) ---------- */
.fiche {
  border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%;
  max-height: 92vh; border-radius: 18px 18px 0 0; color: var(--marine);
  background: var(--papier);
}
.fiche::backdrop { background: rgba(27, 38, 56, .55); }
.fiche form { padding: 1.1rem 1.1rem calc(1.1rem + var(--bas)); max-width: 40rem; margin: 0 auto; }
.fiche-tete { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.fiche-tete > div { flex: 1; }
.fiche-tete h2 { font-size: 1.8rem; }
.fiche-detail { color: var(--gris); margin: .2rem 0 0; }
.fiche-fermer { font: 400 2rem/1 var(--texte); background: none; border: 0; color: var(--gris); width: 2.6rem; height: 2.6rem; cursor: pointer; }

fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; margin-bottom: .5rem; padding: 0; }
.statuts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.statuts legend { grid-column: 1 / -1; }
.statut-choix { margin: 0; }
.statut-choix input, .modes input { position: absolute; opacity: 0; pointer-events: none; }
.statut-choix span {
  display: flex; align-items: center; justify-content: center; min-height: 3.4rem;
  font: 600 1.05rem var(--texte); border: 2px solid var(--trait); border-radius: var(--rayon);
  background: var(--papier); cursor: pointer; text-align: center; padding: .3rem;
}
.s-donne { grid-column: 1 / -1; }
.s-donne span { min-height: 3.8rem; font-size: 1.2rem; }
.statut-choix input:checked + span { color: #fff; border-color: transparent; }
.s-donne input:checked + span { background: var(--s-donne); }
.s-deja_donne input:checked + span { background: var(--s-deja_donne); }
.s-absent input:checked + span { background: var(--s-absent); color: var(--marine); }
.s-repasser input:checked + span { background: var(--s-repasser); }
.s-refus input:checked + span { background: var(--s-refus); }
.statut-choix input:focus-visible + span, .modes input:focus-visible + span { outline: 3px solid var(--jaune); outline-offset: 2px; }

.bloc-don { background: var(--beton); border-radius: var(--rayon); padding: .9rem 1rem; margin-bottom: 1rem; }
.ligne-don { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.libelle { font-weight: 600; }
.compteur { display: flex; align-items: center; gap: .3rem; }
.compteur button {
  width: 3rem; height: 3rem; font: 600 1.6rem/1 var(--texte); cursor: pointer;
  border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--papier); color: var(--marine);
}
.compteur output { min-width: 2.5rem; text-align: center; font: 700 1.6rem var(--titre); }
.montant { display: flex; align-items: center; gap: .4rem; font-weight: 600; font-size: 1.2rem; }
.montant input { width: 6.5rem; text-align: right; font: 700 1.4rem var(--titre); margin: 0; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.modes label { margin: 0; }
.modes span {
  display: block; text-align: center; padding: .7rem .3rem; cursor: pointer;
  border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--papier); font-weight: 600;
}
.modes input:checked + span { background: var(--marine); border-color: var(--marine); color: #fff; }
.note { margin-bottom: .2rem; }
.note-aide { font-size: .85rem; color: var(--gris); margin: 0 0 .5rem; }

/* ---------- Caisse ---------- */
.caisse-equipe { background: var(--papier); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.caisse-equipe h3 { font-size: 1.5rem; margin-bottom: .6rem; }
.chiffres { width: 100%; border-collapse: collapse; }
.chiffres td { padding: .45rem 0; border-bottom: 1px solid var(--trait); }
.chiffres tr:last-child td { border-bottom: 0; }
.chiffres td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.chiffres .total td { font-size: 1.15rem; border-top: 2px solid var(--marine); }

/* ---------- Notifications ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + var(--bas)); transform: translate(-50%, 1rem);
  background: var(--marine); color: #fff; padding: .85rem 1.2rem; border-radius: var(--rayon);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 3000;
  width: max-content; max-width: calc(100% - 2rem); text-align: center;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.erreur { background: var(--rouge); }

@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
