/*
 * Descripción: Estilos específicos para la interfaz del estudiante.
 */

/* ==========================================================================
   STUDENT.CSS — Interfaz del alumno
   Dashboard, visor de cursos, tipos de quiz, feedback, ruta de aprendizaje
   ========================================================================== */

/* ==========================================================================
   1. SISTEMA HEADER (barra fija — dashboard y syllabus)
   ========================================================================== */

.sistema-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 72px;
    z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
}

[data-theme="dark"] .sistema-header {
    background: rgba(10, 10, 12, 0.7);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sistema-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 25px;
}

@media (max-width: 768px) {
    .sistema-nav { padding: 0 20px; }
}

.header-left-part  { flex: 1; display: flex; justify-content: flex-start; }
.header-center-part { flex: 0 0 auto; display: flex; justify-content: center; }

@media (max-width: 900px) {
    .header-center-part, .header-center-group { 
        display: none !important; 
    }
}

.header-right-part { flex: 1; display: flex; justify-content: flex-end; }


.header-identity-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.class-name-row {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    line-height: 1;
}

.alias-number-row {
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1;
    margin-top: 2px;
}

.header-center-group {
    background: rgba(0, 0, 0, 0.03);
    padding: 6px 16px 6px 14px;
    border-radius: 40px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 16px;
}

[data-theme="dark"] .header-center-group {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.header-profile-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--glass-border);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.header-profile-circle:hover {
    transform: scale(1.1) rotate(5deg);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.3);
}

.stat-item-simple {
    font-size: 0.85rem;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 99px;
    background: rgba(var(--primary-rgb), 0.06);
    color: var(--primary);
}

.header-stats-compact {
    border-radius: 12px;
    background: var(--glass-bg);
}

.class-badge {
    background: rgba(0,0,0,0.05);
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dim);
    border: 1px solid var(--glass-border);
}

[data-theme="dark"] .class-badge { background: rgba(255,255,255,0.1); }

.header-alias {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
}

.badge-count {
    background: var(--error);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Logo Geomatics — currentColor controla el tema ("Geoma" y "s"), cyan fijo para "tic" */
.logo-geomatics {
    height: 44px;
    width: auto;
    min-width: 120px;
    color: #1a1a2e;
    transition: color 0.3s ease, opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    overflow: visible;
}

@media (max-width: 650px) {
    .logo-geomatics { height: 34px; }
}

.logo-geomatics svg {
    width: auto;
    height: 100%;
    overflow: visible;
}

[data-theme="dark"]  .logo-geomatics { color: #ffffff; }
[data-theme="rosa"] .logo-geomatics { color: #1a1a2e; }

/* ==========================================================================
   2. STUDENT DASHBOARD — Layout y tarjetas
   ========================================================================== */

.mobile-layout {
    padding-top: 72px; /* reserva el sistema-header */
}

main.main-container {
    padding: 12px 25px 60px !important;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 768px) {
    main.main-container {
        padding-top: 18px !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }
}

.responsive-grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.horizontal-scroll-snap {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 10px;
}
.horizontal-scroll-snap::-webkit-scrollbar { display: none; }

.dashboard-header {
    background: linear-gradient(180deg, var(--bg) 0%, rgba(255,255,255,0) 100%);
}

.profile-avatar-container {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--card-bg);
}

.xp-card {
    border-radius: var(--card-radius);
    border: 1px solid var(--glass-border);
}

.level-pill {
    background: var(--primary);
    color: white;
    border-radius: 6px;
}

.streak-pill {
    background: #ffede0;
    color: #ff9500;
    border-radius: 6px;
}

[data-theme="dark"] .streak-pill {
    background: rgba(255, 149, 0, 0.2);
}

.apple-progress-bar {
    height: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 10px;
    overflow: hidden;
}

[data-theme="dark"] .apple-progress-bar { background: rgba(255,255,255,0.1); }

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 10px;
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.course-card-apple {
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--glass-bg);
    overflow: hidden;
}

.course-card-apple:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-elevated);
    border-color: var(--primary);
}

