<?php

$construction_hub_tp_theme_css = '';

// Get the primary color (1st color) from the theme customizer, with a fallback
$construction_hub_tp_color_option = get_theme_mod('construction_hub_tp_color_option', '#9105ea'); // Default primary color

// Get the secondary color (2nd color) from the theme customizer, with a fallback
$painting_contractor_tp_color_sec = get_theme_mod('painting_contractor_tp_color_sec', '#f73c95'); // Default secondary color

// Fallbacks if colors are not set
if (empty($construction_hub_tp_color_option)) {
    $construction_hub_tp_color_option = '#9105ea'; // Default primary color
}

if (empty($painting_contractor_tp_color_sec)) {
    $painting_contractor_tp_color_sec = '#f73c95 '; // Default secondary color
}

// Generate the CSS for the primary and secondary colors (1st and 2nd color)
$construction_hub_tp_theme_css .= ':root {';
$construction_hub_tp_theme_css .= '--color-primary1: ' . esc_attr($construction_hub_tp_color_option) . ';'; // Primary color
$construction_hub_tp_theme_css .= '--color-secondary1: ' . esc_attr($painting_contractor_tp_color_sec) . ';'; // Secondary color
$construction_hub_tp_theme_css .= '}';

// Generate the linear gradient CSS for specific elements
$construction_hub_tp_theme_css .= '.wc-block-checkout__actions_row .wc-block-components-checkout-place-order-button,
.woocommerce ul.products li.product .onsale, 
.woocommerce span.onsale,
.wc-block-cart__submit-container a,
#theme-sidebar button[type="submit"], 
.error-404 [type="submit"], 
#footer button[type="submit"],
.prev.page-numbers, 
.next.page-numbers,
.page-numbers,
.woocommerce #respond input#submit, 
.woocommerce a.button, 
.woocommerce button.button, 
.woocommerce input.button, 
.woocommerce #respond input#submit.alt, 
.woocommerce a.button.alt, 
.woocommerce button.button.alt, 
.woocommerce input.button.alt,
#comments input[type="submit"],
.main-navigation ul ul a:hover,
span.meta-nav,
.more-btn a,
#our_project i,
.search-box i,
.readmore-btn a, 
#footer .wp-calendar-table th, 
#secondary .wp-calendar-table th, 
.search-bar i, 
.search-outer .inner_searchbox button[type="submit"], 
a.added_to_cart.wc-forward{';

// Apply the linear gradient background using the two colors
$construction_hub_tp_theme_css .= 'background-image: linear-gradient(to right, ' 
    . esc_attr($construction_hub_tp_color_option) . ', ' 
    . esc_attr($painting_contractor_tp_color_sec) . ') !important;';

$construction_hub_tp_theme_css .= '}'; // Close the CSS block

// Output the generated CSS within a <style> tag
echo '<style>' . $construction_hub_tp_theme_css . '</style>';


//======================= slider Content layout ===================== //

$painting_contractor_slider_content_layout = get_theme_mod('painting_contractor_slider_content_layout', 'LEFT-ALIGN'); 
$construction_hub_tp_theme_css .= '#slider .carousel-caption{';
switch ($painting_contractor_slider_content_layout) {
    case 'LEFT-ALIGN':
        $construction_hub_tp_theme_css .= 'text-align:left; right: 40%; left: 15%';
        break;
    case 'CENTER-ALIGN':
        $construction_hub_tp_theme_css .= 'text-align:center; left: 25%; right: 25%';
        break;
    case 'RIGHT-ALIGN':
        $construction_hub_tp_theme_css .= 'text-align:right; left: 40%; right: 15%';
        break;
    default:
        $construction_hub_tp_theme_css .= 'text-align:left; right: 40%; left: 15%';
        break;
}
$construction_hub_tp_theme_css .= '}';

// logo tagline color
$construction_hub_site_title_color = get_theme_mod('construction_hub_site_title_color');

if($construction_hub_site_title_color != false){
$construction_hub_tp_theme_css .='.logo h1 a, .logo p.site-title a{';
$construction_hub_tp_theme_css .='color: '.esc_attr($construction_hub_site_title_color).';';
$construction_hub_tp_theme_css .='}';
}

$construction_hub_logo_tagline_color = get_theme_mod('construction_hub_logo_tagline_color');
if($construction_hub_logo_tagline_color != false){
$construction_hub_tp_theme_css .='p.site-description{';
$construction_hub_tp_theme_css .='color: '.esc_attr($construction_hub_logo_tagline_color).';';
$construction_hub_tp_theme_css .='}';
}

// footer widget title font size
    $construction_hub_footer_widget_title_font_size = get_theme_mod('construction_hub_footer_widget_title_font_size', '');{
    $construction_hub_tp_theme_css .='#footer h3, #footer h2.wp-block-heading{';
        $construction_hub_tp_theme_css .='font-size: '.esc_attr($construction_hub_footer_widget_title_font_size).'px !important;';
    $construction_hub_tp_theme_css .='}';
    }


// menu color
$construction_hub_menu_color = get_theme_mod('construction_hub_menu_color');
if($construction_hub_menu_color != false){
$construction_hub_tp_theme_css .='.main-navigation a{';
$construction_hub_tp_theme_css .='color: '.esc_attr($construction_hub_menu_color).';';
$construction_hub_tp_theme_css .='}';
}

/*------------------ Slider CSS -------------------*/
    $construction_hub_slider_opacity_setting = get_theme_mod('construction_hub_slider_opacity_setting', true);
    $construction_hub_image_opacity_color    = get_theme_mod('construction_hub_image_opacity_color', '');
    $construction_hub_slider_opacity         = get_theme_mod('construction_hub_slider_opacity', '1');

    if ($construction_hub_slider_opacity_setting) {
        // Apply opacity value to slider image
        if ($construction_hub_slider_opacity !== '') {
            $construction_hub_tp_theme_css .= '#slider img {';
            $construction_hub_tp_theme_css .= 'opacity: ' . esc_attr($construction_hub_slider_opacity) . ';';
            $construction_hub_tp_theme_css .= '}';
        }

        // Apply background color to slider if defined
        if ($construction_hub_image_opacity_color !== '') {
            $construction_hub_tp_theme_css .= '#slider {';
            $construction_hub_tp_theme_css .= 'background-color: ' . esc_attr($construction_hub_image_opacity_color) . ';';
            $construction_hub_tp_theme_css .= '}';
        }
    } else {
        // If setting is disabled, force full opacity
        $construction_hub_tp_theme_css .= '#slider img {';
        $construction_hub_tp_theme_css .= 'opacity: 1;';
        $construction_hub_tp_theme_css .= '}';
    }

    /*---------------------------Slider Height ------------*/
    $construction_hub_slider_img_height       = get_theme_mod('construction_hub_slider_img_height');
    $construction_hub_slider_img_height_resp  = get_theme_mod('construction_hub_slider_img_height_responsive');

    if ( $construction_hub_slider_img_height ) {
        $construction_hub_tp_theme_css .= '#slider img {';
        $construction_hub_tp_theme_css .= 'height: ' . esc_attr( $construction_hub_slider_img_height ) . ';';
        $construction_hub_tp_theme_css .= '}';
    }

    if ( $construction_hub_slider_img_height_resp ) {
        $construction_hub_tp_theme_css .= '@media only screen and (max-width: 767px) {';
        $construction_hub_tp_theme_css .= '#slider img {';
        $construction_hub_tp_theme_css .= 'height: ' . esc_attr( $construction_hub_slider_img_height_resp ) . '!important;';
        $construction_hub_tp_theme_css .= '}';
        $construction_hub_tp_theme_css .= '}';
    }
