/**
 * Estilos para el Mapa Interactivo de Reportes
 * Rediseño: Floating Cards UI
 */

/* ===== LAYOUT PRINCIPAL ===== */
/* Nota: Las reglas globales de html/body se aplican en la sección principal más abajo si este archivo es concatenado, 
   pero por seguridad las definimos aquí también o las removemos si es duplicado. 
   Para evitar conflictos, mantendré este bloque limpio apuntando al contenedor.
*/
#map-container {
    display: block;
    width: 100%;
    height: calc(100% - 80px);
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ===== OVERLAYS CONTAINER ===== */
.map-overlays-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Permite clicks en el mapa */
    z-index: 1000;
    padding: 20px;
}

/* ===== FLOATING CARDS ===== */
.card-overlay {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    /* Reactiva clicks en las tarjetas */
    position: absolute;
    width: 300px;
    /* Ancho base */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    visibility: visible !important;
    /* Forzar visibilidad */
    opacity: 1 !important;
}

/* POSICIONES */
.stats-card {
    top: 20px;
    right: 20px;
    z-index: 1001;
}

.filters-card {
    top: 20px;
    left: 20px;
    z-index: 1002;
    /* Mayor que stats para que esté encima */
}

/* HEADER TOGGLE */
.card-header-toggle {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    user-select: none;
}

.card-header-toggle:hover {
    background: rgba(0, 0, 0, 0.02);
}

.card-content {
    padding: 20px;
    background: transparent;
}

/* ESTADO CHIPS (Filtros) */
.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    cursor: pointer;
    margin: 0;
    transition: all 0.2s;
}

.filter-chip input {
    display: none;
}

.filter-chip .badge {
    opacity: 0.5;
    transition: all 0.2s;
    font-size: 0.85rem;
    padding: 6px 12px;
}

.filter-chip input:checked+.badge {
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ESTADÍSTICAS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-item {
    text-align: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--color-gray-500);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ===== POPUPS (Sobrescritura para estilo moderno) ===== */
.custom-popup .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.custom-popup .leaflet-popup-content {
    margin: 0;
    width: 280px !important;
}

/**
 * Estilos para el Mapa Interactivo de Reportes
 * Rediseño: Floating Cards UI
 */

/* ===== LAYOUT PRINCIPAL ===== */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-y: hidden;
    /* Forzar sin scroll vertical */
}

/* ===== LAYOUT PRINCIPAL ===== */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-y: hidden;
    /* Forzar sin scroll vertical */
}

/* Necesario para que el mapa ocupe el 100% del alto disponible */
.main-content,
.main-content .container {
    height: 100%;
    padding: 0 !important;
    /* Eliminar padding para aprovechar todo el espacio */
    margin: 0 !important;
    max-width: none !important;
    /* Permitir ancho completo */
}

#map-container {
    display: block;
    width: 100%;
    /* Altura total menos el header (76px aprox, ponemos 80px por seguridad) */
    height: calc(100% - 80px);
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ===== OVERLAYS CONTAINER ===== */
.map-overlays-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Permite clicks en el mapa */
    z-index: 1000;
    padding: 20px;
}

/* ===== FLOATING CARDS ===== */
.card-overlay {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    /* Reactiva clicks en las tarjetas */
    position: absolute;
    width: 300px;
    /* Ancho base */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}

/* POSICIONES */
.stats-card {
    top: 20px;
    right: 20px;
}

.filters-card {
    top: 20px;
    left: 80px;
    /* Movido hacia la derecha para no tapar controles de zoom */
}

/* HEADER TOGGLE */
.card-header-toggle {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    user-select: none;
}

.card-header-toggle:hover {
    background: rgba(0, 0, 0, 0.02);
}

/* BOTÓN DE ACTUALIZACIÓN */
.btn-refresh-map {
    background: transparent;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--color-primary, #007bff);
    transition: all 0.3s ease;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.btn-refresh-map:hover {
    background: rgba(0, 123, 255, 0.1);
    transform: scale(1.1);
}

.btn-refresh-map i {
    font-size: 1.1rem;
    transition: transform 0.6s ease;
}

.btn-refresh-map.rotating i {
    animation: rotate360 1s ease-in-out;
}

@keyframes rotate360 {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.card-content {
    padding: 20px;
    background: transparent;
}

/* ESTADO CHIPS (Filtros) */
.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    cursor: pointer;
    margin: 0;
    transition: all 0.2s;
}

.filter-chip input {
    display: none;
}

.filter-chip .badge {
    opacity: 0.5;
    transition: all 0.2s;
    font-size: 0.85rem;
    padding: 6px 12px;
}

.filter-chip input:checked+.badge {
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ESTADÍSTICAS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-item {
    text-align: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--color-gray-500);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ===== POPUPS (Sobrescritura para estilo moderno) ===== */
.custom-popup .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.custom-popup .leaflet-popup-content {
    margin: 0;
    width: 280px !important;
}

/* ===== IMPROVED MARKERS ===== */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

.custom-marker {
    background: transparent;
    border: none;
}

.marker-pin {
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    background: linear-gradient(45deg, #dc3545, #ff6b6b);
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -18px 0 0 -18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
    animation: pulse 2s infinite;
    transition: all 0.3s ease;
}

.marker-pin::after {
    content: '';
    width: 20px;
    height: 20px;
    margin: 4px 0 0 4px;
    background: #fff;
    position: absolute;
    border-radius: 50%;
}

.marker-pin i {
    transform: rotate(45deg);
    color: #dc3545;
    font-size: 16px;
    z-index: 2;
    position: relative;
    top: 0;
    right: 0;
}

.marker-pin:hover {
    transform: rotate(-45deg) scale(1.1);
    background: linear-gradient(45deg, #c82333, #e4606d);
    z-index: 1000;
}

.marker-shadow {
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%) scaleY(0.5);
    filter: blur(4px);
}

/* ===== IMPROVED POPUPS ===== */
.popup-content {
    display: flex;
    flex-direction: column;
}

.popup-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.popup-no-image {
    width: 100%;
    height: 140px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-gray-400);
    border-bottom: 1px solid var(--color-gray-200);
}

.popup-body {
    padding: 20px;
    padding-top: 10px;
}

.popup-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--color-gray-900);
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.popup-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.popup-code {
    background: var(--color-gray-100);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--color-gray-600);
    letter-spacing: 0.5px;
}

.popup-description {
    font-size: 0.9rem;
    color: var(--color-gray-600);
    margin-bottom: 15px;
    line-height: 1.5;
}

.popup-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--color-gray-500);
    margin-bottom: 4px;
}

.popup-info-item i {
    color: var(--color-primary);
    width: 16px;
    text-align: center;
}

.btn-detalles {
    margin-top: 10px;
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 8px;
    width: 100%;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
    display: block;
}

.btn-detalles:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    color: white;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .map-overlays-container {
        padding: 10px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 10px;
        pointer-events: none;
    }

    .card-overlay {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        pointer-events: auto;
    }

    /* Stats Card - Primero (arriba) */
    .stats-card {
        order: 1;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .stat-item {
        padding: 8px 4px;
    }

    .stat-number {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    /* Filters Card - Segundo (debajo del resumen) */
    .filters-card {
        order: 2;
        max-height: 50vh;
        overflow-y: auto;
    }

    .card-content {
        padding: 15px;
    }
}