<?php
/*
 * Displays the header section with logo, site title, tagline, navigation, and contact information.
 */
?>

<?php $doctor_general_physician_topbar = get_theme_mod('doctor_general_physician_topbar', true);
?>

<?php if (!empty($doctor_general_physician_topbar)) { ?>
    <div class="top-header py-2">
        <div class="container">
            <div class="row m-0">
                <div class="col-lg-8 col-md-6 align-self-center">
                    <div class="contact message">
                        <?php if (get_theme_mod('doctor_general_physician_message_text')) : ?>
                            <p class="mb-md-0 mb-2 ps-md-3 ps-lg-0 contact-content">
                                <?php echo esc_html(get_theme_mod('doctor_general_physician_message_text')); ?>
                            </p>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="col-lg-2 col-md-3 align-self-center">
                    <div class="timing">
                        <?php if (get_theme_mod('doctor_general_physician_time')) : ?>
                            <p class="mb-md-0 mb-2 contact-content">
                                <i class="far fa-clock me-2"></i><?php echo esc_html(get_theme_mod('doctor_general_physician_time')); ?>
                            </p>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="col-lg-2 col-md-3 align-self-center">
                    <div class="contact call">
                        <?php if (get_theme_mod('doctor_general_physician_call')) : ?>
                            <div class="text-md-end contact-col call">
                                <p class="mb-0 contact-content call">
                                    <a href="tel:<?php echo esc_html(get_theme_mod('doctor_general_physician_call')); ?>"><i class="fas fa-phone"></i>
                                        <?php echo esc_html(get_theme_mod('doctor_general_physician_call')); ?>
                                    </a>
                                </p>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php } ?>

<div class="headerbox my-2">
    <div class="container header-main">
        <div class="row m-0">
            <div class="col-lg-3 col-md-4 col-12 logo-col align-self-center">
                <div class="logo text-center text-md-start">
                    <?php if (has_custom_logo()) : ?>
                        <?php the_custom_logo(); ?>
                    <?php endif; ?>

                    <?php if (get_theme_mod('doctor_general_physician_site_title', 1)) : ?>
                        <?php if (is_front_page() && is_home()) : ?>
                            <p class="text-capitalize mb-0">
                                <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                            </p>
                        <?php else : ?>
                            <h1 class="text-capitalize">
                                <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                            </h1>
                        <?php endif; ?>
                    <?php endif; ?>

                    <?php
                    $description = get_bloginfo('description', 'display');
                    if ($description || is_customize_preview()) :
                        if (get_theme_mod('doctor_general_physician_site_tagline', 1)) :
                            ?>
                            <p class="site-description my-1 text-capitalize"><?php echo esc_html($description); ?></p>
                        <?php endif; 
                    endif;
                    ?>
                </div>
            </div>
            <div class="col-lg-7 col-md-4 col-12 align-self-center">
                <div class="main-navhead">
                    <div class="menubox">
                        <div class="menu-content">
                            <?php get_template_part('template-parts/navigation/site-nav'); ?>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-2 col-md-4 align-self-center mb-md-0 mb-3">
                <?php
                $doctor_general_physician_like_option = get_theme_mod('doctor_general_physician_like_option');
                ?>
                <div class="header-details">
                    <span class="search-bar me-3">
                        <button type="button" class="open-search"><i class="fas fa-search"></i></button>
                    </span>
                    <?php if (!empty($doctor_general_physician_like_option)): ?>
                        <p class="mb-0">
                            <a href="<?php echo esc_url($doctor_general_physician_like_option); ?>">
                                <i class="far fa-heart me-3"></i>
                            </a>
                        </p>
                    <?php endif; ?>

                    <p class="mb-0">
                        <?php if (class_exists('YITH_WCWL')): ?>
                            <a href="<?php echo esc_url(YITH_WCWL()->get_wishlist_url()); ?>">
                                <i class="fas fa-heart me-3"></i>
                            </a>
                        <?php endif; ?>
                    </p>

                    <p class="mb-0">
                        <?php if (class_exists('woocommerce')): ?> 
                            <span class="product-cart text-center position-relative pe-2">
                                <a href="<?php echo esc_url(wc_get_cart_url()); ?>" title="<?php esc_attr_e('Shopping cart', 'doctor-general-physician'); ?>">
                                    <i class="fas fa-shopping-cart me-3"></i>
                                </a>
                                <?php 
                                $cart_count = WC()->cart->get_cart_contents_count(); 
                                if ($cart_count > 0): ?>
                                    <span class="cart-count"><?php echo esc_html($cart_count); ?></span>
                                <?php endif; ?>
                            </span>
                        <?php endif; ?>
                    </p>

                    <p class="mb-0">
                        <?php if (class_exists('woocommerce')): ?>
                            <?php if (is_user_logged_in()): ?>
                                <a href="<?php echo esc_url(get_permalink(get_option('woocommerce_myaccount_page_id'))); ?>">
                                    <i class="fas fa-user"></i>
                                </a>
                            <?php else: ?>
                                <a href="<?php echo esc_url(get_permalink(get_option('woocommerce_myaccount_page_id'))); ?>">
                                    <i class="far fa-user"></i>
                                </a>
                            <?php endif; ?>
                        <?php endif; ?>
                    </p>
                    
                </div>
            </div>

            <div class="search-outer">
                <div class="inner_searchbox w-100 h-100">
                    <?php get_search_form(); ?>
                </div>
                <button type="button" class="search-close"><?php esc_html_e('CLOSE', 'doctor-general-physician'); ?></button>
            </div>
        </div>
    </div>
</div>