/*
 * Estilos mejorados para el menú desplegable "Análisis y Reportes"
 * Diseño premium con animaciones modernas y efectos visuales atractivos
 */

/* ========== ESTILOS DEL TREEVIEW PRINCIPAL ========== */

/* Contenedor del treeview con transiciones suaves */
.treeview {
    position: relative;
    overflow: visible !important;
}

/* Área de conexión invisible para evitar vibración entre padre e hijos */
.treeview>.app-menu__item {
    position: relative !important;
    margin-bottom: 0 !important;
}

/* Asegurar que el contenedor li también tenga área de hover extendida */
li.treeview.is-expanded {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* Flecha indicadora animada */
.treeview-indicator {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 12px !important;
    margin-left: auto !important;
}

/* Rotación de la flecha cuando está expandido */
.treeview.is-expanded .treeview-indicator {
    transform: rotate(90deg) !important;
    color: #fff !important;
}

/* ========== CONTENEDOR DEL SUBMENÚ ========== */

/* Contenedor del menú desplegable - SIN ESPACIOS */
.treeview-menu {
    background: linear-gradient(180deg, #0d0d0d 0%, #1a1a1a 100%) !important;
    border-left: 3px solid transparent !important;
    border-image: linear-gradient(180deg, #4CAF50, #2E7D32) 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    overflow: visible !important;
    display: none;
    /* Eliminar cualquier max-height del main.css */
    max-height: none !important;
}

/* Estado expandido del menú - conectado directamente al padre */
/* SUPERPOSICIÓN MÍNIMA para eliminar el gap sin bloquear clics */
.treeview.is-expanded>.treeview-menu {
    display: block !important;
    padding: 0 !important;
    padding-top: 5px !important;
    padding-bottom: 8px !important;
    margin-top: -5px !important;
    animation: expandMenu 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    max-height: none !important;
}

@keyframes expandMenu {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Efecto de brillo superior en el submenú - usando ::after para no conflictuar con la zona anti-vibración */
.treeview.is-expanded>.treeview-menu::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(76, 175, 80, 0.6), transparent);
    z-index: 1;
}

/* ========== ITEMS DEL SUBMENÚ ========== */

/* Estilo base de los items del submenú */
.treeview-menu>li {
    opacity: 0;
    transform: translateX(-10px);
    animation: slideInItem 0.3s ease forwards;
    margin: 0 !important;
    padding: 0 !important;
}

/* Primer item sin margen superior para eliminar el gap */
.treeview-menu>li:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Animación de entrada escalonada para cada item */
.treeview.is-expanded .treeview-menu>li:nth-child(1) {
    animation-delay: 0.05s;
}

.treeview.is-expanded .treeview-menu>li:nth-child(2) {
    animation-delay: 0.08s;
}

.treeview.is-expanded .treeview-menu>li:nth-child(3) {
    animation-delay: 0.11s;
}

.treeview.is-expanded .treeview-menu>li:nth-child(4) {
    animation-delay: 0.14s;
}

.treeview.is-expanded .treeview-menu>li:nth-child(5) {
    animation-delay: 0.17s;
}

.treeview.is-expanded .treeview-menu>li:nth-child(6) {
    animation-delay: 0.20s;
}

.treeview.is-expanded .treeview-menu>li:nth-child(7) {
    animation-delay: 0.23s;
}

.treeview.is-expanded .treeview-menu>li:nth-child(8) {
    animation-delay: 0.26s;
}

.treeview.is-expanded .treeview-menu>li:nth-child(9) {
    animation-delay: 0.29s;
}

@keyframes slideInItem {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Estilo de los enlaces del submenú */
.treeview-menu .treeview-item {
    display: flex !important;
    align-items: center !important;
    padding: 10px 15px 10px 25px !important;
    margin: 2px 8px !important;
    border-radius: 8px !important;
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    text-decoration: none !important;
    position: relative !important;
    overflow: hidden !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    background: transparent !important;
    border-left: 3px solid transparent !important;
}

/* PRIMER ITEM - Sin margen superior para eliminar el gap */
.treeview-menu>li:first-child>.treeview-item {
    margin-top: 4px !important;
}

/* Icono del item */
.treeview-menu .treeview-item .icon {
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-right: 12px !important;
    font-size: 14px !important;
    color: rgba(255, 255, 255, 0.7) !important;
    background: rgba(76, 175, 80, 0.1) !important;
    border-radius: 6px !important;
    transition: all 0.3s ease !important;
}

/* ========== EFECTOS HOVER ========== */

/* Efecto hover en los items */
.treeview-menu .treeview-item:hover {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.2) 0%, rgba(56, 142, 60, 0.3) 100%) !important;
    border-left: 3px solid #4CAF50 !important;
    color: #ffffff !important;
    transform: translateX(3px) !important;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.15) !important;
}

