﻿/**`n * =====================================================`n * ESTILOS MEJORADOS PARA SIDEBAR`n * =====================================================`n */

/* ===================================
   SIDEBAR PRINCIPAL
   =================================== */

/* Contenedor del sidebar */
.main-sidebar {
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%) !important;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

/* Menú del sidebar */
.sidebar-menu {
    padding-top: 10px;
}

/* ===================================
   ITEMS DEL MENÚ
   =================================== */

/* Items normales del menú */
.sidebar-menu > li > a {
    padding: 15px 20px;
    font-size: 15px;
    font-weight: 500;
    color: #ecf0f1 !important;
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Efecto de ondulación en hover */
.sidebar-menu > li > a::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: translateY(-50%);
    transition: all 0.5s ease;
}

.sidebar-menu > li > a:hover::before {
    left: 100%;
}

/* Hover de items */
.sidebar-menu > li > a:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.2) 0%, transparent 100%) !important;
    border-left-color: #667eea;
    color: #fff !important;
    padding-left: 25px;
}

/* Item activo */
.sidebar-menu > li.active > a {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.2) 100%) !important;
    border-left-color: #667eea;
    color: #fff !important;
    font-weight: 600;
    box-shadow: inset 0 0 20px rgba(102, 126, 234, 0.2);
}

/* Iconos del menú */
.sidebar-menu > li > a > .fa,
.sidebar-menu > li > a > .glyphicon,
.sidebar-menu > li > a > .ion {
    width: 30px;
    font-size: 18px;
    text-align: center;
    transition: all 0.3s ease;
}

.sidebar-menu > li.active > a > .fa,
.sidebar-menu > li > a:hover > .fa {
    transform: scale(1.2);
    color: #667eea;
}

/* ===================================
   TREEVIEW (MENÚ DESPLEGABLE)
   =================================== */

/* Treeview principal */
.sidebar-menu .treeview > a {
    position: relative;
}

/* Indicador de flecha */
.sidebar-menu .treeview > a .pull-right-container {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.3s ease;
}

.sidebar-menu .treeview.active > a .pull-right-container,
.sidebar-menu .treeview:hover > a .pull-right-container {
    right: 5px;
}

.sidebar-menu .treeview > a .fa-angle-left {
    transition: all 0.3s ease;
    font-size: 18px;
}

.sidebar-menu .treeview.active > a .fa-angle-left {
    transform: rotate(-90deg);
}

/* Treeview activo */
.sidebar-menu .treeview.active > a {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.25) 0%, rgba(118, 75, 162, 0.15) 100%) !important;
    border-left-color: #667eea;
    color: #fff !important;
}

/* ===================================
   SUBMENÚ
   =================================== */

/* Contenedor del submenú */
.sidebar-menu .treeview-menu {
    background: rgba(0,0,0,0.2) !important;
    padding: 10px 0 10px 0;
    margin: 5px 0;
}

/* Items del submenú */
.sidebar-menu .treeview-menu > li > a {
    padding: 12px 20px 12px 50px;
    color: #bdc3c7 !important;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    position: relative;
}

/* Icono del submenú */
.sidebar-menu .treeview-menu > li > a > .fa-circle-o {
    font-size: 10px;
    margin-right: 8px;
    transition: all 0.3s ease;
}

/* Hover del submenú */
.sidebar-menu .treeview-menu > li > a:hover {
    background: rgba(102, 126, 234, 0.15) !important;
    color: #fff !important;
    padding-left: 55px;
    border-left-color: #667eea;
}

.sidebar-menu .treeview-menu > li > a:hover > .fa-circle-o {
    transform: scale(1.3);
    color: #667eea;
}

/* Submenú activo */
.sidebar-menu .treeview-menu > li.active > a {
    background: rgba(102, 126, 234, 0.2) !important;
    color: #fff !important;
    font-weight: 600;
    border-left-color: #667eea;
}

/* ===================================
   EFECTOS ESPECIALES
   =================================== */

/* Badge/contador */
.sidebar-menu .label {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* Separador visual entre secciones */
.sidebar-menu > li:not(:last-child) {
    margin-bottom: 2px;
}

/* ===================================
   USER PANEL (si existe)
   =================================== */

.user-panel {
    padding: 15px;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.user-panel .image img {
    border: 3px solid rgba(102, 126, 234, 0.5);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.user-panel .info {
    color: #ecf0f1;
    font-weight: 500;
}

.user-panel .info a {
    color: #fff !important;
}

.user-panel .info .fa-circle {
    color: #2ecc71;
    font-size: 8px;
}

/* ===================================
   SCROLLBAR PERSONALIZADO
   =================================== */

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #764ba2 0%, #667eea 100%);
}

/* ===================================
   SIDEBAR COLAPSADO
   =================================== */

.sidebar-collapse .main-sidebar {
    overflow: visible;
}

.sidebar-mini.sidebar-collapse .sidebar-menu > li:hover > a {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%) !important;
    border-radius: 0 5px 5px 0;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
}

.sidebar-mini.sidebar-collapse .sidebar-menu > li.active:hover > a {
    background: linear-gradient(90deg, #764ba2 0%, #667eea 100%) !important;
}

/* ===================================
   ANIMACIONES
   =================================== */

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar-menu > li {
    animation: slideInLeft 0.3s ease-out;
}

.sidebar-menu > li:nth-child(1) { animation-delay: 0.05s; }
.sidebar-menu > li:nth-child(2) { animation-delay: 0.1s; }
.sidebar-menu > li:nth-child(3) { animation-delay: 0.15s; }
.sidebar-menu > li:nth-child(4) { animation-delay: 0.2s; }
.sidebar-menu > li:nth-child(5) { animation-delay: 0.25s; }
.sidebar-menu > li:nth-child(6) { animation-delay: 0.3s; }
.sidebar-menu > li:nth-child(7) { animation-delay: 0.35s; }
.sidebar-menu > li:nth-child(8) { animation-delay: 0.4s; }

/* Animación de pulsación para item activo */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: inset 0 0 20px rgba(102, 126, 234, 0.2);
    }
    50% {
        box-shadow: inset 0 0 30px rgba(102, 126, 234, 0.4);
    }
}

