/* ==========================================================================
   Vue carte de l'onglet Planification (10/10/2026) — chargé après tuiles.css.
   Couleurs uniquement par tokens (AGENTS.md). Le fond de carte vient de Leaflet : tuiles claires ou
   sombres selon le thème (carte-planification.js). Les surcharges Leaflet ci-dessous remplacent ses
   couleurs par défaut (popups, contrôles de zoom, attribution) pour rester lisibles dans les deux thèmes.
   ========================================================================== */

.vue-carte[hidden], .vue-seg[hidden] { display: none; }

/* Bascule Liste | Carte (même rendu que le segment de l'onglet Logistique) */
.vue-seg {
  display: inline-flex;
  border: 1px solid var(--bordure-controle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}
.vue-seg button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--texte-att);
  background: var(--surface);
  border: 0;
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
}
.vue-seg button + button { border-left: 1px solid var(--bordure-controle); }
.vue-seg button[aria-pressed="true"] { background: var(--action); color: var(--sur-action); }
.vue-seg button:hover:not([aria-pressed="true"]) { color: var(--texte); }

.vue-carte { display: grid; gap: var(--space-4); }
.carte-grille {
  padding: 0 var(--space-6) var(--space-8);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: var(--space-4);
  align-items: start;
}
.carte-grille > * { min-width: 0; }
.carte-tuile { display: grid; gap: var(--space-2); }
.carte-tuile .tuile-sous-titre { margin: 0; }

.carte-leaflet {
  height: clamp(420px, calc(100vh - 200px), 760px);
  width: 100%;
  border: 1px solid var(--bordure);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--neutre-doux);
  font-family: var(--font-sans);
}
.carte-calques { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Liste « Dans le rayon » : ligne cliquable, qui ouvre le marqueur sur la carte */
.carte-liste { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow-y: auto; }
.carte-liste li + li { border-top: 1px solid var(--bordure); }
.carte-ligne {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-1);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--texte);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.carte-ligne:hover { background: var(--action-doux); }
.carte-ligne-texte { min-width: 0; }
.carte-ligne-titre { display: block; font-weight: 600; overflow-wrap: anywhere; }
.carte-ligne-detail { display: block; font-size: 12px; color: var(--texte-att); overflow-wrap: anywhere; }
.carte-ligne-km { font-size: 12px; color: var(--texte-att); white-space: nowrap; font-variant-numeric: tabular-nums; }
.carte-vide { padding: var(--space-3) var(--space-1); }

/* Formes distinctes dans la liste : losange = technicien, rond = intervention (la couleur seule ne suffit pas) */
.carte-forme-tech {
  width: 9px;
  height: 9px;
  margin: 0 var(--space-1);
  background: var(--succes);
  border-radius: 2px;
  transform: rotate(45deg);
}
.carte-forme-interv {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--attention);
}

/* Marqueurs Leaflet */
.carte-marqueur-tech::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  background: var(--succes);
  border: 2px solid var(--surface);
  border-radius: 4px;
  transform: rotate(45deg);
  box-shadow: var(--ombre-2);
}
.carte-marqueur-centre::before {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  background: var(--action);
  border: 3px solid var(--surface);
  border-radius: var(--radius-full);
  box-shadow: var(--ombre-2);
}
.carte-marqueur-interv {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 2px solid var(--attention);
  border-radius: var(--radius-full);
  background: var(--attention-doux);
  color: var(--attention-texte);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--ombre-2);
}
/* Thème sombre : tuiles OpenStreetMap inversées et adoucies. Seul le fond de carte est filtré ; marqueurs et fiches restent nets. */
.carte-leaflet.carte-sombre .leaflet-tile-pane { filter: invert(1) grayscale(1) brightness(0.8) contrast(0.95); }
.carte-leaflet .leaflet-marker-icon:focus-visible { outline: 2px solid var(--anneau-focus); outline-offset: 2px; }

/* Cercle du rayon */
.carte-rayon { fill: var(--action); fill-opacity: 0.06; stroke: var(--action); stroke-width: 2; stroke-dasharray: 6 6; }

/* Fiche qui s'ouvre au clic sur un marqueur */
.carte-leaflet .leaflet-popup-content-wrapper,
.carte-leaflet .leaflet-popup-tip {
  background: var(--surface);
  color: var(--texte);
  border: 1px solid var(--bordure);
  box-shadow: var(--ombre-2);
}
.carte-leaflet .leaflet-popup-content { margin: var(--space-3); font-size: 13px; line-height: 20px; }
.carte-leaflet .leaflet-popup-close-button { color: var(--texte-att); }
.carte-popup-titre { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.carte-popup dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
  margin: var(--space-2) 0 0;
}
.carte-popup dt { color: var(--texte-att); }
.carte-popup dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* Contrôles et attribution Leaflet */
.carte-leaflet .leaflet-bar a {
  background: var(--surface);
  color: var(--texte);
  border-bottom-color: var(--bordure);
}
.carte-leaflet .leaflet-bar a:hover { background: var(--surface-2); }
.carte-leaflet .leaflet-bar a.leaflet-disabled { color: var(--texte-desactive); }
.carte-leaflet .leaflet-control-attribution { background: var(--surface); color: var(--texte-att); }
.carte-leaflet .leaflet-control-attribution a { color: var(--action-texte); }

@media (max-width: 760px) {
  .carte-grille { grid-template-columns: minmax(0, 1fr); }
  .carte-leaflet { height: 360px; }
  .carte-liste { max-height: none; }
}
