document.addEventListener("DOMContentLoaded", function () {
    let subContainer = document.querySelector(".attributes_table");
    let isMouseOverSub = false;

    subContainer.addEventListener("mouseenter", () => isMouseOverSub = true);
    subContainer.addEventListener("mouseleave", () => isMouseOverSub = false);

    subContainer.addEventListener("wheel", function (event) {
        let atTop = subContainer.scrollTop === 0;
        let atBottom = subContainer.scrollTop + subContainer.clientHeight >= subContainer.scrollHeight;

        if ((event.deltaY < 0 && atTop) || (event.deltaY > 0 && atBottom)) {
            event.preventDefault();
            document.documentElement.scrollBy(0, event.deltaY);
        }
    }, { passive: false });

    window.addEventListener("wheel", function (event) {
        if (!isMouseOverSub) {
            document.documentElement.scrollBy(0, event.deltaY);
        }
    });
});
