/* 
 * MAP STYLES - OSM RECORRIDO
 * Archivo: map-styles.css
 * Descripción: Estilos específicos para mapas y visualización de rutas
 */

/* ========================================
   MAPA BASE
   ======================================== */

.leaflet-container {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.leaflet-popup-content {
    margin: 12px 16px;
    line-height: 1.4;
}

.leaflet-popup-tip {
    background: white;
    border: 1px solid #ccc;
}

/* ========================================
   MARCADORES PERSONALIZADOS
   ======================================== */

.custom-marker {
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 12px;
}

.marker-start {
    background: #10b981;
    width: 24px;
    height: 24px;
}

.marker-end {
    background: #ef4444;
    width: 24px;
    height: 24px;
}

.marker-waypoint {
    background: #3b82f6;
    width: 20px;
    height: 20px;
}

.marker-stop {
    background: #f59e0b;
    width: 18px;
    height: 18px;
}

.marker-speed-high {
    background: #dc2626;
    width: 16px;
    height: 16px;
}

.marker-speed-normal {
    background: #10b981;
    width: 16px;
    height: 16px;
}

.marker-speed-low {
    background: #6b7280;
    width: 16px;
    height: 16px;
}

/* ========================================
   LÍNEAS DE RUTA
   ======================================== */

.route-line {
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.route-line-normal {
    stroke: #3b82f6;
    stroke-opacity: 0.8;
}

.route-line-high-speed {
    stroke: #dc2626;
    stroke-opacity: 0.9;
    stroke-width: 4;
}

.route-line-low-speed {
    stroke: #6b7280;
    stroke-opacity: 0.6;
    stroke-width: 2;
}

.route-line-stop {
    stroke: #f59e0b;
    stroke-opacity: 0.7;
    stroke-dasharray: 5, 5;
}

/* ========================================
   POPUPS DE INFORMACIÓN
   ======================================== */

.route-popup {
    min-width: 200px;
}

.route-popup-header {
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e5e7eb;
}

.route-popup-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    font-size: 13px;
}

.route-popup-label {
    font-weight: 600;
    color: #6b7280;
}

.route-popup-value {
    color: #374151;
}

.route-popup-actions {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.route-popup-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin-right: 6px;
}

.route-popup-btn:hover {
    background: #2563eb;
}

/* ========================================
   CONTROLES PERSONALIZADOS - POSICIÓN ORIGINAL
   ======================================== */

.custom-controls {
    position: absolute !important;
    top: 10px !important; /* Posición original */
    right: 10px !important;
    z-index: 799 !important; /* Debajo del header (800) */
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
}

.custom-control-btn {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: background-color 0.2s ease;
}

.custom-control-btn:hover {
    background: #f9fafb;
}

.custom-control-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.custom-control-btn i {
    font-size: 16px;
}

/* ========================================
   LEGENDA
   ======================================== */

.map-legend {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    font-size: 12px;
}

.map-legend-title {
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
}

.map-legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.map-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid #ccc;
}

.map-legend-line {
    width: 20px;
    height: 3px;
    margin-right: 8px;
    border-radius: 2px;
}

/* ========================================
   ANIMACIONES
   ======================================== */

.route-animation {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawRoute 3s ease-in-out forwards;
}

@keyframes drawRoute {
    to {
        stroke-dashoffset: 0;
    }
}

.marker-pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .custom-controls {
        top: 5px;
        right: 5px;
    }
    
    .custom-control-btn {
        padding: 6px;
    }
    
    .custom-control-btn i {
        font-size: 14px;
    }
    
    .map-legend {
        bottom: 5px;
        left: 5px;
        padding: 8px;
        font-size: 11px;
    }
    
    .route-popup {
        min-width: 150px;
    }
    
    .route-popup-info {
        font-size: 12px;
    }
}

[data-theme="dark"] .leaflet-popup-content-wrapper {
    background: #20232a;
    color: #f9fafb;
}

