/* ==========================================================================
   TECLITA BOT: LABORATORIO DE ALGORITMOS • ESTILOS (3ER GRADO)
   ========================================================================== */

:root {
    --bg-dark: #0A0F1D;
    --primary-indigo: #4F46E5;
    --primary-cyan: #06B6D4;
    --accent-emerald: #10B981;
    --accent-amber: #F59E0B;
    --accent-rose: #F43F5E;
    
    --card-bg: rgba(19, 27, 46, 0.85);
    --border-glow: rgba(6, 182, 212, 0.35);
    
    --font-main: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-kids: 'Fredoka', cursive, sans-serif;
    --font-pixel: 'Press Start 2P', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body.bot-body {
    min-height: 100vh;
    background: radial-gradient(circle at 50% 15%, #1E1B4B 0%, #0A0F1D 70%, #030611 100%);
    color: #FFFFFF;
    font-family: var(--font-kids);
    overflow-x: hidden;
    padding-bottom: 25px;
}

#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

/* 1. BARRA SUPERIOR */
.bot-header {
    max-width: 1300px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.btn-bot-nav {
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    text-decoration: none;
    font-weight: 800;
    font-size: 1rem;
    padding: 8px 18px;
    border-radius: 99px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-bot-nav:hover {
    background: var(--primary-indigo);
    border-color: #818CF8;
    transform: scale(1.05);
}

.bot-title-group {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.badge-grade {
    background: #06B6D4;
    color: #0A0F1D;
    font-weight: 900;
    font-size: 0.8rem;
    padding: 3px 12px;
    border-radius: 99px;
}

.bot-title {
    font-size: 1.45rem;
    font-weight: 900;
    background: linear-gradient(135deg, #FFFFFF 0%, #38BDF8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.bot-tools {
    display: flex;
    gap: 8px;
}

.btn-tool {
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.btn-tool:hover {
    background: var(--primary-cyan);
    color: #0A0F1D;
    transform: scale(1.1);
}

/* 2. TRACK DE NIVELES */
.levels-track-bar {
    max-width: 1300px;
    margin: 0 auto 15px auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
}

.levels-lbl {
    font-size: 0.85rem;
    font-weight: 800;
    color: #94A3B8;
    white-space: nowrap;
}

.levels-pills-list {
    display: flex;
    gap: 6px;
}

.lvl-btn {
    background: rgba(30, 41, 59, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.15);
    color: #E2E8F0;
    font-family: var(--font-kids);
    font-weight: 800;
    font-size: 0.9rem;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.lvl-btn:hover {
    border-color: var(--primary-cyan);
    background: rgba(6, 182, 212, 0.2);
}

.lvl-btn.active {
    background: var(--primary-cyan);
    border-color: #67E8F9;
    color: #0A0F1D;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.6);
    transform: scale(1.1);
}

.lvl-btn.completed {
    background: var(--accent-emerald);
    border-color: #6EE7B7;
    color: #FFFFFF;
}

/* 3. CONTENEDOR PRINCIPAL */
.bot-main-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr 440px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 950px) {
    .bot-main-container {
        grid-template-columns: 1fr;
    }
}

/* 4. PANEL DEL TABLERO DE CIRCUITOS */
.circuit-board-panel {
    background: var(--card-bg);
    border: 3px solid var(--border-glow);
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.mission-title {
    font-size: 1.3rem;
    font-weight: 900;
    color: #38BDF8;
}

.mission-desc {
    font-size: 0.95rem;
    color: #94A3B8;
}

.chips-counter-box {
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid #F59E0B;
    border-radius: 14px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chips-lbl {
    font-size: 0.8rem;
    color: #F59E0B;
    font-weight: 900;
}

.chips-val {
    font-size: 1.2rem;
    font-weight: 900;
    color: #FFFFFF;
}

/* Matriz de Juego */
.matrix-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #060B18;
    border: 3px solid #1E293B;
    border-radius: 20px;
    padding: 15px;
    overflow: hidden;
}

.matrix-grid {
    display: grid;
    gap: 6px;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 1;
}

.grid-cell {
    background: #0F172A;
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 1.8rem;
    transition: all 0.2s;
}

.grid-cell.path {
    background: #1E293B;
    border-color: rgba(56, 189, 248, 0.25);
}

.grid-cell.wall {
    background: #334155;
    border-color: #475569;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.6);
}

.grid-cell.chip {
    animation: chipGlow 2s infinite;
}

.grid-cell.bug {
    animation: bugShake 3s infinite;
}

.grid-cell.goal {
    background: rgba(16, 185, 129, 0.25);
    border: 2px dashed #10B981;
    animation: goalPulse 2s infinite;
}

/* Sprite de Teclita Bot */
.bot-character {
    position: absolute;
    width: 80%;
    height: 80%;
    background-image: url('../assets/teclita.jpg');
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    border: 3px solid #38BDF8;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.8);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), top 0.3s, left 0.3s;
    z-index: 10;
}

/* Indicador de Dirección del Bot (flecha frontal) */
.bot-character::after {
    content: "▲";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    color: #FDE047;
    font-size: 0.85rem;
    filter: drop-shadow(0 0 4px #F59E0B);
}

.bot-hint-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(79, 70, 229, 0.25);
    border: 2px solid rgba(129, 140, 248, 0.4);
    border-radius: 16px;
    padding: 10px 16px;
    font-size: 0.95rem;
    color: #E0E7FF;
}

.bot-avatar-mini {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #818CF8;
}

/* 5. PANEL DE WORKSPACE DE PROGRAMACIÓN */
.code-workspace-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.toolbox-box, .program-stack-box {
    background: var(--card-bg);
    border: 3px solid var(--border-glow);
    border-radius: 24px;
    padding: 16px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.5);
}

.section-tag {
    display: block;
    font-size: 0.8rem;
    font-weight: 900;
    color: #38BDF8;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.toolbox-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.code-block-btn {
    border: none;
    border-radius: 14px;
    padding: 12px 8px;
    color: #FFFFFF;
    font-family: var(--font-kids);
    font-weight: 800;
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.15s;
}

.code-block-btn i {
    font-size: 1.3rem;
}

.code-block-btn:hover {
    transform: translateY(-3px) scale(1.04);
    filter: brightness(1.15);
}

.code-block-btn:active {
    transform: scale(0.95);
}

.btn-forward { background: linear-gradient(135deg, #0284C7, #0EA5E9); }
.btn-turn-left { background: linear-gradient(135deg, #7C3AED, #9333EA); }
.btn-turn-right { background: linear-gradient(135deg, #4F46E5, #6366F1); }
.btn-jump { background: linear-gradient(135deg, #D97706, #F59E0B); }
.btn-collect { background: linear-gradient(135deg, #059669, #10B981); }
.btn-loop { background: linear-gradient(135deg, #DB2777, #EC4899); }

/* Pila de Códigos */
.stack-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-clear-code {
    background: rgba(239, 68, 68, 0.2);
    border: 1.5px solid #EF4444;
    color: #FCA5A5;
    font-family: var(--font-kids);
    font-weight: 800;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.btn-clear-code:hover {
    background: #EF4444;
    color: #FFFFFF;
}

.stack-items-list {
    min-height: 180px;
    max-height: 260px;
    overflow-y: auto;
    background: #060B18;
    border: 2px solid #1E293B;
    border-radius: 16px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empty-stack-placeholder {
    height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #475569;
    gap: 8px;
    text-align: center;
    font-size: 0.95rem;
}

.stack-block-item {
    background: #1E293B;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 800;
    font-size: 0.95rem;
    animation: slideIn 0.2s ease;
}

.stack-block-item.executing {
    border-color: #FDE047;
    background: rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.7);
    transform: scale(1.02);
}

.block-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-del-block {
    background: transparent;
    border: none;
    color: #64748B;
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.2s;
}

.btn-del-block:hover {
    color: #EF4444;
}

/* 6. CONTROLES DE EJECUCIÓN */
.execution-controls-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
}

.btn-exec {
    font-family: var(--font-kids);
    font-size: 1.15rem;
    font-weight: 900;
    padding: 14px;
    border-radius: 18px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    transition: all 0.2s;
}

.btn-run {
    background: linear-gradient(135deg, #059669 0%, #10B981 100%);
    color: #FFFFFF;
}

.btn-run:hover {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
    transform: scale(1.03);
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.6);
}

.btn-reset {
    background: #334155;
    color: #E2E8F0;
}

.btn-reset:hover {
    background: #475569;
}

/* 7. MODALES */
.bot-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 17, 0.92);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 200;
}

.bot-modal-overlay.active {
    display: flex;
}

.bot-modal-card {
    background: #FFFFFF;
    color: #0F172A;
    width: 100%;
    max-width: 540px;
    border-radius: 28px;
    border: 8px solid var(--primary-cyan);
    padding: 30px;
    text-align: center;
    box-shadow: 0 25px 70px rgba(0,0,0,0.8);
    animation: zoomIn 0.3s ease;
}

.modal-badge {
    background: #0284C7;
    color: #FFFFFF;
    font-size: 0.85rem;
    font-weight: 900;
    padding: 5px 16px;
    border-radius: 99px;
    display: inline-block;
    margin-bottom: 8px;
}

.modal-title {
    font-size: 1.8rem;
    font-weight: 900;
    color: #0F172A;
    margin-bottom: 6px;
}

.modal-mascot {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 3px solid #38BDF8;
    margin: 12px 0;
}

.modal-desc {
    font-size: 1.05rem;
    color: #475569;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.btn-modal {
    font-family: var(--font-kids);
    font-size: 1.05rem;
    font-weight: 900;
    padding: 12px 24px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-next { background: #10B981; color: #FFFFFF; }
.btn-retry { background: #F59E0B; color: #0F172A; }
.btn-print { background: #0284C7; color: #FFFFFF; }
.btn-home { background: #334155; color: #FFFFFF; }

.btn-modal:hover { transform: scale(1.05); }

/* Diploma Específico */
.diploma-card {
    max-width: 640px;
}

.student-input {
    width: 85%;
    max-width: 360px;
    padding: 10px 16px;
    font-family: var(--font-kids);
    font-size: 1.3rem;
    font-weight: 900;
    text-align: center;
    color: #0284C7;
    background: #F0F9FF;
    border: 3px dashed #38BDF8;
    border-radius: 16px;
    outline: none;
    margin: 10px 0 16px 0;
}

/* Animaciones */
@keyframes goalPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 25px rgba(16, 185, 129, 0.9); }
}

@keyframes chipGlow {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 5px #F59E0B); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 15px #FDE047); }
}

@keyframes bugShake {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(-8deg); }
    40% { transform: rotate(8deg); }
}

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

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