<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

if ( ! cleaning_services_agent_has_page_header() ) {
    return;
}

$cleaning_services_agent_classes = array( 'page-header' );
$cleaning_services_agent_style = cleaning_services_agent_page_header_style();

if ( $cleaning_services_agent_style ) {
    $cleaning_services_agent_classes[] = $cleaning_services_agent_style . '-page-header';
}

$cleaning_services_agent_visibility = get_theme_mod( 'cleaning_services_agent_page_header_visibility', 'all-devices' );

if ( 'hide-all-devices' === $cleaning_services_agent_visibility ) {
    // Don't show the header at all
    return;
}

if ( 'hide-tablet' === $cleaning_services_agent_visibility ) {
    $cleaning_services_agent_classes[] = 'hide-on-tablet';
} elseif ( 'hide-mobile' === $cleaning_services_agent_visibility ) {
    $cleaning_services_agent_classes[] = 'hide-on-mobile';
} elseif ( 'hide-tablet-mobile' === $cleaning_services_agent_visibility ) {
    $cleaning_services_agent_classes[] = 'hide-on-tablet-mobile';
}

$cleaning_services_agent_PAGE_TITLE_background_color = get_theme_mod('cleaning_services_agent_page_title_background_color_setting', '');

// Get the toggle switch value
$cleaning_services_agent_background_image_enabled = get_theme_mod('cleaning_services_agent_page_header_style', true);

// Add background image to the header if enabled
$cleaning_services_agent_background_image = get_theme_mod( 'cleaning_services_agent_page_header_background_image', '' );
$cleaning_services_agent_background_height = get_theme_mod( 'cleaning_services_agent_page_header_image_height', '200' );
$cleaning_services_agent_inline_style = '';

if ( $cleaning_services_agent_background_image_enabled && ! empty( $cleaning_services_agent_background_image ) ) {
    $cleaning_services_agent_inline_style .= 'background-image: url(' . esc_url( $cleaning_services_agent_background_image ) . '); ';
    $cleaning_services_agent_inline_style .= 'height: ' . esc_attr( $cleaning_services_agent_background_height ) . 'px; ';
    $cleaning_services_agent_inline_style .= 'background-size: cover; ';
    $cleaning_services_agent_inline_style .= 'background-position: center center; ';

    // Add the unique class if the background image is set
    $cleaning_services_agent_classes[] = 'has-background-image';
}

$cleaning_services_agent_classes = implode( ' ', $cleaning_services_agent_classes );
$cleaning_services_agent_heading = get_theme_mod( 'cleaning_services_agent_page_header_heading_tag', 'h1' );
$cleaning_services_agent_heading = apply_filters( 'cleaning_services_agent_page_header_heading', $cleaning_services_agent_heading );

?>

<?php do_action( 'cleaning_services_agent_before_page_header' ); ?>

<header class="<?php echo esc_attr( $cleaning_services_agent_classes ); ?>" style="<?php echo esc_attr( $cleaning_services_agent_inline_style ); ?> background-color: <?php echo esc_attr($cleaning_services_agent_PAGE_TITLE_background_color); ?>;">

    <?php do_action( 'cleaning_services_agent_before_page_header_inner' ); ?>

    <div class="asterthemes-wrapper page-header-inner">

        <?php if ( cleaning_services_agent_has_page_header() ) : ?>

            <<?php echo esc_attr( $cleaning_services_agent_heading ); ?> class="page-header-title">
                <?php echo wp_kses_post( cleaning_services_agent_get_page_title() ); ?>
            </<?php echo esc_attr( $cleaning_services_agent_heading ); ?>>

        <?php endif; ?>

        <?php if ( function_exists( 'cleaning_services_agent_breadcrumb' ) ) : ?>
            <?php cleaning_services_agent_breadcrumb(); ?>
        <?php endif; ?>

    </div><!-- .page-header-inner -->

    <?php do_action( 'cleaning_services_agent_after_page_header_inner' ); ?>

</header><!-- .page-header -->

<?php do_action( 'cleaning_services_agent_after_page_header' ); ?>