<?php
if (!defined('ABSPATH'))
{
	exit; // Exit if accessed directly
}
if (!function_exists('ethrik_theme_inline_style')):
	function ethrik_theme_inline_style() {
		wp_enqueue_style('ethrik-custom-style', get_template_directory_uri() . '/assets/css/custom-style.css');

		$default_gradient_enable = ethrik_get_customize_option('default_gradient_enable');
		$gradient_one = ethrik_get_customize_option('gradient_one');
		$gradient_two = ethrik_get_customize_option('gradient_two');
		$theme_main_color = ethrik_get_customize_option('theme_main_color');
		$theme_preloader_spinner = ethrik_get_customize_option('theme_preloader_spinner');
		$custom_css = '';

		if($default_gradient_enable == false ) {
			if (!empty($gradient_one) and !empty($gradient_two) ) {
				
				$custom_css .= ' a.banner-btn-one, .footer-submit, .backto, .custom-themee-contactt .fsubmitt, a.nft-buy-now-btn, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt, .woocommerce #respond input#submit, .woocommerce a.button, .woocommerce input.button, .woocommerce button.button.alt.disabled, .wp-block-search .wp-block-search__button, .blog-post-comment .comment-respond .comment-form .btn-comments {
					background: linear-gradient(90deg, ' . esc_attr($gradient_one) . ' 0%, ' . esc_attr($gradient_two) . ' 100%)!important;
					}';
				
				$custom_css .= ' a.banner-btn-one:hover, .footer-submit:hover, .backto:hover, .custom-themee-contactt .fsubmitt:hover, a.nft-buy-now-btn:hover, .woocommerce #respond input#submit.alt:hover, .woocommerce a.button.alt:hover, .woocommerce button.button.alt:hover, .woocommerce input.button.alt:hover, .woocommerce #respond input#submit:hover, .woocommerce a.button:hover, .woocommerce input.button:hover, .woocommerce button.button.alt.disabled:hover, .widget_block.widget_search .wp-block-search__button:hover, .blog-post-comment .comment-respond .comment-form .btn-comments:hover {
					background: linear-gradient(90deg, ' . esc_attr($gradient_two) . ' 0%, ' . esc_attr($gradient_one) . ' 100%)!important;
				}';
				
				
				$custom_css .= ' .header-create-nft-btn a:after {
						background-image: linear-gradient(to right, ' . esc_attr($gradient_one) . ' 0%, ' . esc_attr($gradient_two) . ' 100%)!important;
				}';
			}
		}
		if (!empty($theme_main_color)) {
			$custom_css .= ' .nft-page .navigation.pagination .page-numbers.current {background: ' . esc_attr($theme_main_color) . '!important;}';

			$custom_css .= ' .blog-sidebar .widget ul li::before, .main-container .theme-pagination-style ul.page-numbers li span.current, .main-container .theme-pagination-style ul.page-numbers li a.page-numbers:hover, .comments-list .comment-reply-link:hover, .nft-page .navigation.pagination span:hover, .nft-page .navigation.pagination a:hover, .nft-page .navigation.pagination .page-numbers.current {background-color: ' . esc_attr($theme_main_color) . '!important;}';
				
			$custom_css .= '.header-login-btn a:hover, .search-form-main form button.hsearch-button:hover, .nav-menu-wrapper .mainmenu ul li a:hover, .slide-arrow-left.slick-arrow:hover, .slide-arrow-right.slick-arrow:hover, body.page .theme-page-spacing .entry-content .nft-cat-box-inner h3 a:hover, body.page .theme-page-spacing .entry-content .nf-grid-inner-top h3.post-title a:hover, .woocommerce ul.products li.product .woocommerce-loop-product__title a:hover, .woocommerce-page ul.products li.product .woocommerce-loop-product__title a:hover, .footer-social a:hover, .blog-sidebar .widget ul li a:hover, .tagcloud a:hover, .wp-block-tag-cloud a:hover, .post-block-wrapper-latest h3.post-title a:hover, .blog-details-content ul li::marker, .theme-tags__wrapper a:hover, #comments .comment-content a, .nft-page .navigation.pagination .next.page-numbers, .nft-page .navigation.pagination .prev.page-numbers, body.likhun-dark .nav-menu-wrapper .mainmenu li ul.sub-menu a:hover, ul.main-responsive-menu a:hover {color: ' . esc_attr($theme_main_color) . '!important;}';
			
			$custom_css .= '.header-create-nft-btn a, a.discover-nft-btn, .tagcloud a:hover, .wp-block-tag-cloud a:hover, .main-container .theme-pagination-style ul.page-numbers li span.current, .main-container .theme-pagination-style ul.page-numbers li a.page-numbers:hover, .theme-tags__wrapper a:hover, .nft-page .navigation.pagination span:hover, .nft-page .navigation.pagination a:hover, .nft-page .navigation.pagination .page-numbers.current {border-color: ' . esc_attr($theme_main_color) . '!important;}';
		}
		if (!empty($theme_preloader_spinner)) {
			$custom_css .= '.theme-preloader-style .animation-preloader .spinner {border-color: ' . esc_attr($theme_preloader_spinner) . ';}';
		}

		// Get Category Color for List Widget
		$categories_widget_color = get_terms('category');
        if ($categories_widget_color) {
            foreach( $categories_widget_color as $tag) {
				$tag_link = get_category_link($tag->term_id);
				$title_bg_Color = get_term_meta($tag->term_id, 'ethrik', true);
				$catColor = !empty( $title_bg_Color['cat-color'] )? $title_bg_Color['cat-color'] : '#FF3797';
				$custom_css .= '
					.cat-item-'.$tag->term_id.' span.post_count {background-color : '.$catColor.' !important;} 
				';
			}
        }	
		wp_add_inline_style('ethrik-custom-style', $custom_css);
	}
	add_action('wp_enqueue_scripts', 'ethrik_theme_inline_style');
endif;