<?php
/*
* Display Logo and header details
*/
?>
<div class="main-header">
  <div class="headerbox">
    <div class="menubox py-md-2 py-3">
      <div class="container">
        <div class="row">
          <div class="col-lg-3 col-md-4 logo-col align-self-center">
            <div class="logo my-lg-2 my-3">
              <?php if( has_custom_logo() ) optical_glasses_the_custom_logo(); ?>
              <?php if(get_theme_mod('optical_glasses_site_title',true) == 1){ ?>
                <?php if (is_front_page() && is_home()) : ?>
                  <h1 class="text-capitalize">
                    <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                  </h1> 
                <?php else : ?>
                  <p class="text-capitalize site-title mb-1">
                    <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                  </p>
                <?php endif; ?>
              <?php }?>
              <?php $optical_glasses_description = get_bloginfo( 'description', 'display' );
              if ( $optical_glasses_description || is_customize_preview() ) : ?>
                <?php if(get_theme_mod('optical_glasses_site_tagline',false)){ ?>
                  <p class="site-description mb-0"><?php echo esc_html($optical_glasses_description); ?></p>
                <?php }?>
              <?php endif; ?>
            </div>
          </div>
          <div class="col-lg-6 col-md-4 align-self-center">
            <?php get_template_part('template-parts/navigation/site-nav'); ?>
          </div>
          <!-- Header Details Section -->
            <div class="col-lg-3 col-md-4 align-self-center mb-md-0 mb-3">
                <div class="header-details mt-md-0 mt-2">

                   <p class="mb-0">
                    <?php if (class_exists('WooCommerce')): ?>
                      <a href="<?php echo esc_url(get_permalink(get_option('woocommerce_myaccount_page_id'))); ?>">
                          <i class="me-4 <?php echo esc_attr(is_user_logged_in() ? 'fas' : 'far'); ?> fa-user" aria-hidden="true"></i>
                      </a>
                    <?php endif; ?>
                  </p>

                  <?php 
                    $optical_glasses_like_option = get_theme_mod('optical_glasses_like_option');
                    if ($optical_glasses_like_option): ?>
                        <p class="mb-0">
                            <a href="<?php echo esc_url($optical_glasses_like_option); ?>">
                                <i class="far fa-heart me-3" aria-hidden="true"></i>
                            </a>
                        </p>
                    <?php endif; ?>

                   <?php if ( class_exists( 'YITH_WCWL' ) ) : ?>
                        <a href="<?php echo esc_url( YITH_WCWL()->get_wishlist_url() ); ?>" class="wishlist-icon">

                            <i class="fas fa-heart me-3" aria-hidden="true"></i>

                        </a>
                    <?php endif; ?>

                    <!-- Search Bar -->
                    <span class="search-bar">
                        <button type="button" class="open-search" aria-label="<?php esc_attr_e('Open Search', 'optical-glasses'); ?>">
                            <i class="fas fa-search"></i>
                        </button>
                    </span>
                    <p class="mb-0">
                      <?php if (class_exists('WooCommerce')): ?> 
                        <span class="product-cart text-center position-relative pe-2">
                          <a href="<?php echo esc_url(wc_get_cart_url()); ?>" title="<?php esc_attr_e('Shopping cart', 'optical-glasses'); ?>">
                              <i class="fas fa-shopping-bag ms-4" aria-hidden="true"></i>
                              <?php 
                            $optical_glasses_cart_count = WC()->cart->get_cart_contents_count(); 
                            if ($optical_glasses_cart_count > 0): ?>
                                <span class="cart-count"><?php echo esc_html($optical_glasses_cart_count); ?></span>
                            <?php endif; ?>
                          </a>
                        </span>
                      <?php endif; ?>
                    </p>
                </div>
            </div>
            <!-- Search Overlay -->
            <div class="search-outer">
                <div class="inner_searchbox w-100 h-100">
                    <?php get_search_form(); ?>
                </div>
                <button type="button" class="search-close"><?php esc_html_e('CLOSE', 'optical-glasses'); ?></button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>