/* Estilos del mapa LTV (scrape) */
:root {
  /* Paleta adaptada al fondo claro de la página (señalética tipo calor) */
  --bg: #ffffff;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  /* Tres categorías de velocidad (leyenda y mapa) */
  --critical: #f5a442;
  --low: #fade91;
  --medium: #62827a;
  /* Valores residuales (ya no se usan, pero se dejan por compatibilidad) */
  --high: #62827a;
  --reduced: #62827a;
}

/* * { box-sizing: border-box; } */

/* body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
} */

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.brand span { color: var(--muted); font-size: 0.85rem; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  transition: max-height 0.25s ease, padding 0.25s ease, overflow 0.25s ease;
}

/* Tipografía MarcinAntB para los textos de la barra y leyenda */
.filter-bar,
.filter-bar label,
.bucket-btn,
.counter,
.legend,
.legend h3,
.legend li,
.footer {
  font-family: MarcinAntB, sans-serif;
}

@media (min-width: 769px) {
  .filter-bar {
    padding-top: 10px;
    padding-bottom: 10px;
  }
}

@media (max-width: 768px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar-content { order: 0; }
  .legend { display: none; }
  .counter { margin-left: 0; }
}

.filter-bar label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.85rem; color: var(--muted); }

.ep-grafico-heading {
  width: 100%;
  margin: 0 0 8px 0;
  font-family: MajritTxRoman, Georgia, serif;
  /* font-size: 1rem; */
  font-weight: 600;
  color: var(--text);
}

.filter-bar-title {
  width: 100%;
  margin: 0 0 8px 0;
  /* font-size: 0.9rem;
  font-weight: 600; */
  color: var(--text);
  font-size: 1.1rem;
}

.buckets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.bucket-btn {
  background: transparent;
  border: 1px solid var(--border);
  /* border-radius: 8px; */
  padding: 6px 12px;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* Mejor respuesta al tacto en móvil (evita delay 300ms y estados incorrectos) */
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.08);
  user-select: none;
  -webkit-user-select: none;
}

.bucket-btn.active { border-color: currentColor; color: var(--text); }
/* hover solo en dispositivos con ratón; en táctil evita que el estado se quede "pegado" */
@media (hover: hover) {
  .bucket-btn:hover { border-color: currentColor; color: var(--text); }
}

@media (max-width: 768px) {
  .bucket-btn {
    /* min-height: 44px;
    padding: 10px 14px; */
  }
}
.bucket-btn .dot { width: 8px; height: 8px; border-radius: 50%; }

.counter { margin-left: auto; font-size: 0.9rem; color: var(--muted); }
.counter strong { color: var(--text); }

.map-export-btn {
  margin-left: auto;
  background: var(--reduced);
  color: #fff;
  border-color: var(--reduced);
}
@media (hover: hover) {
  .map-export-btn:hover { opacity: 0.9; color: #fff; }
}

.map-container {
  position: relative;
  width: 100%;
  /* height: 550px; */
  min-height: 550px;
  overflow: hidden;
}

/* Pseudo-fullscreen para iOS Safari (no soporta Fullscreen API) */
.map-container.map-container--pseudo-fullscreen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  z-index: 9999;
  background: #fff;
}

/* Overlay móvil: un toque para activar el mapa, evita perder el control del scroll */
.map-tap-overlay {
  display: none;
}

@media (max-width: 768px) {
  .map-tap-overlay {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }
  .map-tap-overlay--activated {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .map-tap-overlay-text {
    font-family: MarcinAntB, sans-serif;
    font-size: 0.9rem;
    color: #333;
    padding: 12px 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  }
  .counter{
    margin-left:initial;}
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

/* Marcadores arrastrables (icono circular) */
.ltv-draggable-marker {
  background: none !important;
  border: none !important;
}
.ltv-draggable-marker.leaflet-marker-draggable {
  cursor: move;
}

/* Botón reset vista (control Leaflet) - icono tipo marco Mapbox */
.leaflet-control-reset {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0,0,0,0.2);
  color: #333;
}
.leaflet-control-reset:hover {
  background: #f4f4f4;
}
.leaflet-control-reset svg {
  display: block;
}

/* Botón fullscreen (control Leaflet) - SVG compatible Safari */
.leaflet-control-fullscreen {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0,0,0,0.2);
  color: #333;
}
.leaflet-control-fullscreen:hover {
  background: #f4f4f4;
}
.leaflet-control-fullscreen svg {
  display: block;
}

/* Contenedor del mapa en fullscreen */
.map-container:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
}
.map-container:-webkit-full-screen { width: 100vw; height: 100vh; min-height: 100vh; }
.map-container:-ms-fullscreen { width: 100vw; height: 100vh; min-height: 100vh; }

/* Coordenadas bajo el cursor */
.map-coords {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: MarcinAntB, monospace;
  color: var(--text);
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: opacity 0.15s ease;
}
.map-coords { opacity: 0; }
.map-coords.visible { opacity: 1; }
.map-coords-copy {
  pointer-events: auto;
  cursor: pointer;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-family: MarcinAntB, sans-serif;
  background: var(--border);
  border: none;
  border-radius: 4px;
  color: var(--text);
}
.map-coords-copy:hover {
  background: var(--muted);
  color: #fff;
}

.legend {
  display: none;
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 1000;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.6);
  /* border: 1px solid var(--border); */
  /* border-radius: 10px; */
  padding: 10px 14px;
  font-size: 0.8rem;
}

.legend h3 { margin: 0 0 8px 0; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.legend ul { list-style: none; margin: 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; }

.footer {
  padding: 8px 20px;
  /* background: var(--card);
  border-top: 1px solid var(--border); */
  font-size: 0.75rem;
  color: var(--muted);
}

.footer a { color: var(--reduced); }

/* ---------- Leyenda de vías OpenRailwayMap ---------- */
.rail-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 20px;
  font-family: MarcinAntB, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}

.rail-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rail-legend-line {
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: 2px;
}

/* ---------- Tooltip / popup Leaflet estilo especial ---------- */

/* Tarjeta principal del popup (wrapper Leaflet) */
.leaflet-popup-content-wrapper {
  background: #ffffff;
  color: #0f172a;
  border-radius: 14px;
  border: none;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
  padding: 0;
}

/* Triángulo del popup */
.leaflet-popup-tip {
  background: #ffffff;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
}

/* Contenedor interno que añade Leaflet */
.leaflet-popup-content {
  margin: 0;
  padding: 0;
}

/* Contenido interno que generamos desde JS */
.popup-content {
  position: relative;
  padding: 22px 18px 14px;
  min-width: 240px;
  font-size: 0.8rem;
  line-height: 1.4;
  font-family: 'MarcinAntB', serif;
  color: #0f172a;
}

.popup-content h4 {
  margin: 0 0 8px 0;
  font-size: 0.9rem;
}

.popup-row {
  margin-bottom: 4px;
}

.popup-row strong {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 1px;
}

.popup-row-inline strong {
  display: inline;
  margin-bottom: 0;
}

.popup-row:first-of-type {
  margin-top: 4px;
}

.popup-row span,
.popup-row {
  color: #0f172a;
}

/* Pastilla velocidad con color de leyenda */
.speed-value.speed-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 2px;
}
