/* Optimized general styles for better performance */
body {
    font-family: Arial, sans-serif;
    background: linear-gradient(-45deg, #f7fafc, #e2e8f0, #cbd5e0, #a0aec0);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    margin: 0;
    padding: 0;
    will-change: background-position;
    contain: layout style;
}

/* Modal de login */
.login-modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.90);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-content {
    background: #d0d0d0;
    padding: 2em;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.login-content input {
    margin-bottom: 1em;
    padding: 0.5em;
    width: 80%;
}

body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: linear-gradient(-45deg, #f7fafc, #e2e8f0, #cbd5e0, #a0aec0);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    will-change: background-position;
}

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

header {
    background-color: #2d3748;
    color: white;
    padding: 1rem;
    will-change: transform;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar {
    background-color: #f7fafc;
    padding: 1rem;
    min-height: 100%;
    will-change: transform;
}

.header-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    justify-content: center;
}

.btn-admin,
.btn-logout {
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s, opacity 0.2s;
    text-decoration: none;
}

.btn-admin {
    background-color: #667eea;
    color: #fff;
}

.btn-admin:hover {
    background-color: #5a67d8;
}

.btn-logout {
    background-color: #e53e3e;
    color: #fff;
}

.btn-logout:hover {
    background-color: #c53030;
}

.spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    font-size: 2rem;
    color: #3182ce;
}

/* Loading mejorado (mismo estilo que leccion.html) */
.loading-message {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1.2em;
    color: #666;
    background: linear-gradient(-45deg, #f7fafc, #e2e8f0);
    border-radius: 8px;
    margin: 2rem 0;
    will-change: opacity;
    text-align: center;
}

.loading-message>div {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
        transform: translate3d(0, 0, 0);
    }

    50% {
        background-position: 100% 50%;
        transform: translate3d(0, 0, 0);
    }

    100% {
        background-position: 0% 50%;
        transform: translate3d(0, 0, 0);
    }
}

/* Optimización para mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }
}

/* Hardware-accelerated gradient animation */
@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
        transform: translate3d(0, 0, 0);
    }

    50% {
        background-position: 100% 50%;
        transform: translate3d(0, 0, 0);
    }

    100% {
        background-position: 0% 50%;
        transform: translate3d(0, 0, 0);
    }
}

/* Optimized header styles */
header {
    background-color: #2d3748;
    color: white;
    padding: 1rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    will-change: transform;
    contain: layout style;
}

header h1 {
    font-size: 1.5rem;
    margin: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 90%;
    margin: 0 auto;
    padding: 0 1rem;
}

.logo-left,
.logo-right {
    flex: 1;
    /* Ocupa el espacio disponible */
    display: flex;
    align-items: center;
}

.logo-left {
    justify-content: flex-start;
    /* Alinea el logo a la izquierda */
}

.logo-right {
    justify-content: flex-end;
    /* Alinea el logo a la derecha */
}

.logo-left img,
.logo-right img {
    max-height: 100px;
    /* Altura máxima */
    width: auto;
    /* Ancho proporcional */
}

.header-title {
    flex: 1;
    /* Da más espacio al título para evitar saltos de línea en desktop */
    min-width: 0;
    text-align: center;
    padding: 0 1rem;
    /* Espaciado lateral para separar los logos */
}

.header-title h1 {
    font-size: clamp(1rem, 4vw, 1.75rem);
    margin: 0;
    font-weight: bold;
    white-space: nowrap;
}

.header-title p {
    font-size: 1rem;
    margin: 0.25rem 0 0;
    color: #cbd5e0;
    white-space: nowrap;
    /* Color gris claro para el texto secundario */
}

.menu-toggle {
    background-color: #4299e1;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    cursor: pointer;
    display: none;
    /* Ocultar en pantallas grandes */
}

.menu-toggle i {
    margin-right: 0.5rem;
}

/* Contenedor principal */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Menú lateral */
.sidebar {
    width: 285px;
    background-color: white;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    max-height: calc(100vh - 140px);
    /* Solo activa scroll si el contenido supera la vista disponible */
    overflow-y: auto;
    overscroll-behavior: contain;
    transition: transform 0.3s ease;
    position: relative;
}

.sidebar-top {
    position: sticky;
    top: 0;
    background: inherit;
    /* o color de fondo de la barra */
    z-index: 10;
    padding-top: 1pt;
}

.sidebar h2 {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: #2d3748;
}

