<?php
/**
 * The header for our theme
 *
 * @subpackage lz-toy-store
 * @since 1.0
 * @version 0.1
 */

?><!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
<?php if ( function_exists( 'wp_body_open' ) ) {
    wp_body_open();
} else {
    do_action( 'wp_body_open' );
}?>

<div class="main-content">
	<div class="body-overlay"></div>
	<header role="banner" id="header">
		<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'lz-toy-store' ); ?></a>
		<div class="top">
			<div class="container">
				<div class="main-top">
					<div class="row">
						<div class="col-lg-3 col-md-3 layout">
							<div class="logo">
						        <?php if ( has_custom_logo() ) : ?>
							        <div class="site-logo"><?php the_custom_logo(); ?></div>
							    <?php endif; ?>
					            <?php if (get_theme_mod('lz_toy_store_show_site_title',true)) {?>
							        <?php $blog_info = get_bloginfo( 'name' ); ?>
							        <?php if ( ! empty( $blog_info ) ) : ?>
							            <?php if ( is_front_page() && is_home() ) : ?>
								            <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
							        	<?php else : ?>
						            		<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
							            <?php endif; ?>
							        <?php endif; ?>
							    <?php }?>
					        	<?php if (get_theme_mod('lz_toy_store_show_tagline',true)) {?>
							        <?php
							        $description = get_bloginfo( 'description', 'display' );
							        if ( $description || is_customize_preview() ) :
							          ?>
								        <p class="site-description">
								            <?php echo esc_html($description); ?>
								        </p>
							        <?php endif; ?>
							    <?php }?>
						    </div>
						</div>
						<div class="col-lg-9 col-md-9 align-self-end">
							<?php if (get_theme_mod('lz_toy_store_hide_show_topbar',false) == true) {?>
								<div class="contact-details">
									<span class="call">
										<?php if( get_theme_mod( 'lz_toy_store_call','' ) != '') { ?>
									    	<i class="fas fa-phone"></i><span class="col-org"><a href="tel:<?php echo esc_attr( get_theme_mod('lz_toy_store_call','') ); ?>"><?php echo esc_html( get_theme_mod('lz_toy_store_call','') ); ?></a></span>
										<?php } ?>
									</span>
									<span class="call">
										<?php if( get_theme_mod( 'lz_toy_store_address','' ) != '') { ?>
										<span>|</span>
									    	<i class="fas fa-map-marker-alt"></i><span class="col-org"><?php echo esc_html( get_theme_mod('lz_toy_store_address','') ); ?></span>
										<?php } ?>
									</span>
								</div>	
							<?php }?>
							<div class="menu-section">
								<div class="row">
									<div class="col-lg-6 col-md-2">
										<?php if (has_nav_menu('primary')){ ?>
											<div class="toggle-menu responsive-menu">
									            <button onclick="lz_toy_store_open()" role="tab" class="mobile-menu"><i class="fas fa-bars"></i><span class="screen-reader-text"><?php esc_html_e('Open Menu','lz-toy-store'); ?></span></button>
									        </div>
											<div id="sidelong-menu" class="nav sidenav">
								                <nav id="primary-site-navigation" class="nav-menu" role="navigation" aria-label="<?php esc_attr_e( 'Top Menu', 'lz-toy-store' ); ?>">
								                  <?php 
								                    wp_nav_menu( array( 
								                      'theme_location' => 'primary',
								                      'container_class' => 'main-menu-navigation clearfix' ,
								                      'menu_class' => 'clearfix',
								                      'items_wrap' => '<ul id="%1$s" class="%2$s mobile_nav">%3$s</ul>',
								                      'fallback_cb' => 'wp_page_menu',
								                    ) ); 
								                  ?>
								                  <a href="javascript:void(0)" class="closebtn responsive-menu" onclick="lz_toy_store_close()"><i class="fas fa-times"></i><span class="screen-reader-text"><?php esc_html_e('Close Menu','lz-toy-store'); ?></span></a>
								                </nav>
								            </div>
								        <?php }?>
									</div>
									<div class="col-lg-4 col-md-6">
										<span class="search-icon">
								            <?php get_search_form(); ?>
								        </span>
									</div>
									<div class="col-lg-2 col-md-4 p-0">
										<div class="cart_icon">
										 	<a href="<?php the_permalink((get_option('woocommerce_cart_page_id'))); ?>"><i class="fas fa-shopping-bag"></i><?php echo esc_html_e('SHOPPING CART','lz-toy-store'); ?></a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div> 
	</header>

	<?php
    $container_type = get_theme_mod('lz_toy_store_boxfull_width', ''); // Get the selected container type
	// Define the default container class
	$container_class = 'container';
	
	// If container or container-fluid is selected, update the container class
	if ($container_type === 'container' || $container_type === 'container-fluid') {
		$container_class = $container_type;
	}
    ?>
	<div class="<?php echo esc_attr($container_class); ?>">
		<section id="category-dropdown" class="white-border">
			<div class="row">
				<?php if(class_exists('woocommerce')){ ?>
					<div class="col-lg-3 col-md-3 layout">
				        <button role="tab" class="product-btn"><i class="fa fa-bars" aria-hidden="true"></i><?php echo esc_html_e('BROWSE BY DEPARTMENTS','lz-toy-store'); ?></button>
				        <div class="product-cat">
				          <?php
				            $args = array(
				              //'number'     => $number,
				              'orderby'    => 'title',
				              'order'      => 'ASC',
				              'hide_empty' => 0,
				              'parent'  => 0
				              //'include'    => $ids
				            );
				            $lz_toy_store_product_categories = get_terms( 'product_cat', $args );
				            $count = count($lz_toy_store_product_categories);
				            if ( $count > 0 ){
				                foreach ( $lz_toy_store_product_categories as $product_category ) {
				                  $product_cat_id   = $product_category->term_id;
				                  $cat_link = get_category_link( $product_cat_id );
				                  if ($product_category->category_parent == 0) { ?>
				                <li class="drp_dwn_menu"><a href="<?php echo esc_url(get_term_link( $product_category ) ); ?>">
				                <?php
				              }
				                echo esc_html( $product_category->name ); ?></a><i class="fas fa-chevron-right"></i></li>
				                <?php
				                }
				              }
				          ?>
			        	</div>
			      	</div>
			    <?php }?>
				<div class="col-lg-9 col-md-9 layout1">
					<?php $lz_toy_store_sale_pages = array();
					$mod = intval( get_theme_mod( 'lz_toy_store_servicesettings_page'));
					if ( 'page-none-selected' != $mod ) {
					 	$lz_toy_store_sale_pages[] = $mod;
					}
					if( !empty($lz_toy_store_sale_pages) ) :
					 	$args = array(
						   'post_type' => 'page',
						   'post__in' => $lz_toy_store_sale_pages,
						   'orderby' => 'post__in'
						);
						$query = new WP_Query( $args );
					if ( $query->have_posts() ) :
						while ( $query->have_posts() ) : $query->the_post(); ?>
							<div class="view-product">
							<div class="text">
							    <span class="heading"><?php the_title(); ?></span>
							    <span class="know-btn">
							      <a href="<?php echo esc_url( get_permalink(get_option('woocommerce_shop_page_id')) );?>" class="blogbutton-small" title="<?php esc_attr_e( 'View Products', 'lz-toy-store' ); ?>"><?php esc_html_e('View Products','lz-toy-store'); ?>
		    					  </a>
							    </span>
							</div>
						    <div class="box-image">
						        <?php the_post_thumbnail(); ?>
						    </div>
							</div>
						<?php  endwhile; ?>
				 	<?php else : ?>
					   <div class="no-postfound"></div>
					<?php endif;
					endif;
					wp_reset_postdata();
					?>
				</div>
			</div>	
		</section>

	<?php if(is_singular()) {?>
		<div id="inner-pages-header">
			<div class="container">
			    <div class="header-content py-2">
				    <div class="container"> 
				      	<h1><?php single_post_title(); ?></h1>
			      	</div>
		      	</div>
		      	<div class="theme-breadcrumb py-2">
		      		<div class="container py-1">
						<?php lz_toy_store_breadcrumb();?>
					</div>
				</div>
			</div>
		</div>
	<?php } ?>