/* --- VARIABLES DE DISEÑO ARCADE NEÓN --- */
:root {
    --bg-main: #060713;
    --bg-panel: rgba(15, 16, 38, 0.85);
    --bg-card: rgba(26, 20, 54, 0.6);
    --border-color: rgba(138, 75, 243, 0.25);
    --border-focus: #00f0ff;
    
    /* Colores Gamer */
    --color-primary: #8a4bf3;       /* Morado gamer */
    --color-secondary: #00f0ff;     /* Cian cyber */
    --color-pink: #ff007f;          /* Rosa neón */
    --color-green: #39ff14;         /* Verde matrix */
    --color-text: #f1f3f9;          /* Blanco brillante */
    --color-text-muted: #737b98;    /* Gris azulado */
    --color-error: #ff3366;         /* Rojo laser */
    --color-warning: #ffaa00;       /* Naranja alerta */
    
    /* Fuentes */
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'Source Code Pro', monospace;
    
    /* Efectos */
    --transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    --shadow-purple: 0 0 15px rgba(138, 75, 243, 0.35);
    --shadow-cyan: 0 0 15px rgba(0, 240, 255, 0.35);
    --shadow-pink: 0 0 15px rgba(255, 0, 127, 0.35);
}

/* --- RESET & GENERAL --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--color-text);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(138, 75, 243, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 240, 255, 0.05) 0%, transparent 40%);
}

/* Scrollbar Personalizado */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-secondary);
}

/* --- HEADER DE LA CONSOLA --- */
.app-header {
    background-color: rgba(6, 7, 19, 0.95);
    border-bottom: 2px solid var(--color-primary);
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 10px rgba(138, 75, 243, 0.15);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.8rem;
    animation: floating 2.5s infinite ease-in-out;
}

.logo-area h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ffffff 30%, var(--color-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    font-size: 0.65rem;
    background: rgba(255, 0, 127, 0.1);
    color: var(--color-pink);
    border: 1px solid rgba(255, 0, 127, 0.25);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 0 5px rgba(255, 0, 127, 0.2);
}

.header-stats {
    display: flex;
    gap: 1rem;
}

.stat-card {
    background: rgba(138, 75, 243, 0.08);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.8rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    box-shadow: var(--shadow-purple);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

.stat-value {
    font-size: 1.05rem;
    font-weight: 800;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

.text-green {
    color: var(--color-green);
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.4);
}

/* --- APP LAYOUT --- */
.app-container {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    padding: 1.25rem;
    max-width: 1700px;
    width: 100%;
    margin: 0 auto;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 0;
}

/* --- INSTRUCCIONES --- */
.instruction-card {
    background: var(--bg-panel);
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    box-shadow: var(--shadow-purple);
}

.instruction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(138, 75, 243, 0.2);
    padding-bottom: 0.4rem;
}

.instruction-header h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--color-secondary);
    text-shadow: 0 0 5px rgba(0, 240, 255, 0.2);
}

.step-indicator {
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(0, 240, 255, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    color: var(--color-secondary);
    border: 1px solid rgba(0, 240, 255, 0.2);
}

.instruction-content {
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--color-text);
}

.instruction-content p {
    margin-bottom: 0.5rem;
}

.instruction-content h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--color-secondary);
    margin-bottom: 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid rgba(0, 240, 255, 0.15);
}

.instruction-content h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-top: 0.8rem;
    margin-bottom: 0.4rem;
}

.instruction-content ul, .instruction-content ol {
    margin-left: 1.2rem;
    margin-bottom: 0.5rem;
}

.instruction-content li {
    margin-bottom: 0.3rem;
}

.instruction-content li::marker {
    color: var(--color-secondary);
}

.instruction-content code {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-pink);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.instruction-content pre {
    background: #0a0c1a;
    border: 1px solid rgba(138, 75, 243, 0.3);
    border-left: 3px solid var(--color-primary);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.6rem 0;
    overflow-x: auto;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.instruction-content pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--color-green);
    font-size: 0.8rem;
    line-height: 1.5;
}

.instruction-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.6rem 0;
    font-size: 0.82rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(138, 75, 243, 0.25);
}

