<?php
/*
* Display Logo and nav
*/
?>

<div class="headerbox">
  <div class="container-fluid">
    <div class="row head-bg">
      <div class="col-lg-3 col-md-3 logo-box p-0">
        <div class="logo">
          <?php if( has_custom_logo() ) fitness_supplement_store_the_custom_logo(); ?>
          <?php if(get_theme_mod('fitness_supplement_store_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">
                    <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                </p>
            <?php endif; ?>
          <?php }?>
        </div>
        <div class="logo-text text-center py-3">
          <?php $fitness_supplement_store_description = get_bloginfo( 'description', 'display' );
          if ( $fitness_supplement_store_description || is_customize_preview() ) : ?>
            <?php if(get_theme_mod('fitness_supplement_store_site_tagline',false)){ ?>
              <p class="site-description mb-0 text-capitalize"><?php echo esc_html($fitness_supplement_store_description); ?></p>
            <?php }?>
          <?php endif; ?>
        </div>
      </div>
      <div class="col-lg-9 col-md-9 p-0">
          <div class="row m-0 headertext py-2">
            <div class="col-lg-4 col-md-4 align-self-center">
              <?php if(class_exists('woocommerce')){ ?>
                <button class="category-btn text-capitalize"><i class="fa fa-bars" aria-hidden="true"></i><?php echo esc_html(get_theme_mod('fitness_supplement_store_category_text','Shop By Category','fitness-supplement-store')); ?><i class="fas fa-chevron-right cat-icon"></i></button>
                <div class="category-dropdown">
                  <?php
                    $args = array(
                      'number'     => get_theme_mod('fitness_supplement_store_product_category_number'),
                      'orderby'    => 'title',
                      'order'      => 'ASC',
                      'hide_empty' => 0,
                      'parent'  => 0
                    );
                    $product_categories = get_terms( 'product_cat', $args );
                    $count = count($product_categories);
                    if ( $count > 0 ){
                      foreach ( $product_categories as $product_category ) {
                        $fitness_supplement_store_cat_id   = $product_category->term_id;
                        $cat_link = get_category_link( $fitness_supplement_store_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></li>
                      <?php
                      }
                    }
                  ?>
                </div>
              <?php }?>
            </div>
            <div class="col-lg-4 col-md-4 align-self-center pr-lg-0">
              <div class="search-block">
                <?php get_search_form(); ?>
              </div>
            </div>
            <div class="col-lg-4 col-md-4 woo-content align-self-center text-md-center">
              <div class="top-woo">
                <?php if(get_theme_mod('fitness_supplement_store_user_icon',true) != ''){ ?>
                    <?php if(class_exists('woocommerce')){ ?>
                      <?php if (is_user_logged_in()) : ?>
                        <a href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>"><i class="fas fa-user pe-2"></i><?php esc_html_e( 'Sign In/ Register', 'fitness-supplement-store' ); ?></a>
                      <?php else : ?>
                        <a href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>"><i class="fas fa-user px-lg-2"></i><?php esc_html_e( 'Login', 'fitness-supplement-store' ); ?></a>
                      <?php endif;?>
                    <?php } ?>
                <?php }?>
                <?php if(get_theme_mod('fitness_supplement_store_cart_icon',true) != ''){ ?>
                    <?php if(class_exists('woocommerce')){ ?>
                      <span class="product-cart text-center position-relative ps-4 ps-lg-4 ps-md-3">
                        <a href="<?php if(function_exists('wc_get_cart_url')){ echo esc_url(wc_get_cart_url()); } ?>" title="<?php esc_attr_e( 'shopping cart','fitness-supplement-store' ); ?>"><i class="fas fa-shopping-basket"></i></a>
                        <?php 
                        $fitness_supplement_store_cart_count = WC()->cart->get_cart_contents_count();
                        if($fitness_supplement_store_cart_count > 0): ?>
                            <span class="cart-count"><?php echo $fitness_supplement_store_cart_count; ?></span>
                        <?php endif; ?>
                      </span>
                    <?php } ?>
                <?php } ?>
              </div>
            </div>
          </div>

        <?php get_template_part( 'template-parts/navigation/site', 'nav' ); ?>
      </div>
    </div>
  </div>
</div>