document.addEventListener('DOMContentLoaded', function() { const chatMessages = document.getElementById('chat-messages'); const userInput = document.getElementById('user-input'); const sendButton = document.getElementById('send-button'); function addMessage(role, content) { const messageDiv = document.createElement('div'); messageDiv.className = `message ${role} ${role === 'user' ? 'bg-gray-700 rounded-xl p-4 border-l-4 border-neon-500' : 'bg-gray-700 bg-opacity-50 rounded-xl p-4 border-l-4 border-quantum-500'}`; const messageContent = `

${content}

`; messageDiv.innerHTML = messageContent; chatMessages.appendChild(messageDiv); chatMessages.scrollTop = chatMessages.scrollHeight; feather.replace(); } function simulateTyping() { const typingDiv = document.createElement('div'); typingDiv.className = 'message bot bg-gray-700 bg-opacity-50 rounded-xl p-4 border-l-4 border-quantum-500'; const typingContent = `
`; typingDiv.innerHTML = typingContent; chatMessages.appendChild(typingDiv); chatMessages.scrollTop = chatMessages.scrollHeight; feather.replace(); return typingDiv; } function removeTypingIndicator(typingElement) { if (typingElement && typingElement.parentNode) { typingElement.remove(); } } sendButton.addEventListener('click', function() { const message = userInput.value.trim(); if (message) { addMessage('user', message); userInput.value = ''; const typingElement = simulateTyping(); // Simulate AI response after a delay setTimeout(() => { removeTypingIndicator(typingElement); // Generate a mock response (in a real app, this would be from an API) const responses = [ "I've processed your quantum query and found interesting patterns in the data.", "The neural network suggests several possible interpretations of your request.", "Analyzing temporal dimensions... your input resonates with 87.3% probability.", "The quantum algorithm has converged on this response after evaluating multiple possibilities.", "Fascinating perspective! My cognitive modules are processing the implications." ]; const randomResponse = responses[Math.floor(Math.random() * responses.length)]; addMessage('bot', randomResponse); }, 1500 + Math.random() * 2000); } }); userInput.addEventListener('keypress', function(e) { if (e.key === 'Enter') { sendButton.click(); } }); });