/* Estilos mejorados para el módulo de mapas */

/* Controles de leaflet personalizados */
.leaflet-control-zoom {
    margin-top: 60px !important;
}

.leaflet-control-layers {
    margin-top: 10px !important;
    margin-right: 430px !important;
}

.side-panel.collapsed ~ #mapContainer .leaflet-control-layers {
    margin-right: 80px !important;
}

#mapaPage.panel-collapsed .leaflet-control-layers {
    margin-right: 80px !important;
}

/* Marcadores personalizados */
.cruce-marker div {
    transition: all 0.2s ease;
}

.cruce-marker:hover div {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4) !important;
}

.poi-marker div {
    transition: all 0.2s ease;
}

.poi-marker:hover div {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4) !important;
}

.geo-marker div {
    transition: all 0.2s ease;
}

.geo-marker:hover div {
    transform: scale(1.2);
}

/* Street View marker */
.street-view-marker {
    background: transparent;
    border: none;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

/* Popup personalizado */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.leaflet-popup-content {
    margin: 13px 19px;
    line-height: 1.5;
}

.leaflet-popup-content strong {
    color: var(--primary-color);
}

/* Panel lateral mejorado */
.side-panel {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.side-panel-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.side-panel-content::-webkit-scrollbar {
    width: 8px;
}

.side-panel-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.side-panel-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.side-panel-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Lista de elementos mejorada */
.list-group-item-action {
    transition: all 0.2s ease;
}

.list-group-item-action:hover {
    background-color: #f8f9fa;
    transform: translateX(5px);
}

.list-group-item-action.active {
    background-color: var(--primary-color) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
}

.list-group-item-action.active small {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Toolbar del mapa */
.map-toolbar {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -20px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.map-toolbar .btn {
    transition: all 0.2s ease;
}

.map-toolbar .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Layer switcher */
.layer-switcher {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Search box */
.search-box {
    animation: slideRight 0.3s ease;
}

@keyframes slideRight {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(44, 62, 80, 0.25);
}

/* File grid mejorado */
.file-grid {
    max-height: 300px;
    overflow-y: auto;
}

.file-item {
    position: relative;
    overflow: hidden;
}

.file-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.5) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.file-item:hover::before {
    transform: translateX(100%);
}

.file-item i {
    color: var(--primary-color);
}

/* Tabs personalizados */
.nav-tabs .nav-link {
    border: none;
    color: #6c757d;
    transition: all 0.2s ease;
}

.nav-tabs .nav-link:hover {
    border: none;
    color: var(--primary-color);
    transform: translateY(-2px);
}

.nav-tabs .nav-link.active {
    border: none;
    border-bottom: 3px solid var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Animación para marcadores nuevos */
@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.leaflet-marker-icon {
    animation: bounceIn 0.5s ease;
}

/* Estados de carga */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .side-panel {
        width: 100% !important;
    }
    
    .side-panel.collapsed {
        transform: translateX(100%);
    }
    
    #mapContainer.expanded {
        width: 100% !important;
    }
    
    .map-toolbar {
        flex-wrap: wrap;
        left: 10px !important;
        transform: none !important;
        right: 10px;
        width: auto;
    }
    
    .layer-switcher {
        right: 10px !important;
        top: 130px !important;
    }

    .search-box {
        right: 10px !important;
        left: auto !important;
        top: 70px !important;
        width: min(320px, calc(100% - 20px)) !important;
    }
    
    .street-view-pip {
        width: 200px;
        height: 150px;
    }
}

/* Modo oscuro */
@media (prefers-color-scheme: dark) {
    .side-panel {
        background: rgba(33, 37, 41, 0.95);
        color: #e9ecef;
    }
    
    .side-panel-header {
        background: linear-gradient(135deg, #343a40 0%, #212529 100%);
    }
    
    .list-group-item {
        background-color: #2d3238;
        color: #e9ecef;
        border-color: #495057;
    }
    
    .list-group-item-action:hover {
        background-color: #343a40;
    }
    
    .doc-panel {
        background: #343a40;
        color: #e9ecef;
    }
    
    .file-item {
        background: #2d3238;
        border-color: #495057;
        color: #e9ecef;
    }
}

/* Mejoras de accesibilidad */
.btn:focus,
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.25rem rgba(44, 62, 80, 0.25);
}

/* Transiciones suaves */
* {
    transition-property: background-color, border-color, box-shadow;
    transition-duration: 0.15s;
    transition-timing-function: ease-in-out;
}
