document.addEventListener('DOMContentLoaded',function(){console.log("DOM fully loaded and parsed");const buttons=document.querySelectorAll('.specbtn-dropbtn');buttons.forEach((button)=>{button.addEventListener('click',function(){if(window.innerWidth<=767){this.classList.toggle('active');}});});var dropdownContainers=document.querySelectorAll('.specbtn-dropdown');let isButtonClicked=false;dropdownContainers.forEach(function(container,index){console.log(`Initializing dropdown container #${index}`);var button=container.querySelector('.specbtn-dropbtn, .specbtn-dropbtn-focused');var dropdown=container.querySelector('.specbtn-dropdown-content');if(button&&dropdown){console.log(`Button and dropdown found for container #${index}`);button.addEventListener('click',function(e){e.preventDefault();isButtonClicked=true;console.log(`Button clicked in container #${index}`);var isDropdownOpen=dropdown.classList.contains('spec-show');console.log(`Dropdown is currently ${isDropdownOpen ? "open" : "closed"}`);dropdownContainers.forEach(function(otherContainer,otherIndex){var otherDropdown=otherContainer.querySelector('.specbtn-dropdown-content');var otherButton=otherContainer.querySelector('.specbtn-dropbtn-focused');if(otherDropdown&&otherDropdown.classList.contains('spec-show')){console.log(`Closing dropdown in container #${otherIndex}`);otherDropdown.classList.remove('spec-show');otherDropdown.classList.add('spec-hide');} if(otherButton){console.log(`Resetting button state in container #${otherIndex}`);otherButton.classList.remove('specbtn-dropbtn-focused');otherButton.classList.add('specbtn-dropbtn');}});if(!isDropdownOpen){console.log(`Opening dropdown in container #${index}`);dropdown.classList.remove('spec-hide');dropdown.classList.add('spec-show');button.classList.remove('specbtn-dropbtn');button.classList.add('specbtn-dropbtn-focused');}else{console.log(`Closing dropdown in container #${index}`);dropdown.classList.remove('spec-show');dropdown.classList.add('spec-hide');button.classList.remove('specbtn-dropbtn-focused');button.classList.add('specbtn-dropbtn');}});}else{console.warn(`Button or dropdown not found in container #${index}`);}});window.addEventListener('click',function(e){console.log("Window click detected");if(isButtonClicked){isButtonClicked=false;console.log("Window click ignored due to button click");return;} dropdownContainers.forEach(function(container,index){var dropdown=container.querySelector('.specbtn-dropdown-content');var button=container.querySelector('.specbtn-dropbtn-focused');if(dropdown&&dropdown.classList.contains('spec-show')){console.log(`Closing dropdown in container #${index} due to outside click`);dropdown.classList.remove('spec-show');dropdown.classList.add('spec-hide');if(button){button.classList.remove('specbtn-dropbtn-focused');button.classList.add('specbtn-dropbtn');}}});});});