/* CSS MODERNO Y LIMPIO PARA EL MENÚ BOOTSTRAP */
/* Eliminado todo el código anticuado y conflictivo */

/* ===== RESET Y BASE ===== */
* {
    box-sizing: border-box;
}

/* ===== NAVBAR PRINCIPAL ===== */
.navbar {
    background: linear-gradient(135deg, var(--navbar-primary-color, #007bff) 0%, var(--navbar-secondary-color, #0056b3) 100%) !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 0.5rem 1rem;
    position: relative;
    width: 100%;
    z-index: 1030;
}

/* ===== LOGO/BRAND ===== */
.navbar-brand {
    font-weight: 600;
    font-size: 1.2rem;
    color: #ffffff !important;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.navbar-brand:hover {
    background-color: rgba(255,255,255,0.1);
    color: #ffffff !important;
    text-decoration: none;
    transform: translateY(-1px);
}

/* ===== NAVIGATION ITEMS ===== */
.navbar-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.navbar-nav .nav-item {
    position: relative;
    margin: 0 0.25rem;
}

.navbar-nav .nav-link {
    color: rgba(255,255,255,0.9) !important;
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: 5px;
    text-decoration: none;
    display: block;
    transition: all 0.3s ease;
    position: relative;
}

.navbar-nav .nav-link:hover {
    color: #ffffff !important;
    background-color: rgba(255,255,255,0.1);
    text-decoration: none;
    transform: translateY(-1px);
}

.navbar-nav .nav-link:focus {
    color: #ffffff !important;
    background-color: rgba(255,255,255,0.15);
    text-decoration: none;
}

/* ===== DROPDOWN MENUS ===== */
.nav-item.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    z-index: 1000;
    display: none;
    min-width: 280px;
    width: auto;
    max-width: none;
    padding: 0.5rem 0;
    margin: 0.5rem 0 0 0;
    background: #ffffff;
    border: none;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    white-space: nowrap;
    transform: none;
}

/* ===== DROPDOWN MENUS A LA DERECHA ===== */
.dropdown-menu-right {
    left: auto !important;
    right: 0 !important;
    min-width: 320px !important; /* Ancho mínimo mayor para menús complejos */
    width: auto !important;
    max-width: 400px !important; /* Ancho máximo para evitar que sea demasiado ancho */
}

/* Asegurar que los menús a la derecha tengan el ancho correcto */
.nav-item.dropdown:last-child .dropdown-menu,
.nav-item.dropdown:nth-last-child(2) .dropdown-menu {
    min-width: 320px !important;
    width: auto !important;
    max-width: 400px !important;
    left: auto !important;
    right: 0 !important;
}

/* ===== DROPDOWN ITEMS ===== */
.dropdown-item {
    padding: 0.75rem 1.5rem;
    color: #495057;
    font-weight: 500;
    text-decoration: none;
    display: block;
    width: 100%;
    white-space: nowrap;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Asegurar que los items en menús a la derecha no se desborden */
.dropdown-menu-right .dropdown-item {
    padding-right: 1.5rem !important;
    padding-left: 1.5rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.dropdown-item:hover {
    background-color: #e9ecef;
    color: #007bff;
    border-left-color: #007bff;
    text-decoration: none;
}

.dropdown-item:active {
    background-color: #007bff;
    color: #ffffff;
    text-decoration: none;
}

/* ===== DROPDOWN HEADERS ===== */
.dropdown-header {
    padding: 0.5rem 1.5rem;
    font-weight: 600;
    color: #6c757d;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    white-space: nowrap;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Asegurar que los headers en menús a la derecha no se desborden */
.dropdown-menu-right .dropdown-header {
    padding-right: 1.5rem !important;
    padding-left: 1.5rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.dropdown-header:first-child {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

/* ===== DROPDOWN DIVIDERS ===== */
.dropdown-divider {
    height: 1px;
    background-color: #dee2e6;
    margin: 0.5rem 0;
    border: none;
}

/* ===== ICONOS ===== */
.dropdown-item i,
.dropdown-header i,
.nav-link i {
    margin-right: 0.5rem;
    width: 16px;
    text-align: center;
}

/* ===== ITEMS EN NEGRITA ===== */
.dropdown-item.font-weight-bold {
    font-weight: 700 !important;
    color: #495057;
}

.dropdown-item.font-weight-bold:hover {
    color: #007bff;
}

/* ===== BOTÓN HAMBURGUESA ===== */
.navbar-toggler {
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.25rem 0.5rem;
    border-radius: 5px;
    background-color: transparent;
}

.navbar-toggler:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(255,255,255,0.25);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background: rgba(0,0,0,0.95);
        border-radius: 10px;
        margin-top: 1rem;
        padding: 1rem;
        box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    }
    
    .navbar-nav .nav-item {
        margin: 0.25rem 0;
    }
    
    .dropdown-menu {
        position: static;
        float: none;
        width: 100%;
        margin: 0.5rem 0;
        box-shadow: none;
        border: 1px solid rgba(255,255,255,0.1);
        background: rgba(255,255,255,0.05);
    }
    
    .dropdown-item {
        color: rgba(255,255,255,0.8);
        border-left-color: transparent;
    }
    
    .dropdown-item:hover {
        background-color: rgba(255,255,255,0.1);
        color: #ffffff;
    }
    
    .dropdown-header {
        color: rgba(255,255,255,0.6);
        background-color: transparent;
        border-bottom-color: rgba(255,255,255,0.1);
    }
}

/* ===== ANIMACIONES ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== ESTADOS ACTIVOS ===== */
.navbar-nav .nav-item.active .nav-link {
    background-color: rgba(255,255,255,0.2);
    color: #ffffff !important;
}

.navbar-nav .nav-item:not(.active) .nav-link {
    color: rgba(255,255,255,0.9) !important;
}

/* ===== DROPDOWNS ANIDADOS ===== */
.dropdown-menu .dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: 0;
    margin-left: 0.125rem;
}

/* ===== COLORES DE ESTADO ===== */
.dropdown-item.text-success {
    color: #28a745 !important;
}

.dropdown-item.text-warning {
    color: #ffc107 !important;
}

.dropdown-item.text-danger {
    color: #dc3545 !important;
}

.dropdown-item.text-secondary {
    color: #6c757d !important;
}

/* ===== UTILIDADES ===== */
.navbar > .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

.navbar-nav.ml-auto {
    margin-left: auto !important;
}

.text-light {
    color: rgba(255,255,255,0.9) !important;
}

/* ===== COMPATIBILIDAD BOOTSTRAP ===== */
.navbar-expand-lg .navbar-nav .nav-link {
    padding-right: 1rem;
    padding-left: 1rem;
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255,255,255,0.9) !important;
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: #ffffff !important;
}

.navbar-dark .navbar-nav .nav-link:focus {
    color: #ffffff !important;
}

/* ===== MENÚ ADMIN ESPECÍFICO ===== */
/* Asegurar que los menús del admin tengan el ancho correcto */
#navbarAdmin .dropdown-menu {
    min-width: 280px !important;
    width: auto !important;
}

#navbarAdmin .dropdown-menu-right {
    min-width: 320px !important;
    width: auto !important;
    max-width: 400px !important;
    left: auto !important;
    right: 0 !important;
}

