<?php
/**
 * Displays main header
 *
 * @package Curtains Fabric
 */
?>

<?php
$curtains_fabric_sticky_header = get_theme_mod('curtains_fabric_sticky_header');
    $curtains_fabric_data_sticky = "false";
    if ($curtains_fabric_sticky_header) {
    $curtains_fabric_data_sticky = "true";
    }
?>
<div class="main-header text-center text-md-start py-3" data-sticky="<?php echo esc_attr($curtains_fabric_data_sticky); ?>">
    <div class="container">
        <div class="row nav-box">
            <div class="col-lg-3 col-md-4 col-sm-5 col-12 align-self-center">
                <div class="navbar-brand text-center text-md-start">
                    <?php if ( has_custom_logo() ) : ?>
                        <div class="site-logo"><?php the_custom_logo(); ?></div>
                    <?php endif; ?>
                    <?php $curtains_fabric_blog_info = get_bloginfo( 'name' ); ?>
                        <?php if ( ! empty( $curtains_fabric_blog_info ) ) : ?>
                            <?php if ( is_front_page() && is_home() ) : ?>
                                <?php if( get_theme_mod('curtains_fabric_logo_title_text',true) != ''){ ?>
                                    <h1 class="site-title pt-2"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
                                <?php } ?>
                            <?php else : ?>
                                <?php if( get_theme_mod('curtains_fabric_logo_title_text',true) != ''){ ?>
                                    <p class="site-title "><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
                                <?php } ?>
                            <?php endif; ?>
                        <?php endif; ?>
                        <?php
                            $curtains_fabric_description = get_bloginfo( 'description', 'display' );
                            if ( $curtains_fabric_description || is_customize_preview() ) :
                        ?>
                        <?php if( get_theme_mod('curtains_fabric_theme_description',false) != ''){ ?>
                            <p class="site-description pb-2"><?php echo esc_html($curtains_fabric_description); ?></p>
                        <?php } ?>
                    <?php endif; ?>
                </div>
            </div>
            <div class="col-lg-6 col-md-3 col-sm-2 col-3 align-self-center">
                <?php get_template_part('template-parts/navigation/nav'); ?>
            </div>
            <div class="col-lg-3 col-md-5 col-sm-5 col-9 align-self-center text-end">
                <?php if(get_theme_mod('curtains_fabric_search_setting',true) != ''){ ?>
                    <span class="head-search">
                        <div class="header-search-wrapper">
                            <span class="search-main">
                                <i class="fa fa-search"></i>
                            </span>
                            <div class="search-form-main clearfix">
                                <form method="get" class="search-form">
                                  <label>
                                    <input type="search" class="search-field form-control" placeholder="Search …" value="<?php echo esc_attr( get_search_query() ); ?>" name="s">
                                  </label>
                                  <input type="submit" class="search-submit btn btn-primary mt-3" value="Search">
                                </form>
                            </div>
                        </div>
                    </span>
                <?php }?>
                <span class="cart_no">
                    <?php if(class_exists('woocommerce')){ ?>
                        <?php global $woocommerce; ?>
                        <a class="cart-customlocation" href="<?php echo esc_url(wc_get_cart_url()); ?>" title="<?php esc_attr_e( 'shopping cart','curtains-fabric' ); ?>"><i class="fas fa-shopping-cart"></i><span class="cart-value"><?php echo sprintf ( esc_html( '%d', '%d', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?></span></a>
                    <?php }?>
                </span>
                <?php if ( get_theme_mod('curtains_fabric_header_wishlist_link') != "" ) {?>
                    <a class="wishlist" href="<?php echo esc_url(get_theme_mod('curtains_fabric_header_wishlist_link')); ?>"><i class="fas fa-heart"></i></a>
                <?php }?>
                <?php if(class_exists('woocommerce')){ ?>
                    <span class="user-btn-top">
                        <?php if ( is_user_logged_in() ) { ?>
                            <a class="account-btn" href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>" title="<?php esc_attr_e('My Account','curtains-fabric'); ?>"><i class="fas fa-user"></i><?php echo esc_html('Account','curtains-fabric'); ?></a>
                        <?php } 
                        else { ?>
                            <a class="account-btn" href="<?php echo esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); ?>" title="<?php esc_attr_e('My Account','curtains-fabric'); ?>"><i class="fas fa-user"></i><?php echo esc_html('Account','curtains-fabric'); ?></a>
                        <?php } ?>
                    </span>
                <?php }?>
            </div>
        </div>
    </div>
</div>
