// main.js document.addEventListener('DOMContentLoaded', () => { const themeToggle = document.getElementById('theme-toggle'); const currentTheme = localStorage.getItem('theme'); if (currentTheme === 'dark') { document.body.classList.add('dark-mode'); themeToggle.innerHTML = ''; } else { themeToggle.innerHTML = ''; } themeToggle.addEventListener('click', () => { document.body.classList.toggle('dark-mode'); let theme = 'light'; if (document.body.classList.contains('dark-mode')) { theme = 'dark'; themeToggle.innerHTML = ''; } else { themeToggle.innerHTML = ''; } localStorage.setItem('theme', theme); }); const animatedElements = document.querySelectorAll('.floating-card'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('is-visible'); observer.unobserve(entry.target); } }); }, { threshold: 0.1 }); animatedElements.forEach(el => { observer.observe(el); }); }); function openChatWidget() { // This function attempts to open the chat widget. // The AnyChat script might create a global object to control the widget. if (typeof AnyChat !== 'undefined' && AnyChat.open) { AnyChat.open(); } else { console.log('Chat widget function not found. The widget might open automatically or requires a different function call.'); // As a fallback, we can try to find the launcher button and click it. const chatLauncher = document.getElementById('anychat-launcher'); // This ID is a guess if(chatLauncher) chatLauncher.click(); } }