<?php
/**
 * The template part for Home Right Sidebar
 *
 * @package Anime Stream 
 * @subpackage anime-stream
 * @since anime-stream 1.0
 */
?>

<?php if (get_theme_mod('anime_stream_right_sidebar_hide_show', false)) { ?>
  <div class="col-xl-2 home-right-sidebar p-0">
    <div class="toggle-right">
      <button><i class="fa-solid fa-arrow-left"></i></button>
    </div>
    <div class="right-inner-sidebar">
      <span class="closebtn"><i class="fas fa-times"></i></span>
      <?php if(get_theme_mod('anime_stream_right_sidebar_title') != '' || get_theme_mod('anime_stream_right_top_cards_title') != '') {?>
        <div class="right-sidebar-top p-2 mb-3">
          <div class="right-top-cards pb-4 mb-3 position-relative wow zoomIn">
            <div class="row">
                <div class="col-lg-9 col-md-9 col-9 align-self-center">
                    <h4 class="right-card-title text-capitalize mb-0"><i class="fa-solid fa-bars-staggered me-2"></i><?php echo esc_html(get_theme_mod('anime_stream_right_top_cards_title')) ?></h4>
                </div>
                <div class="col-lg-3 col-md-3 col-3 align-self-center d-flex justify-content-between">
                  <div class="swiper-button-prev"><i class="fa-solid fa-chevron-left"></i></div>
                  <div class="swiper-button-next"><i class="fa-solid fa-chevron-right"></i></div>
                </div>
            </div>
            <div class="swiper mySwiper mt-3">
              <div class="swiper-wrapper">
                <?php
                  $anime_stream_featured_post = get_theme_mod('anime_stream_select_cards_number');
                  for ($anime_stream_i = 1; $anime_stream_i <= $anime_stream_featured_post; $anime_stream_i++) {
                  $anime_stream_postData = get_theme_mod('anime_stream_select_card_name' . $anime_stream_i);
                  if ($anime_stream_postData) {
                    $anime_stream_args = array(
                      'p' => esc_html($anime_stream_postData, 'anime-stream'),
                      'post_type' => 'post'
                    );
                    $anime_stream_query = new WP_Query($anime_stream_args);
                      if ($anime_stream_query->have_posts()) :
                      while ($anime_stream_query->have_posts()) : $anime_stream_query->the_post();
                    ?>
                    <div class="swiper-slide card-box position-relative">
                      <div class="card-inner-box position-relative">
                        <?php if (has_post_thumbnail()) { ?>
                          <a href="<?php the_permalink(); ?>">
                            <?php the_post_thumbnail(); ?>
                            <div class="card-overlay position-absolute"></div>
                          </a>
                        <?php } else { ?>
                          <a href="<?php the_permalink(); ?>">
                            <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/post-image.png" alt="<?php echo esc_attr('Post Image', 'anime-stream'); ?>">
                            <div class="card-overlay position-absolute"></div>
                          </a>
                        <?php } ?>
                      </div>
                      <?php if (get_theme_mod('anime_stream_add_card_text' . $anime_stream_i) != '') { ?>
                        <p class="card-text position-absolute text-center"><i class="fa-solid fa-eye me-2"></i><?php echo esc_html(get_theme_mod('anime_stream_add_card_text' . $anime_stream_i)); ?></p>
                      <?php } ?>
                    </div>
                    <?php
                    endwhile;
                      wp_reset_postdata();
                    endif;
                    }
                  }
                ?>
              </div>
            </div>
          </div>
          <div class="right-top-slider wow zoomIn">
            <h4 class="right-side-title text-capitalize mb-3"><?php echo esc_html(get_theme_mod('anime_stream_right_sidebar_title')) ?></h4>
            <div class="right-img-slider position-relative">
              <?php for ($anime_stream_i = 1; $anime_stream_i <= 3; $anime_stream_i++) { ?>
                <?php if (get_theme_mod('anime_stream_top_charts_slider_img' . $anime_stream_i) != "") { ?>
                  <div class="right-img-box position-absolute">
                    <img src="<?php echo esc_url(get_theme_mod('anime_stream_top_charts_slider_img' . $anime_stream_i)); ?>" alt="<?php echo esc_attr('Image', 'anime-stream'); ?>">
                  </div>
                <?php } ?>
              <?php } ?>
            </div>
          </div>
        </div>
      <?php }?>
      <?php if(get_theme_mod('anime_stream_right_sidebar_wallpaper_title') != '' || get_theme_mod('anime_stream_gallery_button_url') != '' || get_theme_mod('anime_stream_gallery_button_text') != '') {?>
        <div class="right-sidebar-bottom p-2">
          <div class="right-gallery wow zoomIn">
            <h4 class="gallery-title text-capitalize mb-3"><i class="fa-solid fa-image me-2"></i><?php echo esc_html(get_theme_mod('anime_stream_right_sidebar_wallpaper_title')) ?></h4>
              <div class="gallery-img-box">
                <?php for ($anime_stream_k = 1; $anime_stream_k <= 3; $anime_stream_k++) { ?>
                  <?php if (get_theme_mod('anime_stream_right_sidebar_wallpaper_img' . $anime_stream_k) != "") { ?>
                    <img src="<?php echo esc_url(get_theme_mod('anime_stream_right_sidebar_wallpaper_img' . $anime_stream_k)); ?>" alt="<?php echo esc_attr('Image', 'anime-stream'); ?>">
                  <?php } ?>
                <?php } ?>
              </div>
              <div class ="gallery-btn text-center mb-2">
                <?php if(get_theme_mod('anime_stream_gallery_button_url') != '' || get_theme_mod('anime_stream_gallery_button_text') != '') {?>
                  <a href="<?php echo esc_url(get_theme_mod('anime_stream_gallery_button_url'));?>" class="text-capitalize p-2"><i class="fa-solid fa-comment-dots me-2"></i><?php echo esc_html(get_theme_mod('anime_stream_gallery_button_text'));?>
                <?php }?>
                </a>
              </div>
          </div>
        </div>
      <?php }?>
    </div>
  </div>
<?php }?>