/* Mapa público de intervenciones */
.mapa-page {
    position: relative;
    display: flex;
    flex-direction: column;
    margin-top: 92px;
    min-height: calc(100vh - 92px);
    height: calc(100vh - 92px);
    background: #0b0b0b;
    color: #fff;
    overflow: hidden;
}

.mapa-page--embed {
    margin-top: 0;
    min-height: 100%;
    height: 100%;
}

.mapa-map-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
}

.mapa-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #111;
    z-index: 1;
}

.mapa-map .leaflet-container {
    font: inherit;
    background: #111;
    width: 100%;
    height: 100%;
}

.mapa-map.mapa-map--dark .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.95);
}

.mapa-map .leaflet-overlay-pane {
    z-index: 450;
}

.mapa-map .leaflet-overlay-pane canvas {
    z-index: 460;
}

.mapa-heat-canvas {
    pointer-events: none !important;
}

.mapa-map .leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.55) !important;
    color: rgba(255, 255, 255, 0.65);
}

.mapa-map .leaflet-control-attribution a {
    color: rgba(255, 255, 255, 0.85);
}

/* Botón filtros / fullscreen: mismo estilo claro que zoom Leaflet */
.leaflet-control-mapa-filtros a,
.mapa-fs-control a.mapa-fs-btn {
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    background: #fff !important;
    color: #333 !important;
    border: none;
    text-decoration: none !important;
    cursor: pointer;
    box-shadow: none;
}

.leaflet-control-mapa-filtros a:hover,
.mapa-fs-control a.mapa-fs-btn:hover {
    background: #f4f4f4 !important;
}

.leaflet-control-mapa-filtros a.is-open {
    background: #E10613 !important;
    color: #fff !important;
}

.mapa-filtros-icon {
    display: block;
    pointer-events: none;
}

.mapa-fs-control a.mapa-fs-btn {
    font-size: 15px !important;
    font-weight: 700;
}

.mapa-map-wrap.mapa-pseudo-fs {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 100000 !important;
    background: #111;
}

/* Panel de filtros flotante sobre el mapa */
.mapa-filters-panel {
    position: absolute;
    top: 10px;
    left: 52px;
    z-index: 800;
    width: min(340px, calc(100% - 70px));
    max-height: calc(100% - 24px);
    overflow: auto;
    box-sizing: border-box;
    padding: 0.85rem 0.9rem 0.95rem;
    border-radius: 10px;
    background: rgba(16, 16, 16, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
}

.mapa-filters-panel.is-collapsed {
    display: none;
}

.mapa-filters-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mapa-filters-head strong {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
}

.mapa-filters-close {
    appearance: none;
    border: 0;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.75);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.mapa-filters-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.mapa-filter-block {
    margin-bottom: 0.85rem;
}

.mapa-filter-block:last-of-type {
    margin-bottom: 0.5rem;
}

.mapa-filter-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

.mapa-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.mapa-chip {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.82);
    border-radius: 8px;
    padding: 0.32rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.25;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.mapa-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.mapa-chip.is-active {
    background: rgba(225, 6, 19, 0.28);
    border-color: rgba(225, 6, 19, 0.9);
    color: #ff9aa0;
}

.mapa-heat-legend {
    margin-top: 0.15rem;
}

.mapa-heat-legend-bar {
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        #1e3a8a 0%,
        #2563eb 18%,
        #0d9488 38%,
        #eab308 58%,
        #f97316 72%,
        #E10613 86%,
        #7c3aed 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mapa-heat-legend-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.28rem;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

/* En Calor los puntos de color de tipo no representan el mapa */
.mapa-filters-panel[data-vista="calor"] #mapaLeyendaCalor {
    display: block;
}
.mapa-filters-panel[data-vista="calor"] .mapa-tipo-dot {
    opacity: 0.35;
}
.mapa-filters-panel[data-vista="zonas"] #mapaLeyendaCalor {
    display: none;
}
.mapa-filters-panel[data-vista="zonas"] .mapa-tipo-dot {
    opacity: 1;
}
.mapa-filters-panel[data-vista="ambos"] #mapaLeyendaCalor {
    display: block;
}
.mapa-filters-panel[data-vista="ambos"] .mapa-tipo-dot {
    opacity: 1;
}

.mapa-tipos {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.45rem;
}

.mapa-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.15rem 0;
    user-select: none;
}

.mapa-switch-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.88);
    min-width: 0;
}

.mapa-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.mapa-switch-track {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.18s ease, border-color 0.18s ease;
}

.mapa-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: transform 0.18s ease;
}

.mapa-switch input:checked + .mapa-switch-track {
    background: rgba(225, 6, 19, 0.85);
    border-color: rgba(225, 6, 19, 0.95);
}

.mapa-switch input:checked + .mapa-switch-track .mapa-switch-thumb {
    transform: translateX(18px);
}

.mapa-switch input:focus-visible + .mapa-switch-track {
    outline: 2px solid rgba(225, 6, 19, 0.55);
    outline-offset: 2px;
}

.mapa-tipo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mapa-tipo-1,
.mapa-tipo-5 { background: #E10613; }
.mapa-tipo-2 { background: #ffaa00; }
.mapa-tipo-3 { background: #3b82f6; }
.mapa-tipo-4 { background: #22c55e; }

.mapa-filter-block input[type="search"] {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 0.86rem;
}

.mapa-filter-block input[type="search"]::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.mapa-filter-stats {
    margin-top: 0.35rem;
    padding-top: 0.7rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.6);
}

.mapa-filter-stats strong {
    color: #fff;
    margin-right: 0.3rem;
    font-size: 1.05rem;
}

.mapa-popup {
    min-width: 180px;
    font-size: 0.88rem;
    line-height: 1.35;
    color: #111;
}

.mapa-popup a {
    color: #E10613;
    font-weight: 700;
}

.mapa-popup .mapa-popup-meta {
    margin: 0.25rem 0 0.45rem;
    color: #555;
    font-size: 0.8rem;
}

@media (max-width: 720px) {
    .mapa-page {
        margin-top: 84px;
        min-height: calc(100vh - 84px);
        height: calc(100vh - 84px);
    }
    .mapa-page--embed {
        margin-top: 0;
        min-height: 100%;
        height: 100%;
    }
    .mapa-filters-panel {
        left: 10px;
        right: 10px;
        width: auto;
        top: 52px;
    }
}
