<?php

namespace XIMSAPLUGIN\Element;

use Elementor\Controls_Manager;
use Elementor\Controls_Stack;
use Elementor\Group_Control_Typography;
use Elementor\Scheme_Typography;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Border;
use Elementor\Repeater;
use Elementor\Widget_Base;
use Elementor\Utils;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Background;
use Elementor\Plugin;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.

class fintech_fanfact extends Widget_Base {

	/**
	 * Get widget name.
	 *
	 * Retrieve Elementor widget name.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'fintech_fanfact';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Finetech Fanfact', 'ximsa' );
	}

	/**
	 * Get widget icon.
	 *
	 * Retrieve Elementor widget icon.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'gl-custom-icon';
	}

	/**
	 * Get widget categories.
	 *
	 * Retrieve the list of categories the Elementor widget belongs to.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories() {
		return [ 'ximsa' ];
	}

	/**
	 * Register Elementor widget controls.
	 *
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @since 1.0.0
	 * @access protected
	 */
	 
	
	protected function register_controls() {
        $this->start_controls_section(
            'fanfact_info',
            [
                'label' => __( 'Fanfact Info Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'fnf_img',
			[
				'label' => esc_html__( 'Fanfact Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        
        $repeater->add_control(
			'number',
			[
				'label' => esc_html__( 'Number', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'symbole',
			[
				'label' => esc_html__( 'Symbole', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        
        $repeater->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        
        
        $this->add_control(
			'fanfacts',
			[
				'label' => esc_html__( 'Fanfact Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);
		$this->end_controls_section();

        $this->start_controls_section(
            'fanf_settings_style',
            [
                'label' => __( 'Fanfact Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        
        $this->add_control(
            'slider_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'sl_title_cl',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sec-title-four h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'sl_clr_title_cl',
            [
                'label'     => esc_html__( 'Colerd Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sec-title-four h2 span' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .sec-title-four h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fnf_title_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Fanfact Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'fanfact_title_cl',
            [
                'label'     => esc_html__( 'Fanfact Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .counter-section-three .counter-column .text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fnf_info_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .counter-section-three .counter-column .text',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fnf_number_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Fanfact Number Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'fanfact_no_cl',
            [
                'label'     => esc_html__( 'Fanfact NUmber Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .counter-column h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fnf_no_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .counter-column h3',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->end_controls_section();
	}
		


	protected function render() {
		
		$settings = $this->get_settings_for_display(); ?>
		<!-- Counter Section Three -->
        <section class="counter-section-three">
            <div class="bubble-dotted">
                <span class="dotted dotted-1"></span>
                <span class="dotted dotted-2"></span>
                <span class="dotted dotted-3"></span>
                <span class="dotted dotted-4"></span>
                <span class="dotted dotted-5"></span>
                <span class="dotted dotted-6"></span>
                <span class="dotted dotted-7"></span>
                <span class="dotted dotted-8"></span>
                <span class="dotted dotted-9"></span>
                <span class="dotted dotted-10"></span>
            </div>
            <div class="auto-container">
                <div class="sec-title-four centered">
                    <h2><?php echo wp_kses( $settings['title'], true );?></h2>
                </div>
                
                <div class="inner-container">
                    <div class="row clearfix">
                        <?php foreach($settings['fanfacts'] as $item):?>
                        <!-- Counter Column -->
                        <div class="counter-column col-lg-4 col-md-6 col-sm-12">
                            <div class="inner-column">
                                <div class="icon"><img src="<?php echo esc_url($item['fnf_img']['url']);?>" alt="" /></div>
                                <h3><span class="odometer" data-count="<?php echo esc_attr($item['number']);?>"></span><?php echo esc_html($item['symbole']);?></h3>
                                <div class="text"><?php echo esc_html($item['title']);?></div>
                            </div>
                        </div>
                        <?php endforeach;?>
                    </div>
                </div>
            </div>
        </section>
        <!-- End Counter Section Three -->
		<?php 
      }
	
	

}
