document.addEventListener('DOMContentLoaded', function () {
  var sideMenu = document.getElementById('sideMenu');
  var burgerIcon = document.querySelector('.burger-icon');

  function toggleMenu() {
    sideMenu.style.width = (sideMenu.style.width === '250px') ? '0' : '250px';
  }

  function closeMenu(event) {
    if (event.target !== sideMenu && event.target !== burgerIcon && sideMenu.style.width === '250px') {
      sideMenu.style.width = '0';
    }
  }

  burgerIcon.addEventListener('click', function() {
    toggleMenu();
  });

  document.body.addEventListener('click', closeMenu);
});