/* ============================================
   APP LAYOUT
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gradient-dark);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: width var(--transition);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    height: var(--topbar-height);
}

.sidebar-header i {
    font-size: 1.5rem;
    color: var(--primary-light);
    min-width: 24px;
    text-align: center;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
    transition: opacity var(--transition);
}

.sidebar.collapsed .sidebar-title {
    opacity: 0;
    width: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

#sidebar-toggle {
    background: none;
    border: none;
    color: var(--gray-700); 
    
    font-size: 1.45rem; 
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center; 
    padding: 0 0.5rem; 
    height: 100%; 
    z-index: 101;
    transition: transform var(--transition);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    color: var(--gray-400);
    text-decoration: none;
    transition: all var(--transition-fast);
    cursor: pointer;
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.nav-item i {
    font-size: 1.125rem;
    min-width: 24px;
    text-align: center;
}

.nav-item span {
    transition: opacity var(--transition);
}

.sidebar.collapsed .nav-item span {
    opacity: 0;
    width: 0;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--gray-300);
    font-size: 0.875rem;
}

.user-info i {
    font-size: 1.25rem;
}

.btn-logout {
    width: 100%;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: none;
    padding: 0.625rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* Top Navbar */
.top-navbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* ============================================
   TOP NAVBAR - MARCA Y LOGO INTERACTIVO
   ============================================ */

/* Contenedor que junta el logo y el texto */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem; /* Separación sutil entre el logo y el texto */
    cursor: default;
    
    /* Transición para que todo el conjunto reaccione al unísono al pasar el mouse */
    transition: transform 0.3s ease, filter 0.3s ease;
}

/* Estilo para la imagen del Logo */
.navbar-logo {
    height: 60px; /* Altura ideal para que no altere el tamaño de la navbar */
    width: auto;  /* Mantiene la proporción original del PNG */
    object-fit: contain;
}

/* Estilos para el texto del título */
.navbar-brand-title {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    user-select: none;
    
    /* Texto en Degradado Azul Moderno */
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

/* EFECTO INTERACTIVO GLOBAL (Ahora se aplica a todo el conjunto al hacer hover) */
.navbar-brand:hover {
    filter: drop-shadow(0 2px 8px rgba(59, 130, 246, 0.4)); /* Brillo azul moderno */
    transform: translateY(-1px); /* Elevación sutil */
}

/* Ajustes Responsivos para celulares */
@media (max-width: 480px) {
    .navbar-logo {
        height: 28px; /* Un poco más pequeño en pantallas chicas */
    }
    .navbar-brand-title {
        font-size: 1.15rem;
    }
}

/* --- Estilos por defecto (Escritorio) --- */
.hamburger-btn, .close-sidebar-btn {
    display: none; /* Ocultos en PC */
    background: none;
    border: none;
    color: #333; /* Cambia según tu paleta */
    font-size: 1.5rem;
    cursor: pointer;
}

/* ============================================
   SIDEBAR OVERLAY (Fondo oscuro)
   ============================================ */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5); /* Fondo negro semi-transparente */
    z-index: 150; /* Por debajo del sidebar pero por encima de las páginas */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto; /* Permite capturar el clic para cerrarse */
}

/* ==================================================================
   ESTILOS PARA LA PESTAÑA DE ADMINISTRACIÓN DEL SIDEBAR
================================================================== */

#sidebar-admin-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #b0c4de; 
    text-decoration: none;
    font-weight: 500;
    border-radius: 8px;
    margin: 8px 14px;
    transition: all 0.3s ease;
    border-left: 3px solid transparent; 
}

/* Icono especial de seguridad */
#sidebar-admin-btn i {
    font-size: 1.1rem;
    color: #4a90e2; 
    transition: transform 0.3s ease;
}

/* Efecto Hover  */
#sidebar-admin-btn:hover {
    background-color: rgba(74, 144, 226, 0.1); 
    color: #ffffff; 
    border-left: 3px solid #4a90e2; 
    transform: translateX(4px); 
}

/* Animación del icono al pasar el mouse */
#sidebar-admin-btn:hover i {
    transform: scale(1.15) rotate(5deg); 
    color: #63a4ff;
}

/* Estado Activo o de Carga (Opcional, por si lo necesitas) */
#sidebar-admin-btn:active {
    background-color: rgba(74, 144, 226, 0.2);
    transform: scale(0.98);
}

/* ============================================
   MEDIA QUERY RESPONSIVA ÚNICA (Móviles ≤ 768px)
   ============================================ */
@media (max-width: 768px) {
    
    /* Forzar que el botón de hamburguesa se muestre arriba en móvil */
    #sidebar-toggle {
        display: flex !important;
    }

    /* FORZAR que el sidebar se esconda por completo a la izquierda */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        width: var(--sidebar-width) !important;
        /* El transform con !important obliga al navegador a sacarlo de pantalla */
        transform: translateX(-100%) !important; 
        transition: transform 0.3s ease !important;
        z-index: 200 !important; /* Queda por encima de todo */
    }

    /* Cuando JavaScript le añade la clase 'open', la deslizamos hacia adentro */
    .sidebar.open {
        transform: translateX(0) !important;
    }

    /* Forzar que las vistas de las páginas ocupen todo el ancho en el celular */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .sidebar.collapsed + .main-content {
        margin-left: 0 !important;
    }
}