/* =========================================
   VISOR REAI - Estilos específicos de gamificación
   Base visual de recuedu.css
   ========================================= */

/* Variables adicionales para temas */
:root {
    /* TEMA POR DEFECTO: GAMER (PLAYFUL) - basado en recuedu */
    --bg-app-game: #e0f2fe;        
    --accent: #8b5cf6;        
    --success: #22c55e;       
    --error: #ef4444;         
    --radius-game: 20px;
    --font-game: 'Nunito', sans-serif;
    --shadow: 0 10px 30px -5px rgba(59, 130, 246, 0.3);
    --border-width: 2px;
}

/* TEMA: ZEN (CLEAN) */
[data-theme="theme-clean"] {
    --bg-app-game: #f8fafc;
    --primary: #475569;       
    --primary-dark: #1e293b;
    --accent: #94a3b8;
    --radius-game: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --border-width: 1px;
}

/* TEMA: OSCURO (DARK) */
[data-theme="theme-dark"] {
    --bg-app-game: #0f172a;        
    --bg-card: #1e293b;       
    --primary: #38bdf8;       
    --primary-dark: #0ea5e9;
    --accent: #c084fc;
    --text-main: #f1f5f9;     
    --text-muted: #94a3b8;
    --radius-game: 16px;
    --shadow: 0 0 20px rgba(56, 189, 248, 0.15);
    --border-width: 2px;
}

/* =========================================
   2. RESET Y LAYOUT BASE
   ========================================= */
* { box-sizing: border-box; user-select: none; }

body {
    font-family: var(--font-game);
    background-color: var(--bg-app-game);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.5s ease, color 0.5s ease;
    padding-top: 0; /* Se ajusta cuando tiene topbar */
}

/* Ajuste cuando tiene topbar de RecuEdu Labs */
body.has-topbar {
    padding-top: 42px; /* Keep content below fixed topbar */
}

body.has-topbar #app-container {
    height: calc(100vh - 42px);
}

/* Keep topbar attached to the top edge */
body.has-topbar .recuedu-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 2000;
}

#app-container {
    width: 100%;
    max-width: 650px; /* Un poco más ancho para matching */
    margin: 0 auto;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* PANTALLAS (SPA) */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    opacity: 1;
    z-index: 10;
}

/* TARJETAS DE CRISTAL */
.card-glass {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    border: var(--border-width) solid rgba(0,0,0,0.05);
}

.center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
    margin: auto; /* Centrado vertical */
}

/* =========================================
   3. COMPONENTES UI (HUD, Upload, Botones)
   ========================================= */

