<?php
/*
* Display Logo and contact details
*/
?>

<div class="topbar my-2">
    <div class="container">
        <div class="row">
            <div class="col-lg-4 col-md-3 col-12 align-self-center">
                <div class="logo">
                    <?php if (has_custom_logo()) appliances_store_the_custom_logo(); ?>
                    <?php if (get_theme_mod('appliances_store_site_title', true) == 1) { ?>
                        <?php if (is_front_page() && is_home()) : ?>
                            <h1 class="text-capitalize">
                                <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                            </h1>
                        <?php else : ?>
                            <p class="text-capitalize site-title mb-1">
                                <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                            </p>
                        <?php endif; ?>
                    <?php } ?>
                    <?php $appliances_store_description = get_bloginfo('description', 'display');
                    if ($appliances_store_description || is_customize_preview()) : ?>
                        <?php if (get_theme_mod('appliances_store_site_tagline', false)) { ?>
                            <p class="site-description"><?php echo esc_html($appliances_store_description); ?></p>
                        <?php } ?>
                    <?php endif; ?>
                </div>
            </div>

            <div class="col-lg-5 col-md-5 main-cat-box text-md-end text-start align-self-center mb-lg-0 mb-3">
                <?php if (class_exists('woocommerce')) { ?>
                    <div class="searching-area">
                        <div class="search-cat-box">
                            <div class="row m-0 align-items-center">
                                <div class="col-xl-3 col-lg-4 col-md-5 px-2 align-self-center main-cat-text">
                                    <button class="category-btn btn btn-secondary">
                                        <?php esc_html_e('All Categories', 'appliances-store'); ?> <i class="fas fa-chevron-down ps-2"></i>
                                    </button>
                                    <ul class="category-dropdown" style="display: none;">
                                        <?php
                                        $args = array(
                                            'taxonomy'   => 'product_cat',
                                            'orderby'    => 'name',
                                            'order'      => 'ASC',
                                            'hide_empty' => 0,
                                            'parent'     => 0
                                        );
                                        $product_categories = get_terms($args);

                                        if (!empty($product_categories)) {
                                            foreach ($product_categories as $product_category) {
                                                echo '<li><a href="' . esc_url(get_term_link($product_category)) . '" data-id="' . esc_attr($product_category->term_id) . '">' . esc_html($product_category->name) . '</a></li>';
                                            }
                                        } else {
                                            echo '<li>' . esc_html__('No categories found.', 'appliances-store') . '</li>';
                                        }
                                        ?>
                                    </ul>
                                </div>
                                <div class="col-lx-9 col-lg-8 col-md-7 px-2 main-searh-col align-self-center">
                                    <form id="searchForm" action="<?php echo esc_url(home_url('/')); ?>" method="get">
                                        <input class="search-text" type="text" name="s" placeholder="<?php esc_attr_e('Enter Search Products', 'appliances-store'); ?>">
                                        <input type="hidden" name="post_type" value="service">
                                        <input type="hidden" name="category" id="categoryInput" value="">
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php } ?>
            </div>

            <div class="col-lg-3 col-md-4 col-12 langauge-box align-self-center d-flex align-items-center justify-content-md-end justify-content-center">
                <span class="currency me-md-2 mb-md-0 mb-2">
                    <?php if (get_theme_mod('appliances_store_currency_switcher', true) && class_exists('WooCommerce')) : ?>
                        <div class="currency-box d-md-inline-block">
                            <?php echo wp_kses_post(do_shortcode('[woocommerce_currency_switcher_drop_down_box]')); ?>
                        </div>
                    <?php endif; ?>
                </span>
                <span class="translate-btn d-flex">
                    <?php if (get_theme_mod('appliances_store_cart_language_translator', true) && class_exists('GTranslate')) : ?>
                        <div class="translate-lang position-relative d-md-inline-block me-3">
                            <?php echo wp_kses_post(do_shortcode('[gtranslate]')); ?>
                        </div>
                    <?php endif; ?>
                </span>
            </div>
        </div>
    </div>
</div>

<div class="headerbox-main">
    <div class="headerbox container py-2">
        <div class="flex-row">
            <div class="menu-left align-self-center">
                <span class="menu-box">
                    <?php get_template_part('template-parts/navigation/site-nav'); ?>
                    <?php 
                    $appliances_store_track_order_link_sec = get_theme_mod('appliances_store_track_order_link_sec');
                    $appliances_store_track_order_button_sec = get_theme_mod('appliances_store_track_order_button_sec', esc_html__('Track Your Order', 'appliances-store'));
                    if ($appliances_store_track_order_link_sec) : ?>
                        <span class="header-btn sec">
                            <a href="<?php echo esc_url($appliances_store_track_order_link_sec); ?>" class="book-appoin">
                                <i class="fas fa-truck pe-2"></i><?php echo esc_html($appliances_store_track_order_button_sec); ?>
                            </a>
                        </span>
                    <?php endif; ?>
                </span>
            </div>

            <div class="menu-center align-self-center">
                <div class="call">
                    <?php if (get_theme_mod('appliances_store_header_call_no') != '') { ?>
                        <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-1 text-start"><?php echo esc_html(get_theme_mod('appliances_store_header_call_text', '')); ?></p>
                                <p class="call-simplep mb-0 text-start">
                                    <a href="tel:<?php echo esc_html(get_theme_mod('appliances_store_header_call_no')); ?>">
                                        <?php echo esc_html(get_theme_mod('appliances_store_header_call_no')); ?>
                                    </a>
                                </p>
                            </div>
                        </div>
                    <?php } ?>
                </div>
            </div>

            <div class="menu-right align-self-center">
                <div class="header-details">
                    <?php if ($appliances_store_like_option = get_theme_mod('appliances_store_like_option')) : ?>
                        <p class="mb-0">
                            <a href="<?php echo esc_url($appliances_store_like_option); ?>">
                                <i class="far fa-heart" aria-hidden="true"></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" aria-hidden="true"></i>
                            </a>
                        <?php endif; ?>
                    </p>

                    <p class="mb-0 ps-4 ps-md-2">
                        <?php if (class_exists('WooCommerce')) : ?>
                            <span class="product-cart text-center position-relative">
                                <a href="<?php echo esc_url(wc_get_cart_url()); ?>" title="<?php esc_attr_e('Shopping cart', 'appliances-store'); ?>">
                                    <i class="fas fa-shopping-cart" aria-hidden="true"></i>
                                </a>
                                <?php 
                                $appliances_store_cart_count = WC()->cart->get_cart_contents_count(); 
                                if ($appliances_store_cart_count > 0) : ?>
                                    <span class="cart-count"><?php echo esc_html($appliances_store_cart_count); ?></span>
                                <?php endif; ?>
                            </span>
                        <?php endif; ?>
                    </p>
                </div>
            </div>
        </div>
    </div>
</div>