 //------------------CALENDAR FUNCTIONS---------------------//

  document.addEventListener("DOMContentLoaded", function() {
    var now = new Date();
    var formattedDateTime = now.toISOString().slice(0, 16);
    document.getElementById('validFrom').value = formattedDateTime;
  });

//---------------------DARK MODE--------------------------------//
document.addEventListener('DOMContentLoaded', () => {
  const themeToggler = document.querySelector(".theme_toggler");

  // Check for saved theme in localStorage
  const savedTheme = localStorage.getItem('theme');
  if (savedTheme) {
    document.body.classList.add(savedTheme);
    const spans = themeToggler.querySelectorAll('span');
    if (savedTheme === 'dark-theme-variables') {
      spans[0].classList.remove('active');
      spans[1].classList.add('active');
    } else {
      spans[0].classList.add('active');
      spans[1].classList.remove('active');
    }
  }

  if (themeToggler) {
    themeToggler.addEventListener('click', () => {
      document.body.classList.toggle('dark-theme-variables');
      const spans = themeToggler.querySelectorAll('span');
      spans[0].classList.toggle('active');
      spans[1].classList.toggle('active');

      // Save theme preference in localStorage
      if (document.body.classList.contains('dark-theme-variables')) {
        localStorage.setItem('theme', 'dark-theme-variables');
      } else {
        localStorage.removeItem('theme');
      }
    });
  }
});
