document.addEventListener("DOMContentLoaded", () => {
    const voltarTopo = document.getElementById("voltar-topo");

    if (!voltarTopo) return;

    window.addEventListener("scroll", () => {
        if (window.scrollY > 300) {
            voltarTopo.classList.add("show");
        } else {
            voltarTopo.classList.remove("show");
        }
    });

    voltarTopo.addEventListener("click", () => {
        window.scrollTo({
            top: 0,
            behavior: "smooth",
        });
    });
});
