function toggleSidebar() {
    const sidebar = document.getElementById("sidebar");
    sidebar.classList.toggle("-translate-x-full");
}

// Close sidebar when clicking outside on mobile
document.addEventListener("click", function (event) {
    const sidebar = document.getElementById("sidebar");
    const toggleBtn = event.target.closest("button");

    if (
        !sidebar.contains(event.target) &&
        !toggleBtn &&
        window.innerWidth < 1024
    ) {
        sidebar.classList.add("-translate-x-full");
    }
});
