document.addEventListener('DOMContentLoaded', function() {
    // Elementi
    const menuToggle = document.getElementById('mobile-menu-toggle');
    const menuDrawer = document.getElementById('mobile-drawer');
    const menuOverlay = document.getElementById('mobile-menu-overlay');
    
    // Dodajemo console.log za debugging
    console.log("Menu toggle element:", menuToggle);
    console.log("Menu drawer element:", menuDrawer);
    console.log("Menu overlay element:", menuOverlay);
    
    // Otvaranje menija
    if (menuToggle) {
        menuToggle.addEventListener('click', function() {
            console.log("Menu button clicked");
            menuDrawer.classList.add('active');
            menuOverlay.classList.add('active');
            document.body.classList.add('menu-open');
        });
    }
    
    // Zatvaranje menija klikom na overlay
    if (menuOverlay) {
        menuOverlay.addEventListener('click', function() {
            menuDrawer.classList.remove('active');
            menuOverlay.classList.remove('active');
            document.body.classList.remove('menu-open');
        });
    }
    
    // Zatvaranje menija na escape tipku
    document.addEventListener('keydown', function(e) {
        if (e.key === 'Escape' && menuDrawer && menuDrawer.classList.contains('active')) {
            menuDrawer.classList.remove('active');
            menuOverlay.classList.remove('active');
            document.body.classList.remove('menu-open');
        }
    });
});