<?php
/**
 * Main Class
 *
 * @author   Fernando_Acosta
 * @since    1.0.0
 * @package  make-column-clickable-elementor
 */

if (!defined('ABSPATH')) {
    exit;
}

if (!class_exists('Pakrco_Elementor_Color_Schema')) :

    /**
     * The main Pakrco_Elementor_Color_Schema class
     */
    class Pakrco_Elementor_Color_Schema {

        public function __construct() {
            add_action('wp_enqueue_scripts', [$this, 'global_css'], 20);
        }

        public function global_css() {
            wp_enqueue_style('pakrco-elementor-style', get_theme_file_uri('elementor.css'), array(), PAKRCO_VERSION);
            wp_style_add_data('pakrco-elementor-style', 'rtl', 'replace');

            $active_kit_id = Elementor\Plugin::$instance->kits_manager->get_active_id();
            Elementor\Plugin::$instance->kits_manager->frontend_before_enqueue_styles();
            $myvals = get_post_meta($active_kit_id, '_elementor_page_settings', true);
            if (!empty($myvals)) {
                $css = '';
                foreach ($myvals['system_colors'] as $key => $value) {
                    $css .= $value['color'] !== '' ? '--' . $value['_id'] . ':' . $value['color'] . ';' : '';
                }

                $var = ":root{{$css}}";
                $var .= <<<CSS
.dark-mode{
    --e-global-color-primary: #CFA336;
    --e-global-color-primary_hover: #ba9230;
    --e-global-color-secondary: #A4A4A4;
    --e-global-color-secondary_hover: #fff;
    --e-global-color-text: #bababa;
    --e-global-color-accent: #fff;
    --e-global-color-border: rgba(255, 255, 255, 0.1);
    --e-global-color-dark: #253046;
    --e-global-color-light: #A4A4A4;
    --e-global-color-background: #303D57;
    --e-global-color-background2: #253046;
    
    --primary: #CFA336;
    --primary_hover: #ba9230;
    --secondary: #A4A4A4;
    --secondary_hover: #fff;
    --text: #bababa;
    --accent: #fff;
    --border: rgba(255, 255, 255, 0.1);
    --dark: #253046;
    --light: #A4A4A4;
    --background: #303D57;
    --background2: #253046;
}
CSS;
                wp_add_inline_style('pakrco-style', $var);
            }
        }
    }

endif;

new Pakrco_Elementor_Color_Schema();
