<?php
function drivingschoolacademy_custom_header_setup() {
	add_theme_support( 'custom-header', apply_filters( 'drivingschoolacademy_custom_header_args', array(
		'default-image'      => '',
		'default-text-color' => 'fff',
		'width'              => 2000, 
		'height'             => 200,
		'flex-height'        => true,
		'wp-head-callback'   => 'drivingschoolacademy_header_style',
	) ) );
}
add_action( 'after_setup_theme', 'drivingschoolacademy_custom_header_setup' );

if ( ! function_exists( 'drivingschoolacademy_header_style' ) ) :

function drivingschoolacademy_header_style() {
	$header_text_color = get_header_textcolor();

	$topheader_logowidth = esc_attr(get_theme_mod('topheader_logowidth','auto'));

	$drivingschoolacademy_logo_top_padding    = esc_attr(get_theme_mod('drivingschoolacademy_logo_top_padding','2'));
	$drivingschoolacademy_logo_left_padding   = esc_attr(get_theme_mod('drivingschoolacademy_logo_left_padding','2'));
	$drivingschoolacademy_logo_bottom_padding = esc_attr(get_theme_mod('drivingschoolacademy_logo_bottom_padding','2'));
	$drivingschoolacademy_logo_right_padding  = esc_attr(get_theme_mod('drivingschoolacademy_logo_right_padding','2'));

  	$feature_disable_section    = esc_attr(get_theme_mod('feature_disable_section','YES'));
  	$ourservice_disable_section = esc_attr(get_theme_mod('ourservice_disable_section','YES'));
  	$aboutus_disable_section    = esc_attr(get_theme_mod('aboutus_disable_section','YES'));

	$custom_css = "";

	
	// Logo
	$custom_css .= "
	.site-logo img {
		width: {$topheader_logowidth};
		padding-top: {$drivingschoolacademy_logo_top_padding}px;
		padding-left: {$drivingschoolacademy_logo_left_padding}px;
		padding-bottom: {$drivingschoolacademy_logo_bottom_padding}px;
		padding-right: {$drivingschoolacademy_logo_right_padding}px;
	}
	";

	// Header colors
	$custom_css .= "
	header.site-header .site-title {
		color: " . esc_attr(get_theme_mod('topheader_sitetitlecol')) . ";
	}
	header.site-header .site-logo a {
		text-decoration-color: " . esc_attr(get_theme_mod('topheader_sitetitlecol')) . " !important;
	}
	p.site-description {
		color: " . esc_attr(get_theme_mod('topheader_taglinecol')) . ";
	}
	header .tphead {
		background: " . esc_attr(get_theme_mod('header_topheadtophbgcolor')) . ";
	}
	header .h-sectionbx {
		background: " . esc_attr(get_theme_mod('header_topheadbgcolor')) . ";
	}

	header .delsbx li a,header .delsbx li i,header .delsbx li p {
		color: " . esc_attr(get_theme_mod('header_topheadtextcolor')) . ";
	}
	header .delsbx li a:hover {
		color: " . esc_attr(get_theme_mod('header_topheadtexthvrcolor')) . ";
	}
	header .s-media li a {
		color: " . esc_attr(get_theme_mod('header_topheadsocialiconscolor')) . ";
	}
	header .s-media li a:hover {
		color: " . esc_attr(get_theme_mod('header_topheadsocialiconshvrcolor')) . ";
	}

	.main-header .navbar .navbar-menu ul li a, 
	.main-header .navbar .navbar-menu ul li.dropdown>a::after {
		color: " . esc_attr(get_theme_mod('header_menuscolor')) . ";
	}
	.main-header .navbar .navbar-nav > li:hover a, 
	.main-header .navbar .navbar-nav > li.focus a, 
	.main-header .navbar .navbar-nav > li.active a, 
	.main-header .navbar .navbar-nav > li a.active,
	.main-header .navbar .navbar-menu ul li:hover.dropdown>a::after {
		color: " . esc_attr(get_theme_mod('header_menushovercolor')) . ";
	}
	.main-header .navbar .navbar-menu ul li.dropdown .sub-menu a:not(.remove) {
		color: " . esc_attr(get_theme_mod('header_submenutextcolor')) . ";
	}
	.main-header .navbar .navbar-menu ul li.dropdown .sub-menu a {
		background: " . esc_attr(get_theme_mod('header_submenusbgcolor')) . ";
	}
	.main-header .navbar .navbar-menu ul li.dropdown .sub-menu a:not(.remove) {
		border-left-color: " . esc_attr(get_theme_mod('header_submenusbordercolor')) . ";
	}
	.main-header .navbar .navbar-menu ul li.dropdown .sub-menu a:hover {
		background: " . esc_attr(get_theme_mod('header_submenusbghovercolor')) . " !important;
		color: " . esc_attr(get_theme_mod('header_submenustxthovercolor')) . ";
	}
	header .bn-btn a {
		color: " . esc_attr(get_theme_mod('header_btntextcolor')) . ";
	}
	header .bn-btn a {
		background: " . esc_attr(get_theme_mod('header_buttonbg_color')) . ";
	}
	header .bn-btn a:hover {
		background: " . esc_attr(get_theme_mod('header_btnbghover_color')) . ";
	}
	";

	// Slider
	$custom_css .= "
	.hero-style .slide-title h2 {
		color: " . esc_attr(get_theme_mod('slider_titlecolor')) . " !important;
	}
	.hero-style .slide-text p {
		color: " . esc_attr(get_theme_mod('slider_descriptioncolor')) . ";
	}
	.hero-style a.contactus {
		color: " . esc_attr(get_theme_mod('slider_btntxt1color')) . ";
		background: " . esc_attr(get_theme_mod('slider_btntxt1bgcolor')) . ";
	}
	.hero-style a.contactus:hover {
		color: " . esc_attr(get_theme_mod('slider_btntxthrvcolor')) . " !important;
	}

	.hero-style a.view {
		color: " . esc_attr(get_theme_mod('slider_btntxt2color')) . ";
		background: " . esc_attr(get_theme_mod('slider_btntxt2bgcolor')) . ";
	}
	.hero-style a.view:hover {
		color: " . esc_attr(get_theme_mod('slider_btntxt2hrvcolor')) . " !important;
	}

	.next-sec-tab a {
		background: " . esc_attr(get_theme_mod('slider_scrolldownarrowbgcolor')) . " !important;
	}
	.hero-slider .driving_school_academyswiper-button-prev i, 
	.hero-slider .driving_school_academyswiper-button-next i {
		color: " . esc_attr(get_theme_mod('slider_arrowiconcolor')) . " !important;
	}
	.hero-slider .driving_school_academyswiper-button-prev, 
	.hero-slider .driving_school_academyswiper-button-next {
		background: " . esc_attr(get_theme_mod('slider_arrowiconbgcolor')) . " !important;
	}
	.hero-slider .driving_school_academyswiper-button-prev:hover i,
	.hero-slider .driving_school_academyswiper-button-next:hover i {
		color: " . esc_attr(get_theme_mod('slider_arrowiconhrvcolor')) . " !important;
	}
	";

	// Feature
	$custom_css .= "
	#feature-section .box-space i {
		color: " . esc_attr(get_theme_mod('feature_iconcolor')) . ";
	}
	#feature-section .box-space h3 {
		color: " . esc_attr(get_theme_mod('feature_titlecolor')) . ";
	}
	#feature-section .box-space:nth-child(odd) i {
		background: " . esc_attr(get_theme_mod('feature_box1bgcolor')) . ";
	}
	#feature-section .box-space:nth-child(even) i {
		background: " . esc_attr(get_theme_mod('feature_box2bgcolor')) . ";
	}
	";

	// Our Service
	$custom_css .= "
	#ourservice-section .heading h4 {
		color: " . esc_attr(get_theme_mod('ourservice_subheadingcolor')) . ";
	}
	#ourservice-section .heading h2 {
		color: " . esc_attr(get_theme_mod('ourservice_headingcolor')) . ";
	}
	#ourservice-section .heading p {
		color: " . esc_attr(get_theme_mod('ourservice_descriptioncolor')) . ";
	}
	#ourservice-section .ourtbx .single-ourservice h3 {
		color: " . esc_attr(get_theme_mod('ourservice_boxtitlecolor')) . ";
	}
	#ourservice-section .sercontbx p {
		color: " . esc_attr(get_theme_mod('ourservice_boxdescriptioncolor')) . ";
	}
	#ourservice-section .threebox:hover .sercontbx h3 {
		color: " . esc_attr(get_theme_mod('ourservice_boxtitlehvrcolor')) . ";
	}
	";

	// About us
	$custom_css .= "
	#aboutus-section .abt-subtitle h4 {
		color: " . esc_attr(get_theme_mod('aboutus_subtitlecolor')) . ";
	}
	#aboutus-section .abt-dbx h2 {
		color: " . esc_attr(get_theme_mod('aboutus_titlecolor')) . ";
	}
	#aboutus-section .abt-box p {
		color: " . esc_attr(get_theme_mod('aboutus_descriptioncolor')) . ";
	}
	#aboutus-section .lists p {
		color: " . esc_attr(get_theme_mod('aboutus_listcolor')) . ";
	}
	#aboutus-section .reg-label {
		color: " . esc_attr(get_theme_mod('aboutus_boxsubtitlecolor')) . ";
	}
	#aboutus-section .reg-number {
		color: " . esc_attr(get_theme_mod('aboutus_boxtitlecolor')) . ";
	}
	#aboutus-section .abtph {
		color: " . esc_attr(get_theme_mod('aboutus_btntextcolor')) . ";
		background: " . esc_attr(get_theme_mod('aboutus_btnbgcolor')) . ";
	}
	#aboutus-section .abtph:hover {
		color: " . esc_attr(get_theme_mod('aboutus_btntexthvrcolor')) . ";
	}
	#aboutus-section .learn {
		color: " . esc_attr(get_theme_mod('aboutus_btntext2color')) . ";
		background: " . esc_attr(get_theme_mod('aboutus_btn2bgcolor')) . ";
	}
	#aboutus-section .learn:hover {
		color: " . esc_attr(get_theme_mod('aboutus_btn2texthvrcolor')) . ";
	}
	";

	// Footer
	$custom_css .= "
	.footer-area {
		background: " . esc_attr(get_theme_mod('footer_bgcolor')) . ";
	}
	.copy-right p,.copy-right p a {
		color: " . esc_attr(get_theme_mod('footer_copyrightcolor')) . ";
	}
	.copy-right {
		border-color: " . esc_attr(get_theme_mod('footer_copyrightbrdcolor')) . ";
	}
	.footer-area .footer-widget .w-title {
		color: " . esc_attr(get_theme_mod('footer_widgettilecolor')) . ";
	}
	.footer-area .widget_text, .footer-area .widget_text p, .wp-block-latest-comments__comment-excerpt p, 
	.wp-block-latest-comments__comment-date, 
	.has-avatars .wp-block-latest-comments__comment .wp-block-latest-comments__comment-excerpt, 
	.has-avatars .wp-block-latest-comments__comment .wp-block-latest-comments__comment-meta,
	.footer-area .widget_block h1, 
	.footer-area .widget_block h2, 
	.footer-area .widget_block h3, 
	.footer-area .widget_block h4, 
	.footer-area .widget_block h5, 
	.footer-area .widget_block h6,
	.footer-area .footer-widget .widget:not(.widget_social_widget):not(.widget_tag_cloud) li a {
		color: " . esc_attr(get_theme_mod('footer_textcolor')) . ";
	}
	.footer-area li:before, 
	.page-template-home-template .footer-area li:before, 
	.page .footer-area li:before, 
	.single .footer-area li:before {
		color: " . esc_attr(get_theme_mod('footer_iconcolor')) . ";
	}
	.footer-area .footer-widget .widget:not(.widget_social_widget):not(.widget_tag_cloud) li a:hover {
		color: " . esc_attr(get_theme_mod('footer_listhovercolor')) . ";
	}
	.scroll-top i {
		color: " . esc_attr(get_theme_mod('footer_scrolltotopiconcolor')) . ";
	}
	.scroll-top {
		background: " . esc_attr(get_theme_mod('footer_scrolltotopiconbgcolor')) . ";
	}
	.scroll-top:hover {
		background: " . esc_attr(get_theme_mod('footer_scrolltotopiconbghrvcolor')) . ";
	}
	";

	// Header text
	if ( ! display_header_text() ) {
		$custom_css .= "
		.site-title,
		.site-description {
			position: absolute;
			clip: rect(1px,1px,1px,1px);
		}";
	} else {
		$custom_css .= "
		.breadcrumb-section h1, .breadcrumb-list li a, .breadcrumb-list li, breadcrumb-list span{
			color: #{$header_text_color} !important;
		}";
	}

	// Section disable
	if ( $feature_disable_section == 1 ) {
		$custom_css .= "#feature-section { display: none; }";
	} else {
		$custom_css .= "#feature-section { display: block; }";
	}
	if ( $ourservice_disable_section == 1 ) {
		$custom_css .= "#ourservice-section { display: none; }";
	} else {
		$custom_css .= "#ourservice-section { display: block; }";
	}
	if ( $aboutus_disable_section == 1 ) {
		$custom_css .= "#aboutus-section { display: none; }";
	} else {
		$custom_css .= "#aboutus-section { display: block; }";
	}

	// Add inline style
	if ( ! empty( $custom_css ) ) {
		wp_add_inline_style( 'drivingschoolacademy-style', $custom_css );
	}
}
endif;
add_action( 'wp_enqueue_scripts', 'drivingschoolacademy_header_style' );
