.addEventListener('change', () => {
        toggleSpan.classList.add('animate');
        setTimeout(() => {
            toggleSpan.classList.remove('animate'); // Remove the animation class after completion
        }, 400); // Match the CSS transition duration (0.4s)
    });
});

// Avoid flickering of theme toggle on page load
document.addEventListener("DOMContentLoaded", () => {
    const body = document.body;

    // Temporarily disable transitions during page load
    body.classList.add('no-transition')