/* Icono en hover */
.treeview-menu .treeview-item:hover .icon {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%) !important;
    color: #ffffff !important;
    transform: scale(1.1) !important;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.4) !important;
}

/* Efecto ripple en hover */
.treeview-menu .treeview-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(76, 175, 80, 0.3), transparent);
    transform: translateY(-50%);
    transition: width 0.4s ease;
    z-index: -1;
}

.treeview-menu .treeview-item:hover::after {
    width: 100%;
}

/* ========== ESTADO ACTIVO ========== */

/* Item activo */
.treeview-menu .treeview-item.active {
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%) !important;
    border-left: 3px solid #2E7D32 !important;
    color: #ffffff !important;
    font-weight: 500 !important;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.35) !important;
}

/* Icono activo */
.treeview-menu .treeview-item.active .icon {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
}

/* Hover en item activo */
.treeview-menu .treeview-item.active:hover {
    background: linear-gradient(135deg, #45a049 0%, #2E7D32 100%) !important;
    transform: translateX(3px) !important;
}

/* ========== MÓDULO ANÁLISIS Y REPORTES ESPECÍFICO ========== */

/* Estilo especial para el item principal de Análisis y Reportes */
.treeview>.app-menu__item[data-module="analisis_reportes"] {
    position: relative !important;
}

/* Indicador visual cuando el módulo está expandido */
.treeview.is-expanded>.app-menu__item[data-module="analisis_reportes"]::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #4CAF50, transparent);
}

/* ========== SEPARADOR VISUAL ========== */

/* Separador entre grupos de items */
.treeview-menu>li:nth-child(5)::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 25px;
    right: 25px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

/* ========== BADGE CONTADOR (Opcional) ========== */

/* Badge para mostrar contadores o notificaciones */
.treeview-item .badge-count {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #ff5722 0%, #e64a19 100%);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ========== MODO SIDEBAR EXPANDIDO - MEJORAS ========== */

/* Contenedor cuando el sidebar está abierto */
body:not(.sidenav-toggled) .treeview-menu {
    border-radius: 0 !important;
    margin: 0 !important;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 991px) {
    .treeview-menu .treeview-item {
        padding: 12px 15px 12px 25px !important;
    }

    .treeview-menu .treeview-item .icon {
        width: 26px !important;
        height: 26px !important;
    }
}

@media (max-width: 767px) {
    .treeview-menu .treeview-item {
        padding: 14px 15px 14px 25px !important;
        font-size: 14px !important;
    }
}

/* ========== ANIMACIÓN DE PULSE PARA NUEVOS ITEMS ========== */

@keyframes pulseNew {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(76, 175, 80, 0);
    }
}

.treeview-item.is-new {
    animation: pulseNew 2s infinite;
}

/* ========== SCROLLBAR PERSONALIZADO ========== */

.treeview-menu::-webkit-scrollbar {
    width: 4px;
}

.treeview-menu::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.treeview-menu::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #4CAF50, #2E7D32);
    border-radius: 2px;
}

.treeview-menu::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #66BB6A, #4CAF50);
}

/* ========== CORRECCIÓN DE VIBRACIÓN DEL HOVER ========== */

/* Asegurar que el treeview no tenga espacios que causen vibración */
.treeview.is-expanded {
    overflow: visible !important;
}

/* El elemento li padre debe tener control sobre todo el área */
li.treeview {
    position: relative !important;
}

/* Eliminar cualquier gap entre el app-menu__item y el treeview-menu */
.treeview>.app-menu__item {
    margin-bottom: 0 !important;
    padding-bottom: 12px !important;
}

/* El submenú debe comenzar justo debajo sin espacios */
.treeview>.treeview-menu {
    margin-top: -2px !important;
    padding-top: 2px !important;
}

/* Área de conexión entre el elemento padre y el primer hijo */
.treeview.is-expanded>.treeview-menu>li:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Estabilizar el hover en todo el contenedor del treeview */
li.treeview:hover {
    z-index: 100;
}

/* Asegurar que el primer item del submenú esté conectado visualmente */
.treeview.is-expanded>.treeview-menu>li:first-child>.treeview-item {
    margin-top: 0 !important;
    padding-top: 8px !important;
}