.instruction-content th {
    background: rgba(138, 75, 243, 0.15);
    color: var(--color-secondary);
    font-weight: 700;
    text-align: left;
    padding: 0.5rem 0.7rem;
    border-bottom: 2px solid rgba(138, 75, 243, 0.3);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.instruction-content td {
    padding: 0.45rem 0.7rem;
    border-bottom: 1px solid rgba(138, 75, 243, 0.1);
}

.instruction-content tr:last-child td {
    border-bottom: none;
}

.instruction-content tr:hover td {
    background: rgba(138, 75, 243, 0.05);
}

.hint-container {
    background: rgba(138, 75, 243, 0.06);
    border-left: 3px solid var(--color-primary);
    border-radius: 4px;
    padding: 0.6rem 0.8rem;
    margin-top: 0.2rem;
    animation: slideIn 0.25s ease-out;
}

.hint-title {
    font-weight: 800;
    font-size: 0.8rem;
    color: var(--color-primary);
    margin-bottom: 0.15rem;
}

.hint-text {
    font-size: 0.8rem;
    color: var(--color-text);
    line-height: 1.35;
}

/* --- EDITOR DE CÓDIGO --- */
.editor-container {
    background: var(--bg-panel);
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    box-shadow: var(--shadow-purple);
    min-height: 320px;
}

.editor-header {
    background: rgba(138, 75, 243, 0.04);
    border-bottom: 1px solid var(--border-color);
    padding: 0.4rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-name {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.editor-wrapper {
    flex: 1;
    display: flex;
    background: #04050d;
    position: relative;
}

.line-numbers {
    padding: 1rem 0.5rem;
    color: rgba(138, 75, 243, 0.3);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    text-align: right;
    user-select: none;
    border-right: 1px solid rgba(255, 255, 255, 0.02);
    background: #020307;
    min-width: 32px;
}

.code-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 1rem;
    white-space: pre;
    tab-size: 4;
}

.editor-actions {
    padding: 0.6rem 1rem;
    background: rgba(138, 75, 243, 0.02);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

/* --- CONSOLA ARCADE --- */
.console-container {
    background: #020308;
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    height: 130px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-purple);
}

.console-header {
    background: rgba(138, 75, 243, 0.04);
    border-bottom: 1px solid var(--border-color);
    padding: 0.35rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted);
}

.btn-clear-console {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-clear-console:hover {
    color: var(--color-secondary);
}

.console-body {
    flex: 1;
    padding: 0.6rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.35;
    overflow-y: auto;
    color: #a5b4fc;
}

.console-error {
    color: var(--color-pink);
    text-shadow: 0 0 5px rgba(255, 0, 127, 0.2);
}

.console-success {
    color: var(--color-green);
    text-shadow: 0 0 5px rgba(57, 255, 20, 0.2);
}

.console-info {
    color: var(--color-secondary);
}

/* --- CANVAS & SIMULATION CONTAINER --- */
.canvas-container {
    background: var(--bg-panel);
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    flex: 1;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-purple);
    min-height: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#circuit-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- BOTONES ARCADE --- */
.btn {
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.1rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-pink), var(--color-primary));
    color: #ffffff;
    box-shadow: var(--shadow-pink);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
    transform: scale(1.03);
    box-shadow: 0 0 20px rgba(255, 0, 127, 0.6);
}

.btn-secondary {
    background: rgba(138, 75, 243, 0.08);
    color: var(--color-text);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(138, 75, 243, 0.15);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-purple);
}

.w-full {
    width: 100%;
    justify-content: center;
}

/* --- OVERLAY CARDS (QUIZ & REPORT) --- */
.overlay-card {
    position: absolute;
    width: 92%;
    max-width: 440px;
    background: rgba(10, 11, 28, 0.96);
    border: 2px solid var(--color-secondary);
    border-radius: 16px;
    padding: 1.35rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), var(--shadow-cyan);
    backdrop-filter: blur(10px);
    animation: scaleUp 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}

.quiz-overlay {
    border-color: var(--color-secondary);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.25);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 240, 255, 0.15);
    padding-bottom: 0.6rem;
    margin-bottom: 0.85rem;
}

.quiz-header h3 {
    font-size: 1.1rem;
    color: var(--color-secondary);
    font-weight: 800;
}

.quiz-badge {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--color-green);
    background: rgba(57, 255, 20, 0.1);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(57, 255, 20, 0.2);
}

