document.addEventListener("DOMContentLoaded", function () {
    const toggle = document.getElementById(
        "hyroAdminMenuToggle"
    );

    const sidebar = document.getElementById(
        "hyroAdminSidebar"
    );

    if (!toggle || !sidebar) {
        return;
    }

    toggle.addEventListener("click", function () {
        sidebar.classList.toggle("is-open");
    });

    document.addEventListener("click", function (event) {
        if (
            window.innerWidth <= 900 &&
            !sidebar.contains(event.target) &&
            !toggle.contains(event.target)
        ) {
            sidebar.classList.remove("is-open");
        }
    });
});
