<?php    
/**
 * The header for our theme.
 *
 * This is the template that displays all of the <head> section and everything up until <div id="content">
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package luzuk Premium
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="profile" href="http://gmpg.org/xfn/11">
	<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
	<script src="https://use.fontawesome.com/18a9c36ed1.js"></script>
	<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css
" rel="stylesheet">
	
	
	<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/bootstrap.min.css">
	<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/animate.css" />
	
	<link rel="preconnect" href="https://fonts.googleapis.com">
	<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
	<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap" rel="stylesheet">

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script>

    <script src="<?php echo get_template_directory_uri(); ?>/js/jquery-3.1.1.slim.min.js" crossorigin="anonymous"></script>
    <script src="<?php echo get_template_directory_uri(); ?>/js/bootstrap.min.js" type="text/javascript"  ></script>
    <script src="<?php echo get_template_directory_uri(); ?>/js/wow.js" ></script>

    <script src="<?php echo get_template_directory_uri(); ?>/js/jquery-3.1.1.slim.min.js" type="text/javascript"  ></script>
    <script src="<?php echo get_template_directory_uri(); ?>/js/swiper.min.js" type="text/javascript"  ></script>
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
   	

	<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
	<div class="main-container">
		<!-- <a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'luzuk' ); ?></a> -->
	    <div id="loading-area"><div class="la-anim-10"></div></div>
		<!-- header -->
		<!-- #masthead -->
		<header class="site-header header-transparent header header-seo">
		    <div class="top-bar-head">
		    	<div class="container">
				<?php
					$header_mail = get_theme_mod('header_mail', 'hello@example.com');
					$header_connum = get_theme_mod('header_connum', '(00) 8888-444-22');
					$twitter = get_theme_mod('header_tw', 'https://x.com/');
					$instagram = get_theme_mod('header_insta', 'https://www.instagram.com/');
					$facebook = get_theme_mod('header_fb', 'https://www.facebook.com/');
				?>
				<div class="top-header">
					<div class="row">
						<div class="col-lg-5 col-md-5 col-sm-5 header-deatails">
							<?php if(!empty($header_mail )){ ?>
		    					<div class="header-mail tooltip-container">
		    						<i class="fa fa-envelope"></i>
		    						<svg width="9.61" height="13.523" viewBox="0 0 9.61 13.523">
									  <path id="Path_210" data-name="Path 210" d="M17.565,0A1.567,1.567,0,0,0,16,1.565v9.393a1.567,1.567,0,0,0,1.565,1.565h5.479a1.567,1.567,0,0,0,1.565-1.565V1.565A1.567,1.567,0,0,0,23.044,0Zm1.957,10.567h1.565a.391.391,0,1,1,0,.783H19.522a.391.391,0,1,1,0-.783Z" transform="translate(-15.5 0.5)" fill="none" stroke="#dda759" stroke-width="1"/>
									</svg>
									<span>Email: </span>
		    						<a href="mailto:<?php echo $header_mail;?>"><?php echo $header_mail;?></a>
		    						<span class="tooltip-text">
		    							<a href="mailto:<?php echo $header_mail;?>"><?php echo $header_mail;?></a>
		    						</span>
		    					</div>
		    				<?php }?>
						</div>
						<div class="col-lg-5 col-md-5 col-sm-4 header-deatails">
							<?php if(!empty($header_connum )){ ?>
		    					<div class="header-cnctnum tooltip-container"> 
		    						<i class="fa fa-volume-control-phone"></i>
		    						<svg width="12.052" height="12.052" viewBox="0 0 12.052 12.052">
									  <path id="Path_220" data-name="Path 220" d="M6.591-.022a5.462,5.462,0,0,1,5.461,5.461.565.565,0,1,1-1.13,0A4.332,4.332,0,0,0,6.591,1.108a.565.565,0,1,1,0-1.13ZM6.779,4.5a.753.753,0,1,1-.753.753A.753.753,0,0,1,6.779,4.5ZM6.026,2.8a.564.564,0,0,1,.565-.565,3.2,3.2,0,0,1,3.2,3.2.565.565,0,1,1-1.13,0A2.071,2.071,0,0,0,6.591,3.368.564.564,0,0,1,6.026,2.8ZM2.766.011A.939.939,0,0,1,3.882.557l.942,2.26a.939.939,0,0,1-.273,1.09l-1.16.951A7.956,7.956,0,0,0,7.172,8.64l.949-1.16a.939.939,0,0,1,1.09-.273l2.26.942a.939.939,0,0,1,.546,1.116l-.565,2.071a.939.939,0,0,1-.906.694A10.546,10.546,0,0,1,0,1.484.944.944,0,0,1,.694.576L2.766.011Z" transform="translate(0 0.023)" />
									</svg>
		    						<span>Phone: </span>
		    						<a href="tel:<?php echo $header_connum;?>"><?php echo ($header_connum);  ?></a>	
		    						<span class="tooltip-text">
		    							<a href="tel:<?php echo $header_connum;?>"><?php echo ($header_connum);  ?></a>	
		    						</span>
		    					</div>
		    				<?php }?>
						</div>
						<div class="col-lg-2 col-md-2 col-sm-3 header-social">
							<?php if($facebook || $instagram || $twitter){ ?>
								<div class="header-socialicon">	
									<?php if(!empty($twitter)){ ?>
										<li><a href="<?php echo $twitter ?>" title="Twitter" class="site-button sharp" target="_blank">
										<i class="fa-brands fa-x-twitter"></i></a></li>
									<?php }?>
									<?php if(!empty($instagram)){ ?>
										<li><a href="<?php echo $instagram ?>" title="Instagram" class="site-button sharp" target="_blank"><i class="fa fa-instagram" aria-hidden="true"></i></a></li>
									<?php }?>
									<?php if(!empty($facebook)){ ?>
										<li><a href="<?php echo $facebook ?>" title="Facebook" class="site-button sharp" target="_blank"><i class="fa fa-facebook"></i></a></li>
									<?php }?>	
									<div class="clearfix"></div>
								</div>
							 <?php }?>
						</div>
					</div>
				</div>
                <div class="h-img">
			        <div class="row mr-0 bottom-header">
			        	<div class="col-xl-4 col-lg-4">
				        	<div class="header-oddmenu">
				        		<nav class="navigation">
								    <?php
									    $menu_name = 'primary'; 

									    // Get the menu ID assigned to the 'primary' location
									    $locations = get_nav_menu_locations();
									    $menu_id = isset($locations[$menu_name]) ? $locations[$menu_name] : '';

									    // Get the current menu item ID
									    $current_menu_item_id = 0;
									    if (is_page() || is_single()) {
									        global $post;
									        $current_menu_item = wp_get_nav_menu_items($menu_id);
									        foreach ($current_menu_item as $menu_item) {
									            if ($menu_item->object_id == $post->ID) {
									                $current_menu_item_id = $menu_item->ID;
									                break;
									            }
									        }
									    }

									    function display_menu_items($menu_items, $parent_id = 0, $is_odd_parent = true, $current_menu_item_id = 0) {
									        $output = '';
									        $count = 0;

									        foreach ($menu_items as $menu_item) {
									            if ($menu_item->menu_item_parent == $parent_id) {
									                $count++;

									                // Only process odd-numbered parent menu items or their children
									                if ($parent_id == 0 && $count % 2 != 0) {
									                    $is_odd_parent = true;
									                } elseif ($parent_id == 0) {
									                    $is_odd_parent = false;
									                }

									                if ($is_odd_parent || $parent_id != 0) {
									                    $classes = 'menu-item';
									                    $has_children = false;

									                    // Check if the current menu item has children
									                    foreach ($menu_items as $child_menu_item) {
									                        if ($child_menu_item->menu_item_parent == $menu_item->ID) {
									                            $has_children = true;
									                            break;
									                        }
									                    }

									                    // Add current-menu-item class if this item is the current one
									                    if ($menu_item->ID == $current_menu_item_id) {
									                        $classes .= ' current-menu-item';
									                    }

									                    if ($has_children) {
									                        $classes .= ' menu-item-has-children';
									                    }

									                    $output .= '<li class="' . esc_attr($classes) . '">';
									                    $output .= '<a href="' . esc_url($menu_item->url) . '">' . esc_html($menu_item->title) . '</a>';

									                    if ($has_children) {
									                        $output .= '<ul class="sub-menu">';
									                        $output .= display_menu_items($menu_items, $menu_item->ID, $is_odd_parent, $current_menu_item_id); // Recursive call
									                        $output .= '</ul>';
									                    }

									                    $output .= '</li>';
									                }
									            }
									        }
									        return $output;
									    }

									    if ($menu_id) {
									        $menu_items = wp_get_nav_menu_items($menu_id);

									        if ($menu_items && !is_wp_error($menu_items)) {
									            echo '<ul class="mainmenu ht-clearfix">';
									            echo display_menu_items($menu_items, 0, true, $current_menu_item_id); // Display top-level odd-numbered menu items
									            echo '</ul>';
									        }
									    } else {
									        wp_nav_menu(array(
									            'menu_class' => 'mainmenu ht-clearfix',
									            'container' => 'ul',
									            'theme_location' => 'primary',
									        ));
									    }
							    	?>
								</nav>
				        	</div>
				        </div>
        				<div class="header-left col-xl-2 col-lg-2 col-md-3 col-sm-3 col-xs-4 col-4 logo">
	        				<?php 
	        					if( get_theme_mod('pages_logoTopsetmaxwidth',true) ) {
	        						$pages_logoTopsetmaxwidth = 'max-width:'.esc_attr(get_theme_mod('pages_logoTopsetmaxwidth')).';';
	        					}
	        				?>
        					<!-- website logo -->
        				    <div class="logo-header mostion">
	        					<?php 
	        					if ( function_exists( 'has_custom_logo' ) && has_custom_logo() ) :
	        						the_custom_logo();
	        					else : 
	        						 if( get_theme_mod('head_sitetitle_display','show' ) == 'show') :
	        					if ( is_front_page() ) : ?>
	        					<h1 class="ht-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
	        						<?php else : ?>
	        					<p class="ht-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
	        					<?php endif ?>
	        						<?php endif; ?>
	        					<?php endif; ?>
        				    </div> 
        					<?php if( get_theme_mod('head_tagline_display','show' ) == 'show') :?>	
        						<p class="ht-site-description"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'description' ); ?></a></p> 
        					<?php endif ?>
        							<!-- nav toggle button -->
        					<div class="resp_header_logo">
        						<?php 
        						if ( function_exists( 'has_custom_logo' ) && has_custom_logo() ) :
        							the_custom_logo();
        							else : 
        						if ( is_front_page() ) : ?>
        					    <h1 class="ht-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
        							<?php else : ?>
        					    <p class="ht-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
        						<?php endif; ?>
        							<!-- <p class="ht-site-description"><a href="<?php //echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php //bloginfo( 'description' ); ?></a></p> -->
        					    <?php endif; ?>
        					</div>
        				</div>
				        <div class="col-xl-4 col-lg-4 col-md-2 col-sm-2 col-3 header-menu">
				        	<div class="header-evenmenu">
				        		<div class="nav-menus">                 
									<a class="js-nav-toggle">
										<span></span>
									</a>
								    <div class="nav-wrapper">
										<nav role="navigation">
											<div class="nav-toggle">
													<span class="nav-back"></span>
													<span class="nav-title">Menu</span>
													<span class="nav-close"></span>
											</div>
											<?php
		                                        if( get_post_meta( get_the_ID(), 'intrinsic_header_page_menu', true) !=='0') {
		                                            wp_nav_menu ( array(
		                                                'menu_class' => 'mainm ht-clearfix',
		                                                'container'=> 'ul',
		                                                'menu' => get_post_meta( get_the_ID(), 'intrinsic_header_page_menu', true),
		                                                'theme_location' => 'primary',  
		                                            )); 
		                                        } else {
		                                            wp_nav_menu ( array(
		                                                'menu_class' => 'mainm ht-clearfix',
		                                                'container'=> 'ul',
		                                                'theme_location' => 'primary',  
		                                            )); 
		                                        }
		                                    ?>
										</nav>
									</div>
								</div>
				        		<nav class="navigation">
								    <?php
									    // Check if the function is already declared to avoid redeclaration
									    if (!function_exists('display_menu_items_even')) {
									        // Function to display menu items recursively
									        function display_menu_items_even($menu_items, $parent_id = 0, $is_even_parent = false, $current_menu_item_id = 0) {
									            $output = '';
									            $count = 0;

									            foreach ($menu_items as $menu_item) {
									                if ($menu_item->menu_item_parent == $parent_id) {
									                    $count++;

									                    // Only process even-numbered parent menu items or their children
									                    if ($parent_id == 0 && $count % 2 == 0) {
									                        $is_even_parent = true;
									                    } elseif ($parent_id == 0) {
									                        $is_even_parent = false;
									                    }

									                    if ($is_even_parent || $parent_id != 0) {
									                        $classes = 'menu-item';
									                        $has_children = false;

									                        // Check if the current menu item has children
									                        foreach ($menu_items as $child_menu_item) {
									                            if ($child_menu_item->menu_item_parent == $menu_item->ID) {
									                                $has_children = true;
									                                break;
									                            }
									                        }

									                        // Add current-menu-item class if this item is the current one
									                        if ($menu_item->ID == $current_menu_item_id) {
									                            $classes .= ' current-menu-item';
									                        }

									                        if ($has_children) {
									                            $classes .= ' menu-item-has-children';
									                        }

									                        $output .= '<li class="' . esc_attr($classes) . '">';
									                        $output .= '<a href="' . esc_url($menu_item->url) . '">' . esc_html($menu_item->title) . '</a>';

									                        if ($has_children) {
									                            $output .= '<ul class="sub-menu">';
									                            $output .= display_menu_items_even($menu_items, $menu_item->ID, $is_even_parent, $current_menu_item_id); // Recursive call
									                            $output .= '</ul>';
									                        }

									                        $output .= '</li>';
									                    }
									                }
									            }

									            return $output;
									        }
									    }

									    // Determine the current menu item ID
									    $menu_name = 'primary';
									    $locations = get_nav_menu_locations();
									    $menu_id = isset($locations[$menu_name]) ? $locations[$menu_name] : '';
									    $current_menu_item_id = 0;

									    if ($menu_id) {
									        $menu_items = wp_get_nav_menu_items($menu_id);

									        if ($menu_items && !is_wp_error($menu_items)) {
									            // Determine the current menu item ID
									            if (is_page() || is_single()) {
									                global $post;
									                foreach ($menu_items as $menu_item) {
									                    if ($menu_item->object_id == $post->ID) {
									                        $current_menu_item_id = $menu_item->ID;
									                        break;
									                    }
									                }
									            }

									            echo '<ul class="mainmenu ht-clearfix">';
									            echo display_menu_items_even($menu_items, 0, false, $current_menu_item_id); // Display even-numbered menu items
									            echo '</ul>';
									        }
									    } else {
									        wp_nav_menu(array(
									            'menu_class' => 'mainmenu ht-clearfix',
									            'container' => 'ul',
									            'theme_location' => 'primary',
									        ));
									    }
    								?>
								</nav>
							</div>
				        </div>
				        <div class="col-xl-2 col-lg-2 col-md-7 col-sm-7 col-5 pd-0 header-icon">
				        	<li>
					        <div class="shop-icon header-wishlist tooltip-container">
					            <?php 
					            $user_id = get_current_user_id();
					            $wishlist = get_user_meta($user_id, 'wishlist', true);
					            $wishlist_count = is_array($wishlist) ? count($wishlist) : 0;
					            $wishlist_page = get_page_by_path('wishlist'); // Make sure you have a page with slug 'wishlist'
					            $wishlist_url = $wishlist_page ? get_permalink($wishlist_page->ID) : '#'; 
					            ?>
					            <a href="<?php echo esc_url($wishlist_url); ?>" class="wishlist-link">
					                <i class="fa fa-heart"></i>
					                <?php if ($wishlist_count > 0): ?>
					                    ( <span class="wishlist-count"><?php echo esc_html($wishlist_count); ?></span> )
					                <?php endif; ?>
					                <span class="tooltip-text">Wishlist</span>
					            </a>
					        </div>
				        	</li>
				        	<li class="shop-icon">
				        		<div class="hshop tooltip-container"> 
									<?php if(function_exists ('wc_get_cart_url')){?>				
										<a href="<?php echo wc_get_cart_url();?>" class="">
											<i class="fa fa-shopping-basket" aria-hidden="true"></i> 
											<span class="count">
												( <?php global $woocommerce; ?><?php echo WC()->cart->get_cart_contents_count(); ?> )
											</span>
											<span class="tooltip-text">Cart</span>
										</a>
									<?php }?>
								</div>
				        	</li>
				        	<li class="shop-icon tooltip-container">
				        		<div class="sign_in">
									<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" >
										<i class="fa fa-user"></i> 
										<span class="tooltip-text">My Account</span>
									</a>
								</div>
				        	</li>
				        </div>
				    </div>
	                <!-- </div> -->
	    			<div class="clearfix"></div>
	    		</div>
		    </div>			
			<div class="clearfix"></div>
		</header>
	<div class="clearfix"></div>
</div>