<?php
/**
 * The header for our theme
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package property_dealer
 */

$property_dealer_menu_text_color = get_theme_mod('property_dealer_menu_text_color'); 
$property_dealer_sub_menu_text_color = get_theme_mod('property_dealer_sub_menu_text_color'); 
?>
<!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="https://gmpg.org/xfn/11">
    
	<?php wp_head(); ?>
</head>

<body <?php body_class(get_theme_mod('property_dealer_website_layout', false) ? 'site-boxed--layout' : ''); ?>>
<?php wp_body_open(); ?>
<div id="page" class="site asterthemes-site-wrapper">
<a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'property-dealer' ); ?></a>
    <?php if (get_theme_mod('property_dealer_enable_preloader', false)) : ?>
        <div id="loader" class="<?php echo esc_attr(get_theme_mod('property_dealer_preloader_style', 'style1')); ?>">
            <div class="loader-container">
                <div id="preloader">
                    <?php 
                    $property_dealer_preloader_style = get_theme_mod('property_dealer_preloader_style', 'style1');
                    if ($property_dealer_preloader_style === 'style1') : ?>
                        <!-- STYLE 1 -->
                        <img src="<?php echo esc_url(get_template_directory_uri() . '/resource/loader.gif'); ?>" alt="<?php esc_attr_e('Loading...', 'property-dealer'); ?>">
                    <?php elseif ($property_dealer_preloader_style === 'style2') : ?>
                        <!-- STYLE 2 -->
                        <div class="dot"></div>
                    <?php elseif ($property_dealer_preloader_style === 'style3') : ?>
                        <!-- STYLE 3 -->
                        <div class="bars">
                            <div class="bar"></div>
                            <div class="bar"></div>
                            <div class="bar"></div>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    <?php endif; ?>
        <header id="masthead" class="site-header">
            <div class="header-main-wrapper">
                <?php
                    // Location
                    $property_dealer_header_location_text = get_theme_mod( 'property_dealer_location_text' );
                    $property_dealer_header_location      = get_theme_mod( 'property_dealer_location_value' ); 
                    $property_dealer_location_icon        = get_theme_mod( 'property_dealer_header_location_icon', 'fas fa-map-marker-alt' );

                    // Phone
                    $property_dealer_phone_text   = get_theme_mod( 'property_dealer_phone_number_text' );
                    $property_dealer_phone_number = get_theme_mod( 'property_dealer_phone_number' );
                    $property_dealer_phone_icon   = get_theme_mod( 'property_dealer_header_phone_icon', 'fas fa-phone' );

                    // Time
                    $property_dealer_header_time_text = get_theme_mod( 'property_dealer_time_text' );
                    $property_dealer_header_time      = get_theme_mod( 'property_dealer_time_value' ); 
                    $property_dealer_time_icon        = get_theme_mod( 'property_dealer_header_time_icon', 'far fa-clock' );
                ?>
                <div class="top-header-part">
                    <div class="asterthemes-wrapper">
                        <div class="top-header-part-wrapper">
                            <div class="top-header-left-part">
                                <div class="site-branding">
                                    <?php
                                    // Check if the 'Enable Site Logo' setting is true.
                                    if ( get_theme_mod( 'property_dealer_enable_site_logo', true ) ) {
                                        if ( has_custom_logo() ) { ?>
                                            <div class="site-logo">
                                                <?php the_custom_logo(); ?>
                                            </div>
                                        <?php } else { ?>
                                            <div class="site-logo">
                                                <!-- Fallback logo if no custom logo is set -->
                                                <a href="<?php echo esc_url(home_url('/')); ?>" rel="home">
                                                    <img src="<?php echo esc_url(get_template_directory_uri() . '/resource/img/Logo.png'); ?>" alt="<?php bloginfo('name'); ?>">
                                                </a>
                                            </div>
                                        <?php }
                                    } ?>
                                    <div class="site-identity">
                                        <?php
                                        $property_dealer_site_title_size = get_theme_mod('property_dealer_site_title_size', 35);
                                        if ( get_theme_mod('property_dealer_enable_site_title_setting', false) ) {
                                            if ( is_front_page() && is_home() ) { ?>
                                                <h1 class="site-title" style="font-size: <?php echo esc_attr($property_dealer_site_title_size); ?>px;">
                                                    <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                                                </h1>
                                            <?php } else { ?>
                                                <p class="site-title" style="font-size: <?php echo esc_attr($property_dealer_site_title_size); ?>px;">
                                                    <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                                                </p>
                                            <?php }
                                        }
                                        if ( get_theme_mod('property_dealer_enable_tagline_setting', false) ) :
                                            $property_dealer_description = get_bloginfo('description', 'display');
                                            if ( $property_dealer_description || is_customize_preview() ) : ?>
                                                <p class="site-description"><?php echo esc_html($property_dealer_description); ?></p>
                                            <?php endif;
                                        endif;
                                        ?>
                                    </div>
                                </div>
                            </div>
                            <div class="top-header-right-part">
                                <!-- Location -->
                                <?php if ( ! empty( $property_dealer_header_location ) ) { ?>
                                    <div class="topbar-location">
                                        <a href="https://www.google.com/maps/search/<?php echo urlencode( $property_dealer_header_location ); ?>">
                                            <i class="<?php echo esc_attr( $property_dealer_location_icon ); ?>"></i>
                                            <div class="location-info">
                                                <span class="location-text"><?php echo esc_html( $property_dealer_header_location ); ?></span>
                                                <?php if ( ! empty( $property_dealer_header_location_text ) ) { ?>
                                                    <span><?php echo esc_html( $property_dealer_header_location_text ); ?>:</span>
                                                <?php } ?>
                                            </div>
                                        </a>
                                    </div>
                                <?php } ?>

                                <!-- Phone -->
                                <?php if ( ! empty( $property_dealer_phone_number ) ) { ?>
                                    <div class="topbar-phone">
                                            <div>
                                                <a href="tel:<?php echo esc_attr( substr( $property_dealer_phone_number, 0, 21 ) ); ?>">
                                                <i class="<?php echo esc_attr( $property_dealer_phone_icon ); ?>"></i>
                                            </div>
                                            <div class="phone-info">
                                                <span class="phone-text"><?php echo esc_html( substr( $property_dealer_phone_number, 0, 21 ) ); ?></span>
                                                <?php if ( ! empty( $property_dealer_phone_text ) ) { ?>
                                                    <span><?php echo esc_html( $property_dealer_phone_text ); ?>:</span>
                                                <?php } ?>
                                            </div>
                                        </a>
                                    </div>
                                <?php } ?>

                                <!-- Time -->
                                <?php if ( ! empty( $property_dealer_header_time ) ) { ?>
                                    <div class="topbar-time" tabindex="0">
                                        <i class="<?php echo esc_attr( $property_dealer_time_icon ); ?>"></i>
                                        <div class="time-info">
                                            <span class="time-text"><?php echo esc_html( $property_dealer_header_time ); ?></span>
                                            <?php if ( ! empty( $property_dealer_header_time_text ) ) { ?>
                                                <span><?php echo esc_html( $property_dealer_header_time_text ); ?>:</span>
                                            <?php } ?>
                                        </div>
                                    </div>
                                <?php } ?>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="bottom-header-outer-wrapper">
                    <div class="bottom-header-part <?php echo esc_attr( get_theme_mod( 'property_dealer_enable_sticky_header', false ) ? 'sticky-header' : '' ); ?>">
                        <div class="asterthemes-wrapper">
                            <div class="bottom-header-part-wrapper hello">
                                <div class="navigation-menus">
                                    <div class="navigation-part">
                                        <nav id="site-navigation" class="main-navigation">
                                            <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                                                <span></span>
                                                <span></span>
                                                <span></span>
                                            </button>
                                            <div class="main-navigation-links">
                                                <?php
                                                    wp_nav_menu(
                                                        array(
                                                            'theme_location' => 'primary',
                                                        )
                                                    );
                                                ?>
                                            </div>
                                            <style>
                                                /* Main Menu Links */
                                                .main-navigation ul li a, .menu a {
                                                    color: <?php echo esc_attr($property_dealer_menu_text_color); ?>;
                                                }

                                                /* Submenu Links */
                                                .main-navigation ul.children a, 
                                                .home .main-navigation ul.children a, 
                                                .main-navigation ul.menu li .sub-menu a, 
                                                .home .main-navigation ul ul a {
                                                    color: <?php echo esc_attr($property_dealer_sub_menu_text_color); ?>;
                                                }
                                            </style>
                                        </nav>
                                    </div>
                                </div>
                                <div class="bottom-header-right-part">
                                    <?php if ( get_theme_mod( 'property_dealer_enable_header_icon_section', false ) === true ) { ?>
                                        <div class="social-icons">
                                            <?php if ( get_theme_mod('property_dealer_header_facebook_link')) { ?>
                                                <a target="_blank" href="<?php echo esc_url(get_theme_mod('property_dealer_header_facebook_link')); ?>">
                                                    <i class="<?php echo esc_attr(get_theme_mod('property_dealer_header_facebook_icon', 'fab fa-facebook-square')); ?>"></i>
                                                    <span class="screen-reader-text"><?php esc_html_e('Facebook', 'property-dealer'); ?></span>
                                                </a>
                                            <?php } ?>
                                            <?php if ( get_theme_mod('property_dealer_header_twitter_link')) { ?>
                                                <a target="_blank" href="<?php echo esc_url(get_theme_mod('property_dealer_header_twitter_link')); ?>">
                                                    <i class="<?php echo esc_attr(get_theme_mod('property_dealer_header_twitter_icon', 'fab fa-twitter')); ?>"></i>
                                                    <span class="screen-reader-text"><?php esc_html_e('Twitter', 'property-dealer'); ?></span>
                                                </a>
                                            <?php } ?>
                                            <?php if ( get_theme_mod('property_dealer_header_linkedin_link')) { ?>
                                                <a target="_blank" href="<?php echo esc_url(get_theme_mod('property_dealer_header_linkedin_link')); ?>">
                                                    <i class="<?php echo esc_attr(get_theme_mod('property_dealer_header_linkedin_icon', 'fab fa-linkedin')); ?>"></i>
                                                    <span class="screen-reader-text"><?php esc_html_e('Linkedin', 'property-dealer'); ?></span>
                                                </a>
                                            <?php } ?>
                                            <?php if ( get_theme_mod('property_dealer_header_instagram_link')) { ?>
                                                <a target="_blank" href="<?php echo esc_url(get_theme_mod('property_dealer_header_instagram_link')); ?>">
                                                    <i class="<?php echo esc_attr(get_theme_mod('property_dealer_header_instagram_icon', 'fab fa-instagram')); ?>"></i>
                                                    <span class="screen-reader-text"><?php esc_html_e('Instagram', 'property-dealer'); ?></span>
                                                </a>
                                            <?php } ?>
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>     
            </div>
        </header>
<?php
if ( ! is_front_page() || is_home() ) {
	if ( is_front_page() ) {
		require get_template_directory() . '/sections/sections.php';
		property_dealer_homepage_sections();

	}
	?>
    <?php
        if (!is_front_page() || is_home()) {
            get_template_part('page-header');
        }
    ?>
	<div id="content" class="site-content">
		<div class="asterthemes-wrapper">
			<div class="asterthemes-page">
			<?php } ?>