/* SELECTOR DE TEMA */
.theme-switcher {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 200;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Ajustar posición cuando hay topbar */
body.has-topbar .theme-switcher {
    top: 55px;
}

select {
    padding: 8px 12px;
    border-radius: 20px;
    border: none;
    background: var(--bg-card);
    color: var(--text-main);
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* ZONA DE CARGA (UPLOAD) */
.upload-area {
    border: 3px dashed var(--primary);
    padding: 40px;
    border-radius: var(--radius);
    width: 100%;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    color: var(--primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
.upload-area:hover {
    background: rgba(14, 165, 233, 0.05);
    transform: scale(1.02);
}
.upload-area.dragging {
    background: rgba(14,165,233,0.12);
    border-color: var(--accent);
}

/* HUD (Barra Superior) */
.hud { padding-bottom: 20px; }

.progress-track {
    background: rgba(0,0,0,0.1);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    background: var(--success);
    height: 100%;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    font-size: 1.2rem;
    flex-wrap: wrap;
    gap: 10px;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 5px;
}

.xp { color: #eab308; display: flex; align-items: center; gap: 5px; }
.streak { color: #f97316; display: flex; align-items: center; gap: 5px; }

/* BOTONES PRINCIPALES */
.bottom-bar { margin-top: auto; padding-top: 20px; }

.nav-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.btn-ghost {
    background: transparent;
    border: 2px dashed var(--primary);
    color: var(--primary);
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-ghost:hover { background: rgba(14,165,233,0.1); }

.btn-main {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 16px;
    background: var(--primary);
    color: white;
    font-weight: 800;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--primary-dark);
    transition: transform 0.1s;
}

.btn-main:active { transform: translateY(6px); box-shadow: none; }
.btn-main:disabled {
    background: #cbd5e1;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.7;
    transform: translateY(2px);
}

.btn-action {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}
.btn-action:hover { background: var(--primary); color: white; }

.btn-hint {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border: none;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    box-shadow: 0 4px 0 #d97706;
}
.btn-hint:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #d97706; }
.btn-hint:active { transform: translateY(2px); box-shadow: 0 2px 0 #d97706; }
.btn-hint:disabled {
    background: #cbd5e1;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-reset-header {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid var(--border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 600;
    white-space: nowrap;
}
.btn-reset-header i {
    font-size: 1.2rem;
}
.btn-reset-header:hover { 
    background: var(--primary); 
    color: white; 
    border-color: var(--primary);
}

/* Ocultar texto en móviles */
@media (max-width: 768px) {
    .btn-reset-header .reset-text {
        display: none;
    }
    .btn-reset-header {
        padding: 8px 12px;
    }
}

/* HINT BOX - Caja de pista visible */
.hint-box {
    display: none;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 3px solid #fbbf24;
    border-radius: 16px;
    padding: 16px 20px;
    margin: 15px 0;
    font-size: 1rem;
    color: #92400e;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3);
    align-items: center;
    gap: 12px;
}
.hint-box.show {
    display: flex;
}
.hint-box i {
    font-size: 1.8rem;
    color: #f59e0b;
    flex-shrink: 0;
}
.hint-box span {
    flex: 1;
}

/* =========================================
   4. ESTILOS DE TIPOLOGÍAS DE EJERCICIO
   ========================================= */

.exercise-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 120px; /* Espacio para el modal/botón */
}

.question-text {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
    line-height: 1.5;
}

/* SHORT ANSWER */
.short-answer input {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
    font-size: 1.05rem;
    background: var(--bg-card);
}
.helper { margin-top: 8px; color: var(--text-light); font-size: 0.9rem; }

/* HOTSPOT */
.hotspot-container { display: flex; flex-direction: column; gap: 10px; }
.hotspot-image {
    position: relative;
    width: 100%;
    padding-top: 60%;
    background-size: cover;
    background-position: center;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
    overflow: hidden;
}
.hotspot-zone {
    position: absolute;
    border: 2px dashed var(--primary);
    background: rgba(14,165,233,0.15);
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}
.hotspot-zone:hover { box-shadow: 0 0 0 2px var(--accent); }
.hotspot-zone.selected { background: rgba(34,197,94,0.2); border-color: var(--success); }

/* SLIDER */
.slider-wrap { display: flex; flex-direction: column; gap: 10px; }
.slider-meta { display: flex; justify-content: space-between; font-weight: 700; color: var(--text-light); }

/* TIPO 1 & 2: MULTIPLE CHOICE / TRUE FALSE */
.options-grid { display: grid; gap: 15px; }

.option-btn {
    background: var(--bg-card);
    border: 2px solid #e2e8f0;
    padding: 18px;
    border-radius: 16px;
    text-align: left;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    color: var(--text-main);
    font-weight: 600;
    position: relative;
}

.option-btn:hover { border-color: var(--primary); }
.option-btn.selected {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.1);
    box-shadow: 0 0 0 2px var(--primary);
}

/* TIPO 3: FILL GAPS (HUECOS) */
.cloze-text {
    font-size: 1.3rem;
    line-height: 2.2;
    background: rgba(255, 255, 255, 0.72);
    border: 2px solid #dbeafe;
    border-radius: 16px;
    padding: 16px;
    white-space: normal;
}

.cloze-bank-wrap {
    margin-top: 16px;
}

.cloze-bank {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: 14px;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.82);
}

.cloze-token {
    font-family: inherit;
}

.cloze-bank .cloze-token {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 700;
    background: var(--bg-card);
    color: var(--text-main);
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-size: 1rem;
    line-height: 1.2;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.cloze-bank .cloze-token:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.cloze-bank .cloze-token:active {
    cursor: grabbing;
}

.cloze-bank .cloze-token.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25);
}

.cloze-drop {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 124px;
    min-height: 44px;
    padding: 2px 8px;
    margin: 0 5px;
    border: 2px dashed var(--primary);
    vertical-align: middle;
    border-radius: 10px;
    background: rgba(224, 242, 254, 0.42);
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.cloze-drop.drag-over {
    background: rgba(14, 165, 233, 0.12);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25);
}

.cloze-drop.filled {
    background: rgba(14, 165, 233, 0.08);
    border-style: solid;
}

.cloze-drop .cloze-token {
    margin: 0;
    border: none;
    border-radius: 0;
    padding: 0 2px;
    background: transparent;
    box-shadow: none;
    color: var(--primary-dark);
    cursor: pointer;
    font-weight: 800;
}

.cloze-drop-placeholder {
    color: var(--text-light);
    font-weight: 700;
    letter-spacing: 0.8px;
    opacity: 0.75;
}

.cloze-input {
    border: none;
    border-bottom: 3px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-weight: 800;
    text-align: center;
    width: 120px;
    font-size: 1.2rem;
    padding: 0 5px;
    font-family: inherit;
}
.cloze-input:focus { outline: none; border-color: var(--accent); }

/* TIPO 4: ORDERING (ORDENAR) */
.sortable-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sortable-item {
    background: var(--bg-card);
    padding: 16px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: grab;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.35;
}
.sortable-item:active { cursor: grabbing; border-color: var(--primary); background: #f0f9ff; }

.sortable-handle {
    color: var(--text-light);
    font-size: 1.35rem;
    line-height: 1;
    margin-top: 2px;
    flex: 0 0 auto;
}

.sortable-label {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

/* TIPO 5: MATCHING (RELACIONAR) */
.matching-grid {
    display: grid;
    grid-template-columns: 1fr 40px 1fr;
    gap: 10px;
    align-items: center;
}

.static-list, .draggable-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.static-item {
    background: rgba(0,0,0,0.03);
    border: 2px solid rgba(0,0,0,0.1);
    padding: 10px;
    border-radius: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 70px;
    color: var(--text-light);
    font-size: 0.9rem;
    text-align: center;
}

.draggable-item {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    padding: 10px;
    border-radius: 12px;
    font-weight: 700;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 70px;
    color: var(--text-main);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    font-size: 0.9rem;
    text-align: center;
}
.draggable-item:active { cursor: grabbing; background: #e0f2fe; }

.arrows-column {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    height: 100%;
    color: var(--text-light);
    font-size: 1.5rem;
    align-items: center;
}

/* TIPO 6: GROUPING (CLASIFICACIÓN) */
.grouping-area {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.items-pool {
    background: rgba(0,0,0,0.05);
    padding: 15px;
    border-radius: 16px;
    min-height: 80px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    border: 2px dashed #cbd5e1;
    align-content: center;
}

.buckets-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.bucket {
    background: var(--bg-card);
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.bucket-header {
    background: var(--primary);
    color: white;
    padding: 12px;
    text-align: center;
    font-weight: 800;
    font-size: 0.9rem;
}

.bucket-dropzone {
    padding: 10px;
    min-height: 140px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255,255,255,0.5);
}

.group-item {
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: grab;
    border: 1px solid #e2e8f0;
    color: #333;
}
.group-item:active { cursor: grabbing; transform: scale(1.05); }

/* =========================================
   5. FEEDBACK Y MODALES
   ========================================= */

.feedback-modal {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    border-radius: 30px 30px 0 0;
    padding: 30px;
    box-shadow: 0 -10px 50px rgba(0,0,0,0.25);
    text-align: center;
    z-index: 100;
    transform: translateY(110%);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    color: #333; /* Forzar color oscuro en modal siempre */
}

.feedback-modal.show { transform: translateY(0); }

.feedback-modal.correct { border-top: 8px solid var(--success); }
.feedback-modal.incorrect { border-top: 8px solid var(--error); }

.btn-close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-main);
}
.btn-close-modal:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

.feedback-content i { font-size: 3rem; margin-bottom: 10px; display: block; }

#feedback-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 5px; }
#feedback-text { font-size: 1rem; color: #475569; margin-bottom: 20px; line-height: 1.5; }
.feedback-extra { margin-top: 10px; text-align: left; }
.fb-hint { margin-top: 6px; color: #0f172a; font-weight: 700; }
.fb-expl { margin-top: 6px; color: #334155; }
.fb-more summary { cursor: pointer; font-weight: 700; margin-top: 8px; }
.fb-more div { margin-top: 4px; color: #334155; }

.feedback-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.btn-retry {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 14px 30px;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}
.btn-retry:hover { 
    background: var(--primary); 
    color: white; 
    transform: scale(1.05);
}

.btn-next {
    background: var(--text-main);
    color: white;
    border: none;
    padding: 14px 30px;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}
.btn-next:hover { transform: translateX(5px); }

/* UTILIDADES */
.hidden { display: none !important; }
