<?php

$show_header_topbar = get_theme_mod( 'show_header_topbar', false );
$header_btn_text = get_theme_mod( 'header_btn_text', __( 'Contact', 'edify' ) );
$header_btn_link = get_theme_mod( 'header_btn_link', __( '#', 'edify' ) );

$show_header_btn = get_theme_mod( 'show_header_btn', false );
$show_mini_cart = get_theme_mod( 'show_mini_cart',false );




// header right
$edify_header_right = get_theme_mod( 'header_right_switch', false );

$edify_header_menu_col = $edify_header_right ? 'col-xl-8 d-none d-xl-block' : 'col-xl-10 d-none d-xl-block';
$edify_menu_position = $edify_header_right ? 'text-xxl-center menu-center' : 'text-xxl-end menu-border-none';




$header_site_logo = get_theme_mod( 'header_custom_logo', '' );



?>

<?php if ($show_header_topbar === true){
    get_template_part( 'template-parts/headers/header-topbar-1');
}

?>


<header class="header-style-1"> 
	<!-- Header Main menu -->
    <div class="header-navbar"> 
        <div class="container-lg">
            <div class="row align-items-center justify-content-between">
                <div class="col-xl-2 col-lg-2 col-md-3 col-sm-6 col-8">
                    <div class="site-logo">

                        <a class="" href="<?php echo esc_url( home_url( '/' ) ); ?>">
                            <?php 
                                if (has_custom_logo()) {
                                    the_custom_logo();
                                }
                               
                                elseif (class_exists('kirki') && !empty($header_site_logo)) { ?>
                                <img src="<?php echo esc_url($header_site_logo);?>" alt="<?php bloginfo('name'); ?>">
                            <?php 
                            }
                            
                            // No logo set anywhere (Site Identity or Kirki) -- fall back
                            // to the Site Title as text instead of shipping the theme's
                            // own demo logo image in production.
                            else{
                                ?>
                                <span class="site-title-fallback"><?php bloginfo( 'name' ); ?></span>
                            <?php 
                                }
                            ?>
                        </a>
                    </div>
                

                </div>

                <div class="col-xl-8 col-lg-7 col-md-6 col-sm-3 col-4">
                    <nav id="main-menu" class="main-navigation site-navbar ms-auto" role="navigation" aria-label="<?php esc_attr_e('Primary Menu', 'edify'); ?>">
                    <?php
                    if ( has_nav_menu( 'menu-1' ) ) {
                        wp_nav_menu( array(
                            'theme_location'    => 'menu-1',
                            'container'       	=> false, 
                            'menu_class'        => 'primary-menu',
                            'depth'             => 3,
                        ) );
                        
                    } else   {
                        printf('<div class="nav-admin-notice">%s</div>',
                                esc_html__( 'There are no menus assigned to Primary Navigation. Create one in Appearance - Menus or in Customizer.', 'edify' )
                            );
                    }
                    ?>
                        <a href="#" class="nav-close"><i class="fa fa-times"></i></a>

                        <?php if($show_header_btn === true) :?>
                        <div class="header-btn d-sm-block d-md-none mt-20">
                            <a href="<?php echo esc_url($header_btn_link);?>" class="btn btn-main btn-sm"><?php echo esc_html($header_btn_text);?></a>
                        </div>
                        <?php endif;?>
                    </nav>
                   

                    <div class="offcanvas-icon d-block d-md-none d-lg-none text-right text-end">
                        <a href="#" class="nav-toggler">
                            <i class="fa fa-bars"></i>
                            <span class="screen-reader-text"><?php esc_html_e( 'Open Main menu', 'edify' ); ?></span>
                        </a> 
                    </div>
                </div>

                
                <?php if($edify_header_right  === true) :?>
                <div class="col-xl-2 col-lg-3 col-md-3 col-sm-3 col-5">
                    <div class="header-right d-flex align-items-center justify-content-end">
                        <?php if ( class_exists( 'WooCommerce' ) && ($show_mini_cart  === true)) : ?>

                            <div class="tp-header-right-shop p-relative">
                                <a href="<?php echo wc_get_cart_url(); ?>">

                                <i class="ri-shopping-bag-line"></i>
                                    <span id="tp-cart-item" class="cart__count"><?php echo esc_html(WC()->cart->cart_contents_count); ?></span>
                                </a>
                                <div class="mini_shopping_cart_box"><?php woocommerce_mini_cart(); ?></div>
                            </div>
                        <?php endif; ?>


                        <?php if($show_header_btn === true) :?>

                            <div class="header-btn">
                                <a href="<?php echo esc_url($header_btn_link);?>" class="btn btn-main btn-sm"><?php echo esc_html($header_btn_text);?></a>
                            </div>
                        <?php endif;?>
                    </div>
                    <?php endif;?>
                </div>
            </div>
        </div>
    </div>
</header>