/* BODY y HTML: deben permitir el scroll global */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto; /* IMPORTANTE: permitir el scroll vertical globalmente */
}

/* Contenedor principal */
#layout {
    display: flex;
    min-height: 100vh;
    flex-direction: row;
}

/* Sidebar (SIEMPRE flotante) */
#sidebar {
    width: 250px;
    background-color: #343a40;
    color: white;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1050;
    transition: left 0.3s ease;
}
#sidebar.show {
    left: 0;
}

/* Overlay */
#overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
}
#overlay.active {
    display: block;
}


/* Botón hamburguesa oculto en escritorio */
#toggleSidebar {
    display: none;
}

@media (max-width: 991px) {
    #toggleSidebar {
        display: block;
    }
}

/* Contenido principal */
#content-wrapper {
    flex-grow: 1;
    min-height: 100vh;
    margin-left: 250px;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background-color: #343a40;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* Main */
main {
    flex-grow: 1;
    padding: 20px;
}

/* Footer */
footer {
    background-color: #343a40;
    color: white;
    text-align: center;
    padding: 10px 0;
    width: 100%;
}

/* Animaciones suaves para Sidebar Links */
.sidebar-link {
    transition: background-color 0.3s ease, transform 0.3s ease;
    padding: 10px;
    border-radius: 5px;
}
.sidebar-link:hover {
    background-color: #495057;
    transform: translateX(5px);
}
.sidebar-link.active,
.sidebar-link:focus {
    background-color: #17a2b8;
    color: #ffffff;
    transform: translateX(8px);
}

/* Íconos del sidebar */
.sidebar-link i {
    margin-right: 8px;
    transition: transform 0.3s ease;
}
.sidebar-link:hover i {
    transform: scale(1.2);
}

/* Sidebar oculto SOLO en móviles */
@media (max-width: 991px) {
    #sidebar {
        left: -250px;
    }
    #sidebar.show {
        left: 0;
    }
}

/* Content sin margin en móviles */
@media (max-width: 991px) {
    #content-wrapper {
        margin-left: 0;
    }
}

/* Animación de deslizamiento suave para el sidebar */
@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

/* Aplicamos la animación cuando el sidebar se muestra */
#sidebar.show {
    animation: slideIn 0.4s forwards;
}

/* Aplicamos la animación cuando el sidebar se oculta */
#sidebar.hide {
    animation: slideOut 0.4s forwards;
}