document.addEventListener('DOMContentLoaded', function() {
const menuItems = document.querySelectorAll('.elementor-nav-menu--main .menu-item-has-children');
function adjustSubmenu(item) {
const submenu = item.querySelector('.sub-menu');
if (!submenu) return;
const rect = submenu.getBoundingClientRect();
if (rect.left < 0) {
submenu.classList.add('submenu-right');
} else {
submenu.classList.remove('submenu-right');
}
}
menuItems.forEach(item => {
item.addEventListener('mouseenter', () => adjustSubmenu(item));
});
window.addEventListener('resize', () => menuItems.forEach(adjustSubmenu));
});