/* Variables CSS globales */
:root {
    /* Colores principales */
    --color-primary: #4B2883;
    --color-secondary: #0075BF;
    --color-accent: #6B46C1;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;

    /* Colores de superficie */
    --color-surface: #ffffff;
    --color-background: #0075BF;
    --color-text-primary: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-light: #9ca3af;
    --color-text-inverse: #ffffff;

    /* Sombras */
    --shadow-soft: 0 2px 15px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 25px rgba(0, 0, 0, 0.12);
    --shadow-large: 0 8px 40px rgba(0, 0, 0, 0.16);
    --shadow-brand: 0 4px 20px rgba(75, 40, 131, 0.25);

    /* Transiciones */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.4s ease;

    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;

    /* Espaciado */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 0.75rem;
    --space-lg: 1rem;
    --space-xl: 1.5rem;

    /* Opacidades comunes */
    --opacity-10: 0.1;
    --opacity-15: 0.15;
    --opacity-20: 0.2;
    --opacity-25: 0.25;
    --opacity-80: 0.8;
    --opacity-95: 0.95;

    /* Gradientes */
    --gradient-brand: linear-gradient(135deg, #4B2883 0%, #6B46C1 100%);
    --gradient-ocean: linear-gradient(135deg, #0075BF 0%, #005A8F 100%);
}

/* Estilos personalizados para el mapa */
.leaflet-container {
    font-family: 'Inter', sans-serif;
    background: #e3e3e3 !important; /* Soft gray for tile map background */
}

/* Custom Controls Styles */
.leaflet-control-rotate90 a,
.leaflet-control-custom {
    background-color: white !important;
    box-shadow: 0 1px 5px rgba(0,0,0,0.65);
    border-radius: 4px;
    transition: background-color 0.2s;
    color: #4B2883 !important;
}

.leaflet-control-rotate90 a:hover,
.leaflet-control-custom:hover {
    background-color: #f8f9fa !important;
    color: #3B1F66 !important;
}


/* Ajustar contenedor del mapa para mantener proporciones */
#map {
    width: 100%;
    height: 100%; /* Ocupar toda la altura disponible */
    max-width: none; /* Eliminar límite de ancho para ocupar todo el contenedor */
    margin: 0; /* Eliminar márgenes para ocupar todo el espacio */
    background: #f8f9fa;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .maplibregl-ctrl-bottom-right .maplibregl-ctrl.maplibregl-ctrl-group {
        display: none !important;
    }
}

@media (min-width: 769px) {
    /* Alinear controles de zoom con los botones flotantes de navegación */
    .maplibregl-ctrl-bottom-right {
        bottom: 65px; /* Debajo del botón de Mi ubicación (140px) */
        right: 10px;
    }
    .maplibregl-ctrl-bottom-right .maplibregl-ctrl.maplibregl-ctrl-group {
        border-radius: 16px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    }
}

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

.custom-marker img {
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    object-fit: cover;
}

.custom-marker:hover img {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}



/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.logo-marker {
  transform-origin: 50% 100%;
  will-change: transform;
}
.logo-marker.is-float {
  animation: logoFloat 3.6s ease-in-out infinite;
}
@keyframes logoFloat {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-3px); }
}
.logo-marker.is-jump {
  animation: logoJump 900ms;
}
@keyframes logoJump {
  0%   { transform: translateY(0) scale(1,1); }
  12%  { transform: translateY(0) scale(1.25, .8); }
  18%  { transform: translateY(0) scale(.9, 1.1); }
  45%  { transform: translateY(-14px) scale(1,1); }
  60%  { transform: translateY(-14px) scale(1,1); }
  78%  { transform: translateY(0) scale(1.2, .85); }
  100% { transform: translateY(0) scale(1,1); }
}
@media (prefers-reduced-motion: reduce) {
  .logo-marker.is-float,
  .logo-marker.is-jump {
    animation: none !important;
  }
}

/* Modal animations */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
}

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

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

