<?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 it_features_content 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 'it-feature-content';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'IT Feature Content', '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_content_options',
            [
                'label' => __( 'feature Content Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'bg_img',
			[
				'label' => esc_html__( 'bg_img', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'shape',
			[
				'label' => esc_html__( 'Shape', '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(
			'fs_sub_title',
			[
				'label' => esc_html__( 'Feature Sub Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
                'default' => esc_html__( 'Instant Bank Payment', 'ximsa' ),
				'placeholder' => esc_html__( 'Type feature Sub Title Here', 'ximsa' ),
			]
		);
        $this->add_control(
			'fs_title',
			[
				'label' => esc_html__( 'Feature Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
                'default' => esc_html__( 'Faster payments, lower fees', 'ximsa' ),
				'placeholder' => esc_html__( 'Type feature Title Here', 'ximsa' ),
			]
		);
        $this->add_control(
			'fs_txt',
			[
				'label' => esc_html__( 'Feature Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'btn_label',
			[
				'label' => esc_html__( 'Button Label', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_control(
			'btn_link',
			[
				'label' => esc_html__( 'Button Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        $this->add_control(
			'feature_img',
			[
				'label' => esc_html__( 'Feature Box Img', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'feature_title',
			[
				'label' => esc_html__( 'Feature Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);

        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);        
        $this->add_control(
			'listitems',
			[
				'label' => esc_html__( 'feature List Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);
        $this->add_control(
			'appoinment_label',
			[
				'label' => esc_html__( 'Button Label', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_control(
			'appoinment_link',
			[
				'label' => esc_html__( 'Appoinment Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        $this->end_controls_section();

        $this->start_controls_section(
            'feature_settings_style',
            [
                'label' => __( 'feature Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'feature_sub_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Sub Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'title_color',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-it-system-feature-text-wrap h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'btn-shape-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-it-system-feature-text-wrap h3 span, .xis-it-system-feature-text-wrap h3 span:before',
			]
		);
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-it-system-feature-text-wrap h3',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );

        $this->add_control(
            'feature_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'fs_title_color',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-it-system-feature-text-wrap h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
       
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-it-system-feature-text-wrap h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'feature_desc',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Description Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'sl_desc_color',
            [
                'label'     => esc_html__( 'Description Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-it-system-feature-text-wrap p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'ab_desc_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-it-system-feature-text-wrap p',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'feature_btn',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Button Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'feature_desc_color',
            [
                'label'     => esc_html__( 'Feature Button Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-it-btn a' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'btn-bg-info-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-it-btn a',
			]
		);
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'btn__title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-it-btn a',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );

        $this->add_control(
            'fs_box_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Box Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'box-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-it-system-feature-list-wrap:before, .xis-it-system-feature-list li:before',
			]
		);
        $this->add_control(
            'fs_list_cl',
            [
                'label'     => esc_html__( 'Feature List Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-it-system-feature-list h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_list_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-it-system-feature-list h3',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_list_itm_cl',
            [
                'label'     => esc_html__( 'Feature List Item Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-it-system-feature-list li' => 'color: {{VALUE}} ',
                ],
            ]
        );
        
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_list_item_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-it-system-feature-list li',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'appoinment_btn',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Appionment Button Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'appoinment_btn_color',
            [
                'label'     => esc_html__( 'Appoinment Button Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-it-system-feature-list-wrap .appoint-btn a' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'btn-appoin-info-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-it-system-feature-list-wrap .appoint-btn a:before',
			]
		);
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'btn_appoinemt_btn_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-it-system-feature-list-wrap .appoint-btn a',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
		$this->end_controls_section();
	}
		


	protected function render() {
		
		
		$settings = $this->get_settings_for_display(); ?>
		
        <!-- Start of System feature section
            ============================================= -->
            <section id="xis-it-system-feature" class="xis-it-system-feature-section position-relative" data-background="<?php echo esc_url($settings['bg_img']['url']);?>">
                <span class="xis-it-sf-shape1 position-absolute" data-parallax='{"x" : -150}'><img src="<?php echo esc_url($settings['shape']['url']);?>" alt=""></span>
                <span class="xis-it-sf-line-sh1 position-absolute"  data-parallax='{"y" : -50}'><img src="<?php echo esc_url($settings['shape2']['url']);?>" alt=""></span>
                <span class="xis-it-sf-line-sh2 position-absolute"  data-parallax='{"y" : 10}'><img src="<?php echo esc_url($settings['shape3']['url']);?>" alt=""></span>
                <span class="xis-it-sf-outer-shape1"></span>
                <span class="xis-it-sf-outer-shape2"></span>
                <div class="container">
                    <div class="xis-it-system-feature-content">
                        <div class="row">
                            <div class="col-lg-7">
                                <div class="xis-it-system-feature-text-wrap xis-it-headline pera-content">
                                    <h3 class="wow fadeInUp" data-wow-delay="200ms" data-wow-duration="1500ms"><?php echo wp_kses( 
                                        $settings['fs_sub_title'], true );?></h3>
                                    <h2 class="wow fadeInUp" data-wow-delay="400ms" data-wow-duration="1500ms"><?php echo wp_kses( 
                                        $settings['fs_title'], true );?></h2>
                                    <p class="wow fadeInUp" data-wow-delay="500ms" data-wow-duration="1500ms"><?php echo wp_kses( 
                                        $settings['fs_txt'], true );?></p>
                                    <div class="xis-it-btn wow fadeInUp" data-wow-delay="500ms" data-wow-duration="1500ms">
                                        <a class="d-flex justify-content-center align-items-center" href="<?php echo esc_url($settings['btn_link']['url']);?>"><?php echo esc_html($settings['btn_label']);?></a>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-5 wow fadeInRight" data-wow-delay="200ms" data-wow-duration="1500ms">
                                <div class="xis-it-system-feature-list-wrap position-relative">
                                    <div class="xis-it-system-feature-list position-relative xis-it-headline ul-li" data-background="<?php echo esc_url($settings['feature_img']['url']);?>">
                                        <h3><?php echo wp_kses( 
                                        $settings['feature_title'], true );?></h3>
                                        <ul>
                                            <?php foreach($settings['listitems'] as $item):?>
                                            <li><?php echo esc_html($item['title']);?></li>
                                            <?php endforeach;?>
                                        </ul>
                                    </div>
                                    <div class="appoint-btn text-center" >
                                        <a class="d-flex justify-content-center align-items-center" href="<?php echo esc_url($settings['appoinment_link']['url']);?>"><?php echo esc_html($settings['appoinment_label']);?> <i class="fas fa-arrow-circle-right"></i></a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>		
        <!-- End of System feature section
            ============================================= -->	
		<?php 
      }
	
	

}

