document.addEventListener("DOMContentLoaded", () => {
// Apri e chiudi il menu
const menuItems = document.querySelectorAll(".menu-item");
menuItems.forEach(item => {
item.querySelector(".menu-item-header").addEventListener("click", () => {
menuItems.forEach(i => {
if (i !== item) i.classList.remove("active");
});
item.classList.toggle("active");
});
});
// Funzione di ricerca nel menu
const searchBox = document.getElementById("searchBox");
if (searchBox) {
searchBox.addEventListener("keyup", function () {
let input = this.value.toLowerCase();
let menuItems = document.querySelectorAll(".menu-item");
menuItems.forEach(item => {
let title = item.querySelector(".menu-item-header span").innerText.toLowerCase();
let content = item.querySelector(".menu-item-content").innerText.toLowerCase();
if (title.includes(input) || content.includes(input)) {
item.style.display = "block";
} else {
item.style.display = "none";
}
});
});
}
});