.sidebar ul {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.sidebar li {
    margin-bottom: 0.75rem;
}

.sidebar a {
    color: #3182ce;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.3s ease;
}

.sidebar a:hover {
    background-color: #4299e1;
    color: white;
    transform: translateX(5px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.sidebar a i {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.sidebar a:hover i {
    transform: translateX(5px);
}

.sidebar .home-button {
    display: block;
    text-align: center;
    background-color: #4299e1;
    color: white;
    padding: 0.5rem;
    border-radius: 0.25rem;
    margin-top: 1rem;
    text-decoration: none;
    transition: all 0.3s ease;
}

.sidebar .home-button:hover {
    background-color: #3182ce;
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}


.facultad-link {
    font-weight: bold;
    display: block;
    padding: 10px 15px;
    color: #2c3e50;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.3s;
    border-radius: 4px;
}

.facultad-link:hover {
    background-color: #f0f0f0;
    border-left: 3px solid #3498db;
}

.facultad-link i {
    float: right;
    margin-top: 3px;
    transition: transform 0.3s;
    font-size: 0.9rem;
}


.submenu {
    padding-left: 5px;
    border-left: 2px solid #ddd;
    margin-left: 10px;
    overflow: hidden;
    transition: max-height 1s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 0;
    /* Oculto por defecto */
}

.submenu.active {
    max-height: 1100px;
    transition: max-height 1s cubic-bezier(0.4, 0, 0.2, 1);
}


.submenu a {
    display: block;
    padding: 8px 15px;
    color: #555;
    text-decoration: none;
    transition: all 0.3s;
    border-radius: 4px;
}

.submenu a:hover {
    background-color: #f5f5f5;
    padding-left: 20px;
    color: #3498db;
}


/* Área de contenido */
.content {
    flex: 1;
    background-color: white;
    padding: 1rem;
    overflow-y: auto;
    overflow: visible !important;
    max-height: none !important;
}

.content iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Estilos para la lista de lecciones */
.lesson-list {
    list-style-type: none;
    /* Elimina los números predeterminados */
    padding-left: 0;
    counter-reset: lesson-counter;
    /* Inicia un contador */
}

.lesson-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    margin-right: 20px;
    counter-increment: lesson-counter;
    /* Incrementa el contador */
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.lesson-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.lesson-item::before {
    content: counter(lesson-counter) ". ";
    /* Muestra el número */
    margin-right: 0.5rem;
    /* Espacio entre el número y el texto */
    color: #2d3748;
    /* Color del número */
    font-weight: bold;
    /* Opcional: resalta el número */
}

.lesson-link {
    color: #3182ce;
    text-decoration: none;
    flex: 1;
    /* Ocupa el espacio disponible */
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.3s ease;
}

.lesson-link:hover {
    background-color: #4299e1;
    color: white;
    transform: translateX(5px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.print-icon {
    background-color: #4299e1;
    /* Azul en lugar de verde */
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.print-icon:hover {
    background-color: #3182ce;
    /* Azul más oscuro al hacer hover */
    transform: scale(1.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.print-icon i {
    color: white;
    /* Asegura que el ícono siempre sea blanco */
}

/* Lista de cursos */
.course-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* 3 columnas */
    gap: 1.5rem;
    /* Espacio entre los elementos */
    padding: 0;
    list-style-type: none;
}

/* Estilos para cada curso (botón) */
.course-list li {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #4299e1;
    /* Fondo azul */
    border-radius: 0.5rem;
    /* Bordes redondeados */
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.course-list li:hover {
    background-color: #3182ce;
    /* Fondo azul más oscuro al hacer hover */
    transform: translateY(-5px);
    /* Efecto de elevación */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Estilos para los enlaces (botones) */
.course-link {
    color: white;
    /* Texto blanco */
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: bold;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.course-link:hover {
    color: white;
    /* Mantener el texto blanco */
}

/* Spinner de carga */
.spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    color: #4299e1;
    margin-top: 1rem;
}

/* Responsive design */

/* Tablets y pantallas medianas (768px - 1400px) */
@media (max-width: 1400px) {
    .header-content {
        flex-wrap: nowrap;
        max-width: 98%;
        gap: 0.5rem;
        padding: 0 0.5rem;
    }

    .logo-left,
    .logo-right {
        flex: 0 0 auto;
        min-width: fit-content;
    }

    .logo-left img,
    .logo-right img {
        max-height: 60px;
    }

    .header-title {
        flex: 1;
        min-width: 0;
        padding: 0 0.5rem;
    }

    .header-title h1 {
        font-size: clamp(1rem, 2.5vw, 1.3rem);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-title p {
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .header-actions {
        gap: 0.3rem;
    }

    .btn-admin,
    .btn-logout {
        padding: 0.35rem 0.7rem;
        font-size: 0.75rem;
    }

    .btn-admin span,
    .btn-logout span {
        display: none;
    }
}

/* Móviles (max 768px) */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
        /* Mostrar en móviles */
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 250px;
        transform: translateX(-100%);
        z-index: 1000;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
    }

    .main-content {
        flex-direction: column;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .logo-left,
    .logo-right {
        justify-content: center;
        margin: 0.5rem 0;
    }

    .logo-left img,
    .logo-right img {
        max-height: 50px;
        /* Altura máxima */
        width: auto;
        /* Ancho proporcional */
    }

    .header-title {
        padding: 0;
        /* Elimina el espaciado lateral en móviles */
    }

    .header-title h1 {
        font-size: 1.25rem;
        white-space: normal;
    }

    .header-title p {
        font-size: 0.8rem;
    }
}