<header class="main-header">
    <!-- Topbar Section -->
    <?php if (get_theme_mod('expert_fitness_trainer_topbar', true)) : ?>
        <div class="topbar py-2 wow fadeInDown" data-wow-delay="0.5s">
            <div class="container">
                <div class="row">
                    <div class="col-lg-5 col-md-4 col-sm-3 align-self-center">
                        <?php if (get_theme_mod('expert_fitness_trainer_top_text','Witness the BIGGEST SHOWDOWN in the history! Matt vs Robbie, tickets available for sale')) : ?>
                            <p>
                                <?php echo esc_html(get_theme_mod('expert_fitness_trainer_top_text','Witness the BIGGEST SHOWDOWN in the history! Matt vs Robbie, tickets available for sale')); ?>
                            </p>
                        <?php endif; ?>
                    </div>
                    <div class="col-lg-4 col-md-4 col-sm-6 align-self-center">
                        <?php if (get_theme_mod('expert_fitness_trainer_discount_text','GET 20% OFF ON SELECTED ITEMS SHOP NOW')) : ?>
                            <p class="text-uppercase my-3 my-md-0">
                                <?php echo esc_html(get_theme_mod('expert_fitness_trainer_discount_text','GET 20% OFF ON SELECTED ITEMS SHOP NOW')); ?>
                            </p>
                        <?php endif; ?>
                    </div>
                    <div class="col-lg-3 col-md-4 col-sm-3 align-self-center text-lg-end">
                        <?php if (get_theme_mod('expert_fitness_trainer_mail','contact@example.com')) : ?>
                            <p class="mb-0 email-text">
                                <a href="mailto:<?php echo esc_attr(get_theme_mod('expert_fitness_trainer_mail','contact@example.com')); ?>">
                                    <i class="fas fa-envelope px-2"></i>
                                    <?php echo esc_html(get_theme_mod('expert_fitness_trainer_mail','contact@example.com')); ?>
                                </a>
                            </p>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    <?php endif; ?>

    <!-- Middle Header Section -->
    <div class="<?php if( get_theme_mod( 'expert_fitness_trainer_sticky_header', '0')) { ?>sticky-header<?php } else { ?>close-sticky<?php } ?>">
        <div class="middle-header-area py-2">
            <div class="container">
                <div class="row">
                    <div class="col-lg-3 col-md-4 logo-col text-md-start text-center align-self-center">
                        <div class="logo">
                        <?php 
                            if (has_custom_logo()) {
                                the_custom_logo();
                            } else {
                                // Check if both title and tagline settings are disabled
                                $expert_fitness_trainer_tagline_enabled = get_theme_mod('expert_fitness_trainer_tagline_setting', false);
                                $expert_fitness_trainer_title_enabled = get_theme_mod('expert_fitness_trainer_site_title_setting', true);

                                if (!$expert_fitness_trainer_tagline_enabled && !$expert_fitness_trainer_title_enabled) {
                                    // Display the default logo
                                    $expert_fitness_trainer_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($expert_fitness_trainer_default_logo_url) . '" alt="' . esc_attr(get_bloginfo('name')) . '">';
                                    echo '</a>';
                                }

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

                                <?php
                                // Display site title if the setting is enabled
                                if ($expert_fitness_trainer_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-7 col-md-4 menu-col align-self-center">
                        <div class="menubox">
                            <div class="navbar-menubar responsive-menu navigation_header">
                                <div class="toggle-nav mobile-menu">
                                    <button onclick="expert_fitness_trainer_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', 'expert-fitness-trainer' ); ?>">

                                        <?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="expert_fitness_trainer_closeNav()">
                                            <i class="fa-solid fa-times"></i> <!-- Close icon for the menu -->
                                        </a>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-2 col-md-4 text-md-end text-center align-self-center">
                        <?php 
                            $expert_fitness_trainer_header_button = get_theme_mod('expert_fitness_trainer_header_button', __('JOIN MEMBERSHIP', 'expert-fitness-trainer'));
                            $expert_fitness_trainer_header_link = get_theme_mod('expert_fitness_trainer_header_link', '#');

                            if (!empty($expert_fitness_trainer_header_button) || !empty($expert_fitness_trainer_header_link)) : ?>
                                <span class="header-btn text-center">
                                    <a target="_blank" href="<?php echo esc_url($expert_fitness_trainer_header_link); ?>" class="offer-text" rel="noopener noreferrer">
                                        <?php echo esc_html($expert_fitness_trainer_header_button); ?><i class="ms-2 fas fa-arrow-right"></i>
                                    </a>
                                </span>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>