/* ============================================
   LAYOUT (Estructura de la página)
   ============================================ */

.app-wrapper { display: flex; flex-direction: column; height: 100vh; }

/* NAVBAR */
.app-navbar {
    height: var(--navbar-height);
    background-color: var(--bg-darker);
    background: linear-gradient(to right, var(--bg-dark), var(--bg-darker));
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 1030;
}

.toggle-btn, .user-dropdown-toggle, #btn-global-search {
    background: var(--hover-white-alpha, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--border-dark);
    color: var(--color-nav-muted);
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}
.toggle-btn:hover, .user-dropdown-toggle:hover, #btn-global-search:hover {
    background-color: var(--btn-active-alpha);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    box-shadow: 0 0 10px rgba(79, 179, 255, 0.2);
}
.user-dropdown-toggle {
    font-size: 1.25rem;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.dropdown-menu.user-menu {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-dark);
    border-radius: 10px;
    padding: 0.5rem 0;
    box-shadow: 0 10px 30px var(--shadow-dark);
}
.user-menu .dropdown-item {
    color: var(--color-muted);
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
}
.user-menu .dropdown-item:hover {
    background-color: var(--card-bg);
    color: var(--color-light);
}

/* BODY & SIDEBAR */
.app-body { display: flex; flex: 1; overflow: hidden; position: relative; }
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1040;
    overflow-y: auto;
    padding: 1rem;
}
.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }

@media (min-width: 769px) { .app-sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); } }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--navbar-height));
    background: var(--overlay-bg, rgba(0,0,0,0.5));
    z-index: 1035;
}
.sidebar-overlay.show { display: block; }

/* MAIN */
.app-main {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background-color: var(--bg-main-surface);
}


/* =========================
   NAVEGACIÓN 'PILL' Y SUBMENÚS
========================= */

/* Títulos de sección (ej. PRINCIPAL) */
.nav-header {
    padding: 1.5rem 1rem 0.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--color-muted);
    font-weight: 700;
    opacity: 0.7;
}

/* Elementos de Nivel 1 */
.nav-item a {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    color: var(--color-light);
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-radius: 8px; /* Se mantiene redondeado siempre */
    margin-bottom: 2px;
    position: relative; /* Clave para posicionar la línea */
}

/* LA LÍNEA MÁGICA (Oculta por defecto) */
.nav-item a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%); /* Centrada verticalmente */
    width: 3px;
    height: 0; /* Empieza con altura 0 */
    background-color: var(--brand-primary);
    border-radius: 0 4px 4px 0; /* Redondeo sutil en la línea */
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* Animación suave */
}

.nav-item a i.nav-icon {
    width: 22px;
    margin-right: 12px;
    font-size: 1rem;
    color: var(--color-muted);
    transition: color 0.2s;
}
.nav-item a:hover {
    background-color: var(--hover-white-alpha, rgba(255, 255, 255, 0.05));
    color: #ffffff;
}
.nav-item a:hover i.nav-icon {
    color: var(--brand-primary);
}

/* ESTADO ACTIVO (Se ilumina el icono, el texto y se pone un borde azul) */
.app-sidebar a.active {
    color: #ffffff !important;
    background-color: var(--btn-active-alpha) !important;
    font-weight: 700;
}
.app-sidebar a.active::before {
    height: 70%; /* Se expande desde el centro hacia arriba y abajo */
}

.app-sidebar a.active i.nav-icon {
    color: var(--brand-primary) !important;
}

/* Flechas */
.arrow-icon {
    margin-left: auto;
    transition: transform 0.3s ease;
    font-size: 0.75rem;
    color: var(--color-muted);
}

/* Rotación de la flecha cuando Bootstrap abre el menú */
a[aria-expanded="true"] .arrow-icon {
    transform: rotate(90deg);
}

/* =========================
   SUBMENÚS (Nivel 2 y 3) - MEJORADOS
========================= */

.nav-submenu {
    background-color: transparent;
    position: relative;
    margin-left: 1.5rem;
    border-left: 1px solid rgba(255, 255, 255, 0.15); /* Línea un poco más visible */
    padding-left: 0.5rem;
    margin-top: 2px;
    margin-bottom: 8px;
}

/* Elementos de Nivel 2 */
.nav-submenu li a {
    padding: 0.55rem 1rem;
    color: #cbd5e1; /* ✅ Texto más claro, ya no se ve opaco */
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 6px;
    margin-bottom: 1px;
    transition: color 0.2s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    padding-left: 1.4rem;
}

/* ✅ GUION para ítems sin icono */
.nav-submenu li a::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.4);
    margin-right: 10px;
    transition: background-color 0.2s;
}

