document.addEventListener('DOMContentLoaded', function () {
    const slides = Array.from(document.querySelectorAll('.hero-slide'));
    let current = 0;

    if (slides.length === 0) return;

    const showSlide = index => {
        slides.forEach((slide, i) => {
            slide.classList.toggle('active', i === index);
        });
    };

    showSlide(current);

    const nextSlide = () => {
        current = (current + 1) % slides.length;
        showSlide(current);
    };

    const prevSlide = () => {
        current = (current - 1 + slides.length) % slides.length;
        showSlide(current);
    };

    document.querySelector('.hero-next')?.addEventListener('click', nextSlide);
    document.querySelector('.hero-prev')?.addEventListener('click', prevSlide);

    setInterval(nextSlide, 6000);
});