.modal-enter .modal-content {
    animation: modalFadeIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal-exit .modal-content {
    animation: modalFadeOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.modal-enter::before {
    animation: backdropFadeIn 0.4s ease-out forwards;
}

.modal-exit::before {
    animation: backdropFadeOut 0.3s ease-out forwards;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .custom-marker img {
        width: 30px;
        height: 30px;
    }
}

/* Desktop: hacer que el mapa ocupe todo el ancho disponible */
@media (min-width: 1024px) {
    #map {
        max-width: none !important;
        width: 100% !important;
        margin: 0 !important;
    }

    /* Asegurar que el contenedor del mapa ocupe todo el espacio disponible */
    .leaflet-container {
        width: 100% !important;
        height: 100% !important;
    }
}

/* Responsive para header */
@media (max-width: 1024px) {
    .header-nav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-widgets {
        order: -1;
        width: 100%;
        justify-content: center;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 640px) {
    .header-title {
        font-size: 1.25rem;
    }

    .header-nav {
        order: 1;
        width: 100%;
        justify-content: center;
    }
}

/* ===========================================
   HEADER MÓVIL REDISEÑADO - MEJOR INTEGRACIÓN VISUAL
   =========================================== */

@media (max-width: 640px) {
    /* Header móvil rediseñado - Blanco sólido */
    header .flex.sm\\:hidden {
        background: var(--color-surface);
        border-radius: var(--radius-xl);
        box-shadow: var(--shadow-medium);
        overflow: hidden;
        margin-bottom: var(--space-lg);
    }

    /* Fila superior - Logo y clima con mejor integración */
    .mobile-top-row {
        background: transparent;
        padding: var(--space-lg);
        position: relative;
        margin: 0 calc(-1 * var(--space-xs));
        width: calc(100% + 2 * var(--space-xs));
    }

    .mobile-top-row::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, var(--opacity-20)) 50%, transparent 100%);
    }

    /* Logo con mejor presencia */
    .mobile-top-row img {
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, var(--opacity-20)));
    }

    /* Widget de clima más elegante */
    .mobile-weather-widget {
        background: rgba(255, 255, 255, var(--opacity-15));
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, var(--opacity-20));
        border-radius: var(--radius-lg);
        padding: var(--space-sm) var(--space-md);
        box-shadow: var(--shadow-soft);
        transition: all var(--transition-fast);
    }

    .mobile-weather-widget:hover {
        background: rgba(255, 255, 255, var(--opacity-25));
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, var(--opacity-15));
    }

    /* Mejor tipografía para el clima */
    .mobile-weather-widget .font-medium {
        font-weight: 600;
        color: var(--color-text-inverse);
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
        font-size: 0.75rem;
    }

    /* Iconos del clima más prominentes */
    .mobile-weather-widget svg {
        opacity: 1;
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, var(--opacity-20)));
    }

    /* Fila inferior - Navegación con fondo azul para armonía */
    .mobile-nav-row {
        background: rgba(0, 117, 191, var(--opacity-95));
        backdrop-filter: blur(10px);
        padding: var(--space-md) var(--space-lg);
        margin: 0 var(--space-xs) var(--space-xs) var(--space-xs);
        border-radius: var(--radius-md);
        gap: var(--space-md);
        border: 1px solid rgba(255, 255, 255, var(--opacity-10));
    }

    /* Navegación con mejor integración */
    .mobile-nav-row nav {
        background: rgba(255, 255, 255, var(--opacity-10));
        border-radius: var(--radius-md);
        padding: 0.125rem;
        backdrop-filter: blur(5px);
        border: 1px solid rgba(255, 255, 255, var(--opacity-10));
    }

    /* Botones de navegación - Estado inactivo en azul, activo en violeta */
    .mobile-nav-row .btn-nav {
        font-size: 0.75rem;
        padding: 0.375rem 0.875rem;
        border-radius: 0.375rem;
        transition: all var(--transition-fast);
        font-weight: 500;
        background: rgba(255, 255, 255, var(--opacity-10));
        color: rgba(255, 255, 255, var(--opacity-80));
        border: 1px solid rgba(255, 255, 255, var(--opacity-20));
        min-width: fit-content;
        white-space: nowrap;
    }

    .mobile-nav-row .btn-nav:hover {
        background: rgba(255, 255, 255, var(--opacity-20));
        color: var(--color-text-inverse);
        border-color: rgba(255, 255, 255, 0.4);
    }

    .mobile-nav-row .btn-nav.active {
        background: var(--color-secondary);
        color: var(--color-text-inverse);
        box-shadow: 0 2px 8px rgba(0, 117, 191, 0.4);
        transform: scale(1.02);
        border-color: rgba(0, 117, 191, 0.6);
    }

    /* Botón de filtros - Azul sólido para mantener consistencia */
    #sidebar-toggle-mobile {
        background: var(--color-secondary);
        border: 1px solid rgba(255, 255, 255, var(--opacity-20));
        border-radius: var(--radius-md);
        padding: var(--space-sm) var(--space-md);
        font-size: 0.75rem;
        font-weight: 500;
        box-shadow: 0 2px 8px rgba(0, 117, 191, 0.3);
        transition: all var(--transition-fast);
        min-width: fit-content;
    }

    #sidebar-toggle-mobile:hover {
        background: #005A8F;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 117, 191, 0.4);
    }

    #sidebar-toggle-mobile svg {
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, var(--opacity-20)));
    }

    /* Responsive para pantallas muy pequeñas */
    @media (max-width: 375px) {
        .mobile-top-row {
            padding: 0.75rem 0.75rem 0.5rem 0.75rem;
        }

        .mobile-weather-widget {
            padding: 0.375rem 0.5rem;
            font-size: 0.7rem;
        }

        .mobile-nav-row {
            padding: 0.5rem 0.75rem;
            gap: 0.5rem;
        }

        #sidebar-toggle-mobile {
            padding: 0.375rem 0.5rem;
            font-size: 0.7rem;
        }

        #sidebar-toggle-mobile .hidden.xs\\:inline {
            display: none !important;
        }
    }

    /* Animaciones sutiles para mejor UX */
    .mobile-top-row,
    .mobile-nav-row {
        animation: slideDownFade 0.4s ease-out;
    }

    @keyframes slideDownFade {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}


