const hamburger = document.getElementById('hamburger');
        const navMenu = document.getElementById('navMenu');

        // Toggle mobile menu
        hamburger.addEventListener('click', (e) => {
            e.stopPropagation();
            hamburger.classList.toggle('active');
            navMenu.classList.toggle('active');
        });

        // Function to close all dropdowns
        function closeAllDropdowns() {
            document.querySelectorAll('.vlead-nav-item.active, .vlead-dropdown-item.active, .vlead-subdropdown-item.active')
                .forEach(item => {
                    item.classList.remove('active');
                });
        }

        // Handle all dropdown clicks
        document.addEventListener('click', function(e) {
            if (window.innerWidth <= 768) {
                // Main nav dropdowns
                if (e.target.classList.contains('vlead-nav-link') && e.target.classList.contains('has-dropdown')) {
                    e.preventDefault();
                    e.stopPropagation();
                    
                    const navItem = e.target.closest('.vlead-nav-item');
                    navItem.classList.toggle('active');
                    return;
                }
                
                // First level dropdowns
                if (e.target.classList.contains('vlead-dropdown-link') && e.target.classList.contains('has-subdropdown')) {
                    e.preventDefault();
                    e.stopPropagation();
                    
                    const dropdownItem = e.target.closest('.vlead-dropdown-item');
                    dropdownItem.classList.toggle('active');
                    return;
                }
                
                // Second level dropdowns
                if (e.target.classList.contains('vlead-subdropdown-link') && e.target.classList.contains('has-child-dropdown')) {
                    e.preventDefault();
                    e.stopPropagation();
                    
                    const subdropdownItem = e.target.closest('.vlead-subdropdown-item');
                    subdropdownItem.classList.toggle('active');
                    return;
                }
                
                // Regular link clicks in mobile
                if (e.target.classList.contains('vlead-nav-link') || 
                    e.target.classList.contains('vlead-dropdown-link') || 
                    e.target.classList.contains('vlead-subdropdown-link') ||
                    e.target.classList.contains('vlead-child-dropdown-link') ||
                    e.target.classList.contains('vlead-quote-btn')) {
                    
                    if (!e.target.classList.contains('has-dropdown') && 
                        !e.target.classList.contains('has-subdropdown') && 
                        !e.target.classList.contains('has-child-dropdown')) {
                        
                        setTimeout(() => {
                            hamburger.classList.remove('active');
                            navMenu.classList.remove('active');
                            closeAllDropdowns();
                        }, 300);
                    }
                }
            }
        });

        // Close menu when clicking outside
        document.addEventListener('click', function(e) {
            if (window.innerWidth <= 768) {
                if (!e.target.closest('.vlead-nav-container')) {
                    hamburger.classList.remove('active');
                    navMenu.classList.remove('active');
                    closeAllDropdowns();
                }
            }
        });

        // Reset on window resize
        window.addEventListener('resize', function() {
            if (window.innerWidth > 768) {
                hamburger.classList.remove('active');
                navMenu.classList.remove('active');
                closeAllDropdowns();
            }
        });

        // Prevent default for dropdown links
        if (window.innerWidth <= 768) {
            document.querySelectorAll('a').forEach(link => {
                link.addEventListener('click', function(e) {
                    if (this.classList.contains('has-dropdown') || 
                        this.classList.contains('has-subdropdown') || 
                        this.classList.contains('has-child-dropdown')) {
                        e.preventDefault();
                    }
                });
            });
        }