<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div class="container">
 *
 * @package Mobile Accessories Shop
 */
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<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' );
} ?>

<?php if ( get_theme_mod('mobile_accessories_shop_preloader', false) != "") { ?>
  <div id="preloader">
    <div id="status">&nbsp;</div>
  </div>
<?php }?>

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

<div id="pageholder" <?php if( get_theme_mod( 'mobile_accessories_shop_box_layout', false) != "" ) { echo 'class="boxlayout"'; } ?>>

<div class="mainhead<?php if( get_theme_mod( 'mobile_accessories_shop_stickyheader', false) == 1) { ?> is-sticky-on"<?php } else { ?>close-sticky <?php } ?>">
  <div class="main-header mx-xl-4 mx-lg-3 mx-md-2 mx-1">
    <?php if ( get_theme_mod('mobile_accessories_shop_enable_topbar', false)) { ?>
      <div class="topbar py-2">
        <div class="container">
          <div class="row">
            <div class="col-xl-4 col-lg-2 col-12 align-self-center topbar-blank-box"></div>
            <div class="col-xl-3 col-lg-4 col-md-5 col-12 align-self-center text-lg-end text-md-end text-center top-main-text">
              <?php if (get_theme_mod('mobile_accessories_shop_topbar_text') != "") { ?>
                <p class="topbar-text mb-0 text-capitalize"><i class="fa-solid fa-bullhorn me-2"></i><?php echo esc_html(get_theme_mod('mobile_accessories_shop_topbar_text')); ?></p>
              <?php } ?>
            </div>
            <div class="col-xl-3 col-lg-4 col-md-4 col-12 align-self-center text-lg-end text-md-end text-center top-mail">
              <?php if ( get_theme_mod('mobile_accessories_shop_email_address')) { ?>
                <i class="fa-regular fa-envelope me-2"></i><a class="mail" href="mailto:<?php echo esc_attr( get_theme_mod('mobile_accessories_shop_email_address') ); ?>"><?php echo esc_html(get_theme_mod ('mobile_accessories_shop_email_address')); ?></a>
              <?php } ?>
            </div>
            <div class="col-xl-2 col-lg-2 col-md-3 col-12 align-self-center text-lg-end text-md-end text-center top-phone">
              <?php if ( get_theme_mod('mobile_accessories_shop_phone_number')) { ?>
                <i class="fas fa-phone me-2"></i><a class="phone-no" href="tel:<?php echo esc_url( get_theme_mod('mobile_accessories_shop_phone_number')); ?>"><?php echo esc_html(get_theme_mod ('mobile_accessories_shop_phone_number')); ?></a>
              <?php } ?>
            </div>
          </div>
        </div>
      </div>
    <?php }?>
    <div class="header-bg">
      <div class="container">
        <div class="row">
          <div class="col-xxl-2 col-xl-2 col-lg-2 col-md-3 col-sm-6 col-12 logo-box position-relative py-2">
            <div class="mobile-accessories-shop-logo">
              <?php if (get_theme_mod('mobile_accessories_shop_logo_enable', true)) { ?>
                <?php mobile_accessories_shop_the_custom_logo(); ?>
              <?php }?>
              <div class="site-branding-text">
                <?php if (get_theme_mod('mobile_accessories_shop_title_enable', false)) { ?>
                  <?php if (is_front_page() && is_home()) : ?>
                    <h1 class="site-title"><a href="<?php echo esc_url(home_url('/')); ?>"><?php bloginfo('name'); ?></a></h1>
                  <?php else : ?>
                    <p class="site-title"><a href="<?php echo esc_url(home_url('/')); ?>"><?php bloginfo('name'); ?></a></p>
                  <?php endif; ?>
                <?php } ?>
                <?php $mobile_accessories_shop_description = get_bloginfo('description', 'display');
                if ($mobile_accessories_shop_description || is_customize_preview()) : ?>
                  <?php if (get_theme_mod('mobile_accessories_shop_tagline_enable', false)) { ?>
                    <span class="site-description"><?php echo esc_html($mobile_accessories_shop_description); ?></span>
                  <?php } ?>
                <?php endif; ?>
              </div>
            </div>
            <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/logo-right.png" class="logo-right-img position-absolute" />
          </div>
          <div class="col-xxl-6 col-xl-6 col-lg-6 col-md-4 col-sm-6 col-12 main-menu-box align-self-center">
            <div class="menu-sec">
              <div class="toggle-nav text-center">
                <?php if (has_nav_menu('primary')) { ?>
                  <button role="tab"><?php esc_html_e('Menu', 'mobile-accessories-shop'); ?></button>
                <?php } ?>
              </div>
              <div id="mySidenav" class="nav sidenav">
                <nav id="site-navigation" class="main-nav" role="navigation" aria-label="<?php esc_attr_e('Top Menu', 'mobile-accessories-shop'); ?>">
                  <ul class="mobile_nav">
                    <?php wp_nav_menu(array(
                      'theme_location' => 'primary',
                      'container_class' => 'main-menu',
                      'items_wrap' => '%3$s',
                      'fallback_cb' => 'wp_page_menu',
                    )); ?>
                  </ul>
                  <a href="javascript:void(0)" class="close-button"><?php esc_html_e('CLOSE', 'mobile-accessories-shop'); ?></a>
                </nav>
              </div>
            </div>
          </div>
          <div class="col-xxl-4 col-xl-4 col-lg-4 col-md-5 col-sm-12 col-12 align-self-center d-flex justify-content-lg-end justify-content-md-end justify-content-center gap-3 align-items-center header-top-content">
            <div class="top-search position-relative">
              <?php if(class_exists('woocommerce')):?>
                <?php get_product_search_form(); ?>
              <?php else : ?>
                <?php get_search_form(); ?>
              <?php endif; ?>
            </div>
            <div class="header-shop-icons d-flex justify-content-end gap-3">
              <?php if (class_exists('woocommerce')) { ?>
                <span class="product-cart">
                  <a href="<?php if(function_exists('wc_get_cart_url')){ echo esc_url(wc_get_cart_url()); } ?>" title="<?php esc_attr_e( 'shopping cart','mobile-accessories-shop' ); ?>"><i class="fa-solid fa-cart-shopping"></i></a>
                </span>
              <?php } ?>
              <?php if (class_exists('woocommerce')) { ?>
                <div class="product-account">
                  <?php if (is_user_logged_in()) { ?>
                    <a href="<?php echo esc_url(get_permalink(get_option('woocommerce_myaccount_page_id'))); ?>" title="<?php esc_attr_e('My Account', 'mobile-accessories-shop'); ?>"><i class="fa-regular fa-user"></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', 'mobile-accessories-shop'); ?>"><i class="fa-regular fa-user"></i></a>
                  <?php } ?>
                </div>
              <?php }?>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>