<?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_feature_v2 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-v2';
	}

	/**
	 * 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 V2', '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(
			'subtitle',
			[
				'label'       => __( 'Sub Title', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter Form Sub Title', 'ximsa' ),
			]
		);
		$this->add_control(
			'title',
			[
				'label'       => __( 'Title', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXTAREA,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter Form Title', 'ximsa' ),
			]
		);
        $this->add_control(
			'description',
			[
				'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,
			]
		);

        $repeater = new \Elementor\Repeater();

        $repeater->add_control(
			'icon',
			[
				'label' => esc_html__( 'Icon', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $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(
			'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(
			'feature1',
			[
				'label' => esc_html__( 'Feature 1', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'feature2',
			[
				'label' => esc_html__( 'Feature 2', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                '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 Feature 2 section
        ============================================= -->
        <section id="xis-it-feature-2" class="xis-it-feature-section-2">
            <div class="container">
                <div class="xis-it-feature-content-2">
                    <div class="row">
                        <div class="col-lg-5">
                            <div class="xis-it-feature-text-wrap-2">
                                <div class="xis-it-section-title xis-it-headline pera-content  wow fadeInUp" data-wow-delay="200ms" data-wow-duration="1500ms">
                                    <span><?php echo esc_html($settings['subtitle']);?></span>
                                    <h2><?php echo esc_html($settings['title']);?></h2>
                                    <p><?php echo wp_kses( $settings['description'], true );?></p>
                                </div>
                                <div class="xis-it-extra-feature-wrap d-flex">
                                    <?php foreach($settings['listitems'] as $item):?>
                                    <div class="xis-it-extra-feature-item d-flex align-items-center wow fadeInLeft" data-wow-delay="400ms" data-wow-duration="1500ms">
                                        <div class="inner-icon d-flex align-items-center justify-content-center">
                                            <img src="<?php echo esc_url($item['icon']['url']);?>" alt="">
                                        </div>
                                        <div class="inner-text xis-it-headline">
                                            <h3><?php echo esc_html($item['title']);?></h3>
                                        </div>
                                    </div>
                                    <?php endforeach;?>
                                </div>
                                <div class="xis-it-btn wow fadeInUp" data-wow-delay="800ms" 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-7">
                            <div class="xis-it-feature-img-wrap-2 position-relative">
                                <span class="xis-it-ft-shape position-absolute wow fadeInRight" data-wow-delay="800ms" data-wow-duration="1500ms"><img src="<?php echo esc_url($settings['shape']['url']);?>" alt=""></span>
                                <div class="xis-it-feature-img1 bg-img-area">
                                    <span class="img-shape position-absolute bg-shape"><img src="<?php echo esc_url($settings['shape2']['url']);?>" alt=""></span>
                                    <img src="<?php echo esc_url($settings['feature1']['url']);?>" alt="">
                                </div>
                                <div class="xis-it-feature-img2 position-absolute bg-img-area view-on">
                                    <span class="img-border position-absolute bg-shape view-on"><img src="<?php echo esc_url($settings['shape3']['url']);?>" alt=""></span>
                                    <img src="<?php echo esc_url($settings['feature2']['url']);?>" alt="">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <!-- End of Feature 2 section
        ============================================= -->
		<?php
      }



}
