/**
 * Banner Swiper Slider Initialization
 */

document.addEventListener('DOMContentLoaded', function() {
    // Check if banner swiper exists on page
    const bannerSwiperEl = document.querySelector('.bannerSwiper');

    if (bannerSwiperEl) {
        const bannerSwiper = new Swiper('.bannerSwiper', {
            // Loop through slides
            loop: true,

            // Autoplay settings
            autoplay: {
                delay: 5000,
                disableOnInteraction: false,
                pauseOnMouseEnter: true,
            },

            // Transition speed
            speed: 800,

            // Fade effect
            effect: 'fade',
            fadeEffect: {
                crossFade: true
            },

            // Navigation arrows
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
            },

            // Pagination disabled
            pagination: false,

            // Keyboard control
            keyboard: {
                enabled: true,
                onlyInViewport: true,
            },

            // Accessibility
            a11y: {
                prevSlideMessage: 'Previous slide',
                nextSlideMessage: 'Next slide',
            },

            // Lazy loading images
            lazy: {
                loadPrevNext: true,
            },

            // Events
            on: {
                init: function () {
                    console.log('Banner Swiper initialized');
                },
                slideChange: function () {
                    // Optional: Add custom logic on slide change
                }
            }
        });

        // Pause autoplay on hover
        bannerSwiperEl.addEventListener('mouseenter', function() {
            bannerSwiper.autoplay.stop();
        });

        bannerSwiperEl.addEventListener('mouseleave', function() {
            bannerSwiper.autoplay.start();
        });
    }
});