<header class="main-header">
    <?php $pet_house_topbar = get_theme_mod('pet_house_topbar', true);
    if ($pet_house_topbar == '1') : ?>
        <div class="topbar wow fadeInDown" data-wow-delay="0.5s">
            <div class="container">
                <div class="top-header py-2">
                    <?php 
                    $pet_house_topbar_text = get_theme_mod('pet_house_topbar_text', '100% Secure Delivery Without Contacting The Courier.');
                    if (!empty($pet_house_topbar_text)) { ?>
                        <p class="mb-0 text-center"><?php echo esc_html(sanitize_text_field($pet_house_topbar_text)); ?></p>
                    <?php } ?>
                </div>
            </div>
        </div>
    <?php endif; ?>
    
    <div class="middle-header-area py-2 wow fadeInUp" data-wow-delay="0.5s">
        <div class="container">
            <div class="row">
                <div class="langauge-box col-lg-4 col-md-4 text-md-start text-center align-self-center d-flex align-items-center">
                    <span class="currency me-md-2">
                        <?php if (get_theme_mod('pet_house_currency_switcher', true) && class_exists('woocommerce')) : ?>
                            <div class="currency-box d-md-inline-block">
                                <?php echo do_shortcode('[woocommerce_currency_switcher_drop_down_box]'); ?>
                            </div>
                        <?php endif; ?>
                    </span>
                    <span class="translate-btn d-flex">
                        <?php if (get_theme_mod('pet_house_cart_language_translator', true) && class_exists('GTranslate')) : ?>
                            <div class="translate-lang position-relative d-md-inline-block me-3">
                                <?php echo do_shortcode('[gtranslate]'); ?>
                            </div>
                        <?php endif; ?>
                    </span>
                </div>

                <div class="col-lg-4 col-md-4 logo-col text-center align-self-center">
                    <div class="logo my-md-0 my-3">
                        <?php 
                        if (has_custom_logo()) {
                            the_custom_logo();
                        } else {
                            // Check if both title and tagline settings are disabled
                            $pet_house_tagline_enabled = get_theme_mod('pet_house_tagline_setting', false);
                            $pet_house_title_enabled = get_theme_mod('pet_house_site_title_setting', true);

                            if (!$pet_house_tagline_enabled && !$pet_house_title_enabled) {
                                // Display the default logo
                                $pet_house_default_logo_url = get_template_directory_uri() . '/assets/images/logo.png'; // Replace with your default logo path
                                echo '<a href="' . esc_url(home_url('/')) . '">';
                                echo '<img src="' . esc_url($pet_house_default_logo_url) . '" alt="' . esc_attr(get_bloginfo('name')) . '">';
                                echo '</a>';
                            }

                            // Display tagline if the setting is enabled
                            if ($pet_house_tagline_enabled) :
                                $pet_house_site_desc = get_bloginfo('description'); ?>
                                <p class="site-description"><?php echo esc_html($pet_house_site_desc); ?></p>
                            <?php endif; ?>

                            <?php
                            // Display site title if the setting is enabled
                            if ($pet_house_title_enabled) : ?>
                                <p class="site-title">
                                    <a href="<?php echo esc_url(home_url('/')); ?>">
                                        <?php echo esc_html(get_bloginfo('name')); ?>
                                    </a>
                                </p>
                            <?php endif; ?>
                        <?php } ?>
                    </div>
                </div>

                <div class="col-lg-4 col-md-4 text-md-start text-center align-self-center">
                    <div class="header-details d-flex align-items-center justify-content-end">
                        <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'))); ?>" aria-label="<?php esc_attr_e('My Account', 'pet-house'); ?>">
                                        <i class="fas fa-user"></i>
                                        <span class="login-text"><?php esc_html_e('My Account', 'pet-house'); ?></span>
                                    </a>
                                <?php else : ?>
                                    <a href="<?php echo esc_url(get_permalink(get_option('woocommerce_myaccount_page_id'))); ?>" aria-label="<?php esc_attr_e('My Account', 'pet-house'); ?>">
                                        <i class="far fa-user"></i>
                                        <span class="login-text"><?php esc_html_e('My Account', 'pet-house'); ?></span>
                                    </a>
                                <?php endif; ?>
                            <?php endif; ?>
                        </p>

                        <p class="mb-0">
                            <?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', 'pet-house'); ?>" aria-label="<?php esc_attr_e('My Cart', 'pet-house'); ?>">
                                        <i class="fas fa-shopping-bag"></i>
                                        <span class="login-text"><?php esc_html_e('My Cart', 'pet-house'); ?></span>
                                    </a>
                                    <?php 
                                    $pet_house_cart_count = WC()->cart->get_cart_contents_count(); 
                                    if ($pet_house_cart_count > 0) : ?>
                                        <span class="cart-count">(<?php echo esc_html($pet_house_cart_count); ?>)</span>
                                    <?php endif; ?>
                                </span>
                            <?php endif; ?>
                        </p>

                        <?php if (class_exists('woocommerce')) : ?>
                            <?php if (get_theme_mod('pet_house_like_option') != '') : ?>
                                <p class="mb-0">
                                    <a href="<?php echo esc_url(get_theme_mod('pet_house_like_option')); ?>" aria-label="<?php esc_attr_e('Wishlist', 'pet-house'); ?>">
                                        <i class="far fa-heart"></i>
                                        <span class="login-text"><?php esc_html_e('Wishlist', 'pet-house'); ?></span>
                                    </a>
                                </p>
                            <?php endif; ?>

                            <?php if (class_exists('YITH_WCWL')) : ?>
                                <p class="mb-0">
                                    <a href="<?php echo esc_url(YITH_WCWL()->get_wishlist_url()); ?>" aria-label="<?php esc_attr_e('Wishlist', 'pet-house'); ?>">
                                        <i class="fas fa-heart"></i>
                                        <span class="login-text"><?php esc_html_e('Wishlist', 'pet-house'); ?></span>
                                    </a>
                                </p>
                            <?php endif; ?>
                        <?php endif; ?>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="<?php if( get_theme_mod( 'pet_house_sticky_header', '0')) { ?>sticky-header<?php } else { ?>close-sticky<?php } ?>">
        <div class="menu-header-area py-2">
            <div class="container">
                <div class="row">
                    <div class="col-lg-3 col-md-4 text-md-start align-self-center">
                        <?php if (class_exists('woocommerce')) : ?>
                            <button class="category-btn">
                                <i class="fa fa-bars" aria-hidden="true"></i>
                                <?php echo esc_html(get_theme_mod('pet_house_category_text', __('Select Category', 'pet-house'))); ?>
                                <i class="fas fa-chevron-down"></i>
                            </button>
                            <div class="category-dropdown">
                                <?php
                                $args = array(
                                    'number'     => absint(get_theme_mod('pet_house_product_category_number')),
                                    'orderby'    => 'title',
                                    'order'      => 'ASC',
                                    'hide_empty' => 0,
                                    'parent'     => 0,
                                );
                                $product_categories = get_terms('product_cat', $args);
                                if (!empty($product_categories)) {
                                    foreach ($product_categories as $product_category) { ?>
                                        <li class="drp_dwn_menu">
                                            <a href="<?php echo esc_url(get_term_link($product_category)); ?>">
                                                <?php echo esc_html($product_category->name); ?>
                                            </a>
                                        </li>
                                    <?php }
                                } ?>
                            </div>
                        <?php endif; ?>
                    </div>

                    <div class="col-lg-6 col-md-4 col-12 menu-col align-self-center">
                        <div class="menubox">
                            <!-- Main menu -->
                            <div class="navbar-menubar responsive-menu navigation_header">
                                <div class="toggle-nav mobile-menu">
                                    <button onclick="pet_house_openNav()">
                                        <i class="fa-solid fa-bars"></i> <!-- Initial hamburger icon -->
                                    </button>
                                </div>
                                <div id="mySidenav" class="nav sidenav">
                                    <nav id="site-navigation" class="main-navigation navbar navbar-expand-xl" aria-label="<?php esc_attr_e( 'Top Menu', 'pet-house' ); ?>">

                                        <?php 
                                            wp_nav_menu(
                                                array(
                                                    'theme_location' => 'primary',
                                                    'container_class' => 'main-menu clearfix',
                                                    'menu_class' => 'clearfix menu',
                                                    'items_wrap' => '<ul id="%1$s" class="%2$s mobile_nav">%3$s</ul>',
                                                    'fallback_cb' => 'wp_page_menu',
                                                )
                                            );
                                        ?>
                                        <a href="javascript:void(0)" class="closebtn mobile-menu" onclick="pet_house_closeNav()">
                                            <i class="fa-solid fa-times"></i> <!-- Close icon for the menu -->
                                        </a>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="main-search col-lg-3 col-md-4 text-md-end align-self-center">
                        <div class="product-search">
                            <div class="search_inner my-3 my-md-0">
                                <?php if (class_exists('woocommerce')) : ?>
                                    <?php get_product_search_form(); ?>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>