<?php

/* Custom styles generated from theme options panel */

// if( function_exists('breek_lite_generate_custom_styles') ) return;

function breek_lite_add_custom_styles() {
    $prefix = BREEK_LITE_THEMEPREFIX.'-';
    $custom_css = breek_lite_generate_custom_styles();
    if( !empty($custom_css) ) {
        wp_add_inline_style( $prefix.'theme', $custom_css );
    }
}
add_action( 'wp_enqueue_scripts', 'breek_lite_add_custom_styles', 10 );

function breek_lite_generate_custom_styles(){

    $css = '';

    $red = $primary_color = '#E84E89';
    $yellow = $secondary_color = '#00BEC1';
    $text_color = '#333333';
    $border_color = '#f4f4f4';
    $black = '#222222';
    $white = '#ffffff';

    /* @group General Settings */

    
    $bg_type = breek_lite_get_option( 'background_type', '2' );
    if( $bg_type == 1 && breek_lite_get_option('bg_body_pattern') ){
        $body_pattern_url = wp_get_attachment_image_url( breek_lite_get_option('bg_body_pattern'), 'full' );
        $css .= 'body:before{ background: url('.esc_url($body_pattern_url).') repeat; }';
    }        

    if( $bg_type == 2  && breek_lite_get_option('bg_body_color') != '' ){
        $css .= 'body:before{ background: '.sanitize_hex_color( breek_lite_get_option('bg_body_color') ).'; }';
    }

    if( $bg_type == 3 && breek_lite_get_option('bg_body_full') ){
        $full_url = wp_get_attachment_image_url( breek_lite_get_option('bg_body_full'), 'full' );
        $css .= 'body:before{ background: url('.esc_url($full_url).') no-repeat top center !important; background-size: cover !important; }';
    }

    if( $bg_type == 4 && breek_lite_get_option('bg_gradient_from') && breek_lite_get_option('bg_gradient_to') )
        $css = 'body:before{
            background: -webkit-linear-gradient(0deg, '.sanitize_hex_color( breek_lite_get_option('bg_gradient_from') ).' 30%, '.sanitize_hex_color( breek_lite_get_option('bg_gradient_to') ).' 100%);
            background: linear-gradient(90deg, '.sanitize_hex_color( breek_lite_get_option('bg_gradient_from') ).' 30%, '.sanitize_hex_color( breek_lite_get_option('bg_gradient_to') ).' 100%);
        }';    

    // Primary Color
    if( breek_lite_get_option('primary_color') != '' ){  

        $css .= '
        #header nav ul.sub-menu li.current-menu-item a, .author-meta .meta-info i, .author-meta a.meta-info:hover, div.meta .remixicon, div.meta a:hover, div.epcl-share a, .author-meta a.author:hover,
        .widget_archive>ul>li:before, .widget_categories>ul>li:before, .widget_recent_comments>ul>li:before, .widget_recent_entries>ul>li:before, .widget_rss>ul>li:before,
        
        .author-meta a, .pagination div.nav a, div.text a:not([class]), .pagination div.nav a, section.widget_epcl_tweets p a, #single #comments nav.pagination a:hover, section.widget_epcl_tweets p a, div.text .wp-block-categories li span, div.text .wp-block-categories li a:hover, div.text .wp-block-archives li span, div.text .wp-block-archives li a:hover, div.text .wp-block-archives li a:hover, div.text .wp-block-categories li a:hover, div.text .wp-block-latest-posts li a:hover{ 
            color: '.sanitize_hex_color( breek_lite_get_option('primary_color') ).'; }';

        $css .= '#single .share-buttons .permalink .copy svg{ 
            fill: '.sanitize_hex_color( breek_lite_get_option('primary_color') ).'; }';

        $css .= '
        .button, .epcl-button.red, div.tags a, div.tags span, .epcl-pagination div.nav a, #single .share-buttons .epcl-button,
        .widget_archive ul li span, .widget_categories ul li span, .widget_tag_cloud a, .widget_tag_cloud span, .widget_epcl_tag_cloud a, .widget_epcl_tag_cloud span, #single #comments.hosted nav.pagination a,
        div.text .wp-block-archives li:not(.option) span, div.text .wp-block-categories li:not(.option) span, div.text .wp-block-latest-posts li:not(.option) span,
        
        button, input[type=submit]:hover, .widget .nice-select:hover, .nice-select.open, .widget .nice-select:focus, input[type=submit], #single section.related article .button, .slick-arrow, .slick-arrow:hover, .widget .nice-select{ 
            background-color: '.sanitize_hex_color( breek_lite_get_option('primary_color') ).'; }';

        $css .= 'select.custom-select, #single #comments .comment .outline.comment-reply-link, .button.outline, .pagination div.nav a, input[type=submit], .button, .widget .nice-select, .widget .nice-select:hover, input[type=submit]:hover, .pagination div.nav a:hover, div.epcl-download a, div.epcl-download a:hover, .widget .nice-select:focus{ 
            border-color: '.sanitize_hex_color( breek_lite_get_option('primary_color') ).'; }';

    }

    // Secondary Color
    if( breek_lite_get_option('secondary_color') != '' ){

        $css .= 'a:hover{ 
            color: '.sanitize_hex_color( breek_lite_get_option('secondary_color') ).'; }';

        $css .= '
        .widget_epcl_about .social, form.search-form input.search-field, .epcl-button, div.text blockquote:before, .tag-description .icon, #single #comments.hosted nav.pagination a,
        
        .button:hover, div.text .wp-block-quote:before, div.text .wp-block-pullquote:after, div.text .wp-block-pullquote:before{ 
            background-color: '.sanitize_hex_color( breek_lite_get_option('secondary_color') ).'; }';

        $css .= '
        .widget_epcl_about .avatar a, .tag-description .icon, #author div.avatar a, .wpcf7 label.bordered:after{ 
            border-color: '.sanitize_hex_color( breek_lite_get_option('secondary_color') ).'; }';
         
        $css .= '.gradient-effect a:not(.epcl-button){
            background-image: -webkit-gradient(linear, left top, right top, from('.sanitize_hex_color( breek_lite_get_option('secondary_color') ).'), to('.sanitize_hex_color( breek_lite_get_option('secondary_color') ).'));
            background-image: linear-gradient(to right, '.sanitize_hex_color( breek_lite_get_option('secondary_color') ).' 0%, '.sanitize_hex_color( breek_lite_get_option('secondary_color') ).' 100%);
            background-size: 0px 4px;
            background-repeat: no-repeat;
            background-position: left 87%;
        }
        ';

    }

    // Third Color
    if( breek_lite_get_option('titles_color') != '' ){

        $css .= 'a{ 
            color: '.sanitize_hex_color( breek_lite_get_option('titles_color') ).'; }';

        $css .= '.button.dark, div.tags a:hover, .widget_tag_cloud a:hover{ 
            background-color: '.sanitize_hex_color( breek_lite_get_option('titles_color') ).'; }';

        $css .= 'h1, h2, h3, h4, h5, h6, div.text .epcl-single-toc .toggle-title{ 
            color: '.sanitize_hex_color( breek_lite_get_option('titles_color') ).'; }';

    }

    // Text Color
    if( breek_lite_get_option('text_color') != '' ){

        $css .= 'body, div.text, div.text .wp-block-archives li a, div.text .wp-block-categories li a, div.text .wp-block-latest-posts li a, .woocommerce #reviews #comments ol.commentlist li .comment-text p.meta, .woocommerce .woocommerce-breadcrumb, .woocommerce .woocommerce-breadcrumb a{ 
            color: '.sanitize_hex_color( breek_lite_get_option('text_color') ).'; }';

        $css .= '.widget_epcl_featured_category .item time, .widget_epcl_posts_thumbs .item time, .widget_epcl_related_articles .item time, .widget_recent_entries .post-date, section.widget_epcl_tweets p small{ 
            color: '.sanitize_hex_color( breek_lite_get_option('text_color') ).'; }';

        $css .= 'div.meta a.comments:hover{ 
            color: '.sanitize_hex_color( breek_lite_get_option('text_color') ).'; }';

    }

    /* @end */

    /* @group Content Colors */

    if( breek_lite_get_option('content_border_color') != '' ){

        $css .= '.title.bordered:after{ 
            background: '.sanitize_hex_color( breek_lite_get_option('content_border_color') ).'; }';

        $css .= '
        .author-meta, div.articles article.bgstyle .author-meta,

        div.articles article, .pagination, aside:before, div.left-content, aside .widget, #single .share-buttons, .section.bordered, .widget_archive ul>li, .widget_categories ul>li, .widget_meta ul>li, .widget_nav_menu ul>li, .widget_pages ul>li, .widget_recent_comments ul>li, .widget_recent_entries ul>li, .widget_rss ul>li, .widget_archive ul>li ul.children, .widget_archive ul>li ul.sub-menu, .widget_categories ul>li ul.children, .widget_categories ul>li ul.sub-menu, .widget_meta ul>li ul.children, .widget_meta ul>li ul.sub-menu, .widget_nav_menu ul>li ul.children, .widget_nav_menu ul>li ul.sub-menu, .widget_pages ul>li ul.children, .widget_pages ul>li ul.sub-menu, .widget_recent_comments ul>li ul.children, .widget_recent_comments ul>li ul.sub-menu, .widget_recent_entries ul>li ul.children, .widget_recent_entries ul>li ul.sub-menu, .widget_rss ul>li ul.children, .widget_rss ul>li ul.sub-menu, .widget_calendar table td{ 
            border-color: '.sanitize_hex_color( breek_lite_get_option('content_border_color') ).'; }';
    }

    /* @end */

    if($css)
        return $css;
}