/* =========================================
   1. VARIABLES (COLORES) - ¡ARRIBA DE TODO!
   ========================================= */
:root {
    --primary-color: #249b95;    /* VERDE SEBA BRU */
    --secondary-color: #f0c516;  /* AMARILLO */
    --dark-color: #242c3f;       /* AZUL OSCURO */
    --light-color: #cccac3;
    --text-dark: #333;
    --text-light: #f4f4f4;
}

/* =========================================
   2. FUENTES
   ========================================= */
@font-face { font-family: 'Segoe'; src: url('../fonts/segoeui.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Segoe'; src: url('../fonts/segoeuib.ttf') format('truetype'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Lemon Milk'; src: url('../fonts/LEMONMILK-Regular.otf') format('opentype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Lemon Milk'; src: url('../fonts/LEMONMILK-Medium.otf') format('opentype'); font-weight: 500; font-style: normal; font-display: swap; }

/* =========================================
   3. CONFIGURACIÓN GLOBAL
   ========================================= */
body {
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    font-family: 'Segoe', sans-serif;
    color: var(--text-dark);
}

.intro-box h1 {
    font-family: 'Lemon Milk', sans-serif !important;
    color: var(--dark-color);
    font-size: 2.2rem;
    margin-bottom: 10px;
    font-weight: 500;
}
.intro-box p {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 40px;
}

/* =========================================
   4. ESTRUCTURA DE ESCRITORIO (PC)
   ========================================= */
.aula-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* --- SIDEBAR IZQUIERDO --- */
.sidebar-panel {
    background-color: var(--primary-color);
    color: white;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
}

.sidebar-content {
    padding: 25px;
    display: flex;
    flex-direction: column;
    min-height: 90%;
}

.sidebar-header h3 {
    font-family: 'Lemon Milk', sans-serif;
    color: var(--secondary-color);
    margin: 0 0 5px 0;
    font-size: 1.2rem;
    font-weight: 400;
}
.sidebar-header p {
    margin-top: 0;
    opacity: 0.9;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 15px;
    font-size: 0.9rem;
}

.btn-sidebar-main {
    display: block;
    background: rgba(0,0,0,0.2);
    color: white;
    padding: 12px;
    text-align: center;
    border-radius: 6px;
    text-decoration: none;
    font-family: 'Lemon Milk', sans-serif;
    font-size: 0.85rem;
    margin: 15px 0;
    transition: 0.3s;
}
.btn-sidebar-main:hover {
    background: var(--secondary-color);
    color: var(--dark-color);
}

.auto-nav ul {
    list-style: none;
    padding: 0;
    margin-top: 20px;
}
.auto-nav li a {
    display: block;
    padding: 12px 10px;
    color: white;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    transition: 0.2s;
    font-size: 0.95rem;
}
.auto-nav li a:hover {
    background: rgba(255,255,255,0.15);
    padding-left: 15px;
    color: var(--secondary-color);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    text-align: center;
}
.sidebar-footer a { 
    color: rgba(255,255,255,0.7); 
    text-decoration: none;
    font-size: 0.9rem;
}

/* --- CONTENIDO PRINCIPAL --- */
.main-content {
    padding: 40px 60px;
    max-width: 900px;
    width: 100%;
    box-sizing: border-box;
}

.clase-item {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    margin-bottom: 50px;
    scroll-margin-top: 100px; 
}

.clase-header h2 {
    font-family: 'Lemon Milk', sans-serif;
    color: var(--primary-color);
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    font-size: 1.6rem;
    margin-top: 0;
}
.num {
    background: var(--secondary-color);
    color: var(--dark-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    margin-right: 10px;
    vertical-align: middle;
}

/* --- VIDEO --- */
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    background: #000;
    margin: 20px 0;
    border-radius: 8px;
    overflow: hidden;
    width: 100% !important;
    max-width: 100%;
}
.video-container iframe {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;
}

/* --- DESPLEGABLE Y PDF --- */
.material-desplegable summary {
    cursor: pointer;
    font-weight: bold;
    padding: 15px;
    background: #f4f4f4;
    border-radius: 6px;
    list-style: none;
    color: var(--dark-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s;
}
.material-desplegable summary:hover {
    background: #e0e0e0;
}
.contenido-desplegable {
    padding: 20px 0;
    border-top: none;
}

.pdf-wrapper {
    position: relative;
    width: 100%;
    height: 600px; /* Aumentado según tu arreglo final */
    margin-top: 15px;
    border: 1px solid #ddd;
    background: #fff;
}
.btn-expandir {
    position: absolute;
    top: 10px; right: 10px;
    background: var(--dark-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    z-index: 10;
    font-family: 'Segoe', sans-serif;
    font-weight: bold;
    opacity: 0.9;
}
.btn-expandir:hover { opacity: 1; background: black; }
.pdf-iframe { width: 100%; height: 100%; border: none; }

.pdf-wrapper.fullscreen-mode {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 9999;
    background: black;
    border: none;
}
.pdf-wrapper.fullscreen-mode .pdf-iframe { height: 100%; }
.pdf-wrapper.fullscreen-mode .btn-expandir {
    background: var(--secondary-color);
    color: black;
}

.btn-external {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    font-size: 0.9rem;
}
.btn-external:hover { background-color: var(--dark-color); }

/* =========================================
   5. VERSIÓN MÓVIL (AULA)
   ========================================= */
.mobile-header { display: none; }

@media (max-width: 768px) {
    .aula-layout { display: block; }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background-color: var(--primary-color);
        color: white;
        padding: 0 20px;
        height: 60px;
        position: fixed;
        top: 0; left: 0; width: 100%;
        z-index: 2000;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        box-sizing: border-box;
    }
    .mobile-title {
        font-family: 'Lemon Milk', sans-serif;
        font-size: 0.9rem;
    }
    .hamburger-btn {
        background: transparent;
        border: 1px solid rgba(255,255,255,0.6);
        color: white;
        padding: 6px 12px;
        border-radius: 4px;
        font-family: 'Lemon Milk', sans-serif;
        font-size: 0.8rem;
        cursor: pointer;
    }

    .sidebar-panel {
        position: fixed;
        top: 60px; 
        left: 0;
        width: 100%;
        height: 75vh;
        transform: translateY(-150%);
        transition: transform 0.4s ease-in-out;
        box-shadow: none; 
        background-color: var(--primary-color);
        border-bottom-left-radius: 20px;
        border-bottom-right-radius: 20px;
        z-index: 1500;
    }

    .sidebar-panel.is-open {
        transform: translateY(0);
        box-shadow: 0 100vh 0 rgba(0,0,0,0.5); 
    }

    .main-content {
        padding: 80px 20px 40px 20px;
    }
    .intro-box h1 {
        font-size: 1.8rem;
    }
    .pdf-wrapper {
        height: 400px;
    }
} /* <--- ¡ESTA LLAVE CIERRA LA VERSIÓN MÓVIL! */

/* =========================================
   6. ESTILOS DE LA GALERÍA (INDEX ESCUELA)
   ========================================= */
.bg-escuela {
    background-color: #f0f2f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.school-header {
    text-align: center;
    padding: 60px 20px 40px;
    width: 100%;
    background: var(--primary-color); 
    color: var(--dark-color);         
    margin-bottom: 40px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.school-header h1 {
    font-family: 'Lemon Milk', sans-serif;
    color: var(--dark-color);
    margin: 0;
    font-size: 2.5rem;
}
.back-link {
    display: inline-block;
    margin-top: 15px;
    color: #242c3f; 
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: bold; 
}
.back-link:hover {
    text-decoration: underline;
    color: var(--dark-color);
}

.courses-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    max-width: 1200px;
    width: 90%;
    padding-bottom: 60px;
}
.course-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}
.course-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}
.card-image {
    position: relative;
    width: 100%;
    padding-top: 125%; 
    overflow: hidden;
}

/* ⚠️ AQUÍ ESTÁ EL CAMBIO PRINCIPAL PARA EL VIDEO ⚠️ */
.card-image img, 
.card-image video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover; /* Mantiene la proporción sin deformarse */
    transition: transform 0.5s ease;
}

/* EFECTO ZOOM AL PASAR EL MOUSE (PARA IMAGEN Y VIDEO) */
.course-card:hover .card-image img,
.course-card:hover .card-image video {
    transform: scale(1.1);
}

.overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(36, 155, 149, 0.85); 
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-family: 'Lemon Milk', sans-serif;
    font-size: 1.2rem;
    opacity: 0; 
    transition: opacity 0.3s ease;
    gap: 8px;
    z-index: 2; /* Asegura que quede encima del video */
}
.course-card:hover .overlay {
    opacity: 1;
}
.course-card h3 {
    text-align: center;
    padding: 20px;
    margin: 0;
    color: var(--dark-color);
    font-family: 'Lemon Milk', sans-serif;
    font-size: 1rem;
}

