lightedIndex >= 0) {
            event.preventDefault();
            items[highlightedIndex].click();
        }
    });

    // Hide suggestions when clicking outside
    document.addEventListener("click", (event) => {
        if (!searchBar.contains(event.target) && !autocompleteList.contains(event.target)) {
            autocompleteList.style.display = "none";
        }
    });

    // Adjust width on window resize
    adjustAutocompleteWidth();
    window.addEventListener("resize", adjustAutocompleteWidt