/*
 * =========================================================
 * Mapas raster - interfaz moderna
 * =========================================================
 * Estilos locales para no alterar los visores Leaflet normales.
 */
.saih-raster-map-shell {
    position: relative;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

#mapaSaih {
    width: 100%;
    min-height: 480px;
}

/* Título flotante del mapa. */
#queprediccion {
    position: absolute;
    top: 14px;
    right: 18px;
    z-index: 1010;
    transform: none;

    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid var(--saih-raster-border);
    border-radius: 9px;
    box-shadow: 0 3px 10px rgba(34, 67, 80, 0.13);
    backdrop-filter: blur(4px);

    color: var(--saih-raster-text);
    font-family: 'Open Sans', Arial, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.045em;
    line-height: 1.2;
    text-transform: uppercase;
}

/*
 * Selector temporal.
 * Reproductor fijo arriba + lista con scroll propio.
 */
#tiempo.saih-raster-time-control {
    position: absolute;
    top: 46px;
    left: 12px;
    z-index: 1020;

    width: 90px;
    max-width: 90px;
    max-height: calc(100% - 60px);
    margin: 0;
    padding: 0;

    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.80);
    border: 1px solid var(--saih-raster-border);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(34, 67, 80, 0.16);
    backdrop-filter: blur(5px);

    font-family: 'Open Sans', Arial, sans-serif;
}

.saih-raster-time-header {
    padding: 7px;
    border-bottom: 1px solid #e3ebee;
    background: rgba(255, 255, 255, 0.34);
}

.saih-raster-time-kicker {
    margin-bottom: 5px;
    color: #718995;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-align: center;
    text-transform: uppercase;
}

.saih-raster-player {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.saih-raster-player-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0;

    border-radius: 7px;

    color: var(--saih-raster-text);
    font-family: inherit;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.saih-raster-player-btn:hover,
.saih-raster-player-btn:focus {
    background: var(--saih-raster-hover);
    border-color: #bfd1d7;
    color: var(--saih-raster-ink);
    outline: none;
}

.saih-raster-player-btn.is-active {
    background: var(--saih-raster-accent);
    border-color: var(--saih-raster-accent);
    color: #fff;
}

.saih-raster-time-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #b9c8ce transparent;
}

.saih-raster-time-list::-webkit-scrollbar {
    width: 6px;
}

.saih-raster-time-list::-webkit-scrollbar-thumb {
    background: #b9c8ce;
    border-radius: 999px;
}

#mapaSaih .leaflet-top.leaflet-right {
    top: 52px !important;
    right: 10px !important;
}

#tiempo .saih-raster-time-list ul {
    min-height: 0 !important;
    margin: 0;
    padding: 6px 0;
    background: transparent;
    border-radius: 0;
}

#tiempo .saih-raster-time-list li {
    margin: 0;
    padding: 4px 6px;
    color: #526d78;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    border-radius: 6px;
}

#tiempo .saih-raster-time-list li:hover {
    background: rgba(238, 244, 246, 0.92);
    color: var(--saih-raster-ink);
}

#tiempo .saih-raster-time-list li.activo {
    margin: 1px 6px;
    padding-left: 2px;
    padding-right: 2px;
    background: var(--saih-raster-accent);
    color: #fff;
    font-weight: 700;
}

/* Leyenda compacta dentro del mapa. */
#leyen.saih-raster-legend-wrap {
    position: absolute;
    right: 18px;
    bottom: 14px;
    z-index: 1015;

    width: auto;
    max-width: calc(100% - 245px);
    padding: 0;
    float: none;
}

#leyenda.saih-raster-legend {
    position: static;
    width: auto;
    max-width: 920px;
    margin: 0;
    padding: 0;
    transform: none;

    overflow: hidden;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid var(--saih-raster-border);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(34, 67, 80, 0.15);
    backdrop-filter: blur(5px);

    color: #354f5b;
    font-family: 'Open Sans', Arial, sans-serif;
    font-weight: 400;
    text-align: left;
}

.saih-raster-legend-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22px;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 9px;

    background: rgba(255, 255, 255, 0.20);
    border: 0;
    border-bottom: 1px solid rgba(220, 230, 234, 0.9);
    color: var(--saih-raster-text);
    text-align: left;
    cursor: pointer;
}

.saih-raster-legend-header:hover,
.saih-raster-legend-header:focus {
    background: rgba(238, 244, 246, 0.72);
    outline: none;
}