[data-theme="dark"] .leaflet-popup-tip {
    background: #20232a;
    border-color: #374151;
}

[data-theme="dark"] .route-popup-header {
    color: #f9fafb;
    border-bottom-color: #4b5563;
}

[data-theme="dark"] .route-popup-label {
    color: #9ca3af;
}

[data-theme="dark"] .route-popup-value {
    color: #d1d5db;
}

[data-theme="dark"] .route-popup-actions {
    border-top-color: #4b5563;
}

[data-theme="dark"] .custom-control-btn {
    background: #20232a;
    border-color: #374151;
    color: #f9fafb;
}

[data-theme="dark"] .custom-control-btn:hover {
    background: #374151;
}

[data-theme="dark"] .map-legend {
    background: #20232a;
    border-color: #374151;
    color: #f9fafb;
}

[data-theme="dark"] .map-legend-title {
    color: #f9fafb;
}

/* ========================================
   CONTROLES DE LEAFLET (ZOOM, ETC.)
   ======================================== */

/* Controles de Leaflet - POSICIÓN ORIGINAL */
.leaflet-control-container {
    position: relative !important;
    z-index: 799 !important; /* Debajo del header (800) */
}

/* Selector específico para el control de zoom */
.leaflet-control-zoom.leaflet-bar.leaflet-control {
    position: absolute !important;
    top: 10px !important; /* Posición original */
    left: 10px !important;
    z-index: 799 !important; /* Debajo del header (800) */
    margin: 0 !important;
}

/* Selector específico para el control de capas */
.leaflet-control-layers.leaflet-control {
    position: absolute !important;
    top: 10px !important; /* Posición original */
    right: 10px !important;
    z-index: 799 !important; /* Debajo del header (800) */
    margin: 0 !important;
}

/* Selector general para todos los controles de Leaflet */
.leaflet-control {
    z-index: 799 !important; /* Debajo del header (800) */
}

/* Estilos adicionales para asegurar que no haya conflictos */
#osm-map .leaflet-control-zoom {
    top: 10px !important; /* Posición original */
    left: 10px !important;
    z-index: 799 !important; /* Debajo del header (800) */
}

#osm-map .leaflet-control-layers {
    top: 10px !important; /* Posición original */
    right: 10px !important;
    z-index: 799 !important; /* Debajo del header (800) */
}

#osm-map .custom-controls {
    top: 10px !important; /* Posición original */
    right: 10px !important;
    z-index: 799 !important; /* Debajo del header (800) */
}

/* ========================================
   BARRA DE DESPLAZAMIENTO PERSONALIZADA
   ======================================== */

/* Estilos para la barra de desplazamiento en toda la página */
::-webkit-scrollbar {
    width: 8px; /* Más delgada */
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Tema oscuro para la barra de desplazamiento */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #374151;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #6b7280;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Estilos específicos para Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

[data-theme="dark"] * {
    scrollbar-color: #6b7280 #374151;
}

/* ========================================
   RESPONSIVE MEJORADO
   ======================================== */

@media (max-width: 768px) {
    .custom-controls {
        top: 5px !important; /* Posición original en móvil */
        right: 5px !important;
    }
    
    .leaflet-control-zoom.leaflet-bar.leaflet-control {
        top: 5px !important; /* Posición original en móvil */
        left: 5px !important;
    }
    
    .leaflet-control-layers.leaflet-control {
        top: 5px !important; /* Posición original en móvil */
        right: 5px !important;
    }
    
    .custom-control-btn {
        padding: 6px;
    }
    
    .custom-control-btn i {
        font-size: 14px;
    }
    
    .map-legend {
        bottom: 5px;
        left: 5px;
        padding: 8px;
        font-size: 11px;
    }
    
    .route-popup {
        min-width: 150px;
    }
    
    .route-popup-info {
        font-size: 12px;
    }
    
    /* Barra de desplazamiento más delgada en móvil */
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
}
