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

/**
 * Elementor button widget.
 * Elementor widget that displays a button with the ability to control every
 * aspect of the button design.
 *
 * @since 1.0.0
 */
class digpay_features_sec extends Widget_Base {

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

    /**
     * Get widget title.
     * Retrieve button widget title.
     *
     * @since  1.0.0
     * @access public
     * @return string Widget title.
     */
    public function get_title() {
        return esc_html__( 'Digital Pay Feature', 'ximsa' );
    }

    /**
     * Get widget icon.
     * Retrieve button widget icon.
     *
     * @since  1.0.0
     * @access public
     * @return string Widget icon.
     */
    public function get_icon() {
        return 'eicon-library-open';
    }

    /**
     * Get widget categories.
     * Retrieve the list of categories the button widget belongs to.
     * Used to determine where to display the widget in the editor.
     *
     * @since  2.0.0
     * @access public
     * @return array Widget categories.
     */
    public function get_categories() {
        return [ 'ximsa' ];
    }

    /**
     * Register button 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(
            'digital_pay_app',
            [
                'label' => esc_html__( 'Digital Pay Feature', 'ximsa' ),
            ]
        );
		$this->add_control(
			'shape',
			[
				'label'       => __( 'Shape', 'ximsa' ),
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'shape2',
			[
				'label'       => __( 'Shape 2', 'ximsa' ),
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'subtitle',
			[
				'label'       => __( 'Sub Title', 'ximsa' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter your Sub Title', 'ximsa' ),
			]
		);
		$this->add_control(
			'title',
			[
				'label'       => __( 'Title', 'ximsa' ),
				'type'        => Controls_Manager::TEXTAREA,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter your Title', 'ximsa' ),
			]
		);
		$repeater = new \Elementor\Repeater();
        $repeater->add_control(
			'icon',
			[
				'label' => esc_html__( 'Icon', 'ximsa' ),
				'type' => Controls_Manager::ICONS,
			]
		);
        $repeater->add_control(
            'icon_color',
            [
                'label'     => esc_html__( 'Icon Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} {{CURRENT_ITEM}} .icon' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $repeater->add_control(
            'icon_bg_color',
            [
                'label'     => esc_html__( 'Icon Background Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} {{CURRENT_ITEM}} .icon' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $repeater->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'description',
			[
				'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(
			'features_item',
			[
				'label' => esc_html__( 'Feature Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);
		
		$this->end_controls_section();
        $this->start_controls_section(
            'feature_info_st',
            [
                'label' => __( 'Feature Style Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        
        
        $this->add_control(
            'fs_sub_title_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Sub Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );  
        $this->add_control(
            'fs_sub_title_cl',
            [
                'label'     => esc_html__( 'Sub Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sec-title-three .title' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_sth_typography',
                'label'          => esc_html__( 'Sub Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .sec-title-three .title',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_title_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );  
        $this->add_control(
            'fs_title_cl',
            [
                'label'     => esc_html__( 'Feature Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sec-title-three h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'feature_title_typography',
                'label'          => esc_html__( 'Feature Title Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .sec-title-three h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_reg_title_cl',
            [
                'label'     => esc_html__( 'Feature Reguler Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sec-title-three h2 span' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'feature_reg_title_typography',
                'label'          => esc_html__( 'Feature Reguler Title Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .sec-title-three h2 span',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_main_title_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Item Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );  
        $this->add_control(
            'fs_m_title_cl',
            [
                'label'     => esc_html__( 'Feature Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .feature-block-five .inner-box h5 a' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'feature_m_title_typography',
                'label'          => esc_html__( 'Feature Title Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .feature-block-five .inner-box h5',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_info_title_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Main Info Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );  
        $this->add_control(
            'fs_m_info_cl',
            [
                'label'     => esc_html__( 'Feature Info Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .feature-block-five .inner-box .text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'feature_m_info_typography',
                'label'          => esc_html__( 'Feature Title Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .feature-block-five .inner-box .text',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
		$this->end_controls_section();
    }
    /**
     * Render button widget output on the frontend.
     * Written in PHP and used to generate the final HTML.
     *
     * @since  1.0.0
     * @access protected
     */
    protected function render() {
        $settings = $this->get_settings_for_display();
        $allowed_tags = wp_kses_allowed_html('post');
        ?>
        <!-- Featured Section Five -->
        <section class="featured-section-five" style="background-image: url(<?php echo esc_url($settings['shape']['url']);?>)">
            <div class="shadow-layer" style="background-image: url(<?php echo esc_url($settings['shape2']['url']);?>)"></div>
            <div class="auto-container">
                <div class="sec-title-three centered">
                    <div class="title"><?php echo esc_html($settings['subtitle']);?></div>
                    <h2><?php echo __($settings['title']);?></h2>
                </div>
                
                <div class="row clearfix">
                    <?php foreach($settings['features_item'] as $item):?>
                    <!-- Feature Block Five -->
                    <div class="feature-block-five col-lg-3 col-md-6 col-sm-12 elementor-repeater-item-<?php echo esc_attr($item['_id']);?>">
                        <div class="inner-box wow fadeInLeft" data-wow-delay="450ms" data-wow-duration="1500ms">
                            <div class="icon">
                                <?php \Elementor\Icons_Manager::render_icon( $item['icon'], [ 'aria-hidden' => 'true' ] ); ?>
                            </div>
                            <h5><a href="<?php echo esc_url($item['link']['url']);?>"><?php echo esc_html($item['title']);?></a></h5>
                            <div class="text"><?php echo esc_html($item['description']);?></div>
                        </div>
                    </div>
                    <?php endforeach;?>
                </div>
                
            </div>
        </section>
        <!-- End Featured Section Five -->
 
        <?php
    }
}
