document.addEventListener("DOMContentLoaded", function () {
  const eyeContainer = document.getElementById("eye-container");

  if (eyeContainer) {
    eyeContainer.remove();
    const inputParent =
      document.getElementById("simplyin_api_key").parentNode.parentNode;
    inputParent.style.position = "relative";
    inputParent.appendChild(eyeContainer);
  }

  const paragraphs = document.querySelectorAll(".order_data_column p");

  if (paragraphs) {
    paragraphs.forEach(function (p) {
      if (p.textContent.trim().startsWith("Save my data:")) {
        p.style.display = "none";
      }
    });
  }

  // Zone tab switching for shipping mapping.
  (function () {
    const container = document.getElementById("simply_shipping_mapping");
    if (!container) return;

    const btns = container.querySelectorAll(".simply-zone-tab-btn");
    const panels = container.querySelectorAll(".simply-zone-tab-panel");

    btns.forEach(function (btn) {
      btn.addEventListener("click", function () {
        const zone = this.dataset.zone;

        btns.forEach(function (b) {
          b.classList.remove("active");
          b.setAttribute("aria-selected", "false");
        });
        panels.forEach(function (p) {
          p.classList.remove("active");
        });

        this.classList.add("active");
        this.setAttribute("aria-selected", "true");
        const panel = container.querySelector(
          '.simply-zone-tab-panel[data-zone="' + zone + '"]'
        );
        if (panel) panel.classList.add("active");
      });
    });
  })();
});
