<?php
/**
 * The header for our theme
 *
 * @package SEO Specialist
 */
?>
<!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(); ?>>
<?php wp_body_open(); ?>
<div id="page" class="site">
    <a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'seo-specialist' ); ?></a>

    <?php
    // Check if preloader is enabled in the theme customizer
    $seo_specialist_preloader_wrap = absint( get_theme_mod( 'seo_specialist_enable_preloader', 0 ) );
    if ( $seo_specialist_preloader_wrap === 1 ) : ?>
        <div id="loader">
            <div class="loader-container">
                <div id="preloader" class="loader-2">
                    <div class="dot"></div>
                </div>
            </div>
        </div>
    <?php endif; ?>

    <header id="masthead" class="site-header">
        <div class="headermain">
            <div class="header-info-box">
                <div class="container">
                    <div class="flex-row">
                        <div class="top-left">
                           <?php if (get_theme_mod('seo_specialist_header_info_address','Lorem ipsum dolor sit amet consectetur.')): ?>
                                <div class="address">
                                    <i class="<?php echo esc_attr(get_theme_mod('seo_specialist_header_location_icon','fas fa-location-arrow')); ?>"></i><span class="main-head"><?php echo esc_html(get_theme_mod('seo_specialist_header_info_address','Lorem ipsum dolor sit amet consectetur.')); ?></span>
                                </div>
                            <?php endif; ?>
                        </div>
                        <div class="top-center">
                            
                        </div>
                        <div class="top-right">
                            <span class="social-media">
                                <?php if ( get_theme_mod( 'seo_specialist_facebook_link_option','#' ) ) : ?>
                                    <a href="<?php echo esc_url( get_theme_mod( 'seo_specialist_facebook_link_option','#' ) ); ?>">
                                        <i class="fab fa-facebook-f"></i>
                                    </a>
                                <?php endif; ?>
                                <?php if ( get_theme_mod( 'seo_specialist_twitter_link_option','#' ) ) : ?>
                                    <a href="<?php echo esc_url( get_theme_mod( 'seo_specialist_twitter_link_option','#' ) ); ?>">
                                        <i class="fab fa-twitter"></i>
                                    </a>
                                <?php endif; ?>
                                <?php if ( get_theme_mod( 'seo_specialist_youtube_link_option','#' ) ) : ?>
                                    <a href="<?php echo esc_url( get_theme_mod( 'seo_specialist_youtube_link_option','#' ) ); ?>">
                                        <i class="fab fa-youtube"></i>
                                    </a>
                                <?php endif; ?>
                                <?php if ( get_theme_mod( 'seo_specialist_instagram_link_option','#' ) ) : ?>
                                    <a href="<?php echo esc_url( get_theme_mod( 'seo_specialist_instagram_link_option','#' ) ); ?>">
                                        <i class="fab fa-instagram"></i>
                                    </a>
                                <?php endif; ?>
                                <?php if ( get_theme_mod( 'seo_specialist_linkedin_link_option','#' ) ) : ?>
                                    <a href="<?php echo esc_url( get_theme_mod( 'seo_specialist_linkedin_link_option','#' ) ); ?>">
                                        <i class="fab fa-linkedin-in"></i>
                                    </a>
                                <?php endif; ?>
                            </span>
                            <?php if (class_exists('woocommerce')): ?>
                                <span class="main-woo-box">
                                    <span class="cart-no-box">
                                        <a href="<?php echo esc_url(wc_get_cart_url()); ?>" title="<?php esc_attr_e('Shopping Cart', 'seo-specialist'); ?>">
                                            <i class="fas fa-shopping-cart"></i>
                                            <span class="screen-reader-text"><?php esc_html_e('Shopping Cart', 'seo-specialist'); ?></span>
                                        </a>
                                        <span class="cart-value"><?php echo esc_html(WC()->cart->get_cart_contents_count()); ?></span>
                                    </span>
                                </span>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            </div>

            <?php 
            // Check if header image is set
            $seo_specialist_has_header_image = has_header_image();
            $seo_specialist_header_image_url = $seo_specialist_has_header_image ? esc_url( get_header_image() ) : ''; 
            ?>
                <div class="header-menu-box" style="background-image: url('<?php echo $seo_specialist_header_image_url; ?>'); background-repeat: no-repeat;background-size: cover;">
                    <div class="container menucontent <?php echo esc_attr( get_theme_mod( 'seo_specialist_enable_sticky_header', false ) ? 'sticky-header' : '' ); ?>">
                        <div class="flex-row">
                            <!-- Left Menu -->
                            <div class="nav-menu-header-left">
                                <nav id="site-navigation" class="main-navigation">
                                    <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                                        <span class="screen-reader-text"><?php esc_html_e( 'Primary Menu', 'seo-specialist' ); ?></span>
                                        <i class="fas fa-bars"></i>
                                    </button>
                                    <?php
                                        
                                        wp_nav_menu( array(
                                            'theme_location' => 'right-menu',
                                            'menu_id'        => 'primary-menu',
                                            'menu_class'     => 'primary-menu-with-dots',
                                        ) );
                                    ?>
                                </nav>
                            </div>

                            <!-- Logo and Site Branding -->
                            <div class="nav-menu-header-center">
                                <div class="logo_outer_box">
                                    <div class="logo_outer">
                                        <div class="site-branding">
                                            <?php
                                            the_custom_logo();
                                            if ( is_front_page() && is_home() ) :
                                                if ( get_theme_mod( 'seo_specialist_site_title_text', true ) ) : ?>
                                                    <h1 class="site-title">
                                                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
                                                    </h1>
                                                <?php endif;
                                            else :
                                                if ( get_theme_mod( 'seo_specialist_site_title_text', true ) ) : ?>
                                                    <p class="site-title">
                                                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
                                                    </p>
                                                <?php endif;
                                            endif;

                                            $seo_specialist_description = get_bloginfo( 'description', 'display' );
                                            if ( $seo_specialist_description || is_customize_preview() ) :
                                                if ( get_theme_mod( 'seo_specialist_site_tagline_text', false ) ) : ?>
                                                    <p class="site-description"><?php echo esc_html( $seo_specialist_description ); ?></p>
                                                <?php endif;
                                            endif; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- Right Menu -->
                            <span class="nav-menu-header-right">
                                <nav id="site-navigation" class="main-navigation">
                                    <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                                        <span class="screen-reader-text"><?php esc_html_e( 'Primary Menu', 'seo-specialist' ); ?></span>
                                        <i class="fas fa-bars"></i>
                                    </button>
                                    <?php
                                        wp_nav_menu( array(
                                            'theme_location' => 'left-menu',
                                            'menu_id'        => 'primary-menu',
                                            'menu_class'     => 'primary-menu-with-dots',
                                        ) );
                                    ?>
                                </nav>
                                <span class="header-search">
                                    <span class="search-box text-center">
                                      <?php if(get_theme_mod('seo_specialist_search_option',true) != ''){ ?>
                                        <button type="button" class="search-open"><i class="fas fa-search"></i></button>
                                      <?php }?>
                                    </span>
                                </span>
                            </span>
                            <div class="search-outer">
                                <div class="serach_inner">
                                    <?php get_search_form(); ?>
                                </div>
                                <button type="button" class="search-close">
                                    <?php echo esc_html__('X', 'seo-specialist'); ?>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

            <!-- Responsive Menu -->
            <nav id="site-navigation" class="main-navigation resp-nav responsive-menus">
                    <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                        <span class="screen-reader-text"><?php esc_html_e( 'Primary Menu', 'seo-specialist' ); ?></span>
                        <i class="fas fa-bars"></i>
                    </button>
                    <?php
                    wp_nav_menu( array(
                        'theme_location' => 'responsive-menu',
                        'menu_id'        => 'responsive-menu',
                    ) );
                    ?>
            </nav>
        </div>
    </header>
</div>