/* =========================================
   7. MODAL LOGIN / REGISTRO (DEFINITIVO)
   ========================================= */

.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); 
    display: none; 
    justify-content: center;
    align-items: center;
    z-index: 9999; 
    backdrop-filter: blur(5px); 
}
.modal-overlay.active { display: flex; }

.modal-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: aparecer 0.3s ease-out;
}

@keyframes aparecer {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-btn {
    position: absolute;
    top: 15px; right: 20px;
    background: none; border: none;
    font-size: 2rem; 
    color: #999;
    cursor: pointer;
    transition: color 0.3s;
}
.close-btn:hover { color: var(--dark-color); }

.modal-box h2 {
    font-family: 'Lemon Milk', sans-serif;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.modal-box p {
    color: #666;
    margin-bottom: 20px;
}

/* Formularios */
form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

input {
    padding: 12px 15px;
    border: 2px solid #eee;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}
input:focus {
    border-color: var(--primary-color);
}

.btn-login {
    background: var(--dark-color);
    color: white;
    border: none;
    padding: 14px;
    font-family: 'Lemon Milk', sans-serif;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 8px;
    transition: transform 0.2s, background 0.3s;
}
.btn-login:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

.modal-box a {
    color: var(--primary-color);
    font-weight: bold;
    text-decoration: none;
}
.modal-box a:hover {
    text-decoration: underline;
}

.error-msg {
    background-color: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    border: 1px solid #ef9a9a;
}

/* =========================================
   8. AJUSTES FINALES PARA MÓVIL (Galería)
   ========================================= */

@media (max-width: 768px) {
    .courses-container {
        width: 95%;
        gap: 20px;
    }
    .course-card h3 {
        font-size: 0.9rem;
        padding: 15px;
    }

    /* CANDADO FLOTANTE MÓVIL */
    .overlay {
        opacity: 1 !important;
        background: transparent !important;
        padding: 0;
        font-size: 0; 
        top: 15px; 
        right: 15px;
    }

    .overlay i {
        font-size: 1.6rem;
        color: white;
        filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8)); 
    }
} /* <--- OTRA LLAVE IMPORTANTE QUE CIERRA EL MEDIA QUERY */


/* =========================================
   9. SEGURIDAD (SPINNER / PORTERO)
   ========================================= */
/* Ahora sí, esto está afuera de todo media query y funciona siempre */
#security-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: white;
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px; height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.texto-seguridad {
    font-family: 'Segoe', sans-serif;
    color: #555;
    font-size: 1rem;
}

.error-seguridad {
    color: red;
    font-weight: bold;
    display: none;
}

@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}