/* ====== Estructura de la app: menú lateral, barra superior y contenido ====== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background-color: var(--azul);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    flex-shrink: 0;
}

.sidebar-titulo {
    padding: 0 1.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.sidebar a {
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
}

.sidebar a:hover, .sidebar a.activo {
    background-color: var(--azul-oscuro);
}

.sidebar a.cerrar-sesion {
    margin-top: auto;
    color: var(--amarillo);
}

.contenido-principal {
    flex: 1;
    min-width: 0;            /* evita que tablas anchas desborden la pantalla */
    padding: 2rem;
}

.topbar {
    text-align: right;
    font-size: 0.85rem;
    color: var(--gris);
    margin-bottom: 1.5rem;
}

.barra-superior {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

/* Barra superior y fondo del menú: solo se usan en el teléfono */
.topbar-movil, .menu-fondo { display: none; }

/* ---------- Teléfono y tablet vertical ---------- */
@media (max-width: 768px) {
    .app-layout { display: block; }

    .topbar-movil {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        position: sticky;
        top: 0;
        z-index: 30;
        background: var(--azul);
        color: white;
        padding: 0.5rem 1rem;
        padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
    }
    .topbar-movil-titulo { font-weight: bold; font-size: 1.05rem; }
    .btn-menu {
        background: transparent;
        border: 0;
        color: white;
        font-size: 1.6rem;
        line-height: 1;
        padding: 0.3rem 0.6rem;
        min-width: 44px;
        min-height: 44px;
        cursor: pointer;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 82vw;
        z-index: 50;
        overflow-y: auto;
        padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }
    .sidebar a { padding: 0.9rem 1.5rem; }      /* zona táctil cómoda */
    .app-layout.menu-abierto .sidebar { transform: none; }

    .menu-fondo {
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(0, 0, 0, 0.45);
    }
    .app-layout.menu-abierto .menu-fondo { display: block; }
    body.menu-abierto-body { overflow: hidden; }

    .contenido-principal { padding: 1rem; padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }
    .topbar { text-align: left; margin-bottom: 1rem; }
}
