// Navigation chevron buttons logic
document.addEventListener("DOMContentLoaded", function () {
  const navPrev = document.getElementById("nav-prev");
  const navNext = document.getElementById("nav-next");

  if (!navPrev || !navNext) return;

  // Define the navigation order (main pages)
  const navPages = [
    window.NAVIGATION_URLS.dashboard,
    window.NAVIGATION_URLS.projects,
    window.NAVIGATION_URLS.imports,
    window.NAVIGATION_URLS.simulations,
    window.NAVIGATION_URLS.reporting,
    window.NAVIGATION_URLS.settings,
  ];

  const currentPath = window.location.pathname;

  // Find current index
  let currentIndex = -1;
  for (let i = 0; i < navPages.length; i++) {
    if (currentPath.startsWith(navPages[i])) {
      currentIndex = i;
      break;
    }
  }

  // If not found, disable both
  if (currentIndex === -1) {
    navPrev.disabled = true;
    navNext.disabled = true;
    return;
  }

  // Set up prev button
  if (currentIndex > 0) {
    navPrev.addEventListener("click", function () {
      window.location.href = navPages[currentIndex - 1];
    });
  } else {
    navPrev.disabled = true;
  }

  // Set up next button
  if (currentIndex < navPages.length - 1) {
    navNext.addEventListener("click", function () {
      window.location.href = navPages[currentIndex + 1];
    });
  } else {
    navNext.disabled = true;
  }
});
