/* =====================================================================
   MAPA INTERACTIVO DEL ATLÁNTICO - SCA Regional Atlántico
   Pines pulsantes (radar) · Tooltip enriquecido · Filtros · Buscador
   ===================================================================== */

:root {
    --map-primary: #cc3333;
    --map-primary-deep: #991b1b;
    --map-bg: #ffffff;
    --map-border: #e5e7eb;
    --map-text: #1f2937;
    --map-muted: #6b7280;
    --map-soft-bg: #f8fafc;
    --map-zone-costa: #0891b2;
    --map-zone-centro: #d97706;
    --map-zone-sur: #16a34a;
}

/* ---------------------------------------------------------------------
   Toolbar superior: Buscador + Filtros
   --------------------------------------------------------------------- */
.map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--map-border);
    background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
}

.map-search-wrap {
    position: relative;
    flex: 1;
    min-width: 240px;
    max-width: 360px;
}

.map-search-wrap .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.95rem;
    pointer-events: none;
    opacity: 0.55;
}

.map-search-input {
    width: 100%;
    padding: 0.7rem 2.5rem 0.7rem 2.6rem;
    font-size: 0.92rem;
    font-family: inherit;
    border: 1px solid var(--map-border);
    border-radius: 999px;
    background: white;
    color: var(--map-text);
    outline: none;
    transition: all 0.25s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.map-search-input::placeholder {
    color: #9ca3af;
}

.map-search-input:focus {
    border-color: var(--map-primary);
    box-shadow: 0 0 0 4px rgba(204, 51, 51, 0.10);
    background: white;
}

.search-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border: none;
    background: var(--map-border);
    color: var(--map-text);
    border-radius: 50%;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.search-clear:hover {
    background: var(--map-primary);
    color: white;
    transform: translateY(-50%) rotate(90deg);
}

/* ---------------------------------------------------------------------
   Chips de filtro por subregión
   --------------------------------------------------------------------- */
.map-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem 0.55rem 0.9rem;
    border: 1px solid var(--map-border);
    background: white;
    color: var(--map-text);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    line-height: 1;
}

.filter-chip .chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--map-muted);
    transition: all 0.25s ease;
}

.filter-chip[data-zone="todos"] .chip-dot { background: var(--map-primary); }
.filter-chip[data-zone="costa"] .chip-dot { background: var(--map-zone-costa); }
.filter-chip[data-zone="centro"] .chip-dot { background: var(--map-zone-centro); }
.filter-chip[data-zone="sur"] .chip-dot { background: var(--map-zone-sur); }

.filter-chip .chip-count {
    background: var(--map-soft-bg);
    color: var(--map-muted);
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 700;
    margin-left: 0.25rem;
    transition: all 0.25s ease;
    font-variant-numeric: tabular-nums;
}

.filter-chip:hover {
    border-color: var(--map-text);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.filter-chip.active {
    background: var(--map-text);
    color: white;
    border-color: var(--map-text);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.18);
}

.filter-chip.active .chip-dot {
    background: white !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.filter-chip.active .chip-count {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.filter-chip[data-zone="costa"].active { background: var(--map-zone-costa); border-color: var(--map-zone-costa); box-shadow: 0 6px 18px rgba(8, 145, 178, 0.3); }
.filter-chip[data-zone="centro"].active { background: var(--map-zone-centro); border-color: var(--map-zone-centro); box-shadow: 0 6px 18px rgba(217, 119, 6, 0.3); }
.filter-chip[data-zone="sur"].active { background: var(--map-zone-sur); border-color: var(--map-zone-sur); box-shadow: 0 6px 18px rgba(22, 163, 74, 0.3); }

/* ---------------------------------------------------------------------
   Hotspots / Pines pulsantes (efecto radar)
   --------------------------------------------------------------------- */
.map-wrapper {
    position: relative;
}

.map-hotspot {
    /* Anclamos en porcentajes (vienen del HTML) y centramos sobre las coordenadas */
    position: absolute;
    transform: translate(-50%, -50%);
    text-decoration: none;
    z-index: 5;
    /* Estado inicial para animación de entrada (oculto) */
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
    transition:
        opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.3s ease;
}

.map-hotspot.is-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Pin central */
.hotspot-pin {
    position: relative;
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--map-primary);
    border: 2.5px solid white;
    box-shadow:
        0 0 0 1px var(--map-primary),
        0 4px 10px rgba(204, 51, 51, 0.4);
    transition: all 0.25s ease;
    z-index: 2;
    cursor: pointer;
}

/* Halo radar pulsante */
.hotspot-pin::before,
.hotspot-pin::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--map-primary);
    transform: translate(-50%, -50%);
    z-index: -1;
    pointer-events: none;
}

.hotspot-pin::before {
    animation: radar-pulse 2.2s ease-out infinite;
    opacity: 0.6;
}

.hotspot-pin::after {
    animation: radar-pulse 2.2s ease-out infinite;
    animation-delay: 1.1s;
    opacity: 0.4;
}