.saih-raster-legend-kicker {
    margin-bottom: 1px;
    color: #748c96;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

.saih-raster-legend-title {
    color: var(--saih-raster-ink);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}

.saih-raster-legend-chevron {
    color: #78909a;
    font-size: 10px;
    text-align: center;
    transition: transform 0.15s ease;
}

#leyenda.is-collapsed .saih-raster-legend-chevron {
    transform: rotate(-90deg);
}

#leyenda.is-collapsed .saih-raster-legend-body {
    display: none;
}

.saih-raster-legend-body {
    padding: 7px 8px 6px;
}

#leyenda .leyenda-colores {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0 !important;
}

#leyenda .leyenda-colores li {
    min-width: 43px;
    margin: 0;
    padding: 3px 6px;
    border-radius: 5px;
    font-size: 9.5px;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
}

#leyenda .leyenda-colores li:first-child {
    min-width: auto !important;
    width: auto !important;
    padding-left: 2px;
    padding-right: 6px;
    background: transparent !important;
    color: var(--saih-raster-text) !important;
}

#leyenda .leyenda-colores li:last-child {
    min-width: auto;
    padding-left: 4px;
    padding-right: 2px;
    background: transparent !important;
    color: #526d78 !important;
}

#leyendaAemet {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(220, 230, 234, 0.85);
    color: #748c96;
    font-size: 9px;
    font-weight: 600;
}

/* Cabecera de selección del mapa raster. */
#meteorologia .well,
#vistamapa .well {
    min-height: 72px;
    margin-bottom: 8px;
    padding: 9px 11px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--saih-raster-border);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(34, 67, 80, 0.08);
}

#meteorologia ul.list-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 0 0 7px 0 !important;
    padding: 0 !important;
}

#meteorologia ul.list-inline > li {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    margin: 0;
    padding: 0 10px;

    background: var(--saih-raster-surface);
    border: 1px solid #dce5e8;
    border-radius: 8px;
    color: var(--saih-raster-text);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
}

#meteorologia ul.list-inline > li:hover {
    background: var(--saih-raster-hover);
    border-color: #bfd1d7;
    color: var(--saih-raster-ink);
    text-decoration: none;
}

#meteorologia ul.list-inline > li.activo {
    background: var(--saih-raster-accent);
    border-color: var(--saih-raster-accent);
    color: #fff;
    box-shadow: 0 2px 6px rgba(57, 117, 140, 0.18);
}

#meteorologia #no-click {
    color: #708791;
    font-size: 10.5px;
}

#vistamapa .well {
    position: relative;
}

#vistamapa .well > strong {
    color: var(--saih-raster-ink);
    font-size: 12px;
}

#vistamapa ul.list-inline {
    position: absolute;
    right: 10px;
    bottom: 9px;
    margin: 0 !important;
}

#mostrarEstaciones {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    min-height: 28px;
    margin: 0 !important;
    padding: 0 10px !important;

    border-radius: 8px;
    color: var(--saih-raster-text) !important;
    font-size: 10.5px;
    font-weight: 700;
    cursor: pointer;
}

#mostrarEstaciones:hover {
    background: var(--saih-raster-hover);
    border-color: #bfd1d7;
    color: var(--saih-raster-ink) !important;
}

/* Estado activo claramente legible sobre fondo azul. */
#vistamapa #mostrarEstaciones.activo {
    background: var(--saih-raster-accent) !important;
    border-color: var(--saih-raster-accent) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 7px rgba(41, 79, 96, 0.16);
}

#vistamapa #mostrarEstaciones.activo .texto-estaciones,
#vistamapa #mostrarEstaciones.activo .icon-estaciones {
    color: #ffffff !important;
}

/* Controles Leaflet limitados al mapa raster. */
#mapaSaih .leaflet-control-layers,
#mapaSaih .leaflet-bar {
    border: 0;
    box-shadow: 0 2px 8px rgba(34, 67, 80, 0.15);
}

#mapaSaih .leaflet-control-layers-toggle,
#mapaSaih .leaflet-bar a {
    width: 34px;
    height: 34px;
    line-height: 34px;
    box-sizing: border-box;
}

#mapaSaih .leaflet-control-layers-toggle {
    background-size: 18px 18px;
}



/*
 * =========================================================
 * Popup de estaciones raster
 * =========================================================
 */
#mapaSaih .saih-raster-popup-shell .leaflet-popup-content-wrapper {
    overflow: hidden;
    padding: 0;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--saih-raster-border);
    border-radius: 11px;
    box-shadow: 0 8px 24px rgba(34, 67, 80, 0.20);
    backdrop-filter: blur(6px);
}

