<?php
$page_ids = array_filter(array(
	get_theme_mod('slider_page1'),
	get_theme_mod('slider_page2'),
	get_theme_mod('slider_page3'),
	get_theme_mod('slider_page4'),
));

// Slider settings
$data_banner = array(
	'effect'        => 'fade',
	'fadeEffect'    => array( 'crossFade' => true ),
	'slidesPerView' => 1,
	'centeredSlides'=> true,
	'keyboard'      => array( 'enabled' => true ),
	'spaceBetween'  => 20,
	'pagination'    => array(
		'el'        => '.swiper-pagination',
		'clickable' => true,
	),
	'navigation'    => array(
		'nextEl' => '.swiper-button-next',
		'prevEl' => '.swiper-button-prev',
	),
	'autoplay' => array(
		'delay'                => 9000,
		'disableOnInteraction' => false,
	),
);
?> 

<?php
$slider_subtitle_text  = get_theme_mod(
    'slider_subtitle_text',
    __( 'Groth Your Business Online', 'siara-digital-solutions' )
);

$slider_learnmorebtn_link  = get_theme_mod(
    'slider_learnmorebtn_link',
    '#'
);
?>

<section class="siaracorporatebusiness-section-banner-wrapper boxed as-carousel style_1 em-animate-content">
	<div class="siaracorporatebusiness-section-banner">
		<div class="row g-1">
			<div class="col-lg-12">
				<div class="siaracorporatebusiness-banner-wrapper siaracorporatebusiness-swiper-outer-bullets swiper"
					 data-banner='<?php echo esc_attr( json_encode( $data_banner ) ); ?>'>
					<div class="siaracorporatebusiness-banner swiper-wrapper">

						<?php if ( ! empty( $page_ids ) ) :
							$args = array(
								'post_type'      => 'page',
								'post__in'       => $page_ids,
								'orderby'        => 'post__in',
								'posts_per_page' => count($page_ids),
							);
							$banner_query = new WP_Query( $args );
							if ( $banner_query->have_posts() ) :
								while ( $banner_query->have_posts() ) : $banner_query->the_post(); 
									$featured_image = get_the_post_thumbnail_url( get_the_ID(), 'full' );
									$background_style = $featured_image ? "background-image: url('" . esc_url( $featured_image ) . "')" : "";
						?>
						<div class="swiper-slide" >
							<div class="banner-block-wrapper">
								<div class="row m-0 pd-0">
									<div class="banner-content-section">
										<div class="banner-content-inner">
											<div class="banner-sub-text">
												<?php echo esc_html( $slider_subtitle_text ); ?>
											</div>
											<h2 class="banner-title">
												<?php the_title(); ?>
											</h2>
											<div class="banner-excerpt">
												<p><?php echo wp_trim_words( get_the_excerpt(), 25, '&hellip;' ); ?></p>
											</div>
											<div class="banner-read-more">
												<a href="<?php the_permalink(); ?>" class="banner-cta-button">
													<?php esc_html_e( 'Get Started', 'siara-digital-solutions' ); ?>
													
												</a>
												<a href="<?php echo esc_url( $slider_learnmorebtn_link ); ?>" class="banner-lrn-button">
													<?php esc_html_e( 'Explore Services', 'siara-digital-solutions' ); ?>
													
												</a>
											</div>
										</div>
									</div>
									<div class="imgbx">
										<div class="slideimg">
											<a href="<?php the_permalink(); ?>">
												<?php the_post_thumbnail( 'siaracorporatebusiness-cover-image', array(
													'alt' => the_title_attribute( array( 'echo' => false ) ),
												) ); ?>
											</a>
							                <div class="overlay"></div>
							            </div>
									</div>
								</div>
							</div>
						</div>
								<?php endwhile; wp_reset_postdata();
							endif;
						else :
							// Static default slider items
							$default_slides = array(
								array(
									'image' => get_template_directory_uri() . '/assets/images/slider-default1.jpg',
									'sub_text' => 'Groth Your Business Online',
									'title' => 'Smart Solutions For Digital Growth',
									'desc'  => 'Siara Digital Solutions helps businesses grow online with innovative strategies, modern websites, and results-driven digital marketing.',
									'link'  => '#',
								),
								array(
									'image' => get_template_directory_uri() . '/assets/images/slider-default2.jpg',
									'sub_text' => 'Groth Your Business Online',
									'title' => 'Smart Financial',
									'desc'  => 'Siara Digital Solutions helps businesses grow online with innovative strategies, modern websites, and results-driven digital marketing.',
									'link'  => '#',
								),
							);

							foreach ( $default_slides as $slide ) : ?>
								<div class="swiper-slide" >
									<div class="banner-block-wrapper">
										<div class="row m-0 pd-0">
											<div class="banner-content-section">
												<div class="banner-content-inner">
													<div class="banner-sub-text">
														<?php echo esc_html( $slide['sub_text'] ); ?>
													</div>
													<h2 class="banner-title">
														<?php echo esc_html( $slide['title'] ); ?>
													</h2>
													<div class="banner-excerpt">
														<p><?php echo esc_html( $slide['desc'] ); ?></p>
													</div>
													<div class="banner-read-more">
														<a href="<?php echo esc_url( $slide['link'] ); ?>" class="banner-cta-button">
															<?php esc_html_e( 'Get Started', 'siara-digital-solutions' ); ?>
															
														</a>
														<a href="<?php echo esc_url( $slide['link'] ); ?>" class="banner-lrn-button">
															<?php esc_html_e( 'Explore Services', 'siara-digital-solutions' ); ?>
															
														</a>
													</div>
												</div>
											</div>
											<div class="imgbx">
												<div class="slideimg">
									                <img src="<?php echo esc_url( $slide['image'] ); ?>" alt="">
									                <div class="overlay"></div>
									            </div>
											</div>		
										</div>
									</div>
								</div>
							<?php endforeach;
						endif; ?>
					</div>

					<div class="swiper-pagination"></div>
					<div class="swiper-button-next"></div>
					<div class="swiper-button-prev"></div>
				</div>
			</div>
		</div>
	</div>
</section>