@keyframes radar-pulse {
    0% {
        width: 14px;
        height: 14px;
        opacity: 0.55;
    }
    100% {
        width: 50px;
        height: 50px;
        opacity: 0;
    }
}

/* Pin de capital (Barranquilla) más grande y dorado */
.map-hotspot.is-capital .hotspot-pin {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #fbbf24, #d97706);
    box-shadow:
        0 0 0 2px var(--map-primary),
        0 6px 16px rgba(217, 119, 6, 0.5);
}

.map-hotspot.is-capital .hotspot-pin::before,
.map-hotspot.is-capital .hotspot-pin::after {
    width: 18px;
    height: 18px;
    background: #d97706;
}

@keyframes radar-pulse-capital {
    0% { width: 18px; height: 18px; opacity: 0.5; }
    100% { width: 60px; height: 60px; opacity: 0; }
}

.map-hotspot.is-capital .hotspot-pin::before { animation: radar-pulse-capital 2.2s ease-out infinite; }
.map-hotspot.is-capital .hotspot-pin::after { animation: radar-pulse-capital 2.2s ease-out infinite; animation-delay: 1.1s; }

/* Hover: pin más grande, pausamos el radar */
.map-hotspot:hover .hotspot-pin {
    transform: scale(1.5);
    box-shadow:
        0 0 0 2px var(--map-primary),
        0 8px 24px rgba(204, 51, 51, 0.6);
    z-index: 10;
}

.map-hotspot:hover .hotspot-pin::before,
.map-hotspot:hover .hotspot-pin::after {
    animation-play-state: paused;
}

/* Etiquetas */
.hotspot-label {
    position: absolute;
    background: rgba(15, 23, 42, 0.92);
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.label-top { bottom: calc(100% + 12px); left: 50%; transform: translate(-50%, 4px); }
.label-bottom { top: calc(100% + 12px); left: 50%; transform: translate(-50%, -4px); }
.label-left { right: calc(100% + 12px); top: 50%; transform: translate(4px, -50%); }
.label-right { left: calc(100% + 12px); top: 50%; transform: translate(-4px, -50%); }

.map-hotspot:hover .hotspot-label,
.map-hotspot.is-highlighted .hotspot-label {
    opacity: 1;
}

.map-hotspot:hover .label-top { transform: translate(-50%, 0); }
.map-hotspot:hover .label-bottom { transform: translate(-50%, 0); }
.map-hotspot:hover .label-left { transform: translate(0, -50%); }
.map-hotspot:hover .label-right { transform: translate(0, -50%); }

/* Estado atenuado por filtro o búsqueda */
.map-hotspot.is-dimmed {
    opacity: 0.18 !important;
    transform: translate(-50%, -50%) scale(0.85) !important;
    filter: grayscale(80%);
    pointer-events: none;
}

/* Estado destacado (búsqueda exitosa) */
.map-hotspot.is-highlighted {
    z-index: 30 !important;
}

.map-hotspot.is-highlighted .hotspot-pin {
    transform: scale(1.8);
    box-shadow:
        0 0 0 4px rgba(204, 51, 51, 0.3),
        0 0 0 2px var(--map-primary),
        0 8px 26px rgba(204, 51, 51, 0.7);
}

.map-hotspot.is-highlighted .hotspot-pin::before,
.map-hotspot.is-highlighted .hotspot-pin::after {
    animation-duration: 1.2s;
    opacity: 0.85;
}

/* Variantes de color por zona (sutil tinte sobre el pin) */
.map-hotspot[data-zone="costa"] .hotspot-pin { background: var(--map-primary); }
.map-hotspot[data-zone="centro"] .hotspot-pin { background: var(--map-primary); }
.map-hotspot[data-zone="sur"] .hotspot-pin { background: var(--map-primary); }

/* Cuando un filtro está activo, los pines de esa zona se resaltan con su color zone */
.map-wrapper.filter-costa .map-hotspot[data-zone="costa"] .hotspot-pin { background: var(--map-zone-costa); box-shadow: 0 0 0 1px var(--map-zone-costa), 0 4px 12px rgba(8, 145, 178, 0.45); }
.map-wrapper.filter-costa .map-hotspot[data-zone="costa"] .hotspot-pin::before,
.map-wrapper.filter-costa .map-hotspot[data-zone="costa"] .hotspot-pin::after { background: var(--map-zone-costa); }

.map-wrapper.filter-centro .map-hotspot[data-zone="centro"] .hotspot-pin { background: var(--map-zone-centro); box-shadow: 0 0 0 1px var(--map-zone-centro), 0 4px 12px rgba(217, 119, 6, 0.45); }
.map-wrapper.filter-centro .map-hotspot[data-zone="centro"] .hotspot-pin::before,
.map-wrapper.filter-centro .map-hotspot[data-zone="centro"] .hotspot-pin::after { background: var(--map-zone-centro); }

.map-wrapper.filter-sur .map-hotspot[data-zone="sur"] .hotspot-pin { background: var(--map-zone-sur); box-shadow: 0 0 0 1px var(--map-zone-sur), 0 4px 12px rgba(22, 163, 74, 0.45); }
.map-wrapper.filter-sur .map-hotspot[data-zone="sur"] .hotspot-pin::before,
.map-wrapper.filter-sur .map-hotspot[data-zone="sur"] .hotspot-pin::after { background: var(--map-zone-sur); }

/* ---------------------------------------------------------------------
   Tooltip enriquecido (mini-card flotante)
   --------------------------------------------------------------------- */
.map-tooltip {
    position: absolute;
    z-index: 50;
    min-width: 250px;
    max-width: 290px;
    background: white;
    border: 1px solid var(--map-border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 20px 50px rgba(15, 23, 42, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.97);
    transform-origin: top center;
    transition:
        opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0s 0.22s;
    pointer-events: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.map-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    cursor: pointer;
    transition:
        opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0s 0s;
}

.map-tooltip.is-visible:hover {
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 24px 60px rgba(204, 51, 51, 0.25);
    transform: translateY(-2px) scale(1);
}

.map-tooltip.is-visible:hover .tooltip-footer {
    color: var(--map-primary-deep);
    background: rgba(204, 51, 51, 0.06);
}

.tooltip-arrow {
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 14px;
    height: 14px;
    background: white;
    border-left: 1px solid var(--map-border);
    border-top: 1px solid var(--map-border);
}

.map-tooltip.arrow-bottom .tooltip-arrow {
    top: auto;
    bottom: -7px;
    border-left: none;
    border-top: none;
    border-right: 1px solid var(--map-border);
    border-bottom: 1px solid var(--map-border);
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.tooltip-icon {
    font-size: 1rem;
    line-height: 1;
}

.tooltip-zone {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--map-primary);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(204, 51, 51, 0.08);
    border: 1px solid rgba(204, 51, 51, 0.18);
}

.tooltip-zone.zone-costa { color: var(--map-zone-costa); background: rgba(8, 145, 178, 0.08); border-color: rgba(8, 145, 178, 0.18); }
.tooltip-zone.zone-centro { color: var(--map-zone-centro); background: rgba(217, 119, 6, 0.08); border-color: rgba(217, 119, 6, 0.18); }
.tooltip-zone.zone-sur { color: var(--map-zone-sur); background: rgba(22, 163, 74, 0.08); border-color: rgba(22, 163, 74, 0.18); }

.tooltip-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--map-text);
    margin: 0 0 0.4rem 0;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.tooltip-desc {
    font-size: 0.78rem;
    color: var(--map-muted);
    margin: 0 0 0.85rem 0;
    line-height: 1.45;
}

.tooltip-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--map-border);
}

