<?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 it_v2_scroll_section 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 'itsl-v2-scroll';
	}

	/**
	 * 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 Solution Scroll', '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(
            'ins_about_opt',
            [
                'label' => __( 'Insurance About', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $repeater = new Repeater();
		$repeater->add_control(
			'icon', [
				'label' => esc_html__( 'Icon', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::ICONS,
				'label_block' => true,
			]
		);

		$repeater->add_control(
			'title', [
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'show_label' => true,
			]
		);

		$repeater->add_control(
			'link', [
				'label' => esc_html__( 'Link', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::URL,
				'show_label' => true,
			]
		);
		$this->add_control(
			'socials',
			[
				'label' => esc_html__( 'Add Social Item', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);
		$this->add_control(
			'scroll_down_text', [
				'label' => esc_html__( 'Scroll Down Text', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'show_label' => true,
			]
		);
		$this->add_control(
			'scroll_down_link', [
				'label' => esc_html__( 'Scroll Down Link', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::URL,
				'show_label' => true,
			]
		);
		$this->add_control(
			'email', [
				'label' => esc_html__( 'Email Text', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'show_label' => true,
			]
		);
		$this->end_controls_section();

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

        $this->add_control(
            'about_box_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'About Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'about_box_verlay',
            [
                'label'     => esc_html__( 'Box Overlay Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .ximsa-about-title:before' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'about_box_title',
            [
                'label'     => esc_html__( 'Box Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .ximsa-about-title h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'about_title__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .ximsa-about-title h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'faanfact_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Fanfact Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'fanfact_number_cl',
            [
                'label'     => esc_html__( 'Fanfact Number Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .ximsa-it-counter-it-counter .inner-text h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fnf_number__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .ximsa-it-counter-it-counter .inner-text h3',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fanfact_title_cl',
            [
                'label'     => esc_html__( 'Fanfact Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .ximsa-it-counter-it-counter .inner-text p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fnf_title__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .ximsa-it-counter-it-counter .inner-text p',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );

		$this->end_controls_section();
	}



	protected function render() {
	$settings = $this->get_settings_for_display();?>
	    <!-- Start of Scroll Down section
        ============================================= -->
        <div class="ximsa-it-scroll-down-contnet d-flex justify-content-between align-items-center">
            <div class="scroll-social ul-li wow fadeInUp" data-wow-delay="200ms" data-wow-duration="1500ms">
                <ul>
                    <?php foreach($settings['socials'] as $item):?>
                    <li><?php \Elementor\Icons_Manager::render_icon( $item['icon'], [ 'aria-hidden' => 'true' ] ); ?>
                        <a
                        class="text-uppercase"
                        href="<?php echo esc_url($item['link']['url']);?>"
                        target="<?php echo esc_attr( $item['link']['is_external'] ? '_blank' : '_self' ); ?>"
                        rel="<?php echo esc_attr( $item['link']['nofollow'] ? 'nofollow' : '' ); ?>"
                        >
                        <?php echo esc_html($item['title']);?></a>
                    </li>
                    <?php endforeach;?>
                </ul>
            </div>
            <div class="scroll-down-icon text-center position-relative wow fadeInUp" data-wow-delay="400ms" data-wow-duration="1500ms">
                <a href="<?php echo esc_html($settings['scroll_down_link']['url']);?>">
                <div class="scroll-icon-area d-flex justify-content-center align-items-center">
                    <i class="fal fa-long-arrow-down"></i>
                </div>
                <span class="scroll-text text-uppercase"><?php echo esc_html($settings['scroll_down_text']);?></span>
                </a>
            </div>
            <div class="scroll-mail text-uppercase wow fadeInUp" data-wow-delay="600ms" data-wow-duration="1500ms">
                <a href="mailto:<?php echo esc_url($settings['email'])?>"><?php echo esc_html($settings['email'])?></a>
            </div>
        </div>
        <!-- End of Scroll Down  section
        ============================================= -->
    <?php
    }

}
