<?php
/**
 * Template Name: Custom Home Page
 */
get_header();
?>

<main role="main" id="skip_content">
  <?php do_action( 'visa_consulting_service_above_banner' ); ?>
  <?php if ( get_theme_mod( 'visa_consulting_service_banner_hide', false ) ) { ?>
    <section id="banner" class="mw-100 m-auto pt-5">
      <div class="container">
        <div class="row">
          <div class="col-xl-5 col-lg-5 col-md-5 col-12 py-5 align-self-center banner-left-content position-relative wow zoomInLeft">
            <?php if(get_theme_mod('visa_consulting_service_banner_sub_title') != ''){ ?>
              <p class="banner-sub-title mb-3 text-lg-start text-md-start text-center text-capitalize"><?php echo esc_html(get_theme_mod('visa_consulting_service_banner_sub_title')); ?></p>
            <?php } ?>
            <?php if ( get_theme_mod( 'visa_consulting_service_banner_title') != '' ){ ?>
              <h1 class="banner-title text-uppercase pb-0 mb-3 text-lg-start text-md-start text-center">
                <?php echo esc_html( get_theme_mod( 'visa_consulting_service_banner_title') ); ?>
              </h1>
            <?php } ?>
            <?php if(get_theme_mod('visa_consulting_service_banner_desc_text') != ''){ ?>
              <p class="banner-desc mb-4 text-lg-start text-md-start text-center"><?php echo esc_html(get_theme_mod('visa_consulting_service_banner_desc_text')); ?></p>
            <?php } ?>
            <div class="banner-main-btn d-flex gap-2 justify-content-lg-start justify-content-md-start justify-content-center mt-xl-5 mt-lg-2 mt-md-4 mt-4">
              <?php if ( get_theme_mod('visa_consulting_service_banner_btn_text1') != '') {?>
                <div class ="banner-btn1">
                  <a class="text-capitalize d-inline-block text-center" href="<?php echo esc_url(get_theme_mod('visa_consulting_service_banner_btn_url1'));?>"><?php echo esc_html(get_theme_mod('visa_consulting_service_banner_btn_text1'));?></a>
                </div>
              <?php }?>
              <?php if ( get_theme_mod('visa_consulting_service_banner_btn_text2') != '') {?>
                <div class ="banner-btn2">
                  <a class="text-capitalize d-inline-block text-center" href="<?php echo esc_url(get_theme_mod('visa_consulting_service_banner_btn_url2'));?>"><?php echo esc_html(get_theme_mod('visa_consulting_service_banner_btn_text2'));?></a>
                </div>
              <?php }?>
            </div>
            <?php if(get_theme_mod('visa_consulting_service_banner_sub_title') != '' || get_theme_mod('visa_consulting_service_banner_title') != '' || get_theme_mod('visa_consulting_service_banner_desc_text') != '' || get_theme_mod('visa_consulting_service_banner_btn_text1') != '' || get_theme_mod('visa_consulting_service_banner_btn_text2') != ''){ ?>
              <div class="wave-img position-absolute">
                <img src="<?php echo esc_url(get_template_directory_uri()) ?>/images/banner-wave.png" alt="<?php echo esc_attr('Wave Image', 'visa-consulting-service'); ?>">
              </div>
            <?php } ?>
          </div>
          <div class="offset-xl-1 offset-lg-1 offset-md-1 col-xl-6 col-lg-6 col-md-6 col-12 align-self-end banner-img-box text-center position-relative">
            <?php if ( get_theme_mod('visa_consulting_service_banner_right_image') != "" ) {?>
              <div class="banner-right-img">
                <img class="banner-img position-relative wow zoomIn pt-3" src="<?php echo esc_url(get_theme_mod('visa_consulting_service_banner_right_image')); ?>">
              </div>
            <?php }?>
            <?php for ($visa_consulting_service_i = 1; $visa_consulting_service_i <= 5; $visa_consulting_service_i++) { ?>
              <?php if ( get_theme_mod('visa_consulting_service_banner_country_image' .$visa_consulting_service_i) != "" ) { ?>
                <div class="banner-country-img position-absolute">
                  <img class="position-relative wow zoomIn"src="<?php echo esc_url( get_theme_mod('visa_consulting_service_banner_country_image' .$visa_consulting_service_i) ); ?>">
                </div>
              <?php } ?>
            <?php } ?>
          </div>
        </div>
      </div>
      <div class="clearfix"></div>
    </section>
  <?php }?>
  <?php do_action( 'visa_consulting_service_below_banner' ); ?>

  <!-- Visa Section -->
  <?php if( get_theme_mod( 'visa_consulting_service_select_category') != '') { ?>
    <section id="visa-sec" class="py-5">
      <div class="container">
        <div class="visa-btm-boxes mt-lg-4 mt-md-4 mt-5">
          <div class="row">
            <!-- LEFT SIDE TABS -->
            <div class="col-xl-6 col-lg-6 col-md-12">
              <div class="tab_list">
                <ul class="nav nav-tabs justify-content-between m-0" role="tablist">
                  <?php
                    $visa_consulting_service_catData = get_theme_mod('visa_consulting_service_select_category');
                    if($visa_consulting_service_catData){
                    $visa_consulting_service_args = array(
                      'category_name'  => esc_html($visa_consulting_service_catData),
                      'posts_per_page' => 4
                    );
                    $visa_consulting_service_query = new WP_Query($visa_consulting_service_args);
                    $visa_consulting_service_i = 0;
                    while($visa_consulting_service_query->have_posts()) : $visa_consulting_service_query->the_post();
                  ?>
                  <li class="nav-item visa d-flex flex-column justify-content-center mb-3 position-relative">
                    <button 
                      class="nav-link p-xl-4 p-lg-3 p-md-3 p-4 <?php if($visa_consulting_service_i==0){echo 'active';} ?>" 
                      data-bs-toggle="tab" 
                      data-bs-target="#visa-tab-<?php echo $visa_consulting_service_i; ?>" 
                      type="button">
                      <div class="box text-start mb-2">
                        <h3 class="visa-title mb-3 pb-3"><?php the_title(); ?></h3>
                        <p class="visa-excerpt">
                          <?php echo wp_trim_words(get_the_excerpt(), 15, '...'); ?>
                        </p>
                      </div>
                    </button>
                    <a href="<?php the_permalink(); ?>" class="visa-btn position-absolute"><i class="fa-solid fa-plus"></i></a>
                  </li>
                  <?php $visa_consulting_service_i++; endwhile; wp_reset_postdata(); } ?>
                </ul>
              </div>
            </div>
            <!-- RIGHT SIDE TAB CONTENT -->
            <div class="col-xl-6 col-lg-6 col-md-12">
              <div class="tab-content visa_tab_content">
                <?php
                  if($visa_consulting_service_catData){
                  $visa_consulting_service_query = new WP_Query($visa_consulting_service_args);
                  $visa_consulting_service_i = 0;
                  while($visa_consulting_service_query->have_posts()) : $visa_consulting_service_query->the_post();
                ?>
                <div class="tab-pane fade <?php if($visa_consulting_service_i==0){echo 'show active';} ?>" id="visa-tab-<?php echo $visa_consulting_service_i; ?>">
                  <div class="visa-img">
                    <?php 
                      if(has_post_thumbnail()){ 
                        the_post_thumbnail('full');
                      } else {
                        echo '<img src="' . esc_url(get_template_directory_uri() . '/images/post-img.png') . '" alt="Default Image">';
                      }
                    ?>
                  </div>
                </div>
                <?php $visa_consulting_service_i++; endwhile; wp_reset_postdata(); } ?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  <?php }?>

  <div class="container front-page-content mt-4">
    <?php while ( have_posts() ) : the_post(); ?>
      <div class="new-text"><?php the_content(); ?></div>
    <?php endwhile; // end of the loop. ?>
  </div>
</main>

<?php get_footer(); ?>