/* Loading spinner */
.spinner {
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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


/* Estilos para marcadores seleccionados */
.marker-selected {
    border-color: #ff6b35 !important;
    transform: scale(1.2) !important;
    z-index: 1000 !important;
}





/* Estilos para el sistema de zoom táctil */
.zooming-active {
    cursor: zoom-in !important;
    user-select: none;
}

.zooming-active .leaflet-container {
    cursor: zoom-in !important;
}

/* Indicador de zoom */
.zoom-indicator {
    font-size: 14px;
    pointer-events: none;
    user-select: none;
}

/* Adjust Leaflet controls position to avoid header overlap */
.leaflet-top .leaflet-control {
    margin-top: 80px !important; /* Adjust based on header height */
}

/* Move bottom controls higher */
.leaflet-bottom .leaflet-control {
    margin-bottom: 120px !important; /* Mobile default */
}

/* Desktop: smaller margin */
@media (min-width: 768px) {
    .leaflet-bottom .leaflet-control {
        margin-bottom: 65px !important;
    }
}

/* Make bottom right controls stick together */
.leaflet-control-bottomright .leaflet-control {
    margin-bottom: 0 !important;
}

/* Estilos para secciones colapsables de rutas */
.route-section {
    border-radius: 8px;
    overflow: hidden;
}

.route-toggle {
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    cursor: pointer;
}

.route-toggle:hover {
    background-color: rgba(34, 197, 94, 0.1);
}

.route-toggle[data-route="vuelta"]:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.route-content {
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.leaflet-pane { z-index: 10; }
.leaflet-tile-pane { z-index: 100; }
.leaflet-overlay-pane { z-index: 300; }
.leaflet-shadow-pane { z-index: 400; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-pane.labels-pane { z-index: 100; }

/* Mejora visual de los markers (MapLibre / DOM) */
.logo-marker {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.logo-marker:hover {
    transform: scale(1.06);
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.28);
}
.custom-marker.selected .logo-marker {
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.2), 0 14px 26px rgba(0, 0, 0, 0.32);
}


/* Mejor contraste para botones de zoom (MapLibre) */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-zoom-in,
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-zoom-out {
    background: #ffffff !important;
    color: #4B2883 !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-zoom-in:hover,
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-zoom-out:hover {
    background: #f4f4f5 !important;
    color: #3b1f66 !important;
    transform: scale(1.02) !important;
}