.course-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resume-card {
    border-radius: 22px;
    border: 1px solid var(--glass-border);
    background: linear-gradient(90deg, var(--card-bg) 0%, rgba(52, 199, 89, 0.05) 100%);
}

.play-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--success);
    color: white;
}

.rate-blocked {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(1);
    transition: opacity 0.3s, filter 0.3s;
}

.challenge-card-apple {
    background: var(--card-bg);
    border-radius: 22px;
    border-top: 4px solid var(--error);
    min-width: 0;
    scroll-snap-align: start;
}

/* ==========================================================================
   3. COURSE VIEWER & CAROUSEL
   ========================================================================== */

.viewer-layout {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    padding-top: 0;
    background-color: #f5f5f7;
    background-image:
        radial-gradient(at 0%   0%,   rgba(var(--primary-rgb), 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%,   rgba(var(--primary-rgb), 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(var(--primary-rgb), 0.05) 0px, transparent 50%),
        radial-gradient(at 0%   100%, rgba(var(--primary-rgb), 0.03) 0px, transparent 50%);
}

[data-theme="dark"] .viewer-layout  { background-color: var(--bg); }
[data-theme="rosa"] .viewer-layout { background-color: var(--bg); }

.step-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.carousel-track {
    display: flex;
    height: 100%;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.viewer-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--glass-border);
    background: var(--bg);
    z-index: 10;
    flex-shrink: 0;
    width: 100%;
    max-width: 840px;
    margin: 0 auto;
}

.viewer-footer {
    padding: 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    z-index: 10;
    flex-shrink: 0;
    width: 100%;
    max-width: 840px;
    margin: 0 auto;
}

@media (max-width: 500px) {
    .viewer-header {
        padding: 10px 15px;
        padding-top: calc(10px + env(safe-area-inset-top));
    }
    .viewer-footer {
        padding: 15px 20px;
        padding-bottom: calc(15px + env(safe-area-inset-bottom));
        max-width: 100%;
    }
}

.carousel-slide {
    min-width: 100%;
    height: 100%;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.step-container {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    width: 100%;
    max-width: 840px;
    margin: 0 auto;
}

.student-course-card:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   4. QUIZ — MCQ (opción múltiple)
   ========================================================================== */

.option-card {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 18px !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
}

.option-card:hover {
    border-color: var(--primary) !important;
    background: rgba(0, 113, 227, 0.02) !important;
    transform: translateY(-2px);
}

.option-card:active { transform: scale(0.98); }

.option-card.active {
    border-color: var(--primary) !important;
    background: rgba(0, 122, 255, 0.05) !important;
    box-shadow: 0 0 0 2px var(--primary);
}

.mcq-indicator {
    width: 22px;
    height: 22px;
    border: 2px solid var(--glass-border);
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mcq-radio    { border-radius: 50%; }
.mcq-checkbox { border-radius: 6px; }

.option-card.active .mcq-indicator,
.active .mcq-indicator {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(0, 113, 227, 0.3);
}

.option-card.active .mcq-radio {
    background: radial-gradient(circle, white 35%, var(--primary) 40%);
}

.option-card.active .mcq-checkbox::after {
    content: 'check';
    font-family: 'Material Symbols Rounded';
    color: white;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none !important;
}

/* ==========================================================================
   5. QUIZ — FIB (fill-in-blank)
   ========================================================================== */

.fib-input {
    display: inline-block;
    width: auto;
    min-width: 80px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-bottom: 2px solid var(--text-dim);
    border-radius: 8px 8px 0 0;
    padding: 4px 10px;
    margin: 0 4px;
    color: var(--text);
    text-align: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--font-code);
    font-weight: 700;
    font-size: 1rem;
    outline: none;
}

[data-theme="dark"] .fib-input { background: rgba(255, 255, 255, 0.05); }

.fib-input:focus {
    background: rgba(0, 0, 0, 0.02);
    border-bottom-color: var(--primary);
}

.fib-input.correct {
    border-bottom-color: var(--success) !important;
    background: rgba(52, 199, 89, 0.1) !important;
    color: var(--success) !important;
}

.fib-input.error {
    border-bottom-color: var(--error) !important;
    background: rgba(255, 59, 48, 0.1) !important;
    color: var(--error) !important;
}

/* ==========================================================================
   6. QUIZ — DND (drag and drop)
   ========================================================================== */

.dnd-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    min-height: 42px;
    margin: 0 6px;
    padding: 0 12px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px dashed var(--glass-border);
    border-radius: 12px;
    vertical-align: middle;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.95rem;
}

[data-theme="dark"] .dnd-slot { background: rgba(255, 255, 255, 0.03); }

.dnd-slot.filled {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
    color: var(--primary);
}

.dnd-slot.correct { background: rgba(52, 199, 89, 0.1) !important; border-color: var(--success) !important; color: var(--success) !important; }
.dnd-slot.error   { background: rgba(255, 59, 48, 0.1)  !important; border-color: var(--error)   !important; color: var(--error)   !important; }

.word-pill {
    padding: 10px 20px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    color: var(--text);
    word-break: break-word;
    text-align: center;
}

.word-pill:active { transform: scale(0.95); }

.word-pill.used {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(1);
}

.dnd-bank {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    overflow-x: hidden;
}

.dnd-content {
    overflow-wrap: break-word;
    word-break: break-word;
    overflow-x: hidden;
}

.flying-pill {
    position: fixed;
    z-index: 9999;
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: 14px;
    font-weight: 700;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   7. FEEDBACK SHEET (estilo Duolingo)
   ========================================================================== */

.feedback-sheet {
    position: fixed;
    bottom: -250px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 840px;
    padding: 25px 30px;
    z-index: 3000;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 24px 24px 0 0;
    color: white;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.feedback-sheet.open   { bottom: 0; }
.feedback-sheet.correct   { background-color: #58cc02; border-top: 5px solid #46a302; }
.feedback-sheet.incorrect { background-color: #ff4b4b; border-top: 5px solid #d33131; }

.feedback-sheet h3 { margin: 0; font-weight: 900; }

.feedback-icon-container {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.correct   .feedback-icon-container { color: var(--success); }
.incorrect .feedback-icon-container { color: var(--error); }

/* Botones de feedback (override sobre el sistema de botones) */
.feedback-sheet .btn-success {
    background: white !important;
    color: #58cc02 !important;
    border-bottom: 4px solid #e5e5e5 !important;
    font-weight: 800 !important;
    text-transform: uppercase;
}

.feedback-sheet .btn-error {
    background: white !important;
    color: #ff4b4b !important;
    border-bottom: 4px solid #e5e5e5 !important;
    font-weight: 800 !important;
    text-transform: uppercase;
}

/* ==========================================================================
   8. SUPPORT PANEL (chat alumno-profesor)
   ========================================================================== */

.support-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    height: 100dvh;
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-left: 1px solid var(--glass-border);
    z-index: 2001;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
}

.support-panel.open { transform: translateX(-420px); }

@media (max-width: 500px) {
    .support-panel { width: 100%; right: 0; border-left: none; }
    .support-panel.open { transform: translateX(0); }
}

.support-header {
    padding: 30px;
    border-bottom: 1px solid var(--glass-border);
}

@media (max-width: 500px) {
    .support-header { padding: 20px; }
}

.support-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    -webkit-overflow-scrolling: touch;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message-bubble.student {
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text);
    border-bottom-right-radius: 2px;
}

.message-bubble.teacher {
    align-self: flex-start;
    background: rgba(0, 242, 255, 0.15);
    border: 1px solid rgba(0, 242, 255, 0.3);
    color: var(--primary-light);
    border-bottom-left-radius: 2px;
}

.support-footer {
    padding: 24px;
    border-top: 1px solid var(--glass-border);
    background: var(--bg);
    flex-shrink: 0;
}

@media (max-width: 500px) { .support-footer { padding: 15px; } }

.support-input-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.type-selector { 
    display: flex; 
    gap: 4px; 
    padding: 4px;
    background: rgba(var(--text-rgb), 0.05);
    border-radius: 16px;
    margin-bottom: 20px; 
}

.type-btn {
    flex: 1;
    padding: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(var(--text-rgb), 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--btn-radius);
    color: var(--text);
    opacity: 0.4;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    text-align: center;
}

.type-btn.active {
    opacity: 1;
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.support-textarea {
    background: rgba(var(--text-rgb), 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    color: var(--text);
    padding: 16px;
    resize: none;
    font-size: 1rem;
    min-height: 100px;
    outline: none;
    transition: border-color 0.3s, background 0.3s;
}

.support-textarea:focus { border-color: var(--primary); }

/* ==========================================================================
   9. BADGE / LOGRO
   ========================================================================== */

.badge-container {
    text-align: center;
    padding: 40px 20px;
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.badge-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    display: block;
}

@keyframes zoomIn {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   10. LEARNING PATH — Ruta de aprendizaje / syllabus
   ========================================================================== */

.syllabus-path {
    padding: 10px 25px 100px;
}

.module-group {
    margin-bottom: 0;
    position: relative;
}

.module-badge-header {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 10px 20px;
    border-radius: 30px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent);
}

.lesson-node {
    margin-bottom: 0;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 18px;
    position: relative;
    z-index: 2;
    cursor: pointer;
}

.lesson-node:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(5px);
}

.lesson-node.completed {
    border-left: 4px solid var(--success);
    background: linear-gradient(90deg, rgba(52, 199, 89, 0.05) 0%, transparent 100%);
}

.lesson-node.locked {
    opacity: 0.4;
    filter: grayscale(1);
    cursor: not-allowed;
}

.lesson-icon-circle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.lesson-node.completed .lesson-icon-circle {
    background: var(--success);
    border-color: var(--success);
    color: var(--bg);
}

.lesson-info-content h4 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 2px 0;
}

.lesson-info-content p {
    font-size: 0.75rem;
    opacity: 0.5;
    margin: 0;
}

/* ==========================================================================
   11. MARKDOWN BODY (renderizado de contenido teórico)
   ========================================================================== */

.markdown-body {
    line-height: 1.8;
    font-size: 1.05rem;
    color: var(--text);
    font-family: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
    letter-spacing: -0.01em;
}

.markdown-body p { margin-bottom: 24px; }

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin: 35px 0 15px;
    line-height: 1.25;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    margin: 20px 0;
    border: 1px solid var(--glass-border);
}

code {
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 5px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95em;
    font-weight: 500;
}

[data-theme="dark"] code { background: rgba(255, 255, 255, 0.1); }

.markdown-body pre {
    background: var(--code-bg);
    padding: 24px;
    border-radius: 18px;
    overflow-x: auto;
    margin: 24px 0;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
    position: relative;
}

.markdown-body pre::before {
    content: '•••';
    position: absolute;
    top: 8px;
    left: 14px;
    font-size: 18px;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.2);
}

.markdown-body pre code {
    line-height: 1.6;
    white-space: pre-wrap;
    display: block;
    color: var(--code-text);
    background: transparent !important;
    font-size: 0.9rem;
    font-family: var(--font-code);
}

[data-theme="dark"] .markdown-body pre {
    border-color: var(--glass-border);
    background: var(--code-bg-deep);
}

.markdown-body pre code .code-line {
    display: block;
    padding: 8px 24px;
    margin: 0 -24px;
    transition: all 0.2s;
    border-left: 4px solid transparent;
    border-bottom: 1px solid var(--code-line-border);
}

.markdown-body pre code .code-line:nth-child(even) {
    background: var(--code-line-even);
}

.markdown-body pre code .code-line:hover {
    background: var(--code-line-hover);
    border-left-color: var(--primary);
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 0.95rem;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.markdown-body th, 
.markdown-body td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
    border-right: 1px solid var(--glass-border);
}

.markdown-body th:last-child,
.markdown-body td:last-child {
    border-right: none;
}

.markdown-body tr:last-child td {
    border-bottom: none;
}

.markdown-body th {
    background: rgba(var(--text-rgb), 0.05);
    font-weight: 800;
    color: var(--text);
}

.markdown-body tr:nth-child(even) {
    background: rgba(var(--text-rgb), 0.02);
}



/* ==========================================================================
   12. STUDENT PLM LAB IDE (cuando el paso es de código)
   ========================================================================== */

.lab-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg);
}