/* Posicionamiento específico para menús a la derecha en el admin */
#navbarAdmin .nav-item.dropdown:last-child .dropdown-menu,
#navbarAdmin .nav-item.dropdown:nth-last-child(2) .dropdown-menu {
    left: auto !important;
    right: 0 !important;
    min-width: 320px !important;
    width: auto !important;
    max-width: 400px !important;
}

/* Asegurar que el texto no se desborde en los menús del admin */
#navbarAdmin .dropdown-item,
#navbarAdmin .dropdown-header {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
}

/* Reglas específicas para los menús Módulos y Configuración */
#navbarAdmin .nav-item.dropdown:last-child .dropdown-menu,
#navbarAdmin .nav-item.dropdown:nth-last-child(2) .dropdown-menu {
    min-width: 320px !important;
    width: auto !important;
    max-width: 400px !important;
    left: auto !important;
    right: 0 !important;
    position: absolute !important;
}

/* Asegurar que los items en estos menús específicos tengan el ancho correcto */
#navbarAdmin .nav-item.dropdown:last-child .dropdown-menu .dropdown-item,
#navbarAdmin .nav-item.dropdown:nth-last-child(2) .dropdown-menu .dropdown-item,
#navbarAdmin .nav-item.dropdown:last-child .dropdown-menu .dropdown-header,
#navbarAdmin .nav-item.dropdown:nth-last-child(2) .dropdown-menu .dropdown-header {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding-right: 1.5rem !important;
    padding-left: 1.5rem !important;
}
