<?php
/**
 * Template part for displaying slider section
 * @package Buildora Architect
 */
$buildora_architect_slider_arrows = get_theme_mod('buildora_architect_slider_arrows', true);
?>

<?php if ($buildora_architect_slider_arrows) : ?>
<section id="banner">
  <div class="container">
    <div class="banner-content">
        <div class="banner-left-content">
          <?php if (get_theme_mod('buildora_architect_banner_title')) : ?>
            <h1 class="banner-title text-capitalize pb-0 mb-1 text-lg-start text-md-start text-center">
              <?php echo esc_html(get_theme_mod('buildora_architect_banner_title')); ?>
            </h1>
          <?php endif; ?>
          <?php if (get_theme_mod('buildora_architect_banner_desc_text')) : ?>
            <p class="banner-desc mb-3 text-lg-start text-md-start text-center">
              <?php echo esc_html(get_theme_mod('buildora_architect_banner_desc_text')); ?>
            </p>
          <?php endif; ?>
        </div>
        <div class="banner-product-sec position-relative">
          <?php 
          $buildora_architect_cat_slug = get_theme_mod('buildora_architect_product_category', 'postcategory1');
          if ($buildora_architect_cat_slug) : 
            $buildora_architect_cat_id = get_category_by_slug($buildora_architect_cat_slug)->term_id;  // Convert slug to ID [web:11]
          ?>
            <div class="slider-for pt-4">
              <?php 
              $buildora_architect_args = array(
                'post_type' => 'post',
                'cat'       => $buildora_architect_cat_id,
                'order'     => 'ASC'
              );
              $buildora_architect_loop = new WP_Query($buildora_architect_args);
              while ($buildora_architect_loop->have_posts()) : $buildora_architect_loop->the_post(); 
              ?>
                <div class="product-single-box position-relative">
                  <div class="product-single-inner-box">
                    <div class="product-single-img-box align-items-center">
                      <a href="<?php echo esc_url(get_permalink()); ?>" title="<?php the_title_attribute(); ?>">
                        <?php if (has_post_thumbnail()) : 
                          the_post_thumbnail('medium');  // Use medium size for posts
                        else : ?>
                          <img src="<?php echo esc_url(get_theme_file_uri('/assets/images/slider-img1.png')); ?>" alt="<?php the_title_attribute(); ?>">
                        <?php endif; ?>
                      </a>
                    </div>
                  </div>
                  <?php 
                  $buildora_architect_banner_image = get_theme_mod('buildora_architect_banner_bottom_image', get_theme_file_uri('/assets/images/review-photo.png'));
                  $buildora_architect_banner_text = get_theme_mod('buildora_architect_banner_review_desc', 'HAPPY CUSTOMER');
                  if ( !empty($buildora_architect_banner_image) || !empty($buildora_architect_banner_text) ) : ?>
                  <div class="banner-bottom-box">
                    <div class="bottom-img-box mb-2">
                      <?php if ( !empty($buildora_architect_banner_image) ) : ?>
                        <img class="banner-btm-img" 
                             src="<?php echo esc_url($buildora_architect_banner_image); ?>" 
                             alt="<?php esc_attr_e('Reviewer image', 'buildora-architect'); ?>">
                      <?php endif; ?>
                    </div>
                    <?php if ( !empty($buildora_architect_banner_text) ) : ?>
                      <p class="clients-desc text-uppercase mt-lg-3 mt-md-2 mb-0"><?php echo esc_html($buildora_architect_banner_text); ?></p>
                    <?php endif; ?>
                  </div>
                  <?php endif; ?>
                </div>
              <?php endwhile; wp_reset_postdata(); ?>
            </div>
            <div class="product-outer-box position-absolute">
              <div class="product-bottom-slider">
                <div class="slider-nav d-flex position-relative">
                  <?php 
                  $buildora_architect_args = array(
                    'post_type'      => 'post',
                    'cat'            => $buildora_architect_cat_id,
                    'order'          => 'ASC',
                    'posts_per_page' => 3
                  );
                  $buildora_architect_loop = new WP_Query($buildora_architect_args);
                  while ($buildora_architect_loop->have_posts()) : $buildora_architect_loop->the_post(); 
                  ?>
                    <div class="product-box">
                      <div class="product-slider-image position-relative">
                        <?php if (has_post_thumbnail()) : 
                          the_post_thumbnail('thumbnail');
                        else : ?>
                          <img src="<?php echo esc_url(get_theme_file_uri('/assets/images/slider-img1.png')); ?>" alt="<?php the_title_attribute(); ?>">
                        <?php endif; ?>
                      </div>
                    </div>
                  <?php endwhile; wp_reset_postdata(); ?>
                </div>
              </div>
            </div>
          <?php endif; ?>
        </div>
    </div>
  </div>
  <div class="clearfix"></div>
</section>
<?php endif; ?>