body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: #f1f5f9;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#app-container {
    display: flex;
    height: 100vh;
    flex-direction: column;
}

#toolbar {
    background-color: #1e293b;
    color: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

#main-area {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#blockly-container {
    flex: 2;
    position: relative;
    background-color: #f1f5f9;
}

#blocklyDiv {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden !important;
}

/* Ocultar barras de scroll de Blockly que a veces aparecen por error de renderizado */
.blocklyMainBackground {
    stroke: none !important;
}

.blocklyScrollbarHandle {
    display: none !important;
}

.blocklyScrollbarBackground {
    display: none !important;
}

#chat-container {
    flex: 1;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    min-width: 350px;
    max-width: 500px;
}

#chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #f8fafc;
}

.chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.4;
    animation: fadeIn 0.3s ease-out;
    word-wrap: break-word;
}

.bubble-user {
    align-self: flex-end;
    background-color: #3b82f6;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.bubble-agent {
    align-self: flex-start;
    background-color: #e2e8f0;
    color: #1e293b;
    border-bottom-left-radius: 0.25rem;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background-color: #e2e8f0;
    border-radius: 1rem;
    align-self: flex-start;
    border-bottom-left-radius: 0.25rem;
    width: fit-content;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #94a3b8;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#chat-input-area {
    padding: 1rem;
    background-color: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 0.5rem;
}

/* Estilos de Blockly personalizados */
.blocklyToolboxDiv {
    background-color: #f8fafc !important;
    border-right: 1px solid #e2e8f0 !important;
}

/* Modal de API Key */
#api-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* --- Pensamientos (Thinking Blocks) --- */
.thought-details {
    margin-top: 0;
    margin-bottom: 0;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    background-color: #f8fafc;
    transition: all 0.2s ease;
}

.thought-summary {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    list-style: none;
    /* Quita el triángulo por defecto */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    border-bottom: 1px solid transparent;
}

.thought-summary::-webkit-details-marker {
    display: none;
}

.thought-details[open] .thought-summary {
    border-bottom-color: #e2e8f0;
    color: #475569;
}

.thought-content {
    padding: 0.75rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #475569;
    font-style: italic;
    white-space: pre-wrap;
    /* Mantener formato de la IA */
}

.thought-summary i {
    font-size: 1rem;
    color: #94a3b8;
}