<?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_features 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-featres';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Fintech Features', '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(
            'fintech_features_options',
            [
                'label' => __( 'Fintech Features Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
       
        $this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'placeholder' => esc_html__( 'The World’s Most Rewarding Buying Experience.', 'ximsa' ),
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'infotext',
			[
				'label' => esc_html__( 'Info', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        
        
        $repeater = new \Elementor\Repeater();        
        $repeater->add_control(
			'animation_delay',
			[
				'label' => esc_html__( 'Animation delay', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'icon_type',
			[
				'label' => esc_html__( 'Icon Type', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::CHOOSE,
				'options' => [
					'icon' => [
						'title' => esc_html__( 'Icon', 'ximsa' ),
						'icon' => 'eicon-nerd',
					],
					'text' => [
						'title' => esc_html__( 'Text', 'ximsa' ),
						'icon' => 'eicon-text-field',
					],
				],
				'default' => 'icon',
				'toggle' => true,
			]
		);
        $repeater->add_control(
			'icon',
			[
				'label' => esc_html__( 'Block Icon', 'ximsa' ),
				'type' => Controls_Manager::ICONS,
                'label_block' => true,
                'condition' => ['icon_type' => 'icon'],
			]
		);
        $repeater->add_control(
			'icon_txt',
			[
				'label' => esc_html__( 'Block Icon Text', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
                'condition' => ['icon_type' => 'text'],
			]
		);
        
        $repeater->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'feature_desc',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'link',
			[
				'label' => esc_html__( 'Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'featuresitem',
			[
				'label' => esc_html__( 'Add Block Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);

		$this->end_controls_section();
        $this->start_controls_section(
            'slider_settings_style',
            [
                'label' => __( 'Banner Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        
        $this->add_control(
            'section_bg_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Section BG Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'section_bg_cl',
            [
                'label'     => esc_html__( 'Section Bg Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .choose-section' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        
        $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(
            'lower_text',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Lower Text Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'sb_txt_cl',
            [
                'label'     => esc_html__( 'Sub Text Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .choose-section .lower-text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sb_txt_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .choose-section .lower-text',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
       
        $this->add_control(
            'reward_block_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Reward Block Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'reward_blog_bg',
            [
                'label'     => esc_html__( 'Feature Block Bg Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .choose-block .inner-box .color-one, .choose-block .inner-box .color-two' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'rew_icon_color',
            [
                'label'     => esc_html__( 'Icon Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .choose-block .inner-box .icon' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'rew_ttl_color',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .choose-block .inner-box h5 a' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'rw_ttl_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .choose-block .inner-box h5',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'rew_txt_color',
            [
                'label'     => esc_html__( 'Text Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .choose-block .inner-box .text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'rw_txt_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .choose-block .inner-box .text',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
		
	}
		


	protected function render() {	
	$settings = $this->get_settings_for_display();?>        
		<!-- Choose Section -->
        <section class="choose-section">
            <div class="auto-container">
                <div class="sec-title-four centered">
                    <h2><?php echo wp_kses( $settings['title'], true );?></h2>
                </div>
                <div class="row clearfix">
                    
                    <?php foreach($settings['featuresitem'] as $item):?>
                    <!-- Choose Block -->
                    <div class="choose-block col-lg-3 col-md-6 col-sm-12">
                        <div class="inner-box wow fadeInLeft" data-wow-delay="<?php echo esc_attr($item['animation_delay']);?>ms" data-wow-duration="1500ms">
                            <span class="color-one"></span>
                            <span class="color-two"></span>
                            <div class="icon">
                                <?php if($item['icon_type'] == 'icon'):?>
                                <?php \Elementor\Icons_Manager::render_icon( $item['icon'], [ 'aria-hidden' => 'true' ] ); ?>
                                <?php else:?>
                                    <i class="<?php echo esc_attr($item['icon_txt']);?>"></i>
                                <?php endif;?>
                            </div>
                            <h5><a href="<?php echo esc_url($item['link']['url']);?>"><?php echo esc_html($item['title']);?></a></h5>
                            <div class="text"><?php echo wp_kses( $item['feature_desc'], true );?></div>
                        </div>
                    </div>
                    <?php endforeach;?>
                    
                </div>
                
                <div class="lower-text"><?php echo wp_kses( $settings['infotext'], true );?></div>
                
            </div>
        </section>
        <!-- End Choose Section -->
    <?php  
    }
	
}

