<?php
	if ( ! function_exists( 'ci_theme_get_part_customizer_css' ) ) :
		/**
		 * Generates CSS based on per-theme customizer settings.
		 *
		 * @return string
		 */
		function ci_theme_get_part_customizer_css() {
			ob_start();
			//
			// Global Colors
			//
			$body_bg = get_theme_mod( 'background_color' );

			if ( ! empty( $body_bg ) ) {
				?>
				.widget-title {
					background-color: <?php echo sanitize_hex_color( $body_bg ); ?>;
				}

				.widget-title:after {
					border-top-color: <?php echo sanitize_hex_color( $body_bg ); ?>;
				}
				<?php
			}

			$site_accent_color = get_theme_mod( 'site_accent_color' );

			if ( ! empty( $site_accent_color ) ) {
				?>
				.woocommerce-MyAccount-navigation-link.is-active a {
					color: <?php echo sanitize_hex_color( $site_accent_color ); ?>;
				}

				.btn:hover,
				input[type="button"]:hover,
				input[type="submit"]:hover,
				input[type="reset"]:hover,
				button:hover,
				.button:hover,
				.comment-reply-link:hover,
				#navigation > li ul a:hover,
				#navigation > li ul .sfHover > a,
				#paging > span.current,
				#paging a.current,
				.page-numbers li > span.current,
				.page-numbers li a.current,
				#paging span.current,
				#paging a:hover,
				.page-numbers li span.current,
				.page-numbers li a:hover,
				.filters-nav .btn:hover,
				.filters-nav a.selected,
				.onsale,
				.woocommerce-tabs .tabs li.active a {
					background-color: <?php echo sanitize_hex_color( $site_accent_color ); ?>;
				}

				input:hover,
				input:focus,
				textarea:hover,
				textarea:focus,
				.btn,
				input[type="button"],
				input[type="submit"],
				input[type="reset"],
				button,
				.button,
				.comment-reply-link,
				#page {
					border-color: <?php echo sanitize_hex_color( $site_accent_color ); ?>;
				}

				#navigation > li > a:hover,
				#navigation > li.sfHover > a,
				#navigation > li.sfHover > a:active,
				#navigation > li.current_page_item > a,
				#navigation > li.current-menu-item > a,
				#navigation > li.current-menu-ancestor > a,
				#navigation > li.current-menu-parent > a,
				#navigation > li.current > a {
					border-bottom-color: <?php echo sanitize_hex_color( $site_accent_color ); ?>;
				}

				<?php
			}

			$site_primary_color = get_theme_mod( 'site_primary_color' );

			if ( ! empty( $site_primary_color ) ) {
				?>
				a,
				a:hover,
				a:focus,
				.btn,
				input[type="button"],
				input[type="submit"],
				input[type="reset"],
				button,
				.button,
				.comment-reply-link,
				.btn.btn-inverted,
				input[type="button"].btn-inverted,
				input[type="submit"].btn-inverted,
				input[type="reset"].btn-inverted,
				button.btn-inverted,
				.button.btn-inverted,
				.comment-reply-link.btn-inverted,
				.btn.btn-inverted:hover,
				input[type="button"].btn-inverted:hover,
				input[type="submit"].btn-inverted:hover,
				input[type="reset"].btn-inverted:hover,
				button.btn-inverted:hover,
				.button.btn-inverted:hover,
				.comment-reply-link.btn-inverted:hover,
				.item-btn:hover,
				.item-timer .count b,
				.entry-title a:hover {
					color: <?php echo sanitize_hex_color( $site_primary_color ); ?>;
				}

				.sale-wrap,
				.price_slider .ui-slider-handle,
				.footer-separator {
					background-color: <?php echo sanitize_hex_color( $site_primary_color ); ?>;
				}

				.section-title:after {
					border-bottom-color: <?php echo sanitize_hex_color( $site_primary_color ); ?>;
				}

				<?php
			}

			$site_secondary_color = get_theme_mod( 'site_secondary_color' );

			if ( ! empty( $site_secondary_color ) ) {
				?>

				.btn.btn-inverted,
				input[type="button"].btn-inverted,
				input[type="submit"].btn-inverted,
				input[type="reset"].btn-inverted,
				button.btn-inverted,
				.button.btn-inverted,
				.comment-reply-link.btn-inverted,
				.btn.btn-inverted:hover,
				input[type="button"].btn-inverted:hover,
				input[type="submit"].btn-inverted:hover,
				input[type="reset"].btn-inverted:hover,
				button.btn-inverted:hover,
				.button.btn-inverted:hover,
				.comment-reply-link.btn-inverted:hover,
				.item-btn,
				#paging > span,
				#paging a,
				.page-numbers li > span,
				.page-numbers li a {
					background-color: <?php echo sanitize_hex_color( $site_secondary_color ); ?>;
				}

				<?php
			}

			$site_text_color = get_theme_mod( 'site_text_color' );

			if ( ! empty( $site_text_color ) ) {
				?>
				body,
				.booking-page .dk_theme_ci.dk_open .dk_toggle,
				.woocommerce-MyAccount-navigation-link a::after {
					color: <?php echo sanitize_hex_color( $site_text_color ); ?>;
				}

				blockquote cite,
				.form-allowed-tags,
				.comment-notes {
					color: rgba( <?php echo sanitize_hex_color( $site_text_color ); ?>, 0.8 );
				}

				input::placeholder {
					color: rgba( <?php echo sanitize_hex_color( $site_text_color ); ?>, 0.5 );
				}
				<?php
			}

			$site_border_color = get_theme_mod( 'site_border_color' );

			if ( ! empty( $site_border_color ) ) {
				?>
				input,
				textarea,
				.item-media-thumb,
				.item-meta,
				.item-timer .count,
				.entry-thumb,
				#paging > span,
				#paging a,
				.page-numbers li > span,
				.page-numbers li a,
				.widget-title,
				.quantity input,
				.entry-content table,
				.entry-content table caption,
				.entry-content table th,
				.entry-content table td,
				.entry-content img,
				.payment_box,
				.variations td {
					border-color: <?php echo sanitize_hex_color( $site_border_color ); ?>;
				}

				.item-meta th,
				.item-meta td,
				.widget ul li,
				.shop-actions,
				.woocommerce-tabs .tabs,
				.shop_attributes th,
				.shop_attributes td,
				.shop_table th,
				.shop_table td,
				.cart_totals th,
				.cart_totals td,
				.woocommerce-checkout .woocommerce-info,
				.order_details li,
				.widget ul.product_list_widget li,
				.woocommerce-MyAccount-navigation-link a,
				.price_slider .ui-slider-range {
					border-bottom-color: <?php echo sanitize_hex_color( $site_border_color ); ?>;
				}

				.widget-title:before,
				.widget ul ul.children li:first-child,
				.woocommerce-tabs .tabs li a,
				.shop_attributes tr:first-child th,
				.shop_attributes tr:first-child td,
				.woocommerce-checkout .woocommerce-info,
				.price_slider .ui-slider-range {
					border-top-color: <?php echo sanitize_hex_color( $site_border_color ); ?>;
				}

				.item-meta th,
				.item-meta td {
					border-left-color: <?php echo sanitize_hex_color( $site_border_color ); ?>;
				}

				.item-meta td,
				.woocommerce-tabs .tabs li a {
					border-right-color: <?php echo sanitize_hex_color( $site_border_color ); ?>;
				}
				<?php
			}

			$site_header_color = get_theme_mod( 'site_header_color' );

			if ( ! empty( $site_header_color ) ) {
				?>
				h1, h2, h3, h4, h5, h6, .widget-title {
					color: <?php echo sanitize_hex_color( $site_header_color ); ?>;
				}
				<?php
			}

			$site_form_bg = get_theme_mod( 'site_form_bg' );

			if ( ! empty( $site_form_bg ) ) {
				?>
				input[type="text"],
				input[type="password"],
				input[type="date"],
				input[type="datetime"],
				input[type="email"],
				input[type="number"],
				input[type="search"],
				input[type="tel"],
				input[type="time"],
				input[type="url"],
				textarea {
					background-color: <?php echo sanitize_hex_color( $site_form_bg ); ?>;
				}
				<?php
			}

			$site_form_color = get_theme_mod( 'site_form_color' );

			if ( ! empty( $site_form_color ) ) {
				?>
				input[type="text"],
				input[type="password"],
				input[type="date"],
				input[type="datetime"],
				input[type="email"],
				input[type="number"],
				input[type="search"],
				input[type="tel"],
				input[type="time"],
				input[type="url"],
				textarea,
				input::placeholder  {
					color: <?php echo sanitize_hex_color( $site_form_color ); ?>;
				}
				<?php
			}

			$site_form_border = get_theme_mod( 'site_form_border' );

			if ( ! empty( $site_form_border ) ) {
				?>
				input[type="text"],
				input[type="password"],
				input[type="date"],
				input[type="datetime"],
				input[type="email"],
				input[type="number"],
				input[type="search"],
				input[type="tel"],
				input[type="time"],
				input[type="url"],
				textarea {
					border-color: <?php echo sanitize_hex_color( $site_form_border ); ?>;
				}
				<?php
			}

			$site_button_bg = get_theme_mod( 'site_button_bg' );

			if ( ! empty( $site_button_bg ) ) {
				?>
				.btn,
				input[type="button"],
				input[type="submit"],
				input[type="reset"],
				button,
				button[type="submit"] {
					background-color: <?php echo sanitize_hex_color( $site_button_bg ); ?>;
				}
				<?php
			}

			$site_button_text = get_theme_mod( 'site_button_text' );

			if ( ! empty( $site_button_text ) ) {
				?>
				.btn,
				input[type="button"],
				input[type="submit"],
				input[type="reset"],
				button,
				button[type="submit"] {
					color: <?php echo sanitize_hex_color( $site_button_text ); ?>;
				}
				<?php
			}

			$site_button_bg_hover = get_theme_mod( 'site_button_bg_hover' );

			if ( ! empty( $site_button_bg_hover ) ) {
				?>
				.btn,
				input[type="button"],
				input[type="submit"],
				input[type="reset"],
				button,
				button[type="submit"] {
					background-color: <?php echo sanitize_hex_color( $site_button_bg_hover ); ?>;
				}
				<?php
			}

			$site_button_border_color = get_theme_mod( 'site_button_border_color' );

			if ( ! empty( $site_button_border_color ) ) {
				?>
				.btn,
				input[type="button"],
				input[type="submit"],
				input[type="reset"],
				button,
				.btn:hover,
				input[type="button"]:hover,
				input[type="submit"]:hover,
				input[type="reset"]:hover,
				button:hover,
				.btn.white:hover,
				input[type="button"].white:hover,
				input[type="submit"].white:hover,
				input[type="reset"].white:hover,
				button.white:hover {
					border-color: <?php echo sanitize_hex_color( $site_button_border_color ); ?>;
				}
				<?php
			}

			//
			// Header Colors
			//

			$header_bg = get_theme_mod( 'header_bg' );

			if ( ! empty( $header_bg ) ) {
				?>
				#header {
					background-color: <?php echo sanitize_hex_color( $header_bg ); ?>;
				}
				<?php
			}

			$header_menu_color = get_theme_mod( 'header_menu_color' );

			if ( ! empty( $header_menu_color ) ) {
				?>
				#navigation a,
				.nav-secondary li a,
				.nav-secondary .cart-head {
					color: <?php echo sanitize_hex_color( $header_menu_color ); ?>;
				}

				#navigation > li > a:hover,
				#navigation > li.sfHover > a,
				#navigation > li.sfHover > a:active,
				#navigation > li.current_page_item > a,
				#navigation > li.current-menu-item > a,
				#navigation > li.current-menu-ancestor > a,
				#navigation > li.current-menu-parent > a,
				#navigation > li.current > a {
					border-bottom-color: <?php echo sanitize_hex_color( $header_menu_color ); ?>;
				}
				<?php
			}

			$header_submenu_color = get_theme_mod( 'header_submenu_color' );

			if ( ! empty( $header_submenu_color ) ) {
				?>
				#navigation > li ul a,
				#navigation > li ul a:hover,
				#navigation > li ul .sfHover > a {
					color: <?php echo sanitize_hex_color( $header_submenu_color ); ?>;
				}
				<?php
			}

			$header_menu_background = get_theme_mod( 'header_menu_background' );

			if ( ! empty( $header_menu_background ) ) {
				?>
				#navigation > li ul a {
					background-color: <?php echo sanitize_hex_color( $header_menu_background ); ?>;
				}
				<?php
			}

			$header_menu_background_hover = get_theme_mod( 'header_menu_background_hover' );

			if ( ! empty( $header_menu_background_hover ) ) {
				?>
				#navigation > li ul a:hover,
				#navigation > li ul .sfHover > a {
					background-color: <?php echo sanitize_hex_color( $header_menu_background_hover ); ?>;
				}
				<?php
			}

			$css = ob_get_clean();
			return apply_filters( 'ci_theme_part_customizer_css', $css );
		}
	endif;
