const EliaChat = () => { const [open, setOpen] = React.useState(false); const [messages, setMessages] = React.useState([ { role: 'elia', text: '¡Hola! Soy Elia, tu asistente estratégica. ✦ ¿En qué puedo ayudarte hoy?' } ]); const [input, setInput] = React.useState(''); const [loading, setLoading] = React.useState(false); const scrollRef = React.useRef(); React.useEffect(() => { if (scrollRef.current) scrollRef.current.scrollTop = scrollRef.current.scrollHeight; }, [messages]); const send = async () => { if (!input.trim() || loading) return; const msg = input.trim(); setInput(''); setMessages(prev => [...prev, { role: 'user', text: msg }]); setLoading(true); try { const res = await API.post('/chat', { message: msg }); setMessages(prev => [...prev, { role: 'elia', text: res.response }]); } catch (e) { setMessages(prev => [...prev, { role: 'elia', text: 'Lo siento, hubo un error al procesar tu solicitud.' }]); } finally { setLoading(false); } }; const bubble = { padding: '10px 14px', borderRadius: 18, fontSize: 13, lineHeight: 1.5, maxWidth: '85%', position: 'relative', marginBottom: 8 }; return (