document.addEventListener('click', function (e) {
const btn = e.target.closest('#close-btn');
if (!btn) return;
e.preventDefault();
// 1) Tenta fechar popup do Elementor (se for o caso)
try {
if (window.elementorProFrontend?.modules?.popup) {
elementorProFrontend.modules.popup.closePopup({});
}
} catch(_) {}
// 2) Tenta fechar janela (se foi aberta com window.open)
if (window.opener && !window.opener.closed) {
try { window.close(); return; } catch(_) {}
}
// 3) Esconde um container custom (ajuste o seletor para o seu modal)
const modal = document.querySelector('#shipping-calculator-modal, .elementor-popup-modal, #shipping-calculator');
if (modal) modal.style.display = 'none';
});