.quiz-question {
    font-size: 0.95rem;
    line-height: 1.4;
    font-weight: 600;
    margin-bottom: 0.85rem;
    color: var(--color-text);
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.quiz-option {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.quiz-option:hover {
    background: rgba(138, 75, 243, 0.05);
    border-color: rgba(138, 75, 243, 0.3);
}

.quiz-option.selected {
    background: rgba(0, 240, 255, 0.05);
    border-color: var(--color-secondary);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.quiz-option.correct {
    background: rgba(57, 255, 20, 0.08) !important;
    border-color: var(--color-green) !important;
    text-shadow: 0 0 5px rgba(57, 255, 20, 0.2);
}

.quiz-option.incorrect {
    background: rgba(255, 51, 102, 0.08) !important;
    border-color: var(--color-error) !important;
}

.opt-bullet {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-muted);
    font-weight: 800;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.selected .opt-bullet {
    background: var(--color-secondary);
    border-color: var(--color-secondary);
    color: var(--bg-main);
}

/* --- TARJETA DE REPORTE GAMER --- */
.report-overlay {
    border-color: var(--color-pink);
    box-shadow: 0 0 25px rgba(255, 0, 127, 0.25);
    max-width: 460px;
    text-align: center;
}

.report-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--color-pink);
    margin-bottom: 0.15rem;
}

.report-header p {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 1.25rem;
}

.grade-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 0, 127, 0.15), rgba(0,0,0,0));
    border: 3px solid var(--color-pink);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto 1.25rem auto;
    box-shadow: var(--shadow-pink);
    animation: breathing 2s infinite ease-in-out;
}

.grade-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-pink);
    line-height: 1;
}

.grade-subtitle {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin-top: 0.15rem;
}

.report-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: rgba(138, 75, 243, 0.04);
    border: 1px solid var(--border-color);
    padding: 0.85rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
}

.r-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.r-label {
    color: var(--color-text-muted);
}

.r-val {
    font-weight: 800;
}

.report-feedback {
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 1.25rem;
    color: var(--color-text);
}

/* --- TARJETA DE REFERENCIA DEL TEMA --- */
.topic-card {
    background: var(--bg-panel);
    border: 2px solid rgba(0, 240, 255, 0.25);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.1);
}

.topic-header {
    background: rgba(0, 240, 255, 0.04);
    border-bottom: 1px solid rgba(0, 240, 255, 0.15);
    padding: 0.5rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.topic-header:hover {
    background: rgba(0, 240, 255, 0.07);
}

.topic-icon {
    font-size: 1rem;
}

.topic-title {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-secondary);
    margin: 0;
}

.topic-toggle {
    background: transparent;
    border: none;
    color: var(--color-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: transform 0.25s ease;
    padding: 0.2rem;
}

.topic-toggle.collapsed {
    transform: rotate(-90deg);
}

.topic-body {
    padding: 0.75rem 0.85rem;
    max-height: 220px;
    overflow-y: auto;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.topic-body.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.topic-description {
    font-size: 0.8rem;
    color: var(--color-text);
    line-height: 1.4;
    margin-bottom: 0.6rem;
}

.topic-syntax {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.5;
    background: #0a0c1a;
    border: 1px solid rgba(138, 75, 243, 0.2);
    border-left: 3px solid var(--color-primary);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    color: var(--color-green);
    white-space: pre-wrap;
    word-break: break-word;
}

.topic-syntax .kw {
    color: var(--color-secondary);
}

.topic-syntax .type {
    color: var(--color-pink);
}

.topic-syntax .str {
    color: var(--color-green);
}

.topic-syntax .cmt {
    color: var(--color-text-muted);
    font-style: italic;
}

/* --- CLASES AUXILIARES --- */
.hidden {
    display: none !important;
}

/* --- ANIMACIONES --- */
@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes breathing {
    0%, 100% { transform: scale(1); box-shadow: 0 0 15px rgba(255, 0, 127, 0.35); }
    50% { transform: scale(1.05); box-shadow: 0 0 25px rgba(255, 0, 127, 0.6); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

/* --- RESPONSIVE LAYOUT --- */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
        padding: 0.75rem;
        gap: 0.75rem;
    }
    .panel-right {
        order: -1;
    }
    .canvas-container {
        min-height: 380px;
    }
}