.sidebar-menu > li.active > a {
    animation: pulse-glow 2s infinite;
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    
    /* Ajustar padding de items principales */
    .sidebar-menu > li > a {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    /* Ajustar submenú */
    .sidebar-menu .treeview-menu > li > a {
        padding: 10px 15px 10px 40px;
        font-size: 13px;
    }
    
    /* IMPORTANTE: Asegurar que el treeview-menu se muestre correctamente */
    .sidebar-menu .treeview.active > .treeview-menu,
    .sidebar-menu .treeview.menu-open > .treeview-menu {
        display: block !important;
        max-height: 500px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        transition: none !important; /* Sin animación que cause movimiento */
        position: static !important; /* Mantener en el flujo normal */
        z-index: 1 !important;
        transform: none !important; /* Sin transformaciones */
    }
    
    /* Fondo del submenú más visible en móvil */
    .sidebar-menu .treeview-menu {
        background: rgba(0,0,0,0.3) !important;
        border-left: 3px solid rgba(102, 126, 234, 0.5);
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
    }
    
    /* Items del submenú más espaciados para touch - FIJO */
    .sidebar-menu .treeview-menu > li {
        min-height: 48px; /* Área táctil mínima aumentada */
        position: static !important; /* Sin posicionamiento absoluto */
        transform: none !important;
    }
    
    .sidebar-menu .treeview-menu > li > a {
        padding: 16px 15px 16px 40px;
        min-height: 48px;
        display: flex;
        align-items: center;
        position: relative;
        touch-action: manipulation; /* Evita doble tap zoom */
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3);
        transform: none !important;
        transition: background 0.2s ease !important; /* Solo animar fondo */
    }
    
    /* Evitar que se mueva el item al presionar */
    .sidebar-menu .treeview-menu > li > a:active {
        background: rgba(102, 126, 234, 0.25) !important;
        transform: none !important;
    }
    
    /* Hacer el sidebar más ancho en móvil cuando está abierto */
    .sidebar-open .main-sidebar {
        width: 260px !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
    }
    
    /* Asegurar que el contenido del sidebar sea scrolleable */
    .sidebar {
        max-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    
    /* DESACTIVAR animación slideDown que causa movimiento diagonal */
    .sidebar-menu .treeview > .treeview-menu {
        animation: none !important; /* Sin animación */
    }
    
    /* Eliminar keyframes que no se usan */
    
    /* Flecha más visible en móvil */
    .sidebar-menu .treeview > a .fa-angle-left {
        font-size: 20px;
        font-weight: bold;
        pointer-events: none; /* Evita conflictos de touch */
        transition: transform 0.2s ease !important; /* Solo rotar flecha */
    }
    
    /* Indicador visual de que el menú está expandido */
    .sidebar-menu .treeview.active > a,
    .sidebar-menu .treeview.menu-open > a {
        background: linear-gradient(90deg, rgba(102, 126, 234, 0.4) 0%, rgba(118, 75, 162, 0.3) 100%) !important;
    }
    
    /* Prevenir scroll durante tap */
    .sidebar-menu .treeview-menu > li > a {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    
    /* Contenedor del treeview sin movimiento */
    .sidebar-menu > li.treeview {
        position: relative;
        overflow: visible !important;
    }
    
    /* Asegurar que no haya transforms heredados */
    .sidebar-menu .treeview-menu,
    .sidebar-menu .treeview-menu > li,
    .sidebar-menu .treeview-menu > li > a {
        will-change: auto !important;
    }
}

/* Para móviles muy pequeños */
@media (max-width: 480px) {
    
    .sidebar-menu > li > a {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .sidebar-menu .treeview-menu > li > a {
        padding: 12px 12px 12px 35px;
        font-size: 12px;
    }
    
    /* Sidebar más estrecho en móviles pequeños */
    .sidebar-open .main-sidebar {
        width: 240px !important;
    }
    
    /* Iconos más pequeños */
    .sidebar-menu > li > a > .fa {
        width: 25px;
        font-size: 16px;
    }
}

/* ===================================
   MEJORAS PARA SKIN BLUE
   =================================== */

.skin-blue .sidebar-menu > li.header {
    background: rgba(0,0,0,0.2);
    color: #fff;
    padding: 12px 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-left: 4px solid #667eea;
}

.skin-blue .sidebar-menu > li > a {
    border-left-width: 4px;
}

/* ===================================
   TOOLTIP PARA SIDEBAR COLAPSADO
   =================================== */

.sidebar-mini.sidebar-collapse .sidebar-menu > li:hover > a > span:not(.pull-right-container) {
    display: inline-block !important;
    position: absolute;
    left: 50px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    white-space: nowrap;
    z-index: 9999;
    font-weight: 600;
}

.sidebar-mini.sidebar-collapse .sidebar-menu > li:hover > a > span:not(.pull-right-container)::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid #667eea;
}