.lab-header {
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
}

.lab-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    overflow: hidden;
}

.lab-toolbar {
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    gap: 10px;
    overflow-x: auto;
}

.lab-editor-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--glass-border);
}

#plm-editor {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    color: #e0e0e0;
    padding: 30px;
    font-family: var(--font-code);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

.lab-preview-pane {
    background: #08080a;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
}

/* ==========================================================================
   13. PWA INSTALL BANNER
   ========================================================================== */

.install-banner {
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: 24px;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg);
    border: 1px solid var(--primary);
    border-radius: 20px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 9999;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 242, 255, 0.1);
    transform: translateY(150%);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.install-banner.show { transform: translateY(0); }

.install-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.install-content { flex: 1; }
.install-content h4 { margin: 0; font-size: 1rem; font-weight: 700; }
.install-content p  { margin: 2px 0 0; font-size: 0.85rem; opacity: 0.7; }

.install-actions { display: flex; gap: 8px; }

.btn-install {
    background: var(--primary) !important;
    color: black !important;
    padding: 8px 16px !important;
    width: auto !important;
    font-size: 0.9rem !important;
}

.btn-close-banner {
    background: transparent !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-dim) !important;
    padding: 8px !important;
    width: auto !important;
}

@media (max-width: 600px) {
    .install-banner { bottom: 12px; left: 12px; right: 12px; padding: 12px 16px; }
    .install-icon   { width: 40px; height: 40px; }
}

