<!-- ********************************************************
 ************************* Begin Header *********************
 ******************************************************** -->
<header>
    <div class="custom-container">
        <!-- topbar -->
        <div class="topbar">

            <!-- html widget here -->
            <div class="topbar-html-widget">
                <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('header_support_widget')) : ?>
                <?php endif; ?>
            </div>

            <!-- menu here -->
            <div class="inline-menu">
                <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('header_links_widget')) : ?>
                <?php endif; ?>
            </div>

        </div>

        <!-- main header box -->
        <div class="header-box">

            <!-- logo -->
            <?php
            $logo = get_option(TEXT_DOMAIN . '_logo');
            if (!empty($logo)) { ?>
                <a href="<?php bloginfo('url'); ?>" class="header-logo">
                    <img src="<?php echo $logo ?>" class="" alt="<?php bloginfo('title'); ?>"></a>
            <?php } else {
                _e('Logo image not selected', TEXT_DOMAIN); ?>
            <?php } ?>

            <!-- main menu here -->
            <div class="main-menu-container">

                <!-- mobile menu backdrop -->
                <div class="banta-menu-backdrop"></div>

                <!-- mobile logo -->
                <?php $mobileLogo = get_option(TEXT_DOMAIN . '_mobile_menu_logo'); ?>
                <input type="hidden" id="mobileMenuLogoSrc" value="<?php echo $mobileLogo ?>">

                <!-- mobile menu profile button -->
                <?php $showMobileAccountBtn = get_option(TEXT_DOMAIN . '_show_mobile_account_btn'); $profileBtnLink = '';
                if($showMobileAccountBtn != 'false' && class_exists('WooCommerce')){
                    $my_account_page_id  = wc_get_page_id( 'myaccount' );
                    $profileBtnLink = $my_account_page_id ? get_permalink( $my_account_page_id ) : '';
                    ?>
                <?php }?>
                <input type="hidden" id="showMobileMenuProfileBtn" value="<?php echo $showMobileAccountBtn; ?>">
                <input type="hidden" id="mobileMenuProfileBtnLink" value="<?php echo $profileBtnLink; ?>">


                <div class="banta-elementor-menu">
                    <div class="banta-elementor-menu-container">
                        <?php
                        $menu_location = 'main_menu';
                        if (has_nav_menu($menu_location)) {
                            wp_nav_menu(array(
                                'theme_location' => 'main_menu',
                                'walker' => new My_Custom_Walker_Nav_Menu(),
                                'menu_class' => 'menu-items',
                                'fallback_cb' => 'wp_page_menu'
                            ));
                        } else {
                            _e('No menu found. Please assign a menu in the WordPress admin', TEXT_DOMAIN);
                        }
                        ?>
                    </div>

                    <!-- mobile menu footer -->
                    <div class="banta-elementor-menu-footer">

                        <?php $instagramLink = get_option(TEXT_DOMAIN . '_instagram');
                        if (!empty($instagramLink)):?>
                            <a href="<?php echo $instagramLink; ?>" class="btn-icon btn-icon-sm"><i
                                        class="icon-instagram"></i></a>
                        <?php endif; ?>

                        <?php $telegramLink = get_option(TEXT_DOMAIN . '_telegram');
                        if (!empty($telegramLink)):?>
                            <a href="<?php echo $telegramLink; ?>" class="btn-icon btn-icon-sm"><i
                                        class="icon-telegram"></i></a>
                        <?php endif; ?>

                        <?php $whatsappLink = get_option(TEXT_DOMAIN . '_whatsapp');
                        if (!empty($whatsappLink)):?>
                            <a href="<?php echo $whatsappLink; ?>" class="btn-icon btn-icon-sm"><i
                                        class="icon-whatsapp"></i></a>
                        <?php endif; ?>

                        <?php $twitterLink = get_option(TEXT_DOMAIN . '_twitter');
                        if (!empty($twitterLink)):?>
                            <a href="<?php echo $twitterLink; ?>" class="btn-icon btn-icon-sm"><i
                                        class="icon-twitter"></i></a>
                        <?php endif; ?>

                        <?php $linkedInLink = get_option(TEXT_DOMAIN . '_linkedin');
                        if (!empty($linkedInLink)):?>
                            <a href="<?php echo $linkedInLink; ?>" class="btn-icon btn-icon-sm"><i
                                        class="icon-linkedin"></i></a>
                        <?php endif; ?>

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

            <!-- buttons -->
            <div class="header-buttons">

                <!-- search button  -->
                <?php
                $showSearchBtn = get_option(TEXT_DOMAIN . '_show_header_search_btn'); ?>
                <?php if ($showSearchBtn != 'false') { ?>
                    <a href="#" class="btn btn-primary header-search-btn">
                        <span class="iconlyBulk-Search"><span class="path1"></span><span class="path2"></span></span>
                    </a>
                <?php } ?>

                <!-- account button (only desktop) -->
                <?php
                $showAccountBtn = get_option(TEXT_DOMAIN . '_show_header_account_btn');
                if($showAccountBtn != 'false' && class_exists('WooCommerce')) {
                    $my_account_page_id  = wc_get_page_id( 'myaccount' );
                    $my_account_page_url = $my_account_page_id ? get_permalink( $my_account_page_id ) : ''; ?>
                <?php if (is_user_logged_in()):?>
                <a href="<?php echo $my_account_page_url; ?>" class="btn btn-primary d-none d-lg-inline-flex">
                    <span class="iconlyBulk-Profile"><span class="path1"></span><span class="path2"></span></span>
                    <span class="ms-1"><?php _e('My Account',TEXT_DOMAIN) ?></span>
                </a>
                <?php else: ?>
                    <a href="<?php echo $my_account_page_url; ?>" class="btn btn-primary d-none d-lg-inline-flex">
                        <span class="iconlyBulk-Login"><span class="path1"></span><span class="path2"></span></span>
                        <span class="ms-1"><?php _e('Sign In',TEXT_DOMAIN) ?></span>
                    </a>
                <?php endif; ?>
                <?php }?>


                <!-- cart -->
                <?php
                $showCartBtn = get_option(TEXT_DOMAIN . '_show_header_cart_btn'); ?>
                <?php if ($showCartBtn != 'false' && class_exists('WooCommerce')) { ?>
                    <div class="cart-button-container">
                        <a href="#" class="btn btn-primary shadow-lg btn-open-wc-cart">
                            <?php $cartItemsCount = count(WC()->cart->get_cart()); ?>
                            <span class="cart-badge"><?php echo $cartItemsCount ?></span>
                            <span class="iconlyBulk-Bag"><span class="path1"></span><span class="path2"></span></span>
                        </a>

                        <div class="cart-dropdown">
                            <div class='cart-dropdown-close'><i class='icon-x1'></i></div>
                            <div class='cart-dropdown-title'><?php _e('Cart', TEXT_DOMAIN); ?></div>
                            <div class="woocommerce-cart-form">
                                <?php if(class_exists( 'WooCommerce' )):?>
                                    <?php echo get_custom_cart_content(); ?>
                                <?php else:?>
                                <span><?php _e('Your cart is empty',TEXT_DOMAIN);?></span>
                                <?php endif;?>

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

                <?php } ?>


                <!-- mobile menu toggle -->
                <span class="banta-elementor-toggle" onclick="menuToggleElementor()">
                           <span></span>
                            <span></span>
                            <span></span>
                    </span>
            </div>

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