<?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 cripto_banner_widget 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 'xim-crypto-banner';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Crypto Banner', '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(
            'slider_options',
            [
                'label' => __( 'Banner Image Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'banner_img',
			[
				'label' => esc_html__( 'Banner BG Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);

        $this->end_controls_section();
        $this->start_controls_section(
            'banner_content_options',
            [
                'label' => __( 'Banner Content Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'We are Digital Marketing', '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,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'button_label',
			[
				'label' => esc_html__( 'Button Label', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Get In Touch', 'ximsa' ),
				'placeholder' => esc_html__( 'Type Slider Button Label Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        $this->add_control(
			'button_link',
			[
				'label' => esc_html__( 'Button Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        $this->add_control(
			'coine_img',
			[
				'label' => esc_html__( 'Coine Image', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'default' => [],
			]
		);
		$this->end_controls_section();
        $this->start_controls_section(
            'slider_settings_style',
            [
                'label' => __( 'Banner Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        
        $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}} .banner-section-two .content-column h1' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'sl_title_leter_cl',
            [
                'label'     => esc_html__( 'Title Leter Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .banner-section-two .content-column h1 span' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .banner-section-two .content-column h1',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'slider_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}} .btn-style-fifteen .txt' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_desc_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .btn-style-fifteen .txt
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        
		$this->end_controls_section();
        
        $this->start_controls_section(
            'button__content',
            [
                'label' => __( 'Crypto 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-fifteen .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}} .btn-style-fifteen' => '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}} .btn-style-fifteen
                ',
            ]
        );
        $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}} .btn-style-fifteen' => '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}} .btn-style-fifteen: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}} .btn-style-fifteen: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}} .btn-style-fifteen: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();?>        
	<!-- Banner Section Two -->
	<section class="banner-section-two" style="background-image: url(<?php echo esc_url($settings['banner_img']['url']);?>)">
		<!-- Icon Layer One -->
		<div class="auto-container">
			<div class="row clearfix">
			
				<!-- Content Column -->
				<div class="content-column col-lg-6 col-md-12 col-sm-12">
					<div class="inner-column">
						<h1 class="wow fadeInUp" data-wow-delay="0ms" data-wow-duration="1500ms"><?php echo __($settings['title']);?></h1>
						<div class="text wow fadeInUp" data-wow-delay=".5s" data-wow-duration="1500ms"><?php echo __($settings['description']);?></div>
						<a href="<?php echo esc_url($settings['button_link']['url']);?>" class="wow fadeInUp theme-btn btn-style-fifteen" data-wow-delay="1s" data-wow-duration="1500ms"><span class="txt"><?php echo esc_html($settings['button_label']);?> <i class="fa fa-chevron-circle-right"></i></span></a>
					</div>
				</div>
				<?php if(!empty($settings['coine_img']['url'])):?>
				<!-- Image Column -->
				<div class="image-column col-lg-6 col-md-12 col-sm-12">
					<div class="inner-column">
						<div class="image updown-animate">
							<img src="<?php echo esc_url($settings['coine_img']['url']);?>" alt="" />
						</div>
					</div>
				</div>
				<?php endif;?>
			</div>
		</div>
	</section>
	<!-- End Banner Section Two -->
    <?php  
    }
	
}

