<?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\Plugin;

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

class banking_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 'banking-fnf-item';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Banking 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(
            'feature_options',
            [
                'label' => __( 'Feature Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'shape',
			[
				'label' => esc_html__( 'Shape 1', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'shape2',
			[
				'label' => esc_html__( 'Shape 2', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'shape3',
			[
				'label' => esc_html__( 'Shape 3', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'shape4',
			[
				'label' => esc_html__( 'Shape 4', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'shape5',
			[
				'label' => esc_html__( 'Shape 5', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $repeater = new \Elementor\Repeater();
        
        $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::TEXT,
				'default' => esc_html__( 'Apply For Innsurance', 'ximsa' ),
				'placeholder' => esc_html__( 'Box Title Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'fanfacts',
			[
				'label' => esc_html__( 'Add Fanfact Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ number }}} {{{ title }}}',
			]
		);
        
		$this->end_controls_section();
        
        $this->start_controls_section(
            'feature_style',
            [
                'label' => __( 'Feature Style Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'featre_box_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Box Style Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'hv-bgbackground',
				'label' => esc_html__( 'Background', 'plugin-name' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-fun-fact-inner-item:before',
			]
		);
       
        $this->add_control(
            'ct_noumer_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Number Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'number-bgbackground',
				'label' => esc_html__( 'Background', 'plugin-name' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-fun-fact-inner-item .xis-inner-text h3',
			]
		);
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'ct_no_typography',
                'label'          => esc_html__( 'Number Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-fun-fact-inner-item .xis-inner-text h3',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'ct_title_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Counter Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'ct_title_cl',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-fun-fact-inner-item .xis-inner-text p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'ct_t_typography',
                'label'          => esc_html__( 'Titlle Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-fun-fact-inner-item .xis-inner-text p',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        
		$this->end_controls_section();
	}
		


	protected function render() {
		
		
	$settings = $this->get_settings_for_display(); ?>
		<!-- Start of Fun Fact section
        ============================================= -->
        <section id="xis-fun-fact" class="xis-fun-fact-section position-relative">

            <span class="xis-fun-shape2 position-absolute"  data-parallax='{"y" : 100, "rotateY":200}'><img src="<?php echo esc_url($settings['shape']['url']);?>" alt=""></span>

            <span class="xis-fun-shape3 position-absolute" data-parallax='{"y" : 200}'><img src="<?php echo esc_url($settings['shape2']['url']);?>" alt=""></span>
            <span class="xis-fun-shape4 position-absolute" data-parallax='{"y" : -100}'><img src="<?php echo esc_url($settings['shape3']['url']);?>" alt=""></span>
            <span class="xis-fun-shape5 position-absolute" ><img src="<?php echo esc_url($settings['shape4']['url']);?>" alt=""></span>
            <div class="container">
                <div class="xis-fun-fact-content position-relative">
                    <div class="xis-fun-shape1 position-absolute"><img src="<?php echo esc_url($settings['shape5']['url']);?>" alt=""></div>
                    <div class="row">
                        <?php foreach($settings['fanfacts'] as $item):?>
                        <div class="col-lg-3 col-md-6">
                            <div class="xis-fun-fact-inner-item position-relative text-center">
                                <div class="xis-inner-text headline pera-content">
                                    <h3><span class="counter"><?php echo esc_html($item['number']);?></span><?php echo esc_html($item['symbole']);?></h3>
                                    <p><?php echo esc_html($item['title']);?></p>
                                </div>
                            </div>
                        </div>
                        <?php endforeach;?>   
                    </div>
                </div>
            </div>
        </section>		
    <!-- End of Fun Fact section
        ============================================= -->
    <?php  
    }
	
	

}