#mapaSaih .saih-raster-popup-shell .leaflet-popup-content {
    width: auto !important;
    min-width: 270px;
    max-width: 340px;
    margin: 0;
    color: #354f5b;
    font-family: 'Open Sans', Arial, sans-serif;
    font-size: 11px;
    line-height: 1.35;
}

#mapaSaih .saih-raster-popup-shell .leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.97);
    box-shadow: none;
}

#mapaSaih .saih-raster-popup-shell .leaflet-popup-close-button {
    top: 7px;
    right: 7px;
    width: 24px;
    height: 24px;
    padding: 0;
    color: #78909a;
    font-size: 19px;
    font-weight: 400;
    line-height: 22px;
    border-radius: 7px;
}

#mapaSaih .saih-raster-popup-shell .leaflet-popup-close-button:hover,
#mapaSaih .saih-raster-popup-shell .leaflet-popup-close-button:focus {
    background: var(--saih-raster-hover);
    color: var(--saih-raster-ink);
    outline: none;
}

.saih-raster-popup {
    min-width: 0;
}

.saih-raster-popup__header {
    padding: 11px 38px 10px 12px;
    background: rgba(238, 244, 246, 0.62);
    border-bottom: 1px solid #e2eaed;
}

.saih-raster-popup__kicker {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 14px;
    margin-bottom: 3px;
    color: #718995;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.055em;
    line-height: 1.2;
    text-transform: uppercase;
}

.saih-raster-popup__badge {
    display: inline-flex;
    align-items: center;
    min-height: 16px;
    padding: 0 5px;
    background: rgba(69, 104, 117, 0.10);
    border: 1px solid rgba(69, 104, 117, 0.16);
    border-radius: 999px;
    color: #526f7a;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}

.saih-raster-popup__title {
    display: flex;
    align-items: baseline;
    gap: 6px;
    color: var(--saih-raster-ink);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
}

.saih-raster-popup__station {
    flex: 0 0 auto;
    color: var(--saih-raster-accent);
    font-weight: 800;
}

.saih-raster-popup__name {
    min-width: 0;
}

.saih-raster-popup__body {
    padding: 8px 12px 10px;
}

.saih-raster-popup__section + .saih-raster-popup__section {
    margin-top: 8px;
    padding-top: 7px;
    border-top: 1px solid #e7edef;
}

.saih-raster-popup__section-title {
    margin-bottom: 3px;
    color: #718995;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

.saih-raster-popup__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 14px;
    min-height: 24px;
    padding: 4px 0;
}

.saih-raster-popup__row + .saih-raster-popup__row {
    border-top: 1px solid rgba(231, 237, 239, 0.75);
}

.saih-raster-popup__label {
    color: #5b737e;
    font-size: 10.5px;
    font-weight: 500;
}

.saih-raster-popup__value {
    color: var(--saih-raster-ink);
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
    text-align: right;
}

.saih-raster-popup__raw {
    color: #526d78;
    font-size: 10.5px;
    line-height: 1.45;
}

.saih-raster-popup__raw b,
.saih-raster-popup__raw strong {
    color: var(--saih-raster-ink);
}

.saih-raster-popup__raw table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
}

.saih-raster-popup__raw td,
.saih-raster-popup__raw th {
    padding: 4px 5px;
    border-bottom: 1px solid #e7edef;
    font-size: 10px;
}

.saih-raster-popup__empty {
    padding: 3px 0;
    color: #80949d;
    font-size: 10.5px;
    font-style: italic;
}

@media (max-width: 900px) {
    #queprediccion {
        display: none;
    }

    #leyen.saih-raster-legend-wrap {
        left: 112px;
        right: 10px;
        max-width: none;
    }

    #leyenda.saih-raster-legend {
        max-width: 100%;
    }
}

@media (max-width: 620px) {
    #mapaSaih .saih-raster-popup-shell .leaflet-popup-content {
        min-width: 230px;
        max-width: min(310px, calc(100vw - 46px));
    }

    #tiempo.saih-raster-time-control {
        top: 56px;
        left: 8px;
        width: 82px;
        max-width: 82px;
        max-height: calc(100% - 72px);
    }

    #leyen.saih-raster-legend-wrap {
        left: 8px;
        right: 8px;
        bottom: 8px;
    }

    #leyenda .leyenda-colores li {
        min-width: 38px;
        padding: 3px 4px;
        font-size: 9px;
    }
}