/* ==========================================================================
   SUPPORT FAB (Floating Action Button)
   ========================================================================== */

.support-fab {
    position: fixed;
    bottom: 30px;
    right: 25px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(var(--primary-rgb), 0.4);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.support-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 30px rgba(var(--primary-rgb), 0.5);
}

.support-fab:active { transform: scale(0.9); }

.notification-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: var(--error);
    border-radius: 50%;
    border: 2px solid var(--bg);
}

/* ==========================================================================
   SCHOOL LOCK OVERLAY
   ========================================================================== */

.school-lock-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    backdrop-filter: blur(20px);
}

@keyframes float {
    0%, 100% { transform: translateY(0);     }
    50%       { transform: translateY(-15px); }
}

.school-lock-icon {
    font-size: 80px;
    animation: float 3s ease-in-out infinite;
}

/* ==========================================================================
   QUIZ — MATCH
   ========================================================================== */

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.match-col  { display: flex; flex-direction: column; gap: 12px; }

.match-card {
    padding: 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
    box-shadow: var(--shadow-soft);
}

.match-card:active  { transform: scale(0.97); }
.match-card.active  { border-color: var(--primary); background: rgba(0,122,255,0.05); box-shadow: 0 0 0 2px var(--primary); }
.match-card.linked  { border-color: var(--success); background: rgba(52,199,89,0.05); }

