document.addEventListener('DOMContentLoaded', () => { const searchInput = document.getElementById('search-input'); const searchBtn = document.getElementById('search-btn'); const searchResults = document.getElementById('search-results'); const exampleQueries = document.getElementById('example-queries'); // Mock data for demonstration const mockResponses = { "what's the capital of france": { answer: "The capital of France is Paris. Paris is located in the northern part of France on the Seine River and has been an important city for over 2,000 years.", sources: [ { name: "Wikipedia", url: "https://en.wikipedia.org/wiki/Paris" }, { name: "Britannica", url: "https://www.britannica.com/place/Paris" } ], process: [ "Searching for 'capital of France' across verified sources", "Analyzing geographical data from multiple references", "Cross-referencing historical records", "Verifying with official government sources" ] }, "explain quantum computing": { answer: "Quantum computing is an area of computing focused on developing computer technology based on the principles of quantum theory, which explains the behavior of energy and material on the atomic and subatomic levels. Unlike classical computers that use bits (0s and 1s), quantum computers use quantum bits or qubits which can exist in multiple states simultaneously (superposition) and be entangled with each other, enabling them to solve certain complex problems much faster than classical computers.", sources: [ { name: "IBM Research", url: "https://research.ibm.com/quantum-computing" }, { name: "Nature Journal", url: "https://www.nature.com/articles/s41534-019-0187-2" } ], process: [ "Compiling definitions from leading research institutions", "Analyzing recent scientific papers on quantum mechanics", "Comparing explanations from multiple experts", "Simplifying complex concepts for general understanding" ] } }; searchBtn.addEventListener('click', performSearch); searchInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') performSearch(); }); // Add click handlers to example queries document.querySelectorAll('#example-queries > div').forEach(example => { example.addEventListener('click', () => { const query = example.querySelector('h3').textContent.replace(/"/g, ''); searchInput.value = query; performSearch(); }); }); function performSearch() { const query = searchInput.value.trim().toLowerCase(); if (!query) return; exampleQueries.classList.add('hidden'); searchResults.classList.remove('hidden'); searchResults.innerHTML = ''; // Show loading state const loadingHTML = `