<?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_about 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-about';
	}

	/**
	 * 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 About', '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_about_options',
            [
                'label' => __( 'Saas About Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'saas_about_bg',
			[
				'label' => esc_html__( 'About Shape Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'dashboard1',
			[
				'label' => esc_html__( 'Dashboard 1', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'dashboard2',
			[
				'label' => esc_html__( 'Dashboard 2', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'dashboard3',
			[
				'label' => esc_html__( 'Dashboard 3', '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,
			]
		);
        

        $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,
			]
		);
        $repeater->add_control(
			'description',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'featurebox',
			[
				'label' => esc_html__( 'Add Feature Box', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);

        $repeater = new \Elementor\Repeater();        
        
        $repeater->add_control(
			'number',
			[
				'label' => esc_html__( 'Number', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
			]
		);
        
        $repeater->add_control(
			'symbole',
			[
				'label' => esc_html__( 'Symbole', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
			]
		);
        
        $repeater->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'fanfact_box',
			[
				'label' => esc_html__( 'Add Fanfact Box', '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(
			'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(
            'feature_box_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Box Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'fs_title_cl',
            [
                'label'     => esc_html__( 'Feature Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-saas-about-feature-item .xis-saas-inner-text h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-saas-about-feature-item .xis-saas-inner-text h3
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_text_cl',
            [
                'label'     => esc_html__( 'Feature Text Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-saas-inner-text.xis-saas-headline.pera-content p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_txt_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-saas-inner-text.xis-saas-headline.pera-content p
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'icon-bgbackground',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-saas-about-feature-item .xis-saas-inner-icon',
			]
		);
        $this->add_control(
            'fnf_box_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Fanfact Box Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'number_cl',
            [
                'label'     => esc_html__( 'Number Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-saas-about-funfact-item .funfact-counter h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'no_cl_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-saas-about-funfact-item .funfact-counter h3
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'ff_title_cl',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-saas-about-funfact-item p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fn_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-saas-about-funfact-item p
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'fnf-bgbackground',
				'label' => esc_html__( 'Background', 'plugin-name' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-saas-about-funfact-item .funfact-counter',
			]
		);
		$this->end_controls_section();
	}
		


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

							<div class="xis-saas-about-img1 position-relative wow fadeInRight" data-wow-delay="0ms" data-wow-duration="1500ms">
								<img src="<?php echo esc_url($settings['dashboard1']['url']);?>">
							</div>

							<div class="xis-saas-about-img2 position-absolute wow fadeInLeft" data-wow-delay="300ms" data-wow-duration="1500ms">
								<img src="<?php echo esc_url($settings['dashboard2']['url']);?>">
							</div>
							<div class="xis-saas-about-img3 position-absolute wow fadeInLeft" data-wow-delay="500ms" data-wow-duration="1500ms">
								<img src="<?php echo esc_url($settings['dashboard3']['url']);?>">
							</div>
						</div>
					</div>
					<div class="col-lg-7">
						<div class="xis-saas-about-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-about-feature-wrapper d-flex justify-content-between flex-wrap">

                                <?php foreach($settings['featurebox'] as $item):?>
								<div class="xis-saas-about-feature-item d-flex wow fadeInUp" data-wow-delay="0ms" data-wow-duration="1500ms">
									<div class="xis-saas-inner-icon d-flex align-items-center justify-content-center">
										<img src="<?php echo esc_url($item['icon']['url']);?>">
									</div>
									<div class="xis-saas-inner-text xis-saas-headline pera-content">
										<h3><?php echo esc_html($item['title']);?></h3>
										<p><?php echo wp_kses( $item['description'], true );?></p>
									</div>
								</div>
                                <?php endforeach;?>
                                
							</div>
							<div class="xis-saas-about-funfact-wrapper d-flex justify-content-between">
                                <?php foreach($settings['fanfact_box'] as $countr):?>
								<div class="xis-saas-about-funfact-item text-center xis-saas-headline pera-content">
									<div class="funfact-counter d-flex align-items-center justify-content-center">
										<h3><span class="odometer" data-count="<?php echo esc_attr($countr['number']);?>"> </span><?php echo esc_html($countr['symbole']);?></h3>
									</div>
									<p><?php echo esc_html($countr['title']);?></p>
								</div>
								<?php endforeach;?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
<!-- End of About section
	============================================= -->
    <?php  
    }
	
}

