document.addEventListener('DOMContentLoaded', function() {
    var burgerBtn = document.getElementById('burgerBtnAdmin');
    var navMenu = document.getElementById('navMenuAdmin');
    var dropdown = document.getElementById('dropdownAdmin');
    var body = document.body;

    if (burgerBtn && navMenu) {
        // Commutation Burger Menu Mobile
        burgerBtn.addEventListener('click', function(e) {
            e.stopPropagation();
            burgerBtn.classList.toggle('active');
            navMenu.classList.toggle('open');
            body.classList.toggle('admin-menu-open');
        });

        // Déplier/Replier le sous-menu "Modifications" au clic sur mobile
        if (dropdown) {
            dropdown.addEventListener('click', function(e) {
                if (window.innerWidth <= 768) {
                    e.stopPropagation();
                    dropdown.classList.toggle('mobile-active');
                }
            });
        }

        // Fermeture automatique au clic en dehors
        document.addEventListener('click', function(e) {
            if (!navMenu.contains(e.target) && !burgerBtn.contains(e.target)) {
                burgerBtn.classList.remove('active');
                navMenu.classList.remove('open');
                body.classList.remove('admin-menu-open');
                if (dropdown) dropdown.classList.remove('mobile-active');
            }
        });
    }
});