<?php
/**
 * The header for our theme
 *
 * This is the template that displays all of the <head> section and everything up until <div id="content">
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package Optical Store
 */
?>

<!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');
	}
?>
<?php if(get_theme_mod('optical_store_preloader_hide', false ) == true){ ?>
	<div class="loader">
		<div class="preloader">
			<div class="diamond">
				<span></span>
				<span></span>
				<span></span>
			</div>
		</div>
	</div>
<?php } ?>

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

<header id="site-navigation" class="header">
	<div class="top-header py-1">
		<div class="container">
			<div class="row d-flex align-items-center row-gap-2">
				<div class="col-md-4 col-sm-6 col-4 order-md-1 order-sm-2 order-2">
					<?php $optical_store_settings = get_theme_mod( 'optical_store_social_links_settings' ); ?>
					<div class="social-links text-sm-start text-end">
						<?php if ( is_array($optical_store_settings) || is_object($optical_store_settings) ){ ?>
							<?php foreach( $optical_store_settings as $optical_store_setting ) { ?>
								<a href="<?php echo esc_url( $optical_store_setting['link_url'] ); ?>" target="_blank">
									<i class="<?php echo esc_attr( $optical_store_setting['link_text'] ); ?> me-2"></i>
								</a>
							<?php } ?>
						<?php } ?>
					</div>
				</div>
				<div class="col-md-4 col-sm-12 col-8 order-md-2 order-sm-1 order-1">
					<div class="logo text-center">
						<div class="logo-image text-center">
							<?php the_custom_logo(); ?>
						</div>
						<div class="logo-content text-center">
							<?php
								if ( get_theme_mod('optical_store_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('optical_store_display_header_text', false) == true ) :
									echo '<span>'. esc_attr(get_bloginfo('description')) . '</span>';
								endif;
							?>
						</div>
					</div>
				</div>
				<div class="col-md-4 col-sm-6 col-12 order-3 d-flex justify-content-sm-end justify-content-center align-self-center gap-3 align-items-center">
					<?php if ( get_theme_mod('optical_store_header_login_url') ) : ?>
						<div class="login-button-text py-2" ><a href="<?php echo esc_url( get_theme_mod('optical_store_header_login_url' ) ); ?>"><?php esc_html_e('Login','optical-store'); ?></a></div>
					<?php endif; ?>
					<?php if ( get_theme_mod('optical_store_header_quote_text') ) : ?>
						<div class="employe-text py-1" ><a href="<?php echo esc_url( get_theme_mod('optical_store_header_quote_url' ) ); ?>"><?php echo esc_html( get_theme_mod('optical_store_header_quote_text' ) ); ?></a></div>
					<?php endif; ?>
				</div>
			</div>
		</div>
	</div>
	<div class="bottom-header <?php if( get_theme_mod( 'optical_store_sticky_header',false) != '') { ?>sticky-header<?php } else { ?>close-sticky <?php } ?>">
		<div class="container py-3">
			<div class="row header-inner d-flex align-items-center row-gap-2">
				<div class="col-xl-2 col-lg-2 col-md-3 col-sm-6 col-9 align-self-center">
					<?php if(class_exists('woocommerce')): ?>
						<div class="order-track position-relative">
						<span><?php esc_html_e('Tracking Order','optical-store'); ?></span>
							<div class="order-track-hover text-start">
								<?php echo do_shortcode('[woocommerce_order_tracking]','optical-store'); ?>
							</div>
						</div>
					<?php endif;?>
				</div>
				<div class="col-xl-7 col-lg-6 col-md-3 col-sm-6 col-3 align-self-center text-lg-left text-md-end toggle-menu-col">
					<button class="menu-toggle" aria-controls="top-menu" aria-expanded="false" type="button">
						<span aria-hidden="true"><i class="fa-solid fa-bars"></i></span>
					</button>
					<nav id="main-menu" class="close-panal">
						<?php
							wp_nav_menu( array(
								'theme_location' => 'main-menu',
								'container' => 'false'
							));
						?>
						<button class="close-menu my-2 p-2" type="button">
							<span aria-hidden="true"><i class="fa fa-times"></i></span>
						</button>
					</nav>
				</div>
				<div class="col-xl-3 col-lg-4 col-md-6 col-sm-12 col-12 d-flex justify-content-lg-end justify-content-center align-self-center gap-3 align-items-center">
					<?php if( get_theme_mod( 'optical_store_disable_search_icon', 'on' ) ){ ?>
						<div class="search-box d-flex justify-content-center justify-content-md-end">
							<?php
								get_search_form();
							?>
						</div>
					<?php } ?>
					<div class="my-cart">
						<?php if ( class_exists( 'woocommerce' ) ) {?>
							<a class="cart-customlocation" href="<?php if(function_exists('wc_get_cart_url')){ echo esc_url(wc_get_cart_url()); } ?>" title="<?php esc_attr_e( 'View Shopping Cart','optical-store' ); ?>"><img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/cart.png" alt=""></a>
						<?php }?>
					</div>
				</div>
			</div>
		</div>
	</div>
</header>