/* Navbar Mobile Fixes - Versión Robusta */

/* Asegurar que el toggle funcione correctamente */
.navbar-toggler {
    border: none !important;
    padding: 0.25rem 0.5rem;
    font-size: 1.25rem;
    line-height: 1;
    background-color: transparent;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
    position: relative;
    z-index: 1051;
}

.navbar-toggler:hover {
    text-decoration: none;
    background-color: rgba(0, 0, 0, 0.05);
}

.navbar-toggler:focus {
    text-decoration: none;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Icono del toggle - Configuración base */
.navbar-toggler-icon {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    vertical-align: middle;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100%;
    transition: all 0.2s ease-in-out;
}

/* Estado normal del icono */
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Animación cuando está activo */
.navbar-toggler.collapsed .navbar-toggler-icon {
    transform: rotate(90deg);
}

/* Mejorar el comportamiento del colapso */
.navbar-collapse {
    transition: all 0.3s ease-in-out !important;
    overflow: hidden;
}

/* Forzar el estado correcto del menú - Solo en móviles */
@media (max-width: 991.98px) {
    .navbar-collapse:not(.show) {
        display: none !important;
    }

    .navbar-collapse.show {
        display: block !important;
    }
}

/* En desktop, dejar que Bootstrap maneje el comportamiento */
@media (min-width: 992px) {
    .navbar-collapse {
        display: flex !important;
    }
}

/* Estilos específicos para móviles */
@media (max-width: 991.98px) {
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-radius: 0 0 0.5rem 0.5rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 1050;
        margin: 0;
        padding: 1rem;
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-top: none;
    }

    /* Dark mode para navbar-collapse en móviles */
    [data-theme="dark"] .navbar-collapse {
        background-color: rgba(22, 27, 34, 0.98) !important;
        border-color: rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
    }

    .navbar-nav {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 0;
        margin: 0.1rem 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease-in-out;
        border-radius: 0.25rem;
    }
    
    .navbar-nav .nav-link:hover {
        background-color: rgba(0, 0, 0, 0.04);
        padding-left: 0.5rem;
    }
    
    .navbar-nav .nav-link:last-child {
        border-bottom: none;
    }

    /* Dark mode para nav-links en móviles */
    [data-theme="dark"] .navbar-nav .nav-link {
        border-bottom-color: rgba(255, 255, 255, 0.1) !important;
        color: rgba(255, 255, 255, 0.85) !important;
    }
    
    [data-theme="dark"] .navbar-nav .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.08) !important;
        color: rgba(255, 255, 255, 0.95) !important;
    }

    /* Form de búsqueda en móvil */
    .navbar-nav + form {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    /* Dark mode para form de búsqueda en móviles */
    [data-theme="dark"] .navbar-nav + form {
        border-top-color: rgba(255, 255, 255, 0.1) !important;
    }
    
    /* Prevenir scroll del body cuando el menú está abierto */
    body.navbar-open {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
    }
}

/* Dark mode support - Solución robusta para el icono */
[data-theme="dark"] .navbar-toggler {
    color: rgba(255, 255, 255, 0.85) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

[data-theme="dark"] .navbar-toggler:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 1) !important;
}

[data-theme="dark"] .navbar-toggler:focus {
    box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.25) !important;
}

/* Forzar el icono blanco en modo oscuro con múltiples métodos */
[data-theme="dark"] .navbar-toggler-icon {
    filter: invert(1) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
    opacity: 0.85 !important;
}

[data-theme="dark"] .navbar-toggler:hover .navbar-toggler-icon {
    opacity: 1 !important;
}

/* Asegurar que el navbar sea visible en dark mode */
[data-theme="dark"] .navbar {
    background-color: var(--navbar-bg) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .navbar-light .navbar-toggler {
    color: rgba(255, 255, 255, 0.85) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

[data-theme="dark"] .navbar-light .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
    filter: none !important;
    opacity: 0.85 !important;
}

[data-theme="dark"] .navbar-light .navbar-toggler:hover .navbar-toggler-icon {
    opacity: 1 !important;
}

[data-theme="dark"] .navbar-collapse {
    background-color: rgb(22 27 34) !important;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .navbar-nav .nav-link {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.85);
}

[data-theme="dark"] .navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
}

/* Accesibilidad */
.navbar-toggler:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Animaciones suaves */
.navbar-nav .nav-link {
    transition: all 0.2s ease-in-out;
}

/* Estado del navbar cuando está sticky */
.navbar.sticky-top {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Asegurar que el navbar tenga prioridad visual */
.navbar {
    z-index: 1030;
}

.navbar-collapse {
    z-index: 1050;
}

/* Hero Section Mobile Styles */
@media (max-width: 767.98px) {
    /* Margen inferior para la imagen del hero en móviles */
    .hero-section img,
    .hero-section picture,
    .hero-section picture img {
        margin-bottom: 5px !important;
    }
    
    /* Selectores más específicos para asegurar que se aplique */
    .hero-section .col-md-6 img,
    .hero-section .col-md-6 picture,
    .hero-section .col-md-6 picture img,
    .hero-section .position-relative img,
    .hero-section .position-relative picture,
    .hero-section .position-relative picture img {
        margin-bottom: 5px !important;
    }
}
