<?php
/**
 * Template part for displaying Banner section.
 *
 * @package Gym Coach
 * @subpackage gym_coach
 */

$gym_coach_banner_main_sec = get_theme_mod('gym_coach_banner_membership_plan_sec_show', true);

if ($gym_coach_banner_main_sec) : ?>
    <div id="membership-plans" class="my-5">
        <div class="container">
            <div class="text-center">
                <?php if ($gym_coach_subheading = get_theme_mod('gym_coach_serv_short_heading')) : ?>
                    <p class="serv-short my-0 text-uppercase"><?php echo esc_html($gym_coach_subheading); ?></p>
                <?php endif; ?>
                <?php if ($gym_coach_heading = get_theme_mod('gym_coach_memebership_section_heading')) : ?>
                    <h2 class="product-heading mt-2 mb-4"><?php echo esc_html($gym_coach_heading); ?></h2>
                <?php endif; ?>
            </div>
            <div class="row">
                <?php for ($gym_coach_i = 1; $gym_coach_i <= 3; $gym_coach_i++) : ?>
                    <div class="col-lg-4 col-md-4">
                        <?php
                        $gym_coach_has_banner_image   = get_theme_mod("gym_coach_select_membership_banner_image" . $gym_coach_i) !== '';
                        $gym_coach_has_type           = get_theme_mod("gym_coach_membership_type" . $gym_coach_i) !== '';
                        $gym_coach_has_fee            = get_theme_mod("gym_coach_membership_fee" . $gym_coach_i) !== '';
                        $gym_coach_has_details        = get_theme_mod("gym_coach_membership_details" . $gym_coach_i) !== '';
                        $gym_coach_has_button_text    = get_theme_mod("gym_coach_membership_button_text" . $gym_coach_i) !== '';

                        // Check features
                        $gym_coach_has_features = false;
                        for ($gym_coach_feature_count = 1; $gym_coach_feature_count <= 3; $gym_coach_feature_count++) {
                            if (get_theme_mod("gym_coach_post{$gym_coach_i}_feature_heading{$gym_coach_feature_count}") != '') {
                                $gym_coach_has_features = true;
                                break;
                            }
                        }
                        // Show box only if any content is present
                        if ($gym_coach_has_banner_image || $gym_coach_has_type || $gym_coach_has_fee || $gym_coach_has_details || $gym_coach_has_features || $gym_coach_has_button_text) :
                        ?>
                        <div class="main-content-box mb-4">
                            <?php if ($gym_coach_has_banner_image) : ?>
                                <div class="gym-img">
                                    <?php
                                    $gym_coach_banner_alt = sprintf(__('Banner Image', 'gym-coach'), $gym_coach_i);
                                    ?>
                                    <img src="<?php echo esc_url(get_theme_mod("gym_coach_select_membership_banner_image" . $gym_coach_i)); ?>" alt="<?php echo esc_attr($gym_coach_banner_alt); ?>" />
                                </div>
                            <?php endif; ?>
                            <div class="gym-total-details text-center">
                                <?php if ($gym_coach_has_type) : ?>
                                    <p class="my-2 membership-type text-uppercase"><?php echo esc_html(get_theme_mod("gym_coach_membership_type" . $gym_coach_i)); ?></p>
                                <?php endif; ?>

                                <?php if ($gym_coach_has_fee) : ?>
                                    <p class="my-2 membership-fee"><?php echo esc_html(get_theme_mod("gym_coach_membership_fee" . $gym_coach_i)); ?></p>
                                <?php endif; ?>

                                <?php if ($gym_coach_has_details) : ?>
                                    <p class="my-2 membership-details"><?php echo esc_html(get_theme_mod("gym_coach_membership_details" . $gym_coach_i)); ?></p>
                                <?php endif; ?>

                                <?php if ($gym_coach_has_features): ?>
                                    <div class="post-features">
                                        <?php 
                                        for ($gym_coach_feature_count = 1; $gym_coach_feature_count <= 3; $gym_coach_feature_count++): 
                                            $gym_coach_feature_text = get_theme_mod("gym_coach_post{$gym_coach_i}_feature_heading{$gym_coach_feature_count}");
                                            if ($gym_coach_feature_text): 
                                        ?>
                                            <div class="feature-item mb-2">
                                                <i class="fas fa-check me-2"></i>
                                                <span class="main-features"><?php echo esc_html($gym_coach_feature_text); ?></span>
                                            </div>
                                        <?php 
                                            endif;
                                        endfor;
                                        ?>
                                    </div>
                                <?php endif; ?>

                                <?php if ($gym_coach_has_button_text) : ?>
                                    <div class="join-btn mt-3" data-wow-duration="2s">
                                        <a href="<?php echo esc_url(get_theme_mod("gym_coach_membership_button_link" . $gym_coach_i)); ?>">
                                            <?php echo esc_html(get_theme_mod("gym_coach_membership_button_text" . $gym_coach_i)); ?>
                                            <span class="screen-reader-text"><?php echo esc_html(get_theme_mod("gym_coach_membership_button_text" . $gym_coach_i)); ?></span>
                                        </a>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                        <?php endif; ?>
                    </div>
                <?php endfor; ?>
            </div>
        </div>
    </div>
<?php endif; ?>