/* ==========================================================================
   LERNISY CODE · ESTILOS DEL ENTORNO DE APRENDIZAJE ESTRUCTURADO (v3.0)
   Diseño sobrio, ergonómico y descansado (Estilo VS Code / Fleet / Linear)
   ========================================================================== */

:root {
    --bg-main: #0b0e14;
    --bg-header: #12161f;
    --bg-card: #161b24;
    --bg-panel: #141822;
    --bg-editor: #0d1117;
    --bg-subtle: #1c222e;

    --border-color: #272f3d;
    --border-subtle: #1e2430;
    --border-focus: #58a6ff;

    --text-primary: #f0f6fc;
    --text-muted: #8b949e;
    --text-dim: #5c6470;

    --primary: #58a6ff;
    --primary-subtle: rgba(88, 166, 255, 0.15);

    --accent-emerald: #3fb950;
    --accent-amber: #d29922;
    --accent-rose: #f85149;

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --header-h: 46px;
    --status-h: 26px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-main);
}

/* TOPBAR */
.topbar {
    height: var(--header-h);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    z-index: 100;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.brand-icon {
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    color: #0b0e14;
    font-family: var(--font-mono);
    font-weight: 900;
    font-size: 0.8rem;
    padding: 3px 7px;
    border-radius: var(--radius-sm);
}

.brand-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.3px;
}

.nav-pills {
    display: flex;
    background: var(--bg-main);
    border: 1px solid var(--border-subtle);
    padding: 2px;
    border-radius: var(--radius-sm);
    gap: 2px;
}

.nav-pill-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.nav-pill-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.nav-pill-btn.active {
    color: #ffffff;
    background: var(--bg-subtle);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.xp-pill {
    color: var(--accent-amber);
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-tool {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-tool:hover {
    color: var(--text-primary);
    border-color: var(--primary);
    background: var(--bg-subtle);
}

.btn-run {
    background: var(--accent-emerald);
    color: white;
    border: none;
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: filter 0.15s ease;
}

.btn-run:hover {
    filter: brightness(1.1);
}

.btn-subtle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-subtle:hover {
    color: var(--text-primary);
    border-color: var(--primary);
}

/* VIEWPORT PRINCIPAL */
.main-viewport {
    height: calc(100vh - var(--header-h) - var(--status-h));
    width: 100vw;
    overflow: hidden;
    position: relative;
}

.screen-panel {
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.screen-panel.active {
    display: flex;
}

/* ==========================================================================
   VISTA 1: CATÁLOGO DE CURSOS Y TEMARIOS
   ========================================================================== */
.catalog-wrapper {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 30px 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.catalog-header-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 26px 30px;
    margin-bottom: 26px;
}

.course-pill {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary);
    background: var(--primary-subtle);
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.course-card-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.course-card-item:hover {
    border-color: var(--primary);
    background: var(--bg-panel);
    transform: translateY(-2px);
}

.course-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.course-card-icon {
    font-size: 2rem;
}

.course-card-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.3;
}

.course-card-desc {
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.5;
    margin-bottom: 20px;
    flex: 1;
}

.course-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border-subtle);
    padding-top: 12px;
}

/* Temario desplegable */
.syllabus-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 26px;
    margin-top: 20px;
    animation: fadeIn 0.2s ease;
}

.syllabus-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 16px;
}

.lessons-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lesson-row-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.15s ease;
}

.lesson-row-card:hover {
    border-color: var(--primary);
    background: var(--bg-subtle);
}

/* ==========================================================================
   VISTA 2: ESPACIO DE TRABAJO (TEORÍA + EDITOR + SALIDA)
   ========================================================================== */
.workspace-split {
    width: 100%;
    height: 100%;
    display: flex;
    background: var(--bg-main);
    overflow: hidden;
}

/* Panel Izquierdo: Explicación Pedagógica */
.theory-panel {
    width: 440px;
    min-width: 340px;
    max-width: 550px;
    height: 100%;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.theory-header {
    height: 48px;
    padding: 0 16px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.badge-tag {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-subtle);
    padding: 2px 6px;
    border-radius: 4px;
}

.theory-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    margin-top: 2px;
}

.theory-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
}

.theory-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.theory-card.task-card {
    border-color: rgba(210, 153, 34, 0.4);
    background: rgba(210, 153, 34, 0.05);
}

.section-label {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rich-text {
    font-size: 0.88rem;
    color: #cbd5e1;
    line-height: 1.6;
}

.rich-text p {
    margin-bottom: 10px;
}

.rich-text code {
    background: var(--bg-subtle);
    color: #38bdf8;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.code-sample-box {
    background: #090c10;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: #e6edf3;
    line-height: 1.5;
    overflow-x: auto;
}

.requirements-box {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.req-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.req-item.passed {
    border-color: var(--accent-emerald);
    color: var(--accent-emerald);
    background: rgba(63, 185, 80, 0.1);
}

.req-item.failed {
    border-color: var(--accent-rose);
    color: var(--accent-rose);
    background: rgba(248, 81, 73, 0.1);
}

.hint-box {
    background: #1f1b0a;
    border: 1px solid rgba(210, 153, 34, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 12px;
    font-size: 0.84rem;
    color: #fef08a;
    line-height: 1.5;
}

/* Panel Derecho: Editor de Código + Consola */
.editor-panel {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-editor);
    min-width: 320px;
}

.editor-bar {
    height: 48px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.editor-mode-indicator {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.editor-mode-indicator strong {
    color: var(--primary);
}

.web-tabs {
    display: flex;
    gap: 4px;
}

.file-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.file-tab:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.file-tab.active {
    color: #ffffff;
    background: var(--bg-editor);
    border-top: 2px solid var(--primary);
}

.code-area-wrapper {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

.gutter {
    width: 44px;
    padding: 14px 8px 14px 0;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 22px;
    color: var(--text-dim);
    background: var(--bg-editor);
    border-right: 1px solid var(--border-subtle);
    user-select: none;
    overflow: hidden;
    white-space: pre-line;
}

.code-editor {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: #f0f6fc;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 22px;
    padding: 14px 16px;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    overflow-y: auto;
    tab-size: 2;
}

/* Panel de Salida / Consola */
.output-panel {
    height: 220px;
    min-height: 140px;
    max-height: 360px;
    background: #090c10;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.output-bar {
    height: 32px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

.test-pill {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dim);
}

.console-box {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.6;
    color: #a5b4fc;
}

.web-preview-frame {
    flex: 1;
    border: none;
    background: #ffffff;
    width: 100%;
    height: 100%;
}

/* ==========================================================================
   VISTA 3: SANDBOX LIBRE
   ========================================================================== */
.sandbox-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.sandbox-toolbar {
    height: 48px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sandbox-workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.sandbox-editor-col {
    flex: 1;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-editor);
}

.sandbox-preview-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

/* STATUSBAR INFERIOR */
.statusbar {
    height: var(--status-h);
    background: var(--bg-header);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
    user-select: none;
}

.sb-left, .sb-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
    .workspace-split {
        flex-direction: column;
    }
    .theory-panel {
        width: 100%;
        max-width: 100%;
        min-height: 40%;
    }
    .editor-panel {
        min-height: 60%;
    }
}
