{topMenuHeight}px`);
    }
}

window.addEventListener("DOMContentLoaded", adjustOutputOffset);
window.addEventListener("resize", adjustOutputOffset);

// Prevent flickering on page navigation
window.addEventListener("beforeunload", () => {
    saveSideNavState();
    saveSidenavScrollPosition();
});

window.addEventListener("load", restoreSidenavScrollPosition);
document.addEventListener("DOMContentLoaded", restorenavbarState);

function initializeSearchBar(searchContainerId, outputSelector) {
    const sea