/* =============================================================================
 * Technosense — mapa_red.css
 * -----------------------------------------------------------------------------
 * El mapa vivo de la red de monitoreo: el marco del mapa, la barra de estado,
 * las pestañas por módulo, el aviso de módulo sin sensores y los popups de los
 * marcadores. Lo usa el parcial mapa_red.php, y la página que lo incluye tiene
 * que cargar esta hoja en su <head>.
 *
 * Nació como parte de technosense-wx.css (la landing de soluciones) más un
 * bloque inline en esa página. Se separa para poner el mapa en la portada sin
 * cargar la hoja entera de la landing, y para que cuando la landing adopte el
 * parcial las dos páginas compartan UNA hoja: un mapa que se rompe en dos
 * sitios distintos es lo que se quiere evitar.
 *
 * Depende de main.css (tokens). Orden: main.css → [página].css → mapa_red.css
 * ============================================================================= */

/* ── Marco del mapa ──────────────────────────────────────────────────────────── */
.wx-map-wrap {
    position: relative;
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--line);
    background: var(--surface-3);
}

#wx-map {
    width: 100%;
    height: clamp(380px, 52vw, 580px);
    display: block;
}

/* Barra de estado sobre el mapa */
.wx-map-bar {
    position: absolute;
    top: 12px; left: 12px; right: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--sp-2) var(--sp-4);
    box-shadow: var(--shadow-sm);
    z-index: 10;
    flex-wrap: wrap;
}

.wx-map-bar-left {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    color: var(--sky-900);
}

.wx-map-bar-right {
    font-size: var(--fs-xs);
    color: var(--muted);
}

.wx-live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse-dot 2s infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%,100% { opacity: 1; }
    50%      { opacity: .3; }
}

/* ── Pestañas por módulo ─────────────────────────────────────────────────────── */
.wx-mod-tabs {
    display: flex;
    gap: .5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 0 0 1.25rem;
}

.wx-mod-tab {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.15rem;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: var(--white);
    color: var(--ink-soft);
    font: 600 .92rem/1 var(--font-body);
    cursor: pointer;
    transition: all .18s ease;
    white-space: nowrap;
}

.wx-mod-tab:hover {
    border-color: var(--muted);
    color: var(--ink);
    transform: translateY(-1px);
}

.wx-mod-tab.active {
    background: var(--sky-900);
    border-color: var(--sky-900);
    color: #fff;
    box-shadow: 0 4px 14px rgba(12,74,110,.25);
}

.wx-mod-tab svg {
    width: 1em; height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.wx-mod-count {
    display: inline-block;
    min-width: 1.35rem;
    padding: .1rem .35rem;
    border-radius: 999px;
    background: rgba(148,163,184,.2);
    font-size: .72rem;
    font-weight: 700;
    text-align: center;
}

.wx-mod-tab.active .wx-mod-count { background: rgba(255,255,255,.22); }

/* ── Aviso: módulo sin sensores publicados, o mapa no disponible ─────────────── */
.wx-map-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248,250,252,.94);
    z-index: 5;
    padding: 2rem;
    text-align: center;
}

.wx-map-empty-in {
    max-width: 30rem;
    color: var(--ink-soft);
    font-size: var(--fs-base);
    line-height: 1.6;
}

.wx-map-empty-in svg {
    width: 2.4rem; height: 2.4rem;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: block;
    margin: 0 auto .75rem;
}

.wx-map-empty-in b {
    color: var(--ink);
    display: block;
    margin-bottom: .4rem;
    font-size: 1.05rem;
}

/* ── Popup del marcador (InfoWindow de Google con nuestro contenido) ────────── */
.wx-popup {
    font-family: var(--font-body, "Inter", sans-serif);
    min-width: 200px;
    max-width: 260px;
}

.wx-popup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
}

.wx-popup-item { display: flex; flex-direction: column; }
.wx-popup-val  { font-size: 1.05rem; font-weight: 700; color: #0c4a6e; }
.wx-popup-lbl  { font-size: .7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: .05em; }

.wx-popup-foot {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    font-size: .72rem;
    color: #94a3b8;
}

/* Condición actual (encabezado del popup de meteo) */
.wx-popup-cond {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.wx-popup-cond-txt { display: flex; flex-direction: column; gap: 2px; }
.wx-popup-cond-txt strong { font-size: .86rem; color: #0c4a6e; line-height: 1.2; }

.wx-popup-badge {
    font-size: .64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #92400e;
    background: rgba(245,158,11,.14);
    padding: .1rem .4rem;
    border-radius: 4px;
    align-self: flex-start;
}

/* Pronóstico SMN a 3 días, dentro del popup de meteo */
.wx-fc { margin-top: 10px; padding-top: 8px; border-top: 1px solid #e2e8f0; }

.wx-fc-head {
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #94a3b8;
    margin-bottom: 6px;
}

.wx-fc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }

.wx-fc-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    background: #f8fafc;
    border-radius: 6px;
}

.wx-fc-lbl { font-size: .66rem; font-weight: 700; text-transform: uppercase; color: #64748b; }

.wx-fc-temp {
    font-family: "JetBrains Mono", "SF Mono", monospace;
    font-size: .72rem;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
}

.wx-fc-temp b { color: #0c4a6e; font-weight: 700; }
.wx-fc-rain   { font-size: .62rem; font-weight: 700; color: #3b82f6; }

/* Cabecera del popup de aire (índice) y de agua (pH) */
.wx-idx {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem .7rem;
    border-radius: .6rem;
    background: #f1f5f9;
    margin-bottom: .6rem;
}

.wx-idx-num {
    width: 2.9rem; height: 2.9rem;
    border-radius: .55rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font: 800 1.2rem/1 var(--font-body);
}

.wx-idx-txt strong { display: block; font-size: .95rem; color: #0f172a; }
.wx-idx-txt span   { font-size: .78rem; color: #64748b; }
