/* Listado / filtros (views/liston/filtrar/index.php). Antes en un <style> incrustado en la vista. */
/* Enhanced Filter Sidebar Styles */
.enhanced-filters {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.08);
}

/* Asegurar que el header de filtros esté por encima de todo en móvil */
@media (max-width: 1199.98px) {

    /* Asegurar que todo el sidebar de filtros esté por encima de la navbar */
    .sidebar-filters,
    .sidebar-filters.active,
    .js-sidebar-filters-mobile,
    .js-sidebar-filters-mobile.active {
        z-index: 999999 !important;
        position: fixed !important;
        max-width: 100vw !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .sidebar-filters-header {
        z-index: 1000000 !important;
        position: sticky !important;
        top: 0 !important;
        background: white !important;
        width: 100% !important;
    }

    .sidebar-filters.active .sidebar-filters-header {
        z-index: 1000000 !important;
    }

    /* Asegurar que el body de los filtros no exceda el ancho */
    .sidebar-filters-body {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
}

.enhanced-filters .sidebar-filters-body {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

/* Search Box */
.search-box {
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.search-box:focus-within {
    background: white;
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.1);
}

.search-box input {
    background: transparent;
    border: none;
    box-shadow: none;
}

.search-box input:focus {
    background: transparent;
    border: none;
    box-shadow: none;
}

.btn-clear-search {
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.btn-clear-search:hover {
    opacity: 1;
}

/* Filter Sections */
.filter-section {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 0;
    transition: border-color 0.3s ease;
}

.filter-section:hover {
    border-color: var(--bs-primary);
}

.filter-header {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f1f3f4;
}

.filter-header:hover {
    background: #f8f9fa;
}

.filter-header .transition-transform {
    transition: transform 0.3s ease;
}

.filter-header[aria-expanded="true"] .transition-transform {
    transform: rotate(180deg);
}

.filter-header h5 i {
    width: 20px;
    text-align: center;
}

/* Custom Select */
.modern-select {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 8px 12px;
    background: #ffffff;
    transition: all 0.3s ease;
    width: 100%;
}

.modern-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.1);
}

/* Selected Filter Display */
.selected-filter-display {
    border: 1px solid #e9ecef;
    color: #495057;
}

/* Custom Checkboxes */
.custom-checkbox {
    padding: 8px 0;
    transition: background-color 0.2s ease;
    margin: 0;
    position: relative;
    display: flex;
    align-items: center;
}

.custom-checkbox:hover {
    background: #f8f9fa;
    padding: 8px;
    margin: 0 -8px;
    border-radius: 4px;
}

.custom-checkbox .form-check-input {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid #dee2e6;
    margin-top: 0;
    margin-left: 0 !important;
    margin-right: 8px;
    position: static;
    float: none;
    flex-shrink: 0;
}

.custom-checkbox .form-check-input:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.custom-checkbox .form-check-input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), 0.25);
}

.custom-checkbox .form-check-label {
    margin-left: 0;
    padding-left: 0;
    display: flex;
    align-items: center;
    flex: 1;
    margin-bottom: 0;
}

/* Characteristic Icons */
.characteristic-icon {
    width: 24px;
    height: 24px;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 12px;
}

/* Filter Count Badge */
.filter-count-badge {
    font-size: 0.75rem;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Action Buttons */
.filter-actions .btn-lg {
    padding: 12px 20px;
    font-weight: 600;
    border-radius: 8px;
}

.filter-actions .btn-outline-secondary,
.filter-actions .btn-outline-primary {
    border-width: 2px;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 1199.98px) {
    .enhanced-filters {
        border-radius: 0;
        box-shadow: none;
    }
}

/* Animation for collapse */
.collapse {
    transition: height 0.3s ease;
}

/* Map Container Styles */
.map-content {
    height: 100vh;
    min-height: 500px;
    position: relative;
    overflow: hidden;
}

.map-grid.map-full {
    width: 100%;
    height: 100% !important;
    min-height: 100vh;
}

#mapCanvasTwo {
    height: 100% !important;
    width: 100% !important;
    border-radius: 0px !important;
}

/* Responsive map */
@media (max-width: 1199.98px) {
    .map-content {
        display: none;
        height: 100vh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        z-index: 1050 !important;
        margin: 0 !important;
    }

    .map-content.active {
        display: block !important;
    }

    /* Asegurar que el mapa interno ocupe todo el espacio */
    .map-content.active #mapCanvasTwo,
    .map-content.active .map-grid {
        height: 100vh !important;
        width: 100% !important;
    }

    /* Botones de cerrar mapa visibles */
    .map-content.active .inner-wrap--top,
    .map-content.active .map-close-icon {
        z-index: 2000 !important;
        display: flex !important;
    }

    /* Controles de zoom de Leaflet visibles en móvil */
    .map-content .leaflet-control-container,
    .map-content .leaflet-top,
    .map-content .leaflet-bottom,
    .map-content .leaflet-control-zoom {
        z-index: 1500 !important;
    }

    .map-close-icon {
        background: white !important;
        width: 40px !important;
        height: 40px !important;
        cursor: pointer !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
    }

    .map-close-icon:hover {
        background: #f8f9fa !important;
    }

    /* Ocultar contenido cuando el mapa está activo */
    body.map-active .items-content {
        display: none !important;
    }

    /* Ocultar filtros cuando el mapa está activo */
    body.map-active .sidebar-filters {
        display: none !important;
    }

    /* Ocultar barra de búsqueda cuando el mapa está activo */
    body.map-active .search-bar {
        display: none !important;
    }
}

/* SOLUCIÓN DEFINITIVA: Forzar dropdown sobre mapa */
.navbar .dropdown-menu {
    z-index: 999999 !important;
    position: absolute !important;
}

.navbar .dropdown-menu.show {
    z-index: 999999 !important;
    position: absolute !important;
}

.navbar {
    z-index: 999998 !important;
    position: relative !important;
}

/* Reducir z-index del mapa y todos sus elementos EXCEPTO controles de zoom */
.map-content,
#mapCanvasTwo,
.leaflet-container,
.leaflet-popup-pane,
.leaflet-tooltip-pane,
.leaflet-shadow-pane,
.leaflet-overlay-pane,
.leaflet-map-pane,
.leaflet-marker-pane,
.leaflet-tile-pane {
    z-index: 100 !important;
}

/* Móvil con "Ver más guachinches" (assets/js/filtros.js): sin los números de página */
@media (max-width: 1199.98px) {
    .con-cargar-mas .pagination {
        display: none !important;
    }
}
