<?php
/**
 * The header for our theme
 *
 * @package Automotive Parts
 */
?>
<!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', 'automotive-parts' ); ?></a>

    <?php
    $automotive_parts_preloader_wrap = absint( get_theme_mod( 'automotive_parts_enable_preloader', 0 ) );
    if ( $automotive_parts_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">
                    <?php if (get_theme_mod('automotive_parts_show_topbar', 1)) : ?>
                        <div class="top-head">
                            <div class="container">
                                <div class="flex-row">
                                    <div class="top-left">
                                        <div class="top-header">
                                            <?php if (get_theme_mod('automotive_parts_add_location') !== 'Lorem ipsum dolor sit amet, consectetuer adipiscing.') : ?>
                                                <span class="location">
                                                    <i class="fas fa-map-marker-alt"></i>
                                                    <span class="top-text"><?php echo esc_html__('ADDRESS :', 'automotive-parts'); ?></span><span class="top-detail"><?php echo esc_html(get_theme_mod('automotive_parts_add_location', 'Lorem ipsum dolor sit amet, consectetuer adipiscing.')); ?></span>
                                                </span>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                    <div class="top-right">
                                        <?php if ( get_theme_mod( 'automotive_parts_header_info_email','info@example.com' ) ) : ?>
                                            <span class="main-box mail">
                                                <i class="fas fa-envelope"></i>
                                                <span class="top-text"><?php echo esc_html__('MAIL :', 'automotive-parts'); ?></span><a class="top-detail" href="mailto:<?php echo esc_attr( get_theme_mod( 'automotive_parts_header_info_email','info@example.com' ) ); ?>">
                                                    <span><?php echo esc_html( get_theme_mod( 'automotive_parts_header_info_email','info@example.com' ) ); ?></span>
                                                </a>
                                            </span>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endif; ?>
                    <?php 
                        $automotive_parts_has_header_image = has_header_image();

                        if ( $automotive_parts_has_header_image ) {
                            $automotive_parts_header_image_url = esc_url( get_header_image() );
                        } else {
                            $automotive_parts_header_image_url = '';
                        }
                    ?>
                    <div class="header-menu-box">
                        <div class="container" style="background-image: url('<?php echo $automotive_parts_header_image_url; ?>'); background-repeat: no-repeat; background-size: cover;">
                            <div class="middle-box">
                                <div class="flex-row">
                                    <div class="middle-left">
                                        <div class="site-branding">
                                            <?php
                                            if ( function_exists( 'the_custom_logo' ) ) {
                                                the_custom_logo();
                                            }
                                            if ( is_front_page() && is_home() ) :
                                                if ( get_theme_mod( 'automotive_parts_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( 'automotive_parts_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;
                                            $automotive_parts_description = get_bloginfo( 'description', 'display' );
                                            if ( $automotive_parts_description || is_customize_preview() ) :
                                                if ( get_theme_mod( 'automotive_parts_site_tagline_text', false ) ) : ?>
                                                    <p class="site-description"><?php echo esc_html( $automotive_parts_description ); ?></p>
                                                <?php endif;
                                            endif; ?>
                                        </div>
                                    </div>
                                    <div class="middle-right">
                                        <div class="call">
                                        <?php if( get_theme_mod( 'automotive_parts_about_call_text' ) != '' || get_theme_mod( 'automotive_parts_about_call' ) != '') { ?>
                                          <div class="main-abt-contact-box">
                                            <div class="about-call-icon me-3"><i class="fas fa-phone"></i></div>
                                            <div class="about-contact-text">
                                                <p class="call-text mb-0 text-start"><?php echo esc_html( get_theme_mod('automotive_parts_about_call_text','') ); ?></p>
                                                <p class="call-simplep mb-0 text-start"><a href="tel:<?php echo esc_html(get_theme_mod('automotive_parts_about_call')); ?>">
                                                    <?php echo esc_html(get_theme_mod('automotive_parts_about_call')); ?></a>
                                                </p>
                                            </div>
                                          </div>
                                        <?php } ?>
                                    </div>
                                        <span class="social-media">
                                            <?php if ( get_theme_mod( 'automotive_parts_facebook_link_option','www.facebook.com' ) ) : ?>
                                                <a href="<?php echo esc_url( get_theme_mod( 'automotive_parts_facebook_link_option','www.facebook.com' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                                    <i class="fab fa-facebook"></i>
                                                </a>
                                            <?php endif; ?>
                                            <?php if ( get_theme_mod( 'automotive_parts_twitter_link_option','www.twitter.com' ) ) : ?>
                                                <a href="<?php echo esc_url( get_theme_mod( 'automotive_parts_twitter_link_option','www.twitter.com' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                                    <i class="fab fa-twitter"></i>
                                                </a>
                                            <?php endif; ?>
                                            <?php if ( get_theme_mod( 'automotive_parts_youtube_link_option','www.youtube.com' ) ) : ?>
                                                <a href="<?php echo esc_url( get_theme_mod( 'automotive_parts_youtube_link_option','www.youtube.com' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                                    <i class="fab fa-youtube"></i>
                                                </a>
                                            <?php endif; ?>
                                            <?php if ( get_theme_mod( 'automotive_parts_google_plus_link_option','www.google.com' ) ) : ?>
                                                <a href="<?php echo esc_url( get_theme_mod( 'automotive_parts_google_plus_link_option','www.google.com' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                                    <i class="fab fa-google-plus-g"></i>
                                                </a>
                                            <?php endif; ?>
                                            <?php if ( get_theme_mod( 'automotive_parts_pinterest_link_option','www.pinterest.com' ) ) : ?>
                                                <a href="<?php echo esc_url( get_theme_mod( 'automotive_parts_pinterest_link_option','www.pinterest.com' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                                    <i class="fab fa-pinterest-p"></i>
                                                </a>
                                            <?php endif; ?>
                                        </span>
                                        <span class="header-button">
                                            <?php if (get_theme_mod('automotive_parts_header_button_link') || get_theme_mod('automotive_parts_header_button_text', 'BOOK AN APPOINTMENT')): ?>
                                                <a href="<?php echo esc_url(get_theme_mod('automotive_parts_header_button_link')); ?>"><i class="fas fa-calendar-alt"></i><?php echo esc_html(get_theme_mod('automotive_parts_header_button_text', 'BOOK AN APPOINTMENT')); ?></a>
                                            <?php endif; ?>
                                        </span>
                                    </div>
                                </div>
                            </div>  
                            <div class="menucontent <?php echo esc_attr( get_theme_mod( 'automotive_parts_enable_sticky_header', false ) ? 'sticky-header' : '' ); ?>">
                                <div class="nav-menu-header">
                                    <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', 'automotive-parts' ); ?></span>
                                            <i class="fas fa-bars"></i>
                                        </button>
                                        <?php
                                        wp_nav_menu( array(
                                            'theme_location' => 'menu-1',
                                            'menu_id'        => 'primary-menu',
                                        ) );
                                        ?>
                                    </nav>
                                    <?php if ( get_theme_mod( 'automotive_parts_header_search', true ) == 1 ) : ?>
                                        <span class="search-bar">
                                            <button type="button" class="open-search"><i class="fas fa-search"></i></button>
                                        </span>
                                    <?php endif; ?>
                                    <div class="search-outer">
                                        <div class="inner_searchbox">
                                            <?php get_search_form(); ?>
                                        </div>
                                        <button type="button" class="search-close"><i class="fas fa-window-close"></i></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div> 
                </div>
            </div>
    </header>
</div>