/* Página del mapa de paradas TUCS.
   Sin frameworks: sólo los estilos de la página y de Leaflet (vendor/). */

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #111827;
}

#map {
  position: absolute;
  inset: 0;
}

/* ---------------------------------------------------------------- leyenda */

#legend {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  width: 260px;
  max-height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  font-size: 13px;
}

#legend header {
  padding: 10px 12px 6px;
  border-bottom: 1px solid #e5e7eb;
}

#legend h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

#legend #count {
  margin: 2px 0 0;
  color: #6b7280;
  font-size: 12px;
}

/* Acciones que afectan a todas las líneas a la vez. */
#bulk {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

#bulk button {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #f9fafb;
  color: #374151;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

#bulk button:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

#bulk button:active {
  background: #e5e7eb;
}

#bulk button[aria-pressed="true"] {
  background: #111827;
  border-color: #111827;
  color: #ffffff;
}

#legend-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  min-height: 0;
}

.legend-item {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto 16px;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.legend-item:hover,
.legend-item:focus-visible {
  background: #f3f4f6;
  outline: none;
}

.legend-item .swatch {
  height: 4px;
  border-radius: 2px;
  background: var(--line-color, #6b7280);
}

.legend-item .name {
  font-weight: 600;
}

.legend-item .count {
  color: #6b7280;
  font-size: 12px;
}

/* Indicador de estado: un círculo dibujado con CSS (no depende de la fuente). */
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-sizing: border-box;
  vertical-align: middle;
  background: #374151;
  border: 1.5px solid #374151;
}

.dot.dim {
  opacity: 0.15;
}

.dot.off {
  background: transparent;
  border-color: #9ca3af;
}

.legend-item .state {
  justify-self: center;
}

.dot-label {
  white-space: nowrap;
}

.dot-label .dot {
  margin-right: 3px;
}

/* alpha 15 % para la línea atenuada; la oculta se muestra apagada */
.legend-item.state-dim .swatch {
  opacity: 0.15;
}

.legend-item.state-dim .name {
  opacity: 0.6;
}

.legend-item.state-off .swatch {
  opacity: 0.15;
}

.legend-item.state-off .name {
  color: #9ca3af;
  text-decoration: line-through;
}

.legend-help {
  margin: 0;
  padding: 8px 12px 10px;
  border-top: 1px solid #e5e7eb;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.4;
}

/* ------------------------------------------------------ mensajes sueltos */

#status {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 8px 14px;
  background: #111827;
  color: #ffffff;
  border-radius: 6px;
  font-size: 13px;
}

#status[hidden] {
  display: none;
}

#hint {
  position: absolute;
  left: 12px;
  bottom: 30px;
  z-index: 900;
  max-width: 60%;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 5px;
  font-size: 12px;
  color: #374151;
  pointer-events: none;
}

/* --------------------------------------------------- recuadro de parada */

.tucs-popup .leaflet-popup-content {
  margin: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
}

.stop-card {
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 4px;
}

.stop-card h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.stop-card h3 {
  margin: 12px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

/* Cabecera de la sección de líneas + botón de actuar sobre todas. */
.stop-card .section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

.stop-card .section-head h3 {
  margin: 0 0 6px;
}

.stop-card .toggle-all {
  flex: 0 0 auto;
  padding: 2px 7px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #f9fafb;
  color: #374151;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}

.stop-card .toggle-all:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

/* Interruptor de una línea dentro de la ficha. */
.stop-card .line-toggle {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.stop-card .line-toggle .tick {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1.5px solid #6b7280;
  background: transparent;
  transform: translateY(1px);
}

.stop-card .line-toggle.state-on .tick {
  background: #6b7280;
}

.stop-card .line-toggle.state-dim .tick {
  background: #6b7280;
  opacity: 0.15;
}

.stop-card .line-toggle.state-off .tick {
  background: transparent;
  border-color: #9ca3af;
}

.stop-card .line-toggle .route-name {
  font-weight: 700;
}

.stop-card .line-toggle .route-count {
  color: #6b7280;
  font-size: 11px;
}

.stop-card .line-toggle.state-off .route-name {
  color: #9ca3af;
  text-decoration: line-through;
}

.stop-card .line-toggle:hover .route-name {
  text-decoration: underline;
}

.stop-card .stop-id,
.stop-card .source {
  color: #6b7280;
  font-size: 12px;
  margin: 2px 0 0;
}

.stop-card .source {
  margin-top: 10px;
}

.stop-card .route {
  border-left: 3px solid #d1d5db;
  padding: 4px 0 4px 8px;
  margin-bottom: 8px;
}

.stop-card .route-head {
  font-weight: 600;
}

.stop-card .route-pos {
  color: #6b7280;
  font-size: 12px;
}

.stop-card .step {
  font-size: 12px;
  color: #374151;
}

.stop-card .step .arrow {
  display: inline-block;
  width: 14px;
  color: #9ca3af;
}

.stop-card .osm-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
}

/* ---------------------------------------------------------- pantallas pequeñas */

@media (max-width: 640px) {
  #legend {
    width: 200px;
    font-size: 12px;
  }

  #hint {
    max-width: 70%;
    font-size: 11px;
  }
}
