document.addEventListener("DOMContentLoaded", () => {
    // ================== DEMO NOTICE MODAL ==================
    if (!sessionStorage.getItem("demoNoticeAcknowledged")) {
        let modal = document.createElement("div");
        modal.id = "demoModal";
        modal.style.position = "fixed";
        modal.style.left = "0";
        modal.style.top = "0";
        modal.style.width = "100%";
        modal.style.height = "100%";
        modal.style.background = "rgba(0, 0, 0, 0.7)";
        modal.style.display = "flex";
        modal.style.alignItems = "center";
        modal.style.justifyContent = "center";
        modal.style.zIndex = "1000";

        let modalContent = document.createElement("div");
        modalContent.style.background = "white";
        modalContent.style.padding = "20px";
        modalContent.style.borderRadius = "10px";
        modalContent.style.textAlign = "center";
        modalContent.style.width = "80%";
        modalContent.style.maxWidth = "400px";

        let heading = document.createElement("h2");
        heading.innerText = "Demo Notice";

        let message = document.createElement("p");
        message.innerText =
            "This site is best viewed using a desktop browser. It is for demonstration purposes only and is not a real e-commerce store. No purchases can be made.";

        let closeButton = document.createElement("button");
        closeButton.innerText = "I Understand";
        closeButton.style.padding = "10px 20px";
        closeButton.style.marginTop = "15px";
        closeButton.style.border = "none";
        closeButton.style.background = "#007bff";
        closeButton.style.color = "white";
        closeButton.style.fontSize = "16px";
        closeButton.style.cursor = "pointer";
        closeButton.style.borderRadius = "5px";

        closeButton.addEventListener("click", function () {
            modal.style.display = "none";
            sessionStorage.setItem("demoNoticeAcknowledged", "true");
        });

        modalContent.appendChild(heading);
        modalContent.appendChild(message);
        modalContent.appendChild(closeButton);
        modal.appendChild(modalContent);
        document.body.appendChild(modal);
    }
});