/* HEADER Y NAVEGACIÓN - ENSLI */

header[role="banner"],
.header__top,
.header__navbar-main,
.header__navbar-main .container,
#mainNavbar,
#navbarNav {
    background-color: #ffffff !important;
}

/* Posicionamiento y Capas */
.header__top {
    border-bottom: 1px solid #eee;
    position: relative;
    z-index: 1030;
}

#mainNavbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 1030 !important;
    background-color: #ffffff !important;
    border-bottom: 1px solid #eee;
}


/* IDENTIDAD INSTITUCIONAL */


.header__brand-text {
    color: #1e3a8a;
    line-height: 1.1;
    display: flex;
    flex-direction: column;
}

.header__brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    text-transform: uppercase;
}

.header__brand-subtitle {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Ajustes para pantallas tipo Laptop/Tablet */
@media (max-width: 991.98px) {
    .header__brand-title { font-size: 0.95rem; }
    .header__brand-subtitle { font-size: 0.8rem; }
    .navbar-brand img { height: 45px; }
}

/* Dispositivos Móviles */

@media (max-width: 480px) {
    .navbar-brand img { height: 35px !important; }
    .header__brand-title { font-size: 0.75rem !important; }
    .header__brand-subtitle { font-size: 0.65rem !important; }
    
    /* Reducir botones de acción para ganar espacio */
    .header__top .btn-outline-primary {
        padding: 0.25rem 0.75rem !important;
        font-size: 0.75rem !important;
        border: 1px solid #1e3a8a !important; /* Volvemos a un borde sutil para consistencia */
        background: transparent !important;
        color: #1e3a8a !important;
        border-radius: 50px !important;
        box-shadow: none !important;
    }
    
    .header__user-avatar {
        font-size: 1.5rem !important;
        display: block;
        width: 32px;
        height: 32px;
        line-height: 32px;
        text-align: center;
    }
    
    .navbar-toggler {
        padding: 0.15rem 0.4rem !important;
        margin-left: 0.2rem !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }
}

/* ENLACES DE NAVEGACIÓN */


.header__navbar-main .nav-link {
    font-weight: 500;
    color: #4a5568 !important;
    padding: 0.5rem 1.1rem !important;
    margin: 6px 2px;
    transition: color 0.2s ease, background-color 0.2s ease;
    position: relative;
}

/* Eliminar líneas de main.css que se filtran en el header modernizado */
.header__navbar-main .nav-link::after {
    display: none !important;
}

.header__navbar-main .nav-link:hover {
    color: #1e3a8a !important;
    background: rgba(30, 58, 138, 0.05) !important;
    border-radius: 6px;
}

/* No aplicar diferenciador activo (solo hover) */
.header__navbar-main .nav-link.active {
    background: transparent !important;
    color: #4a5568 !important;
}

.header__navbar-main .nav-link.active:hover {
    color: #1e3a8a !important;
    background: rgba(30, 58, 138, 0.05) !important;
}

/* Eliminadas líneas indicadoras activas */

/* En móvil: aseguramos que la línea NO aparezca */
@media (max-width: 991.98px) {
    .header__navbar-main .nav-link::before,
    .header__navbar-main .nav-link::after {
        display: none !important;
    }

    /* KILL POPPER.JS / INLINE STYLES in Mobile Dropdowns */
    #navbarNav .dropdown-menu {
        position: static !important;
        inset: auto !important;
        transform: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        box-shadow: none !important;
        border: none !important;
    }
}


/* MENÚS DESPLEGABLES Y NIVELES ANIDADOS */


.navbar .dropdown-menu {
    z-index: 1031 !important;
    background-color: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 0 0 0.5rem 0;
    min-width: 320px;
    z-index: 2200 !important;
}


.navbar .dropdown-item {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    color: #333;
    white-space: normal; /* Permitir wrap controlado si es muy largo */
}

.navbar .dropdown-item:hover {
    background-color: #f8f9fa !important;
    color: #1e3a8a !important;
}

/* Soporte niveles anidados (Dropdown Submenu) */
@media (min-width: 992px) {
    .dropdown-submenu {
        position: relative;
    }

    /* FORZAR que se abra hacia un lado en escritorio */
    .dropdown-submenu > .dropdown-menu {
        top: 0;
        left: 100% !important; /* Hacia la derecha */
        margin-top: -5px;
        margin-left: 0;
        display: none !important;
    }

    .dropdown-submenu:hover > .dropdown-menu {
        display: block !important;
    }
}

/* Menú Móvil - Soporte Expandible */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: #ffffff !important;
        border-top: 1px solid #eee;
    }

    .dropdown-submenu > .dropdown-menu {
        position: static !important;
        display: none !important;
        padding: 0 !important; /* Eliminado todo padding superior/inferior en móvil */
        margin: 0 !important;
        box-shadow: none;
        border: none;
        border-left: 2px solid #eee;
        background: #fdfdfd !important;
        min-width: 100%;
    }

    .header__navbar-main .nav-link,
    #navbarNav .nav-link,
    #navbarNav .dropdown-item {
        border: none !important; /* Quitar líneas divisorias en móvil */
        padding-top: 0.8rem !important;
        padding-bottom: 0.8rem !important;
    }

    /* Clase que activará el JS al tocar */
    .dropdown-submenu.open > .dropdown-menu {
        display: block !important;
    }
    
    /* Flecha indicadora para submenús en móvil */
    .dropdown-submenu .dropdown-toggle::after {
        transform: rotate(-90deg);
        transition: transform 0.3s ease;
    }
    .dropdown-submenu.open .dropdown-toggle::after {
        transform: rotate(0deg);
    }
}

/* PERFIL DE USUARIO */


.header__user-avatar {
    font-size: 2rem;
    color: #1e3a8a;
    transition: transform 0.2s ease;
    display: inline-block;
    vertical-align: middle;
}

#userDropdown:focus, 
#userDropdown:active,
.header__top .btn:focus {
    outline: none !important;
    box-shadow: none !important; /* Eliminamos el anillo de enfoque solicitado */
    border-radius: 50% !important;
}

#userDropdown {
    border-radius: 50% !important;
    padding: 2px !important;
}

#userDropdown:hover .header__user-avatar {
    transform: scale(1.1);
}

/* MENÚ MÓVIL (HAMBURGUESA) */


.navbar-toggler {
    border: none !important;
    padding: 0.5rem !important;
    background: transparent !important;
    box-shadow: none !important;
}

.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%2830, 58, 138, 1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* RESET GLOBAL DE ENFOQUE (Focus Rings) PARA HEADER */
header[role="banner"] button:focus,
header[role="banner"] a:focus,
.header__navbar-main .nav-link:focus,
.header__action-btn:focus,
#navbarNav .nav-link:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* CAPAS Y AJUSTES FINALES */


.hero-section, .page-header, .carousel {
    z-index: 1 !important;
}

/* Botones de acción unificados (Búsqueda/Perfil) */
.header__action-btn {
    width: 42px;
    height: 42px;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    font-size: 1.1rem;
    color: #1e3a8a !important;
    border: 1.5px solid rgba(30, 58, 138, 0.15) !important;
    background: transparent !important;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.header__action-btn:hover {
    background: #ffffff !important;
    border-color: #1e3a8a !important;
}

.header__action-btn:hover i {
    color: #1e3a8a !important;
}

.header__action-btn:active {
    opacity: 0.8;
}
