#menu_navegacion {
    width: 250px;
    height: 100vh;
    background: #ffffff;
    box-shadow: 2px 0 12px rgba(0,0,0,0.05);
    z-index: 1000;
    position: fixed;
    top: 0;
    left: 0;
    transition: transform 0.3s ease;
}

#menu_navegacion.abierto {
    transform: translateX(0) !important;
}

.menu_navegacion_inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Logo Sidebar */
.sidebar-logo {
    padding: 30px 24px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0; /* Evita que el logo se comprima */
}

.sidebar-logo-img {
    width: 70px;
    height: auto;
    margin-bottom: 10px;
    display: block;
}

.escuela-nombre {
    font-size: 14px;
    font-weight: 700;
    color: #1a3a6b;
    letter-spacing: 0.5px;
}

.escuela-sub {
    font-size: 11px;
    color: #9aa3b5;
}

/* Opciones del menú */
.menu_opciones_contenedor {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto; /* Scroll interno si no cabe, sin empujar el footer */
    min-height: 0; /* Necesario para que flex + overflow funcione bien */
}

.nav-label {
    font-size: 10px;
    font-weight: 700;
    color: #b0b8cc;
    text-transform: uppercase;
    padding: 0 24px;
    margin-bottom: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: #7a849e;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: 0.2s;
    border-left: 4px solid transparent;
    flex-shrink: 0; /* Evita que los items se compriman */
}

.nav-item:hover, .nav-item.active {
    background: #eef3fb;
    color: #1a3a6b;
    border-left: 4px solid #1a3a6b;
}

/* Footer Sidebar */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0; /* Muy importante: evita que el footer se comprima o desaparezca */
}

.btn_cerrar_sesion {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #fff0f0;
    color: #e05c5c;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

/* Overlay para cerrar el menú */
#overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}
#overlay.active { display: block; }

/* Topbar móvil superior */
#topbar-movil {
    display: none;
    position: fixed;
    top: 0; 
    left: 0; 
    right: 0;
    height: 70px;
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    z-index: 900;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-logo img { width: 45px; height: auto; }

#btn-hamburguesa {
    background: none;
    border: none;
    font-size: 24px;
    color: #1a3a6b;
    cursor: pointer;
}

/* ==== SPINNER DE CARGA ==== */
#perfil_loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px;
    color: #555;
    font-size: 14px;
    gap: 15px;
}

.spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #1a3a6b;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== MEDIA QUERY MÓVIL (Menú Lateral Derecho + Footer Visible) ===== */
@media (max-width: 768px) {

    #contenedor {
        display: block !important;
    }

    #menu_navegacion {
        left: auto !important;
        right: 0 !important;
        transform: translateX(100%) !important;
        box-shadow: -2px 0 12px rgba(0,0,0,0.1);
    }

    #menu_navegacion.abierto {
        transform: translateX(0) !important;
    }

    #topbar-movil {
        display: flex !important;
    }

    #contenido {
        margin-left: 0 !important;
        padding: 90px 15px 30px !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Reducimos espaciados en móvil para que todo quepa sin scroll */
    .sidebar-logo {
        padding: 20px 24px;
    }

    .sidebar-logo-img {
        width: 55px; /* Logo un poco más pequeño */
    }

    .menu_opciones_contenedor {
        padding: 10px 0;
    }

    .nav-item {
        padding: 10px 24px; /* Items más compactos */
    }

    .sidebar-footer {
        padding: 15px 20px;
    }

    .btn_cerrar_sesion {
        padding: 8px;
        font-size: 12px;
    }

    /* Ajuste de items del menú en móvil */
    .nav-item {
        border-left: none !important;
        border-right: 4px solid transparent;
    }

    .nav-item:hover, .nav-item.active {
        border-right: 4px solid #1a3a6b;
        border-left: none !important;
    }

    /* Ajuste Card Bienvenida en Móvil */
    .card-bienvenida {
        flex-direction: row !important;
        flex-wrap: wrap; 
        padding: 20px !important;
        justify-content: space-between;
    }

    .bienvenida-texto {
        width: 100%;
        margin-bottom: 0;
    }

    .bienvenida-texto h1 { font-size: 1.2rem !important; }

    .bienvenida-icono {
        position: absolute;
        bottom: 20px;
        right: 20px;
        font-size: 3rem !important;
        margin-top: 0 !important;
    }

    .header-top {
        margin-bottom: 20px;
    }
    
    .header-top h2 { font-size: 1.1rem; }
}