/* JDServer-Webs — Mapa de estaciones (Leaflet) */

#jd-map-module { overflow: hidden; }

.jd-map-toolbar{
  display:flex;
  gap:10px;
  align-items:center;
  margin: 10px 0 12px;
}

.jd-map-search{
  flex:1;
  height: 40px;
  border-radius: 999px;
  padding: 0 14px;
  border: 1px solid var(--border, rgba(0,0,0,.12));
  background: var(--card, rgba(255,255,255,.7));
  color: var(--text, #111);
  font-weight: 600;
}

html[data-theme="dark"] .jd-map-search{
  border-color: var(--border, #2b2f36);
  background: var(--card, #111418);
  color: var(--text, #dfe7ef);
}

.jd-map-btn{
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(0,0,0,.12));
  background: var(--card, rgba(255,255,255,.7));
  color: var(--text, #111);
  font-weight: 800;
  cursor: pointer;
}

html[data-theme="dark"] .jd-map-btn{
  border-color: var(--border, #2b2f36);
  background: var(--card, #111418);
  color: var(--text, #dfe7ef);
}

.jd-stations-map{
  height: clamp(360px, 55vh, 620px);
  border-radius: 18px;
  border: 1px solid var(--border, rgba(0,0,0,.12));
  overflow:hidden;
  background: var(--card, #fff);
}

html[data-theme="dark"] .jd-stations-map{
  border-color: var(--border, #2b2f36);
  background: var(--card, #111418);
}

/* Leaflet: que encaje con temas */
.leaflet-control-attribution{
  font-size: 11px;
  opacity: .85;
}

/* ===== Popup: evitar estrechamientos + evitar desbordes ===== */
.leaflet-popup-content,
.leaflet-popup-content *{
  box-sizing: border-box; /* ✅ clave anti “se sale por la derecha” */
}

.leaflet-popup-content{
  margin: 14px 14px 12px;
  min-width: 260px;     /* ✅ un pelín más ancho para que el grid respire */
  max-width: 340px;
  width: auto;
}

@media (max-width: 380px){
  .leaflet-popup-content{
    min-width: 240px;
  }
}

/* Popup estilo nuestro */
.jd-map-popup{
  --st: #12bdb3;
}

.jd-map-pop-top{
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--st), rgba(0,0,0,0));
  margin-bottom: 10px;
  opacity: .95;
}

.jd-map-popup .title{
  font-weight: 950;
  font-size: 18px;
  margin: 0 0 4px;
}

.jd-map-popup .meta{
  opacity: .85;
  font-weight: 750;
  margin: 0 0 10px;
}

.jd-map-loading{
  opacity:.7;
  font-weight:800;
}

.jd-map-open{
  display:inline-flex;
  gap:8px;
  align-items:center;
  text-decoration:none;
  font-weight: 900;
  color: var(--brand, #12bdb3);
  margin-top: 6px;
}

.jd-map-legend{
  margin-top: 10px;
  font-size: 13px;
  opacity: .85;
  font-weight: 700;
}

/* ===== Live mini-card dentro del popup ===== */
.jd-map-live{
  margin: 10px 0 10px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--st) 40%, rgba(0,0,0,.12));
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 24px rgba(0,0,0,.10);
  max-width: 100%;
  overflow: hidden; /* ✅ si algún navegador se pone tonto, lo corta aquí */
}

html[data-theme="dark"] .jd-map-live{
  border-color: color-mix(in srgb, var(--st) 35%, rgba(255,255,255,.14));
  background: rgba(17,20,24,.78);
  box-shadow: 0 10px 26px rgba(0,0,0,.35);
}

/* ✅ Grid 2 columnas “blindado”: nunca empuja fuera */
.jd-map-live-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* ✅ min=0 evita overflow lateral */
  gap: 10px;
  width: 100%;
}

/* en móviles ultra estrechos, 1 columna */
@media (max-width: 360px){
  .jd-map-live-grid{
    grid-template-columns: 1fr;
  }
}

/* Tarjetitas */
.jd-map-live-grid .jd-metric{
  min-width: 0;                 /* ✅ permite encoger */
  padding: 9px 8px;             /* ✅ un pelín más estrechas */
  border-radius: 12px;
  background: rgba(0,0,0,.04);
  text-align: center;
  border: 1px solid rgba(0,0,0,.06);
}

html[data-theme="dark"] .jd-map-live-grid .jd-metric{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.08);
}

.jd-map-live-grid .jd-metric .v{
  display:block;
  font-size: 15px;
  font-weight: 950;
  letter-spacing: -.2px;
  line-height: 1.05;
  white-space: nowrap;          /* ✅ evita que “9.7°C” parta raro */
}

.jd-map-live-grid .jd-metric .k{
  display:block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 850;
  opacity: .82;
  line-height: 1.1;
}

.jd-map-live-upd{
  margin-top: 8px;
  font-size: 11px;
  font-weight: 850;
  opacity: .88;
  text-align: right;
}

/* Si tenemos 5 métricas, la última (lluvia) ocupa 2 columnas */
.jd-map-live-grid .jd-metric:last-child:nth-child(5){
  grid-column: 1 / -1;
}

.jd-map-help{
  margin: 6px 0 12px;
  font-size: 13px;
  font-weight: 650;
  opacity: .82;
  line-height: 1.35;
}

.jd-map-tip{
  margin-top: 10px;
  font-size: 12px;
  font-weight: 650;
  opacity: .75;
}