.link-badge {
    width: 22px;
    height: 22px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}

.linked .link-badge { background: var(--success); }

/* ==========================================================================
   QUIZ — CHECK BUTTON
   ========================================================================== */

.check-mcq {
    min-height: 56px;
    padding: 0 32px;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.check-mcq:hover {
    transform: translateY(-2px);
    opacity: 0.95;
    box-shadow: 0 8px 20px rgba(0, 113, 227, 0.2);
}

/* ==========================================================================
   14. DASHBOARD V2
   ========================================================================== */

/* Hero Section */
.hero-section {
    border-radius: var(--card-radius);
    overflow: hidden;
    position: relative;
    padding: 24px 20px 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
}

.hero-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--hero-color) 0%, transparent 70%);
    opacity: 0.12;
    pointer-events: none;
}

.hero-alias {
    font-size: clamp(2rem, 8vw, 3rem);
    font-weight: 900;
    letter-spacing: -2px;
    line-height: 1;
    color: var(--hero-color);
    margin: 2px 0 0;
}

/* XP bar override — más gruesa en el hero */
.apple-progress-bar.hero-xp-bar { height: 14px; }
.hero-xp-bar .progress-fill { background: var(--stat-xp); }

/* Level Badge */
.level-badge {
    position: relative;
    background: var(--primary);
    color: white;
    border-radius: 16px;
    padding: 8px 16px;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.35);
}

