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

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Fintech Subscribe', '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(
            'subscribe_info',
            [
                'label' => __( 'Subscribe Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'subscribe_pattern',
			[
				'label' => esc_html__( 'Subscribe Pattern', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'default' => [],
			]
		);
        $this->add_control(
			'subscribe_img',
			[
				'label' => esc_html__( 'Subscribe Image', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'default' => [],
			]
		);
        $this->add_control(
			'subscribe_title',
			[
				'label' => esc_html__( 'Subscribe Title', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXTAREA,
				'default' => [],
			]
		);
        $this->add_control(
			'subscribe_form',
			[
				'label' => esc_html__( 'Subscribe Form', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXTAREA,
				'default' => [],
			]
		);
        
		$this->end_controls_section();
        $this->start_controls_section(
            'subscribe_st',
            [
                'label' => __( 'Subscribe Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_control(
            'subscribe_banner',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Subscribe Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'subscribe_bg',
            [
                'label'     => esc_html__( 'Subscribe BG Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .subscribe-section-three .inner-container' => 'background: {{VALUE}} ',
                ],
            ]
        );
        $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}} .subscribe-section-three .title-box h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'sl_clr_title_cl',
            [
                'label'     => esc_html__( 'Colerd Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .subscribe-section-three .title-box h2 span' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .subscribe-section-three .title-box h2',
                '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}} .btn-style-nineteen .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', 'ximsa' ),
            ]
        );
        $this->add_control(
            'btn__color',
            [
                'label'     => esc_html__( 'Color', 'ximsa' ),
                'type'      => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .btn-style-nineteen' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .btn-style-nineteen
                ',
            ]
        );
        $this->add_responsive_control(
            'btn_border_radious',
            [
                'label'      => esc_html__( 'Border Radius', 'ximsa' ),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .btn-style-nineteen' => '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', 'ximsa' ),
            ]
        );
        $this->add_control(
            'btn__hover_color',
            [
                'label'     => esc_html__( 'Color', 'ximsa' ),
                'type'      => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .btn-style-nineteen:hover' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_hover_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .btn-style-nineteen:before
                ',
            ]
        );
        $this->add_responsive_control(
            'btn_hover_border_radious',
            [
                'label'      => esc_html__( 'Border Radius', 'ximsa' ),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .btn-style-nineteen: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(); ?>
        <!-- Subscribe Section Three -->
        <section class="subscribe-section-three">
            <div class="bubble-dotted">
                <span class="dotted dotted-1"></span>
                <span class="dotted dotted-2"></span>
                <span class="dotted dotted-3"></span>
                <span class="dotted dotted-4"></span>
                <span class="dotted dotted-5"></span>
                <span class="dotted dotted-6"></span>
                <span class="dotted dotted-7"></span>
                <span class="dotted dotted-8"></span>
                <span class="dotted dotted-9"></span>
                <span class="dotted dotted-10"></span>
            </div>
            <div class="auto-container">
                <div class="inner-container">
                    <div class="pattern-layer" style="background-image: url(<?php echo esc_url($settings['subscribe_pattern']['url']);?>)"></div>
                    <div class="side-icon">
                        <img src="<?php echo esc_url($settings['subscribe_img']['url']);?>" alt="" />
                    </div>
                    <div class="title-box">
                        <h2><?php echo wp_kses( $settings['subscribe_title'], true );?></h2>
                    </div>
                    
                    <!-- Email Box Three -->
                    <div class="email-box-three">
                        <?php echo do_shortcode( $settings['subscribe_form'] );?>
                    </div>
                    
                </div>
            </div>
        </section>
        <!-- End Subscribe Section Three -->
    <?php  
    }
	
	

}