/* ✅ Lógica para los que SÍ tienen icono real */
.nav-submenu li a i.nav-icon {
    display: block;
    font-size: 0.9rem;
    width: 20px;
    margin-right: 8px;
    color: var(--color-muted);
}

/* Si el enlace tiene un icono, ocultamos el guion */
.nav-submenu li a:has(i.nav-icon)::before {
    display: none;
}

/* Hover en submenús */
.nav-submenu li a:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.06); /* Fondo sutil al pasar el mouse */
}
.nav-submenu li a:hover::before {
    background-color: var(--brand-primary); /* El guion se ilumina */
}

/* Estado Activo en Submenús */
.nav-submenu li a.active {
    color: #ffffff !important;
    background-color: var(--btn-active-alpha) !important;
    font-weight: 600;
}
.nav-submenu li a.active::before {
    background-color: var(--brand-primary);
}

/* Elementos de Nivel 3 */
.nav-submenu .nav-submenu {
    margin-left: 1rem;
    border-left: 1px dashed rgba(255, 255, 255, 0.15);
}

.nav-submenu .nav-submenu li a {
    font-size: 0.9rem;
    padding: 0.45rem 1rem;
    padding-left: 1.4rem;
}


/* =========================
   RESPONSIVE LAYOUT (Móvil)
========================= */
@media (max-width: 768px) {
    .app-main { padding: 1rem 0.75rem; }

    /* NAVBAR */
    .app-navbar { padding: 0 1rem; height: 65px; }
    .toggle-btn, .user-dropdown-toggle {
        width: 46px !important;
        height: 46px !important;
        border-radius: 12px;
        font-size: 1.4rem !important;
    }

    /* SIDEBAR */
    .app-sidebar {
        position: fixed;
        left: 0;
        padding: 1rem;
        width: 280px;
        top: 65px;
        height: calc(100vh - 65px);
        transform: translateX(-100%);
    }
    .app-sidebar.mobile-show {
        transform: translateX(0);
        box-shadow: 4px 0 20px var(--shadow-dark);
    }

    /* Navegación en Móvil (Más espacio táctil) */
    .nav-header { font-size: 0.8rem; padding: 1.25rem 0.75rem 0.5rem; }

    .nav-item a { padding: 0.85rem 1rem; font-size: 1rem; margin-bottom: 4px; }

    .nav-item a i.nav-icon { width: 24px; font-size: 1.2rem; margin-right: 14px; }

    /* Ajuste de submenús en móvil para mantener la línea guía */
    .nav-submenu { margin-left: 1.8rem; }
    .nav-submenu li a { padding: 0.7rem 1rem; font-size: 0.95rem; }
    .nav-submenu .nav-submenu { margin-left: 1rem; }
    .nav-submenu .nav-submenu li a { padding: 0.6rem 1rem; font-size: 0.9rem; }

    .user-menu .dropdown-item { padding: 0.85rem 1.5rem; font-size: 1rem; }
}









/* ============================================
   BUSCADOR GLOBAL (ESTILO GMAIL - CENTRADO)
   ============================================ */
.global-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.4); /* Fondo sutil para enfocar la vista */
    backdrop-filter: blur(3px);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center; /* ✅ Centrado horizontal */
    padding-top: 10vh; /* ✅ Aparece en la parte superior */
    opacity: 0;
    transition: opacity 0.2s ease;
}

.global-search-overlay.show {
    opacity: 1;
}

.global-search-palette {
    width: 100%;
    background-color: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    overflow: hidden;
    transform: translateY(-15px);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.global-search-overlay.show .global-search-palette {
    transform: translateY(0);
}

/* Header del Input */
.search-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-icon {
    color: #64748b;
    font-size: 1.2rem;
    margin-right: 1rem;
}

/* ✅ FORZAMOS AL INPUT A SER TOTALMENTE TRANSPARENTE */
#global-search-input {
    flex-grow: 1;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    color: #f8fafc !important;
    font-size: 1.15rem;
    padding: 0 !important;
}

#global-search-input:focus {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

#global-search-input::placeholder {
    color: #64748b;
}

/* Badge ESC   .search-esc-badge  */
/* Badge genérico para el buscador */
.search-badge {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    letter-spacing: 0.5px;
    margin-left: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}




/* Footer */
.search-footer {
    padding: 0.75rem 1.25rem;
    background-color: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: #64748b;
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
}

/* Resultados */
#global-search-results .search-item {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

#global-search-results .search-item:hover,
#global-search-results .search-item.selected {
    background-color: rgba(79, 179, 255, 0.1);
    color: #ffffff;
}

#global-search-results .search-item i {
    width: 28px;
    color: #64748b;
    margin-right: 12px;
    font-size: 1.1rem;
}

#global-search-results .search-item:hover i,
#global-search-results .search-item.selected i {
    color: var(--brand-primary);
}