/* --- RESET Y BASES --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

header { margin: 20px 0; text-align: center; }
header h1 { color: #1a202c; font-weight: 800; letter-spacing: -1px; }

/* --- TABS --- */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: #e2e8f0;
    padding: 5px;
    border-radius: 12px;
}
.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    color: #4a5568;
    border-radius: 8px;
    transition: 0.2s;
}
.tab-btn.active {
    background: white;
    color: #2b6cb0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.tab-btn:hover:not(.active) { background: rgba(255,255,255,0.5); }

/* --- LAYOUT --- */
.main-layout {
    display: flex;
    gap: 20px;
    width: 95%;
    max-width: 1200px;
    align-items: flex-start;
    margin-bottom: 40px;
}
.visualization-area {
    flex: 2;
    background: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 600px;
    position: relative;
}

/* --- CONTROLES --- */
.controls-panel {
    display: flex;
    background-color: #f7fafc;
    padding: 10px 20px;
    border-radius: 12px;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 15px;
    border: 1px solid #e2e8f0;
}
.control-group { display: flex; align-items: center; gap: 8px; }
.separator { width: 1px; height: 30px; background: #cbd5e0; }
.input-number { width: 50px; padding: 5px; text-align: center; border-radius: 6px; border: 1px solid #cbd5e0; }

/* Estilo específico para el input del Target */
.target-input { width: 70px; background-color: #fff; border-color: #3182ce; color: #2b6cb0; font-weight: bold; }

button {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    background-color: #edf2f7;
    color: #4a5568;
    transition: all 0.2s;
}
button:hover { background-color: #e2e8f0; transform: translateY(-1px); }
button:disabled { opacity: 0.5; transform: none; cursor: not-allowed; }

.primary-btn { background-color: #3182ce; color: white; }
.primary-btn:hover { background-color: #2b6cb0; }
.pause-btn { background-color: #ed8936; color: white; width: 40px; display: flex; justify-content: center;}
.pause-btn.paused { background-color: #48bb78; }
.stop-btn { background-color: #e53e3e; color: white; }
.stop-btn:hover { background-color: #c53030; }
.code-btn { background-color: #805ad5; color: white; }
.code-btn:hover { background-color: #6b46c1; }

/* --- NODOS --- */
.array-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    width: 100%;
    gap: 10px;
    margin-top: 10px;
}
.node {
    width: 55px;
    height: 55px;
    background-color: white;
    border: 2px solid #4299e1;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Roboto Mono', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: #2b6cb0;
    transition: all 0.4s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    z-index: 2;
    position: relative;
}

/* Índice discreto debajo */
.array-container .node::after {
    content: attr(data-index);
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: #a0aec0;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    pointer-events: none;
}

/* --- ESTADOS VISUALES BÚSQUEDA --- */
.node.dimmed { opacity: 0.2; border-color: #cbd5e0; color: #cbd5e0; transform: scale(0.9); }

/* Nodo siendo comparado actualmente */
.node.checked { 
    background-color: #f6ad55; /* Naranja */
    border-color: #dd6b20; 
    color: white; 
    transform: translateY(-10px); 
    z-index: 10;
}

/* Nodo Encontrado */
.node.found { 
    background-color: #48bb78; /* Verde */
    border-color: #2f855a; 
    color: white; 
    transform: scale(1.15); 
    z-index: 20;
    box-shadow: 0 0 15px rgba(72, 187, 120, 0.5);
}

/* Rango activo (Binaria) */
.node.in-range {
    border-color: #3182ce;
    background-color: #ebf8ff;
    opacity: 1;
}

/* --- BITACORA --- */
.log-panel {
    flex: 1;
    background: #2d3748;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 16px;
    height: 600px;
    display: flex;
    flex-direction: column;
}
.log-content {
    flex: 1;
    overflow-y: auto;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.log-content::-webkit-scrollbar { width: 6px; }
.log-content::-webkit-scrollbar-thumb { background: #4a5568; border-radius: 3px; }
.log-entry { padding: 8px; border-radius: 4px; border-left: 3px solid #4299e1; background: rgba(255,255,255,0.05); }
.log-entry.highlight { border-left-color: #f6e05e; background: rgba(246, 224, 94, 0.1); }
.log-entry.found { border-left-color: #48bb78; background: rgba(72, 187, 120, 0.15); font-weight: bold;}
.log-entry.error { border-left-color: #e53e3e; background: rgba(229, 62, 62, 0.1); }

/* --- MODAL --- */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 100;
    display: flex; justify-content: center; align-items: center;
}
.modal.hidden { display: none; }
.modal-content {
    background: white; width: 600px; max-height: 80vh;
    border-radius: 12px; padding: 20px; display: flex; flex-direction: column;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.close-btn { background: none; font-size: 1.5rem; cursor: pointer; color: #e53e3e; }
.language-tabs { display: flex; gap: 10px; margin-bottom: 10px; }
.lang-btn { background: #e2e8f0; padding: 5px 15px; border-radius: 5px; cursor: pointer; }
.lang-btn.active { background: #3182ce; color: white; }
pre { background: #2d3748; color: #a0aec0; padding: 15px; border-radius: 8px; overflow: auto; font-family: 'Roboto Mono'; flex: 1; }

.pointers-container { display: flex; justify-content: center; gap: 10px; margin-top: 5px; height: 30px; }
.pointer-slot { width: 55px; text-align: center; font-weight: bold; font-family: 'Roboto Mono'; }

/* --- LEYENDA --- */
.legend { display: flex; gap: 15px; margin-bottom: 10px; font-size: 0.8rem; flex-wrap: wrap; justify-content: center;}
.legend-item { display: flex; align-items: center; gap: 6px; }
.box { 
    display: inline-block; 
    width: 16px; height: 16px; 
    border-radius: 4px; 
    border: 1px solid rgba(0,0,0,0.2); 
    flex-shrink: 0;
}
.box.active { background: #f6ad55; } 
.box.found { background: #48bb78; } 
.box.dimmed { background: #e2e8f0; border: 1px dashed #cbd5e0; }
.box.range { background: #ebf8ff; border: 1px solid #3182ce; }