<?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 saas_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 'saas-features';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Saas 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(
            'saas_feature_options',
            [
                'label' => __( 'Saas Features Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'saas_about_bg',
			[
				'label' => esc_html__( 'Feature Shape Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'illustration1',
			[
				'label' => esc_html__( 'Illustration 1', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'illustration2',
			[
				'label' => esc_html__( 'Illustration 2', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'illustration3',
			[
				'label' => esc_html__( 'Illustration 3', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'illustration4',
			[
				'label' => esc_html__( 'Illustration 4', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'illustration5',
			[
				'label' => esc_html__( 'Illustration 5', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'illustration6',
			[
				'label' => esc_html__( 'Illustration 6', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'illustration7',
			[
				'label' => esc_html__( 'Illustration 7', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);

        $this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Grow your Business
                Real, Organic & Automatic', 'ximsa' ),
				'placeholder' => esc_html__( 'Type Banner Title Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        $this->add_control(
			'description',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Grow your Business
                Real, Organic & Automatic', 'ximsa' ),
				'placeholder' => esc_html__( 'Type Banner Title Here', 'ximsa' ),
                '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(
			'listitem',
			[
				'label' => esc_html__( 'Add List Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);
		$this->add_control(
			'btn_label',
			[
				'label' => esc_html__( 'Button Label', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
			]
		);
		$this->add_control(
			'btn_link',
			[
				'label' => esc_html__( 'Button Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
			]
		);
		$this->end_controls_section();
        $this->start_controls_section(
            'slider_settings_style',
            [
                'label' => __( 'Banner Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_control(
			'container_width',
			[
				'label' => esc_html__( 'Container Width', 'plugin-name' ),
				'type' => \Elementor\Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 2000,
						'step' => 1,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				
				'selectors' => [
					'{{WRAPPER}} .container' => 'max-width: {{SIZE}}{{UNIT}};',
				],
			]
		);
        $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}} .xis-saas-section-title h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-saas-section-title h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_desc_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Description Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'desc__cl',
            [
                'label'     => esc_html__( 'Description Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-saas-feature-text-wrapper .xis-saas-feature-text p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'desc_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-saas-feature-text-wrapper .xis-saas-feature-text p',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_list_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'List Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'list__cl',
            [
                'label'     => esc_html__( 'List Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-saas-feature-text-wrapper .xis-saas-feature-list li' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'list_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-saas-feature-text-wrapper .xis-saas-feature-list li',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );

		$this->end_controls_section();
        $this->start_controls_section(
            'button__content',
            [
                'label' => __( 'Button Style', 'ximsa' ),
                'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name'           => 'btn_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-saas-btn a .txt
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        
        $this->start_controls_tabs( '_banner_button_1' );
        $this->start_controls_tab(
            '_glow-extension_btn__banner_normal',
            [
                'label' => esc_html__( 'Normal', 'glow-extension-extension' ),
            ]
        );
        $this->add_control(
            'btn__color',
            [
                'label'     => esc_html__( 'Color', 'glow-extension-extension' ),
                'type'      => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-saas-btn a' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_bg_color',
                'label'    => __( 'Background', 'glow-extension-extension' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .xis-saas-btn a
                ',
            ]
        );
        $this->add_responsive_control(
            'btn_border_radious',
            [
                'label'      => esc_html__( 'Border Radius', 'glow-extension-extension' ),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .xis-saas-btn a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        
        $this->end_controls_tab();
        $this->start_controls_tab(
            '_glow-extension_btn_hover',
            [
                'label' => esc_html__( 'Hover', 'glow-extension-extension' ),
            ]
        );
        $this->add_control(
            'btn__hover_color',
            [
                'label'     => esc_html__( 'Color', 'glow-extension-extension' ),
                'type'      => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-saas-btn a:hover' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_hover_bg_color',
                'label'    => __( 'Background', 'glow-extension-extension' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .xis-saas-btn a:before
                ',
            ]
        );
        $this->add_responsive_control(
            'btn_hover_border_radious',
            [
                'label'      => esc_html__( 'Border Radius', 'glow-extension-extension' ),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .xis-saas-btn a:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',                    
                ],
            ]
        );
        $this->end_controls_tab();
        $this->end_controls_tabs();
        $this->end_controls_section();
	}
		


	protected function render() {	
	$settings = $this->get_settings_for_display();?>        
	<!-- Start of Feature section
	============================================= -->
	<section id="xis-saas-feature" class="xis-saas-feature-section position-relative">
		<span class="xis-saas-feature-shape1 position-absolute"><img src="<?php echo esc_url($settings['saas_about_bg']['url']);?>"></span>
		<div class="container">
			<div class="xis-saas-feature-content">
				<div class="row">
					<div class="col-lg-6">
						<div class="xis-saas-feature-img-wrapper position-relative">

							<div class="xis-saas-feature-img1 text-right wow zoomIn" data-wow-delay="0ms" data-wow-duration="1500ms">
								<img src="<?php echo esc_url($settings['illustration1']['url']);?>">
							</div>

							<div class="xis-saas-feature-img2 position-absolute wow fadeInLeft" data-wow-delay="700ms" data-wow-duration="1500ms">
								<img src="<?php echo esc_url($settings['illustration2']['url']);?>">
							</div>

							<div class="xis-saas-feature-img3 position-absolute wow fadeInDown" data-wow-delay="1000ms" data-wow-duration="1500ms">
								<img src="<?php echo esc_url($settings['illustration3']['url']);?>">
							</div>

							<div class="xis-saas-feature-img4 position-absolute">
								<img src="<?php echo esc_url($settings['illustration4']['url']);?>">
							</div>

							<div class="xis-saas-feature-img5 position-absolute">
								<img src="<?php echo esc_url($settings['illustration5']['url']);?>">
							</div>

							<div class="xis-saas-feature-img6 position-absolute">
								<img src="<?php echo esc_url($settings['illustration6']['url']);?>">
							</div>

							<div class="xis-saas-feature-img7 position-absolute">
								<img src="<?php echo esc_url($settings['illustration7']['url']);?>">
							</div>

						</div>
					</div>
					<div class="col-lg-6">
						<div class="xis-saas-feature-text-wrapper">
							<div class="xis-saas-section-title  xis-saas-headline wow fadeInUp" data-wow-delay="0ms" data-wow-duration="1500ms">
								<h2><?php echo wp_kses( $settings['title'], true );?></h2>
							</div>
							<div class="xis-saas-feature-text pera-content wow fadeInUp" data-wow-delay="200ms" data-wow-duration="1500ms">
								<p><?php echo wp_kses( $settings['description'], true );?></p>
								<div class="xis-saas-feature-list ul-li-block">
									<ul>
                                        <?php foreach($settings['listitem'] as $item):?>
										<li><?php echo esc_html($item['title']);?></li>
                                        <?php endforeach;?>
									</ul>
								</div>
							</div>
							<div class="xis-saas-btn wow fadeInLeft" data-wow-delay="400ms" 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']);?> <i class="fal fa-long-arrow-right"></i></a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>				
<!-- End of Feature section
	============================================= -->	
    <?php  
    }
	
}

