<?php 
/**
 * Template part for displaying Featured Classes Section
 *
 * @package prime_tutor_academy
 */

// Get the counter value
$prime_tutor_academy_services_counter = get_theme_mod( 'prime_tutor_academy_services_counter', 1 );
$prime_tutor_academy_services_counter = max( 1, min( 4, intval( $prime_tutor_academy_services_counter ) ) ); // Ensure value stays between 1 and 6

$prime_tutor_academy_classes = get_theme_mod( 'prime_tutor_academy_classes_setting', false );
$prime_tutor_academy_section_title = get_theme_mod( 'prime_tutor_academy_section_title' );
$prime_tutor_academy_section_text = get_theme_mod( 'prime_tutor_academy_section_text' );

if ( $prime_tutor_academy_classes ) { ?>
    <div class="our-classes">
        <div class="container">
            <?php if ( $prime_tutor_academy_section_title ) { ?>
                <h3 class="mb-2"><?php echo esc_html( $prime_tutor_academy_section_title ); ?></h3>
            <?php } ?>
            <?php if ( $prime_tutor_academy_section_text ) { ?>
                <p class="mb-5"><?php echo esc_html( $prime_tutor_academy_section_text ); ?></p>
            <?php } ?>
            <div class="row">
                <?php for ( $i = 1; $i <= $prime_tutor_academy_services_counter; $i++ ) { ?>
                    <div class="col-xl-3 col-lg-3 col-md-4 col-sm-4 service-pos">
                        <div class="category-box m-2 mb-2 wow zoomIn delay-1000" data-wow-duration="2s">
                            <div class="image-blog wow zoomIn" data-wow-duration="2s">
                                <?php 
                                $prime_tutor_academy_services_image = get_theme_mod( 'prime_tutor_academy_service_img' . $i );
                                if ( $prime_tutor_academy_services_image ) { ?>
                                    <img src="<?php echo esc_url( $prime_tutor_academy_services_image ); ?>">
                                <?php } else { ?>
                                    <img src="<?php echo esc_url( get_stylesheet_directory_uri() . '/images/default-header.png' ); ?>">
                                <?php } ?>
                            </div>
                        </div>
                        <div class="service-content wow zoomIn" data-wow-duration="2s">
                            <?php if ( get_theme_mod( 'prime_tutor_academy_category_icon'.$i ) ) { ?>
                                <span><i class="<?php echo esc_attr( get_theme_mod( 'prime_tutor_academy_category_icon'.$i ) ); ?>"></i></span>
                            <?php } ?>
                            <?php if ( get_theme_mod( 'prime_tutor_academy_section_category_title'.$i ) ) { ?>
                                <h5 class="mt-2">
                                    <a target="_blank" href="<?php echo esc_url( get_theme_mod( 'prime_tutor_academy_section_category_title_url'.$i, '' ) ); ?>">
                                        <?php echo esc_html( get_theme_mod( 'prime_tutor_academy_section_category_title'.$i, '' ) ); ?>
                                    </a>
                                </h5>
                            <?php } ?>
                        </div>
                    </div>
                <?php } ?>
            </div>
        </div>
    </div>
<?php } ?>