.level-badge__number {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: -1px;
    line-height: 1;
    display: block;
}

.level-badge__shine {
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    animation: badge-shine 3s ease-in-out infinite;
}

@keyframes badge-shine {
    0%       { left: -60%; }
    40%, 100% { left: 110%; }
}

/* Stat Chips Row */
.stat-chips-row {
    display: flex;
    gap: 10px;
}

.stat-chip {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border-radius: 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 0;
}

.stat-chip__icon  { font-size: 18px; flex-shrink: 0; }
.stat-chip__value {
    font-size: 0.8rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-chip--streak     { border-color: rgba(255, 149, 0, 0.3); }
.stat-chip--challenges { border-color: rgba(215, 0, 21, 0.2); }

.stat-chip:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-elevated);
}

/* CTA Card */
.cta-card {
    border-radius: var(--card-radius);
    padding: 20px;
    background: var(--glass-bg);
    border: 2px solid var(--success);
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 20px rgba(29, 157, 63, 0.15);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.cta-card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(29, 157, 63, 0.05) 0%, transparent 60%);
}

.cta-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(29, 157, 63, 0.25);
}

.cta-card--start {
    border-color: var(--primary);
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.12);
}
.cta-card--start::before {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.05) 0%, transparent 60%);
}
.cta-card--start:hover { box-shadow: 0 8px 30px rgba(var(--primary-rgb), 0.2); }

.cta-card--challenges-empty {
    border-color: rgba(215, 0, 21, 0.3);
    box-shadow: none;
    opacity: 0.7;
}
.cta-card--challenges-empty::before { display: none; }
.cta-card--challenges-empty:hover   { transform: none; box-shadow: none; }

/* CTA Arrow */
.cta-arrow-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(29, 157, 63, 0.3);
}

.cta-card--start .cta-arrow-circle {
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.cta-arrow-icon {
    color: white;
    font-size: 22px;
    animation: arrow-pulse 2s ease-in-out infinite;
}

@keyframes arrow-pulse {
    0%, 100% { transform: translateX(0); }
    50%       { transform: translateX(3px); }
}

/* Course status badges */
.course-done-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--success);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.course-new-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   LAB PREVIEW — Overrides para que el viewer-layout quede contenido
   en el panel de preview del laboratorio y no tape toda la pantalla.
   El viewer-layout usa position:fixed + height:100dvh normalmente.
   Aquí lo convertimos en flex-item para que su altura sea la del frame.
   ========================================================================== */

#lab-viewer-frame .viewer-layout {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: 100% !important;
    height: auto !important;   /* anula los 100dvh originales */
    flex: 1 1 auto !important;
    min-height: 0 !important;  /* permite que flex-shrink funcione */
    z-index: 1 !important;
}

#lab-viewer-frame .viewer-header,
#lab-viewer-frame .viewer-footer {
    max-width: 100%;
}

/* El padding-top:72px de .mobile-layout reserva el header global del alumno,
   que no existe en el preview del lab — lo eliminamos */
#lab-viewer-frame .mobile-layout {
    padding-top: 0 !important;
}

/* ==========================================================================
   DUELOS v2 — Estilos específicos para la arena de combate
   ========================================================================== */

@keyframes pulse {
    from { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4); }
    to { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255, 59, 48, 0); }
}

.duel-timer-box {
    transition: all 0.3s ease;
}

.btn-primary-apple {
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 800;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-primary-apple:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.btn-primary-apple:active {
    transform: scale(0.95);
}

.flying-pill {
    position: fixed;
    z-index: 9999;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

