<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>

<meta http-equiv="Content-Type" content="<?php echo esc_attr(get_bloginfo('html_type')); ?>; charset=<?php echo esc_attr(get_bloginfo('charset')); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.2, user-scalable=yes" />

<?php wp_head(); ?>

</head>

<body <?php body_class(); ?>>

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

<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'auto-parts-supplier' ); ?></a>

<?php if(get_theme_mod('auto_parts_supplier_site_loader',false)!= ''){ ?>
    <?php if(get_theme_mod( 'auto_parts_supplier_preloader_type','four-way-loader') == 'four-way-loader'){ ?>
	    <div class="cssloader">
	    	<div class="sh1"></div>
	    	<div class="sh2"></div>
	    	<h1 class="lt"><?php esc_html_e( 'loading',  'auto-parts-supplier' ); ?></h1>
	    </div>
    <?php }else if(get_theme_mod( 'auto_parts_supplier_preloader_type') == 'cube-loader') {?>
		<div class="cssloader">
    		<div class="loader-main ">
				<div class="triangle35b"></div>
				<div class="triangle35b"></div>
				<div class="triangle35b"></div>
			</div>
    	</div>
    <?php }?>
<?php }?>

<div class="<?php if( get_theme_mod( 'auto_parts_supplier_sticky_header', false) != '') { ?>sticky-header<?php } else { ?>close-sticky main-menus<?php } ?>">
	<div class="main-header-box wow fadeInDown">
		<div class="header-inner py-2">
			<div class="container">
				<div class="row">
					<div class="col-xl-6 col-lg-6 col-md-8 col-sm-12 align-self-center translation-box text-left">
						<?php if ( get_theme_mod('auto_parts_supplier_header_inner_text')) : ?>
							<p class="mb-0 text-inner"><?php echo esc_html(get_theme_mod('auto_parts_supplier_header_inner_text'));?></p>
						<?php endif; ?>
					</div>
					<div class="col-xl-6 col-lg-6 col-md-4 col-sm-12 align-self-center meta-box text-md-end">
						<div class="row">
							<div class="col-lg-6 col-sm-0 align-self-center">
							</div>
							<div class="col-lg-3 col-md-6 col-sm-6 align-self-center">
								<?php if ( shortcode_exists('google-translator') ) : ?>
								    <?php echo do_shortcode('[google-translator]'); ?>
								<?php endif; ?>
							</div>
							<div class="col-lg-3 col-md-6 col-sm-6 align-self-center text-md-end">
								<?php if ( shortcode_exists('woocs') ) : ?>
								    <span>
								        <?php echo do_shortcode('[woocs]'); ?>
								    </span>
								<?php endif; ?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="inner-header-box">
			<div class="top-header text-center text-md-start py-3">
				<div class="container">
					<div class="row">
						<div class="col-xl-3 col-lg-2 col-md-4 col-sm-5 logo-position align-self-center">
				    		<div class="logo text-lg-start">
					    		<div class="logo-image">
					    			<?php the_custom_logo(); ?>
						    	</div>
						    	<div class="logo-content">
							    	<?php
							    		if ( get_theme_mod('auto_parts_supplier_display_header_title', true) == true ) :
								      		echo '<a href="' . esc_url(home_url('/')) . '" title="' . esc_attr(get_bloginfo('name')) . '">';
								      			echo esc_attr(get_bloginfo('name'));
								      		echo '</a>';
								      	endif;

								      	if ( get_theme_mod('auto_parts_supplier_display_header_text', false) == true ) :
							      			echo '<span>'. esc_attr(get_bloginfo('description')) . '</span>';
							      		endif;
						    		?>
								</div>
							</div>
					   	</div>
					   	<div class="col-xl-4 col-lg-5 col-md-8 col-sm-7 search-box align-self-center">
					   		<?php if (class_exists('woocommerce')) : ?>
						        <div class="search-box-main">
						            <div class="box-categories">
						                <button class="categories-button">
						                  <?php esc_html_e('All Categories', 'auto-parts-supplier'); ?>
						                  <i class="fas fa-caret-down"></i>
						                </button>
						                <div class="header-product-categories">
						                  <?php
						                  $product_categories = get_terms(array(
						                      'taxonomy'   => 'product_cat',
						                      'orderby'    => 'title',
						                      'order'      => 'ASC',
						                      'hide_empty' => false,
						                  ));

						                  if (!empty($product_categories)) :
						                      foreach ($product_categories as $category) :
						                          ?>
						                          <h4><a href="<?php echo esc_url(get_term_link($category)); ?>"><?php echo esc_html($category->name); ?></a></h4>
						                          <?php
						                          $products = new WP_Query(array(
						                              'posts_per_page' => -1,
						                              'post_type'      => 'product',
						                              'orderby'        => 'title',
						                              'order'          => 'ASC',
						                              'tax_query'      => array(
						                                  array(
						                                      'taxonomy' => 'product_cat',
						                                      'field'    => 'slug',
						                                      'terms'    => $category->slug,
						                                  ),
						                              ),
						                          ));
						                      endforeach;
						                  endif;
						                  ?>
						                </div>
						            </div>
						            <div class="main-search-box">
						              <?php get_product_search_form(); ?>
						            </div>
						        </div>
						    <?php endif; ?>
					   	</div>	
						<div class="col-xl-3 col-lg-3 col-md-5 col-sm-6 align-self-center contact-box align-self-center">
							<?php if ( get_theme_mod('auto_parts_supplier_header_inner_phone_numer') || get_theme_mod('auto_parts_supplier_header_inner_phone_aditional_heading')) : ?>
								<div class="row">
									<div class="col-lg-3 col-md-3 col-sm-3 col-3 align-self-center text-md-end">
										<i class="fas fa-envelope me-2"></i>
									</div>
									<div class="col-lg-9 col-md-9 col-sm-9 col-9 align-self-center">
										<p class="custom-call"><?php echo esc_html(get_theme_mod('auto_parts_supplier_header_inner_phone_aditional_heading'));?></p>
										<p class="mb-0 text-inner"><a href="tell:<?php echo esc_attr(get_theme_mod('auto_parts_supplier_header_inner_phone_numer'));?>"><?php echo esc_html(get_theme_mod('auto_parts_supplier_header_inner_phone_numer'));?></a></p>
									</div>
								</div>
							<?php endif; ?>
					   	</div>
					   	<div class="col-xl-2 col-lg-2 col-md-7 col-sm-6 align-self-center meta-header-box text-md-end text-sm-end align-self-center">
					   		<?php if ( get_theme_mod('auto_parts_supplier_wislist_url')) : ?>
								<a href="<?php echo esc_url( get_theme_mod('auto_parts_supplier_wislist_url' ) ); ?>" class="myacunt-url me-3"><i class="fas fa-heart"></i></a>
							<?php endif; ?>
							<?php if ( class_exists( 'woocommerce' ) ) {?>
								<a class="cart-customlocation me-3" href="<?php if(function_exists('wc_get_cart_url')){ echo esc_url(wc_get_cart_url()); } ?>" title="<?php esc_attr_e( 'View Shopping Cart','auto-parts-supplier' ); ?>"><i class="fas fa-shopping-cart"></i><span class="cart-item-box"><?php echo esc_html(wp_kses_data( WC()->cart->get_cart_contents_count() ));?></span></a>
							<?php }?>
							<?php if(class_exists('woocommerce')){ ?>
								<span class="admin-title m-0">
						          	<?php if ( is_user_logged_in() ) { ?>
						            	<a href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>"><i class="far fa-user-circle"></i></a>
						          	<?php }
						          	else { ?>
						            	<a href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>" title="<?php esc_attr_e('Login / Register','auto-parts-supplier'); ?>"><i class="far fa-user-circle"></i></a>
						          	<?php } ?>
								</span>
							<?php }?>
						</div>
					</div>
				</div>
			</div>
			<div class="outter-header-box">
				<div class="container">
					<div class="row">
						<div class="col-lg-8 col-md-6 col-sm-6 col-6 align-self-center">
							<div class="top-menu-wrapper">
							    <div class="navigation_header">
							        <div class="toggle-nav mobile-menu">
							            <button onclick="auto_parts_supplier_openNav()">
							                <span class="dashicons dashicons-menu"></span>
							            </button>
							        </div>
							        <div id="mySidenav" class="nav sidenav">
							            <nav id="site-navigation" class="main-navigation navbar navbar-expand-xl" aria-label="<?php esc_attr_e( 'Top Menu', 'auto-parts-supplier' ); ?>">
							                <?php {
							                    wp_nav_menu(
							                        array(
							                            'theme_location' => 'main-menu',
							                            'container_class' => 'navi clearfix navbar-nav',
							                            'menu_class'     => 'menu clearfix',
							                            'items_wrap'     => '<ul id="%1$s" class="%2$s">%3$s</ul>',
							                            'fallback_cb'    => 'wp_page_menu',
							                        )
							                    );
							                } ?>
							            </nav>
							            <a href="javascript:void(0)" class="closebtn mobile-menu" onclick="auto_parts_supplier_closeNav()">
							                <span class="dashicons dashicons-no"></span>
							            </a>
							        </div>
							    </div>
							</div>
						</div>
						<div class="col-lg-4 col-md-6 col-sm-6 col-6 align-self-center">
							<div class="text-center text-md-end sign-button my-3">
								<?php if ( get_theme_mod('auto_parts_supplier_header_button_url') || get_theme_mod('auto_parts_supplier_header_button_text') ) : ?>
									<a href="<?php echo esc_url( get_theme_mod('auto_parts_supplier_header_button_url' ) ); ?>" class=" signin-box"><?php echo esc_html( get_theme_mod('auto_parts_supplier_header_button_text' ) ); ?></a>
								<?php endif; ?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>