<?php
/**
 * The header for our theme
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package jeweler_shop
 */

$jeweler_shop_menu_text_color = get_theme_mod('jeweler_shop_menu_text_color'); 
$jeweler_shop_sub_menu_text_color = get_theme_mod('jeweler_shop_sub_menu_text_color'); 
$jeweler_shop_header_button_url = get_theme_mod( 'jeweler_shop_topheader_button_url' );
$jeweler_shop_header_button_text = get_theme_mod( 'jeweler_shop_topheader_button_text' );
?>
<!doctype html>
<html <?php language_attributes(); ?>>

<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="profile" href="https://gmpg.org/xfn/11">
    
	<?php wp_head(); ?>
</head>

<body <?php body_class(get_theme_mod('jeweler_shop_website_layout', false) ? 'site-boxed--layout' : ''); ?>>
<?php wp_body_open(); ?>
<div id="page" class="site asterthemes-site-wrapper">
<a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'jeweler-shop' ); ?></a>
    <?php if (get_theme_mod('jeweler_shop_enable_preloader', false)) : ?>
        <div id="loader" class="<?php echo esc_attr(get_theme_mod('jeweler_shop_preloader_style', 'style1')); ?>">
            <div class="loader-container">
                <div id="preloader">
                    <?php 
                    $jeweler_shop_preloader_style = get_theme_mod('jeweler_shop_preloader_style', 'style1');
                    if ($jeweler_shop_preloader_style === 'style1') : ?>
                        <!-- STYLE 1 -->
                        <img src="<?php echo esc_url(get_template_directory_uri() . '/resource/loader.gif'); ?>" alt="<?php esc_attr_e('Loading...', 'jeweler-shop'); ?>">
                    <?php elseif ($jeweler_shop_preloader_style === 'style2') : ?>
                        <!-- STYLE 2 -->
                        <div class="dot"></div>
                    <?php elseif ($jeweler_shop_preloader_style === 'style3') : ?>
                        <!-- STYLE 3 -->
                        <div class="bars">
                            <div class="bar"></div>
                            <div class="bar"></div>
                            <div class="bar"></div>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    <?php endif; ?>
        <header id="masthead" class="site-header">
            <div class="header-main-wrapper">
                <?php if ( get_theme_mod( 'jeweler_shop_enable_topbar', true ) === true ) {
                    $jeweler_shop_phone_number = get_theme_mod('jeweler_shop_phone_number');
                    $jeweler_shop_discount_topbar_text = get_theme_mod( 'jeweler_shop_discount_topbar_text');
                ?>
                <?php if ( get_theme_mod( 'jeweler_shop_enable_topbar', false ) ) {
                ?>
                <div class="top-header-part">
                    <div class="asterthemes-wrapper">
                        <div class="top-header-part-wrapper">
                            <div class="topbar-phone">
                                <?php if ( ! empty( $jeweler_shop_phone_number ) ) { ?>
                                    <div class="bottom-top-header-right-part">
                                        <a href="tel:<?php echo esc_attr(  substr( $jeweler_shop_phone_number, 0, 21 )  ); ?>"><i class="<?php echo esc_attr( get_theme_mod( 'jeweler_shop_header_phone_icon', 'fas fa-phone-alt' ) ); ?>"></i><span><?php echo esc_html(  substr( $jeweler_shop_phone_number, 0, 21 )  ); ?></span></a>
                                    </div>
                                <?php } ?>
                            </div>
                            <div class="topbar-text">
                                <?php if ( ! empty( $jeweler_shop_discount_topbar_text ) ) { ?>
                                    <div class="header-contact-inner">
                                        <p><?php echo esc_html( $jeweler_shop_discount_topbar_text ); ?></p>
                                    </div>
                                <?php } ?>
                            </div>
                            <?php if ( get_theme_mod( 'jeweler_shop_enable_header_icon_section', false ) === true ) { ?>
                                <div class="bottom-top-header-left-part">
                                    <div class="social-icons">
                                        <?php if ( get_theme_mod('jeweler_shop_header_facebook_link')) { ?>
                                            <a target="_blank" href="<?php echo esc_url(get_theme_mod('jeweler_shop_header_facebook_link')); ?>">
                                                <i class="<?php echo esc_attr(get_theme_mod('jeweler_shop_header_facebook_icon', 'fab fa-facebook-f')); ?>"></i>
                                                <span class="screen-reader-text"><?php esc_html_e('Facebook', 'jeweler-shop'); ?></span>
                                            </a>
                                        <?php } ?>
                                        <?php if ( get_theme_mod('jeweler_shop_header_pinterest_link')) { ?>
                                            <a target="_blank" href="<?php echo esc_url(get_theme_mod('jeweler_shop_header_pinterest_link')); ?>">
                                                <i class="<?php echo esc_attr(get_theme_mod('jeweler_shop_header_pinterest_icon', 'fab fa-pinterest')); ?>"></i>
                                                <span class="screen-reader-text"><?php esc_html_e('Pinterest', 'jeweler-shop'); ?></span>
                                            </a>
                                        <?php } ?>
                                        <?php if ( get_theme_mod('jeweler_shop_header_instagram_link')) { ?>
                                            <a target="_blank" href="<?php echo esc_url(get_theme_mod('jeweler_shop_header_instagram_link')); ?>">
                                                <i class="<?php echo esc_attr(get_theme_mod('jeweler_shop_header_instagram_icon', 'fab fa-instagram')); ?>"></i>
                                                <span class="screen-reader-text"><?php esc_html_e('Instagram', 'jeweler-shop'); ?></span>
                                            </a>
                                        <?php } ?>
                                        <?php if ( get_theme_mod('jeweler_shop_header_youtube_link')) { ?>
                                            <a target="_blank" href="<?php echo esc_url(get_theme_mod('jeweler_shop_header_youtube_link')); ?>">
                                                <i class="<?php echo esc_attr(get_theme_mod('jeweler_shop_header_youtube_icon', 'fab fa-youtube')); ?>"></i>
                                                <span class="screen-reader-text"><?php esc_html_e('Youtube', 'jeweler-shop'); ?></span>
                                            </a>
                                        <?php } ?>
                                        <?php if ( get_theme_mod('jeweler_shop_header_whatsapp_link')) { ?>
                                            <a target="_blank" href="<?php echo esc_url(get_theme_mod('jeweler_shop_header_whatsapp_link')); ?>">
                                                <i class="<?php echo esc_attr(get_theme_mod('jeweler_shop_header_whatsapp_icon', 'fab fa-whatsapp')); ?>"></i>
                                                <span class="screen-reader-text"><?php esc_html_e('Whatsapp', 'jeweler-shop'); ?></span>
                                            </a>
                                        <?php } ?>
                                    </div>
                                </div>
                            <?php } ?>
                        </div>
                    </div>
                </div>
                <?php } ?>
                <?php } ?>
                <div class="bottom-header-outer-wrapper">
                    <div class="bottom-header-part">
                        <div class="asterthemes-wrapper">
                            <div class="bottom-header-part-wrapper hello <?php echo esc_attr( get_theme_mod( 'jeweler_shop_enable_sticky_header', false ) ? 'sticky-header' : '' ); ?>">
                                <div class="navigation-menus">
                                    <div class="navigation-part">
                                        <nav id="site-navigation" class="main-navigation">
                                            <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                                                <span></span>
                                                <span></span>
                                                <span></span>
                                            </button>
                                            <div class="main-navigation-links">
                                                <?php
                                                    wp_nav_menu(
                                                        array(
                                                            'theme_location' => 'primary',
                                                        )
                                                    );
                                                ?>
                                            </div>
                                            <style>
                                                /* Main Menu Links */
                                                .main-navigation ul li a, .menu a {
                                                    color: <?php echo esc_attr($jeweler_shop_menu_text_color); ?>;
                                                }

                                                /* Submenu Links */
                                                .main-navigation ul.children a, 
                                                .home .main-navigation ul.children a, 
                                                .main-navigation ul.menu li .sub-menu a, 
                                                .home .main-navigation ul ul a {
                                                    color: <?php echo esc_attr($jeweler_shop_sub_menu_text_color); ?>;
                                                }
                                            </style>
                                        </nav>
                                    </div>
                                </div>
                                <div class="bottom-header-left-part">
                                    <div class="site-branding">
                                        <?php
                                        // Check if the 'Enable Site Logo' setting is true.
                                        if ( get_theme_mod( 'jeweler_shop_enable_site_logo', true ) ) {
                                            if ( has_custom_logo() ) { ?>
                                                <div class="site-logo">
                                                    <?php the_custom_logo(); ?>
                                                </div>
                                            <?php } 
                                        } ?>
                                        <div class="site-identity">
                                            <?php
                                            $jeweler_shop_site_title_size = get_theme_mod('jeweler_shop_site_title_size', 24);

                                            if (get_theme_mod('jeweler_shop_enable_site_title_setting', true)) {
                                                if (is_front_page() && is_home()) : ?>
                                                    <h1 class="site-title" style="font-size: <?php echo esc_attr($jeweler_shop_site_title_size); ?>px;">
                                                        <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                                                    </h1>
                                                <?php else : ?>
                                                    <p class="site-title" style="font-size: <?php echo esc_attr($jeweler_shop_site_title_size); ?>px;">
                                                        <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                                                    </p>
                                                <?php endif;
                                            }

                                            if (get_theme_mod('jeweler_shop_enable_tagline_setting', false)) :
                                                $jeweler_shop_description = get_bloginfo('description', 'display');
                                                if ($jeweler_shop_description || is_customize_preview()) : ?>
                                                    <p class="site-description"><?php echo esc_html($jeweler_shop_description); ?></p>
                                                <?php endif;
                                            endif;
                                            ?>
                                        </div>
                                    </div>
                                </div>
                                <div class="bottom-header-right-part nav-box">
                                    <?php $jeweler_shop_enable_header_search_section = get_theme_mod( 'jeweler_shop_enable_header_search_section', false );
                                            if ( $jeweler_shop_enable_header_search_section ) : ?>
                                    <span class="search-main">
                                    <button class="search">
                                        <span class="btn">
                                            <img src="<?php echo esc_url(get_template_directory_uri() . '/resource/img/search.png'); ?>" alt="<?php esc_attr_e('Search', 'jeweler-shop'); ?>">
                                        </span>
                                    </button>
                                    <div class="form">                                      
                                        <?php if(class_exists('woocommerce')): ?>
                                            <form method="get" class="woocommerce-product-search woo-pro-search" action="<?php echo esc_url(home_url('/')); ?>">
                                                <label class="screen-reader-text" for="woocommerce-product-search-field"><?php esc_html_e('Search for:', 'jeweler-shop'); ?></label>
                                                <input type="search" id="woocommerce-product-search-field" class="search-field " placeholder="<?php echo esc_attr('Search Here','jeweler-shop'); ?>" value="<?php echo get_search_query(); ?>" name="s"/>
                                                <button type="submit" class="search-button"><i class="fas fa-search"></i></button>
                                                <input type="hidden" name="post_type" value="product"/>
                                            </form>
                                        <?php else : ?>

                                        <form method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
                                            <label>
                                                <span class="screen-reader-text"><?php echo esc_html( 'Search for:', 'label', 'jeweler-shop' ); ?></span>
                                                <input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search...', 'placeholder', 'jeweler-shop' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
                                            </label>
                                            <button type="submit" class="search-submit"><span class="btn"><i class="fa fa-search" aria-hidden="true"></i></span>
                                            </button>
                                        </form>
                                        <?php endif; ?>
                                    </div>
                                    </span>
                                    <?php endif; ?>
                                    <?php if (class_exists('woocommerce')) { ?>
                                        <span class="user-btn">
                                            <?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','jeweler-shop'); ?>">
                                                    <img src="<?php echo esc_url(get_template_directory_uri() . '/resource/img/user.png'); ?>" alt="<?php esc_attr_e('User', 'jeweler-shop'); ?>">
                                                </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','jeweler-shop'); ?>"></a>
                                            <?php } ?>
                                        </span>
                                    <?php } ?>
                                    <div class="wishlist">
                                        <?php 
                                        if (defined('YITH_WCWL') && class_exists('YITH_WCWL_Wishlists')) {?>
                                        <a class="wishlist_view position-relative" href="<?php echo esc_url(YITH_WCWL()->get_wishlist_url()); ?>">
                                        <img src="<?php echo esc_url(get_template_directory_uri() . '/resource/img/wishlist.png'); ?>" alt="<?php esc_attr_e('Wishlist', 'jeweler-shop'); ?>">
                                        </a>
                                        <?php }?>
                                    </div>
                                    <?php if (class_exists('woocommerce')) { ?>
                                        <span class="cart-count">
                                            <a class="cart-customlocation" href="<?php if (function_exists('wc_get_cart_url')) { echo esc_url(wc_get_cart_url()); } ?>" title="<?php esc_attr_e('View Shopping Cart', 'jeweler-shop'); ?>">
                                                <img src="<?php echo esc_url(get_template_directory_uri() . '/resource/img/cart.png'); ?>" alt="<?php esc_attr_e('Cart', 'jeweler-shop'); ?>">
                                            </a>
                                        </span>
                                    <?php } ?>
                                    <?php if ( ! empty( $jeweler_shop_header_button_text ) ) { ?>
                                        <div class="header-btn">
                                            <a href="<?php echo esc_url( $jeweler_shop_header_button_url ); ?>" class="asterthemes-button"><?php echo esc_html( $jeweler_shop_header_button_text ); ?></a>
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>     
            </div>
        </header>
<?php
if ( ! is_front_page() || is_home() ) {
	if ( is_front_page() ) {
		require get_template_directory() . '/sections/sections.php';
		jeweler_shop_homepage_sections();

	}
	?>
    <?php
        if (!is_front_page() || is_home()) {
            get_template_part('page-header');
        }
    ?>
	<div id="content" class="site-content">
		<div class="asterthemes-wrapper">
			<div class="asterthemes-page">
			<?php } ?>