/* ---------------- liste des waypoints ---------------- */

.waypoint-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.waypoint-list:empty {
  display: none;
}

/* Repliée : départ et arrivée restent visibles, les étapes intermédiaires
   (data-role posé par syncWaypointsPanel, app-waypoints.js) se cachent. */
.waypoint-list.collapsed .waypoint-row[data-role="intermediaire"] {
  display: none;
}

.waypoint-list:empty + #waypoint-empty-hint {
  display: block;
}

#waypoint-empty-hint {
  display: none;
}

.waypoint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  /* Anime le décalage des AUTRES lignes pendant un glisser (voir
     onWaypointDragMove) ; désactivée sur la ligne saisie elle-même
     (.dragging) pour qu'elle suive le pointeur sans latence. */
  transition: transform 0.15s ease;
}

.waypoint-row:hover {
  background: var(--pine-wash);
}

.waypoint-row.dragging {
  position: relative;
  z-index: 10;
  box-shadow: var(--shadow-md);
  background: var(--surface);
  transform: scale(1.02);
}

.waypoint-badge {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  background: #2e5a8c;
}

.waypoint-label {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  font-size: inherit;
  font-family: inherit;
  color: var(--ink);
  border: 1px solid transparent;
  background: none;
  border-radius: 5px;
  padding: 3px 5px;
}

.waypoint-label:hover {
  border-color: var(--line);
}

.waypoint-label:focus {
  outline: none;
  border-color: var(--pine);
  background: var(--surface);
}

.waypoint-drag {
  flex-shrink: 0;
  width: 20px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--ink-3);
  font-size: 0.95rem;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  padding: 0;
}

.waypoint-drag:hover {
  color: var(--pine);
}

.waypoint-row.dragging .waypoint-drag {
  cursor: grabbing;
  color: var(--pine);
}

.waypoint-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--ink-3);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.waypoint-remove:hover {
  background: var(--danger-wash);
  color: var(--danger);
}

#search-suggestions {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  position: absolute;
  z-index: 1200;
  left: 0;
  right: 0;
  top: 100%;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
}

#search-suggestions.hidden {
  display: none;
}

#search-suggestions li {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#search-suggestions li:last-child {
  border-bottom: none;
}

#search-suggestions li:hover,
#search-suggestions li.highlight {
  background: var(--pine-wash);
}

#search-suggestions strong {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

#search-suggestions small {
  font-size: 0.75rem;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- popups Leaflet (menu d'insertion de point) ---------------- */

.insert-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.insert-menu button {
  padding: 7px 11px;
  font-size: 0.85rem;
  white-space: nowrap;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--pine-wash);
  color: var(--ink);
  cursor: pointer;
}

.insert-menu button:hover {
  background: var(--surface-2);
}

.insert-menu button:disabled {
  color: var(--ink-3);
  background: var(--surface-2);
  cursor: not-allowed;
}

.insert-menu button:disabled:hover {
  background: var(--surface-2);
}

.leaflet-popup.insert-popup .leaflet-popup-content {
  margin: 6px 8px;
}

.leaflet-popup.insert-popup .leaflet-popup-content-wrapper {
  border-radius: 10px;
}

/* ---------------- actions sur un itinéraire (listes) ---------------- */

.route-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.route-actions button,
.route-actions a {
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 7px;
  text-decoration: none;
  cursor: pointer;
}

.route-actions button:hover,
.route-actions a:hover {
  background: var(--surface-2);
  border-color: var(--ink-3);
}

/* Menu "Autre" (Google/Apple Maps) : mêmes 4 boutons qu'avant, mais Google
   Maps + Apple Maps regroupés derrière un déclencheur au lieu de deux
   boutons en plus de GPX/FIT — la rangée d'actions débordait vite sur une
   carte étroite. */
.route-actions-other {
  position: relative;
}

.route-actions-other-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 130px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  box-shadow: var(--shadow-md);
}

.route-actions-other-menu.hidden {
  display: none;
}

.route-actions-other-menu a {
  border: none;
  border-radius: 6px;
  padding: 6px 8px;
  white-space: nowrap;
}

.parcours-sport {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---------------- responsive ---------------- */

@media (max-width: 900px) {
  #topbar {
    gap: 12px;
    padding: 0 12px;
  }
  #app-nav {
    gap: 12px;
  }
  .nav-brand .nav-name,
  .nav-brand .nav-chip {
    display: none;
  }
}

/* Pin de résultat de recherche : jaune sombre, forme goutte pour le distinguer
   clairement des points de passage verts tant qu'il n'est pas encore intégré
   au trajet (voir showSearchMarkerMenu dans app-search.js). */
.search-marker span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #B08A1E;
  border: 2.5px solid var(--surface);
  box-shadow: 0 2px 6px rgba(20, 32, 28, 0.4);
}

.warning-marker {
  font-size: 18px;
  line-height: 28px;
  text-align: center;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

@media (max-width: 900px) {
  #sidebar {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 12px;
    width: auto;
    /* dvh (pas vh) : sur Safari mobile, vh se calcule sur la fenêtre plein
       écran alors que la barre d'adresse/le dock rétractables changent la
       hauteur réellement visible en cours de route — vh et le "52vh + 20px"
       de .route-panel ci-dessous dérivaient l'un par rapport à l'autre selon
       que la barre était affichée ou non, d'où le chevauchement remonté. */
    height: 52vh;
    height: 52dvh;
  }
  .route-panel {
    left: 12px;
    right: 12px;
    bottom: calc(52vh + 20px);
    bottom: calc(52dvh + 20px);
  }
  #elevation-profile {
    max-height: 215px;
    overflow-y: auto;
  }
  #elevation-profile svg {
    height: 110px;
  }
  .leaflet-control-attribution {
    display: none;
  }
  /* La sidebar passe en bandeau du bas sur mobile (règle ci-dessus) : le
     pilier couches/zoom/position (voir style-map.css, ancré à
     var(--rail-gutter) ≈ 352px en desktop) se retrouvait hors écran, casé
     à droite d'une sidebar qui n'existe plus dans cette position. Revient
     en haut à droite de la carte, comme le panneau "Carte" le fait déjà. */
  .leaflet-top.leaflet-left {
    left: auto;
    right: 12px;
  }
  .map-layers-panel {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: calc(52vh + 20px);
    bottom: calc(52dvh + 20px);
    top: 12px;
  }
}
