document.getElementById("searchInput").addEventListener("input", function (e) {
  const term = e.target.value.toLowerCase();
  const btns = document.querySelectorAll(".option-btn");

  btns.forEach((btn) => {
    const text = btn.querySelector(".topic-text").textContent.toLowerCase();
    btn.style.display = text.includes(term) ? "flex" : "none";
  });
});

function toggleSelect(element) {
  element.classList.toggle("selected");

  const errorMsg = document.getElementById("topic-error");
  if (document.querySelectorAll(".option-btn.selected").length > 0) {
    errorMsg.style.display = "none";
    errorMsg.classList.add("hidden");
  }
}

document.getElementById("continueBtn").addEventListener("click", function () {
  const selectedTopics = document.querySelectorAll(".option-btn.selected");
  const errorMsg = document.getElementById("topic-error");

  if (selectedTopics.length === 0) {
    errorMsg.style.display = "block";
    errorMsg.classList.remove("hidden");
  } else {
    window.location.href = "./current-exprence-level.html";
  }
});
