/**
 * Hero Slider JavaScript
 * Handles the hero image slider functionality
 */

(function($) {
    'use strict';
    
    $(document).ready(function() {
        const heroSlider = {
            init: function() {
                this.bindEvents();
                this.startSlider();
            },
            
            bindEvents: function() {
                // Hero slider navigation
                $('.hero-indicator').on('click', function() {
                    const index = $(this).data('index');
                    heroSlider.goToSlide(index);
                });
                
                // Auto-advance slider
                setInterval(() => {
                    heroSlider.nextSlide();
                }, 5000);
            },
            
            startSlider: function() {
                const $images = $('.hero-image');
                const $indicators = $('.hero-indicator');
                const $counter = $('.hero-pagination-counter');
                
                if ($images.length === 0) return;
                
                let currentIndex = 0;
                const totalSlides = $images.length;
                
                this.updateSlider(currentIndex, totalSlides);
            },
            
            goToSlide: function(index) {
                const $images = $('.hero-image');
                const $indicators = $('.hero-indicator');
                const $counter = $('.hero-pagination-counter');
                
                // Remove active classes
                $images.removeClass('active');
                $indicators.removeClass('active');
                
                // Add active class to current slide
                $images.eq(index).addClass('active');
                $indicators.eq(index).addClass('active');
                
                // Update counter
                $counter.text(`${index + 1} / ${$images.length}`);
            },
            
            nextSlide: function() {
                const $images = $('.hero-image');
                const currentIndex = $images.index($('.hero-image.active'));
                const nextIndex = (currentIndex + 1) % $images.length;
                
                this.goToSlide(nextIndex);
            },
            
            updateSlider: function(currentIndex, totalSlides) {
                const $counter = $('.hero-pagination-counter');
                $counter.text(`${currentIndex + 1} / ${totalSlides}`);
            }
        };
        
        // Initialize hero slider
        heroSlider.init();
    });
    
})(jQuery);
