<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div class="container">
 *
 * @package Garden Farm
 */
?>
<!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('garden_farm_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', 'garden-farm' ); ?></a>

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

<div class="mainhead">
  <div class="container">


    <div class="main-header">
      <div class="row">
        <div class="col-xxl-2 col-xl-2 col-lg-2 col-md-2 col-sm-12 col-12 align-self-center p-0">
          <div class="garden-farm-logo">
            <?php if (get_theme_mod('garden_farm_logo_enable', true)) { ?>
              <?php garden_farm_the_custom_logo(); ?>
            <?php } ?>
            <div class="site-branding-text">
              <?php if (get_theme_mod('garden_farm_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 $garden_farm_description = get_bloginfo('description', 'display');
              if ($garden_farm_description || is_customize_preview()) : ?>
                <?php if (get_theme_mod('garden_farm_tagline_enable', false)) { ?>
                  <span class="site-description"><?php echo esc_html($garden_farm_description); ?></span>
                <?php } ?>
              <?php endif; ?>
            </div>
          </div>
        </div>
        <div class="col-xxl-10 col-xl-10 col-lg-10 col-md-10 col-sm-12 col-12 align-self-center p-0">
          <?php if (get_theme_mod('garden_farm_enable_topbar_section', true)) { ?>
            <div class="topbar">
              <div class="row m-0">
                <div class="col-xxl-3 col-xl-3 col-lg-3 col-md-6 col-sm-6 col-6 align-self-center">
                  <div class="social-icons d-flex gap-3">
                    <?php if ( get_theme_mod('garden_farm_whatsapp_link') != "") { ?>
                      <a title="<?php echo esc_attr('whatsapp', 'garden-farm'); ?>" target="_blank" href="<?php echo esc_url(get_theme_mod('garden_farm_whatsapp_link')); ?>"><i class="fa-brands fa-whatsapp"></i></a> 
                    <?php } ?>
                    <?php if ( get_theme_mod('garden_farm_fb_link') != "") { ?> 
                      <a title="<?php echo esc_attr('facebook', 'garden-farm'); ?>" target="_blank" href="<?php echo esc_url(get_theme_mod('garden_farm_fb_link')); ?>"><i class="fa-brands fa-facebook-f"></i></a>
                    <?php } ?>
                    <?php if ( get_theme_mod('garden_farm_youtube_link') != "") { ?>
                      <a title="<?php echo esc_attr('youtube', 'garden-farm'); ?>" target="_blank" href="<?php echo esc_url(get_theme_mod('garden_farm_youtube_link')); ?>"><i class="fa-brands fa-youtube"></i></a>
                    <?php } ?>
                    <?php if ( get_theme_mod('garden_farm_instagram_link') != "") { ?> 
                      <a title="<?php echo esc_attr('instagram', 'garden-farm'); ?>" target="_blank" href="<?php echo esc_url(get_theme_mod('garden_farm_instagram_link')); ?>"><i class="fa-brands fa-instagram"></i></a>
                    <?php } ?>
                  </div>
                </div>
                <div class="col-xxl-3 col-xl-3 col-lg-3 col-md-6 col-sm-6 col-6 align-self-center">
                  <?php if ( get_theme_mod('garden_farm_phone_number') != "") { ?>
                    <a class="phone" href="tel:<?php echo esc_attr( get_theme_mod('garden_farm_phone_number')); ?>"><i class="fas fa-phone me-2"></i><?php echo esc_html(get_theme_mod ('garden_farm_phone_number')); ?></a>
                  <?php } ?>
                </div>
                <div class="col-xxl-3 col-xl-3 col-lg-3 col-md-6 col-sm-6 col-6 align-self-center">
                  <?php if ( get_theme_mod('garden_farm_email_address') != "") { ?>
                    <a class="mail" href="mailto:<?php echo esc_attr( get_theme_mod('garden_farm_email_address') ); ?>"><i class="far fa-envelope me-2"></i><?php echo esc_html(get_theme_mod ('garden_farm_email_address')); ?></a>
                  <?php } ?>
                </div>
                <div class="col-xxl-3 col-xl-3 col-lg-3 col-md-6 col-sm-6 col-6 align-self-center">
                  <?php if ( get_theme_mod('garden_farm_address_location') != "") { ?>
                    <a target="_blank" href="<?php echo esc_url(get_theme_mod('garden_farm_track_locatin_url')); ?>"><span class="location-text"><i class="fa-solid fa-location-dot me-2"></i><?php echo esc_html(get_theme_mod('garden_farm_address_location')) ?></span></a> 
                  <?php } ?>
                </div>
              </div>
            </div>
          <?php } ?>
          <div class="header <?php if( get_theme_mod( 'garden_farm_sticky_header', false) == 1 ) { ?> header-sticky"<?php } else { ?>close-sticky <?php } ?>">
            <div class="container">
              <div class="row">
                  <div class="col-xxl-11 col-xl-11 col-lg-10 col-md-6 col-sm-4 col-4 align-self-center ps-4">
                    <div class="toggle-nav text-center">
                      <?php if (has_nav_menu('primary')) { ?>
                        <button role="tab"><?php esc_html_e('Menu', 'garden-farm'); ?></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', 'garden-farm'); ?>">
                        <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', 'garden-farm'); ?></a>
                      </nav>
                    </div>
                  </div>
                  <div class="col-xxl-1 col-xl-1 col-lg-2 col-md-6 col-sm-8 col-8 align-self-center d-flex justify-content-start woo-icon">
                    <?php if(class_exists('woocommerce')):?>
                      <div class="main-search d-inline-block">
                        <span class="search-box text-center me-3">
                          <button type="button" class="search-open"><i class="fas fa-search"></i></button>
                        </span>
                      </div>
                      <div class="search-outer">
                        <div class="serach_inner w-100 h-100">
                          <?php get_product_search_form(); ?>
                        </div>
                        <button type="button" class="search-close"><span>X</span></button>
                      </div>
                    <?php else : ?>
                      <div class="main-search d-inline-block">
                        <span class="search-box text-center me-3">
                          <button type="button" class="search-open"><i class="fas fa-search"></i></button>
                        </span>
                      </div>
                      <div class="search-outer">
                        <div class="serach_inner w-100 h-100">
                          <?php get_search_form(); ?>
                        </div>
                        <button type="button" class="search-close"><span>X</span></button>
                      </div>
                    <?php endif; ?>
                    <?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','garden-farm' ); ?>"><i class="fas fa-shopping-bag"></i></a>
                        <?php 
                          $garden_farm_cart_count = WC()->cart->get_cart_contents_count(); 
                          if($garden_farm_cart_count > 0): ?>
                          <span class="cart-count"><?php echo $garden_farm_cart_count; ?></span>
                        <?php endif; ?>
                      </span>
                    <?php } ?>
                  </div>
                </div>
              </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>