/* ==========================================================================
   RESET Y VARIABLES
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #2563eb;
    --dark-bg: #0f172a;
    --menu-card: #1e293b;
    --text-main: #f8fafc;
    --sidebar-width: 350px;
}

html, body {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #f1f5f9;
    font-family: 'Segoe UI', Roboto, sans-serif;
}

body {
    display: flex;
}

#main-menu {
    background: var(--dark-bg);
    color: var(--text-main);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 25px;
    overflow-y: auto;
    transition: transform 0.4s ease-in-out;
}

#app-container {
    flex-grow: 1;
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

@media (min-width: 1025px) {
    #main-menu {
        width: var(--sidebar-width);
        transform: translateX(0) !important;
        position: relative;
    }
}

@media (max-width: 1024px) {
    #main-menu {
        position: fixed;
        top: 0;
        left: 0;
        width: 85%;
        max-width: 320px;
        height: 100%;
        transform: translateX(-100%);
    }
    #main-menu:not(.hidden) {
        transform: translateX(0);
    }
}

#pills-viewport {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    will-change: transform;
}

.pildora {
    flex-shrink: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.card {
    background: white;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    overflow-y: auto;
}

.card h1, .card h2 { color: #1e293b; margin-bottom: 20px; }
.card p { color: #475569; line-height: 1.6; font-size: 1.1rem; }

/* ESTILOS DEL MAPA */
.tema-container { margin-bottom: 15px; }
.tema-header {
    background: var(--menu-card);
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.subtema-list { margin-left: 15px; margin-top: 10px; border-left: 2px solid #334155; padding-left: 15px; }
.subtema-item { margin-bottom: 10px; }
.subtema-title { color: #94a3b8; font-size: 0.9rem; font-weight: bold; text-transform: uppercase; margin-bottom: 5px; }

.leccion-link {
    display: block;
    padding: 10px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    margin-top: 5px;
    font-size: 0.85rem;
    transition: background 0.2s, color 0.2s;
}

.leccion-link:hover {
    background: rgba(59, 130, 246, 0.1);
    color: white;
}

.hidden { display: none !important; }

.navigation-controls {
    position: fixed;
    bottom: 25px;
    right: 25px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.navigation-controls button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.navigation-controls button:disabled { background: #cbd5e1; opacity: 0.5; }

/* BOTÓN FINALIZAR */
.btn-finish {
    display: block;
    margin: 30px auto 0 auto;
    padding: 16px 40px;
    background: #22c55e;
    color: white;
    border: none;
    border-radius: 14px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.35);
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn-finish:hover {
    background: #16a34a;
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.45);
}

.btn-finish:active {
    transform: scale(0.97);
    box-shadow: 0 3px 10px rgba(34, 197, 94, 0.3);
}

/* IMÁGENES Y VÍDEOS DENTRO DE PÍLDORAS */
#pills-viewport img {
    max-width: 100%;
    max-height: 55vh;
    height: auto;
    display: block;
    margin: 20px auto;
    border-radius: 12px;
    object-fit: contain;
}

@media (min-width: 768px) and (max-width: 1024px) {
    #pills-viewport img {
        max-height: 45vh;
    }
}

#pills-viewport iframe {
    max-width: 100%;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
}