.tooltip-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.tooltip-stat .stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--map-muted);
    font-weight: 700;
}

.tooltip-stat .stat-value {
    font-size: 0.92rem;
    color: var(--map-text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tooltip-footer {
    margin-top: 0.85rem;
    padding: 0.6rem 0.5rem;
    border-top: 1px solid var(--map-border);
    font-size: 0.72rem;
    color: var(--map-primary);
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.01em;
    border-radius: 0 0 6px 6px;
    transition: all 0.2s ease;
}

/* ---------------------------------------------------------------------
   Mensaje "Sin resultados" en búsqueda
   --------------------------------------------------------------------- */
.map-no-results {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 1rem 1.5rem;
    border-radius: 10px;
    border: 1px solid var(--map-border);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
    font-size: 0.9rem;
    color: var(--map-muted);
    z-index: 20;
    animation: fadeInScale 0.3s ease;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---------------------------------------------------------------------
   Footer del mapa
   --------------------------------------------------------------------- */
.map-footer {
    padding: 0.85rem 1.5rem;
    border-top: 1px solid var(--map-border);
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 0.78rem;
    color: var(--map-muted);
}

.map-footer-item strong {
    color: var(--map-primary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.map-footer-divider {
    color: var(--map-border);
    font-weight: 700;
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 768px) {
    .map-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
        padding: 1rem;
    }

    .map-search-wrap {
        max-width: none;
    }

    .map-filters {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .filter-chip {
        flex-shrink: 0;
        font-size: 0.78rem;
        padding: 0.5rem 0.85rem;
    }

    .map-tooltip {
        min-width: 220px;
        max-width: 240px;
        font-size: 0.85rem;
        padding: 0.85rem 0.95rem;
    }

    .tooltip-name {
        font-size: 1rem;
    }

    .hotspot-label {
        font-size: 0.65rem;
        padding: 0.18rem 0.5rem;
    }

    .map-footer {
        font-size: 0.72rem;
        justify-content: center;
        text-align: center;
        padding: 0.7rem 1rem;
    }
}

@media (max-width: 480px) {
    .hotspot-pin {
        width: 11px;
        height: 11px;
    }
    .map-hotspot.is-capital .hotspot-pin {
        width: 14px;
        height: 14px;
    }
}

/* ---------------------------------------------------------------------
   Accesibilidad: respetar prefers-reduced-motion
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .hotspot-pin::before,
    .hotspot-pin::after {
        animation: none;
    }
    .map-hotspot,
    .map-tooltip,
    .filter-chip {
        transition: opacity 0.15s ease;
    }
}
