const menuBtn = document.querySelector(".menu-toggle");
const sidebar = document.querySelector(".sidebar");
const overlay = document.querySelector(".sidebar-overlay");
const closeBtn = document.querySelector(".close-sidebar");

function openSidebar(){

    sidebar.classList.add("show");
    overlay.classList.add("show");
    document.body.style.overflow="hidden";

}

function closeSidebar(){

    sidebar.classList.remove("show");
    overlay.classList.remove("show");
    document.body.style.overflow="auto";

}

menuBtn.onclick = openSidebar;

overlay.onclick = closeSidebar;

closeBtn.onclick = closeSidebar;

document.querySelectorAll(".sidebar-menu a").forEach(link=>{

    link.addEventListener("click",()=>{

        if(window.innerWidth<=992){

            closeSidebar();

        }

    });

});