<?php

$local_supermarket_custom_css = "";

	$local_supermarket_theme_pagination_options_alignment = get_theme_mod('local_supermarket_theme_pagination_options_alignment', 'Center');
	if ($local_supermarket_theme_pagination_options_alignment == 'Center') {
		$local_supermarket_custom_css .= '.navigation.pagination,.navigation.posts-navigation .nav-links{';
		$local_supermarket_custom_css .= 'justify-content: center;margin: 0 auto;';
		$local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_theme_pagination_options_alignment == 'Right') {
		$local_supermarket_custom_css .= '.navigation.pagination,.navigation.posts-navigation .nav-links{';
		$local_supermarket_custom_css .= 'justify-content: right;margin: 0 0 0 auto;';
		$local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_theme_pagination_options_alignment == 'Left') {
		$local_supermarket_custom_css .= '.navigation.pagination,.navigation.posts-navigation .nav-links{';
		$local_supermarket_custom_css .= 'justify-content: left;margin: 0 auto 0 0;';
		$local_supermarket_custom_css .= '}';
	}

	$local_supermarket_theme_breadcrumb_enable = get_theme_mod('local_supermarket_theme_breadcrumb_enable',true);
    if($local_supermarket_theme_breadcrumb_enable != true){
        $local_supermarket_custom_css .='nav.breadcrumb-trail.breadcrumbs,nav.woocommerce-breadcrumb{';
            $local_supermarket_custom_css .='display: none;';
        $local_supermarket_custom_css .='}';
    }

	$local_supermarket_theme_breadcrumb_options_alignment = get_theme_mod('local_supermarket_theme_breadcrumb_options_alignment', 'Left');
	if ($local_supermarket_theme_breadcrumb_options_alignment == 'Center') {
	    $local_supermarket_custom_css .= '.breadcrumbs ul,nav.woocommerce-breadcrumb{';
	    $local_supermarket_custom_css .= 'text-align: center !important;';
	    $local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_theme_breadcrumb_options_alignment == 'Right') {
	    $local_supermarket_custom_css .= '.breadcrumbs ul,nav.woocommerce-breadcrumb{';
	    $local_supermarket_custom_css .= 'text-align: Right !important;';
	    $local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_theme_breadcrumb_options_alignment == 'Left') {
	    $local_supermarket_custom_css .= '.breadcrumbs ul,nav.woocommerce-breadcrumb{';
	    $local_supermarket_custom_css .= 'text-align: Left !important;';
	    $local_supermarket_custom_css .= '}';
	}

	$local_supermarket_single_page_content_alignment = get_theme_mod('local_supermarket_single_page_content_alignment', 'left');
	if ($local_supermarket_single_page_content_alignment == 'left') {
	    $local_supermarket_custom_css .= '#single-page .type-page,section.theme-custom-block.theme-error-sectiontheme-error-section.error-block-middle,section.theme-custom-block.theme-error-section.error-block-heading .theme-area-header{';
	    $local_supermarket_custom_css .= 'text-align: left !important;';
	    $local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_single_page_content_alignment == 'center') {
	    $local_supermarket_custom_css .= '#single-page .type-page,section.theme-custom-block.theme-error-sectiontheme-error-section.error-block-middle,section.theme-custom-block.theme-error-section.error-block-heading .theme-area-header{';
	    $local_supermarket_custom_css .= 'text-align: center !important;';
	    $local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_single_page_content_alignment == 'right') {
	    $local_supermarket_custom_css .= '#single-page .type-page,section.theme-custom-block.theme-error-sectiontheme-error-section.error-block-middle,section.theme-custom-block.theme-error-section.error-block-heading .theme-area-header{';
	    $local_supermarket_custom_css .= 'text-align: right !important;';
	    $local_supermarket_custom_css .= '}';
	}

	$local_supermarket_single_post_content_alignment = get_theme_mod('local_supermarket_single_post_content_alignment', 'left');
	if ($local_supermarket_single_post_content_alignment == 'left') {
	    $local_supermarket_custom_css .= '#single-page .type-post,#single-page .type-post .entry-meta,#single-page .type-post .is-layout-flex{';
	    $local_supermarket_custom_css .= 'text-align: left !important;justify-content: left;';
	    $local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_single_post_content_alignment == 'center') {
	    $local_supermarket_custom_css .= '#single-page .type-post,#single-page .type-post .entry-meta,#single-page .type-post .is-layout-flex{';
	    $local_supermarket_custom_css .= 'text-align: center !important;justify-content: center;';
	    $local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_single_post_content_alignment == 'right') {
	    $local_supermarket_custom_css .= '#single-page .type-post,#single-page .type-post .entry-meta,#single-page .type-post .is-layout-flex{';
	    $local_supermarket_custom_css .= 'text-align: right !important;justify-content: right;';
	    $local_supermarket_custom_css .= '}';
	}

	$local_supermarket_menu_text_transform = get_theme_mod('local_supermarket_menu_text_transform', 'capitalize');
	if ($local_supermarket_menu_text_transform == 'capitalize') {
	    $local_supermarket_custom_css .= '.site-navigation .primary-menu > li a{';
	    $local_supermarket_custom_css .= 'text-transform: capitalize !important;';
	    $local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_menu_text_transform == 'uppercase') {
	    $local_supermarket_custom_css .= '.site-navigation .primary-menu > li a{';
	    $local_supermarket_custom_css .= 'text-transform: uppercase !important;';
	    $local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_menu_text_transform == 'lowercase') {
	    $local_supermarket_custom_css .= '.site-navigation .primary-menu > li a{';
	    $local_supermarket_custom_css .= 'text-transform: lowercase !important;';
	    $local_supermarket_custom_css .= '}';
	}

	$local_supermarket_footer_widget_title_alignment = get_theme_mod('local_supermarket_footer_widget_title_alignment', 'left');
	if ($local_supermarket_footer_widget_title_alignment == 'left') {
	    $local_supermarket_custom_css .= 'h2.widget-title{';
	    $local_supermarket_custom_css .= 'text-align: left !important;';
	    $local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_footer_widget_title_alignment == 'center') {
	    $local_supermarket_custom_css .= 'h2.widget-title{';
	    $local_supermarket_custom_css .= 'text-align: center !important;';
	    $local_supermarket_custom_css .= '}';
	} else if ($local_supermarket_footer_widget_title_alignment == 'right') {
	    $local_supermarket_custom_css .= 'h2.widget-title{';
	    $local_supermarket_custom_css .= 'text-align: right !important;';
	    $local_supermarket_custom_css .= '}';
	}

    $local_supermarket_show_hide_related_product = get_theme_mod('local_supermarket_show_hide_related_product',true);
    if($local_supermarket_show_hide_related_product != true){
        $local_supermarket_custom_css .='.related.products{';
            $local_supermarket_custom_css .='display: none;';
        $local_supermarket_custom_css .='}';
    }

	$local_supermarket_sticky_sidebar = get_theme_mod('local_supermarket_sticky_sidebar',true);
    if($local_supermarket_sticky_sidebar != true){
        $local_supermarket_custom_css .='.widget-area-wrapper{';
            $local_supermarket_custom_css .='position: relative !important;';
        $local_supermarket_custom_css .='}';
    }

	/*-------------------- Global First Color -------------------*/

	$local_supermarket_global_color = get_theme_mod('local_supermarket_global_color', '#6EBA55 '); // Add a fallback if the color isn't set

	if ($local_supermarket_global_color) {
		$local_supermarket_custom_css .= ':root {';
		$local_supermarket_custom_css .= '--global-color: ' . esc_attr($local_supermarket_global_color) . ';';
		$local_supermarket_custom_css .= '}';
	}

	$local_supermarket_global_secondary_color = get_theme_mod('local_supermarket_global_secondary_color', '#1a1a1a'); // Add a fallback if the color isn't set

	if ($local_supermarket_global_secondary_color) {
		$local_supermarket_custom_css .= ':root {';
		$local_supermarket_custom_css .= '--secondary-color: ' . esc_attr($local_supermarket_global_secondary_color) . ';';
		$local_supermarket_custom_css .= '}';
	}

	$local_supermarket_global_third_color = get_theme_mod('local_supermarket_global_third_color', '#FFD239'); // Add a fallback if the color isn't set

	if ($local_supermarket_global_third_color) {
		$local_supermarket_custom_css .= ':root {';
		$local_supermarket_custom_css .= '--third-color: ' . esc_attr($local_supermarket_global_third_color) . ';';
		$local_supermarket_custom_css .= '}';
	}
	
	/*-------------------- Content Font -------------------*/

	$local_supermarket_font_map = array(
		'bad-script' => 'Bad Script',
		'inter'      => 'Inter',
		'bitter'     => 'Bitter',
		'charis-sil' => 'Charis SIL',
		'cuprum'     => 'Cuprum',
		'exo-2'      => 'Exo 2',
		'jost'       => 'Jost',
		'montserrat' => 'Montserrat',
		'open-sans'  => 'Open Sans',
		'oswald'     => 'Oswald',
		'play'       => 'Play',
		'roboto'     => 'Roboto',
		'outfit'     => 'Outfit',
		'ubuntu'     => 'Ubuntu',
		'saira'      => 'Saira',
		'cinzel'     => 'Cinzel',
		'figtree'    => 'Figtree',
		'noto-sans'  => 'Noto Sans',
	);

	$local_supermarket_content_typography_font = sanitize_key( get_theme_mod('local_supermarket_content_typography_font', 'noto-sans') ); // Add a fallback if the color isn't set
	if ( ! isset( $local_supermarket_font_map[ $local_supermarket_content_typography_font ] ) ) {
		$local_supermarket_content_typography_font = 'noto-sans';
	}

	if ($local_supermarket_content_typography_font) {
		$local_supermarket_custom_css .= ':root {';
		$local_supermarket_custom_css .= '--font-main: "' . esc_attr( $local_supermarket_font_map[ $local_supermarket_content_typography_font ] ) . '", ' . ( in_array( $local_supermarket_content_typography_font, array( 'bitter', 'charis-sil' ), true ) ? 'serif' : 'sans-serif' ) . ';';
		$local_supermarket_custom_css .= '}';
	}

	/*-------------------- Heading Font -------------------*/

	$local_supermarket_heading_typography_font = sanitize_key( get_theme_mod('local_supermarket_heading_typography_font', 'noto-sans') ); // Add a fallback if the color isn't set
	if ( ! isset( $local_supermarket_font_map[ $local_supermarket_heading_typography_font ] ) ) {
		$local_supermarket_heading_typography_font = 'noto-sans';
	}

	if ($local_supermarket_heading_typography_font) {
		$local_supermarket_custom_css .= ':root {';
		$local_supermarket_custom_css .= '--font-head: "' . esc_attr( $local_supermarket_font_map[ $local_supermarket_heading_typography_font ] ) . '", ' . ( in_array( $local_supermarket_heading_typography_font, array( 'bitter', 'charis-sil' ), true ) ? 'serif' : 'sans-serif' ) . ';';
		$local_supermarket_custom_css .= '}';
	}

	/*-------------------- FOOTER -------------------*/

	$local_supermarket_footer_widget_background_color = get_theme_mod('local_supermarket_footer_widget_background_color');
    if ($local_supermarket_footer_widget_background_color) {

        $local_supermarket_custom_css .= "
            .footer-widgetarea {
                background-color: ". esc_attr($local_supermarket_footer_widget_background_color) .";
            }
        ";
    }

    $local_supermarket_footer_widget_background_image = get_theme_mod('local_supermarket_footer_widget_background_image');
	if ($local_supermarket_footer_widget_background_image) {
		$local_supermarket_custom_css .= "
			.footer-widgetarea {
				background-image: url(" . esc_url($local_supermarket_footer_widget_background_image) . ");
			}
		";
	}

    $local_supermarket_copyright_font_size = get_theme_mod('local_supermarket_copyright_font_size');
    if ($local_supermarket_copyright_font_size) {

        $local_supermarket_custom_css .= "
            .footer-copyright {
                font-size: ". esc_attr($local_supermarket_copyright_font_size) ."px;
            }
        ";
    }

	$local_supermarket_columns = get_theme_mod('local_supermarket_posts_per_columns', 3);
    $local_supermarket_columns = absint($local_supermarket_columns);
    if ( $local_supermarket_columns < 1 || $local_supermarket_columns > 6 ) {
        $local_supermarket_columns = 3;
    }
    $local_supermarket_custom_css .= "
        .site-content .article-wraper-archive {
            grid-template-columns: repeat({$local_supermarket_columns}, 1fr);
        }
    ";

	$local_supermarket_copyright_alignment = get_theme_mod( 'local_supermarket_copyright_alignment', 'Default' );
	if ( $local_supermarket_copyright_alignment === 'Reverse' ) {
		$local_supermarket_custom_css .= '.site-info .column-row { flex-direction: row-reverse; }';
		$local_supermarket_custom_css .= '.footer-credits { justify-content: flex-end; }';
		$local_supermarket_custom_css .= '.footer-copyright { text-align: right; }';
		$local_supermarket_custom_css .= '.site-info .column.column-3 { text-align: left; }';
	} elseif ( $local_supermarket_copyright_alignment === 'Center' ) {
		$local_supermarket_custom_css .= '.site-info .column-row { flex-direction: column; align-items: center; gap: 15px; }';
		$local_supermarket_custom_css .= '.footer-credits { justify-content: center; }';
		$local_supermarket_custom_css .= '.footer-copyright { text-align: center; }';
		$local_supermarket_custom_css .= '.site-info .column.column-3 { text-align: center; }';
	}