/**
 * erp-sidebar.css — Full-Width & Uniform Identity
 * Rediseño para bloques sólidos que ocupan el 100% del ancho.
 * Restauración de iconografía en submódulos.
 */

/* Botón Hamburguesa (Móvil) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 2000;
    background: var(--erp-teal-600);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Overlay / Máscara */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 999;
}

.side-nav {
    position: fixed;
    top: 56px;
    left: 0;
    width: 240px;
    height: calc(100vh - 56px);
    background: var(--erp-teal-600);
    overflow-y: auto;
    padding: 10px 0 !important;
    z-index: 1000;
    border: none;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── MÓDULOS PADRE (Full-Width) ── */
.side-nav > li.module {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    transition: background 0.2s ease !important;
    width: 100% !important;
    display: block !important;
}

.module-link {
    display: flex !important;
    align-items: center !important;
    padding: 14px 12px !important; /* Reducido de 20px para ganar espacio horizontal */
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 10.5px !important; /* Ajuste sutil para evitar cortes */
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.03em; /* Un poco menos para ganar espacio */
    transition: all 0.2s ease !important;
    border-left: 4px solid transparent;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

.module-icon {
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-right: 8px !important; /* Reducido de 12px */
    font-size: 1.15rem !important;
    color: #ffffff !important;
    opacity: 0.95 !important;
    flex-shrink: 0 !important;
}

.module-text {
    flex: 1 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    overflow: hidden !important;
}

.module-title {
    overflow: visible !important; /* Permitir ver completo */
    text-overflow: clip !important; /* Sin puntos suspensivos */
    white-space: normal !important; /* Permitir quiebre si es extremo, pero intentar linea única */
    line-height: 1.2 !important;
}

.module-caret {
    font-size: 0.95rem !important; /* Más grande para visibilidad */
    opacity: 1 !important; /* Máxima visibilidad */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important; /* Animación más fluida */
    margin-left: 6px !important;
    display: inline-block !important;
}

/* ── SUBMÓDULOS (Con Iconos) ── */
.module-submenu {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: rgba(0,0,0,0.12) !important; /* Fondo sutil para agrupar */
    width: 100% !important;
    box-sizing: border-box !important;
    border: none !important;
}

.sub-module {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    position: relative !important;
    width: 100% !important;
}

.sub-module-link {
    display: flex !important;
    align-items: center !important;
    padding: 10px 20px 10px 32px !important; /* Indentación ligera pero conservando iconos */
    color: rgba(255,255,255,0.85) !important;
    text-decoration: none !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    transition: all 0.2s ease !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Restauración de Iconos Hijos */
.sub-icon {
    width: 25px !important;
    height: 25px !important;
    display: flex !important; /* FORZAR VISIBILIDAD */
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    font-size: 1.3rem !important;
    opacity: 0.8 !important;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ── ESTADOS INTERACTIVOS ── */

/* Hover Padre & Hijo */
.module-link:hover,
.sub-module-link:hover {
    background: rgba(255,255,255,0.12) !important;
    color: #ffffff !important;
}

.sub-module-link:hover .sub-icon {
    opacity: 1;
    transform: scale(1.1);
}

/* Active Parent */
.module.nav-module-active > .module-link {
    background: rgba(0,0,0,0.15) !important;
    border-left-color: #ffffff !important;
}

/* Estado de la flecha al expandir (rotación 180 grados) */
.module .module-link:not(.collapsed) .module-caret {
    transform: rotate(180deg) !important;
}

/* Active Child Page */
.sub-module.active-sub .sub-module-link {
    background: rgba(255,255,255,0.08) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
}

.sub-module.active-sub .sub-icon {
    opacity: 1;
    color: #ffffff;
}

/* Custom Scrollbar */
.side-nav::-webkit-scrollbar { width: 4px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 999px; }

/* Página principal vinculada lateral */
#wrapper { overflow-x: hidden; }

/* ── RESPONSIVE BREADCRUMBS & BREAKPOINTS ── */

@media (max-width: 991px) {
    .sidebar-toggle {
        display: flex;
    }

    .side-nav {
        left: -240px; /* Escondido por defecto */
        top: 0;
        height: 100vh;
        box-shadow: 4px 0 20px rgba(0,0,0,0.25);
    }

    .sidebar-mobile-open .side-nav {
        left: 0;
    }

    .sidebar-mobile-open .sidebar-overlay {
        display: block;
    }

    /* Ajuste para que el contenido no dependa del sidebar fijo */
    #page-wrapper {
        margin-left: 0 !important;
        padding-top: 70px !important;
    }

    .navbar-brand-wrapper {
        margin-left: 32px !important; /* Ajustado para dar espacio suficiente al toggle con el nuevo padding del contenedor */
    }
}

@media (max-width: 480px) {
    .module-link {
        padding: 16px 14px !important; /* Touch targets más amplios */
    }
    .sub-module-link {
        padding: 12px 14px 12px 35px !important;
    }
}
