<?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 nft_team 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 'nft-team';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'NFT Team', '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(
            'nft_team_opt',
            [
                'label' => __( 'NFT Team Option', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );        
        
        $this->add_control(
			'circle_shape',
			[
				'label' => esc_html__( 'Circle Shape', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'subtitle_shape',
			[
				'label' => esc_html__( 'Sub Title Shape', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'subtitle',
			[
				'label' => esc_html__( 'Sub Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_control(
			'subtitle_line',
			[
				'label' => esc_html__( 'Sub Title Line', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'title_main',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'title-shape-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'classic' ],
				'exclude' => [ 'color' ],
				'selector' => '{{WRAPPER}} .xis-nft-section-title-2 h2 span:before',
			]
		);
        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'authore_img',
			[
				'label' => esc_html__( 'Authore Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'authore_title',
			[
				'label' => esc_html__( 'Authore Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'count',
			[
				'label' => esc_html__( 'Count', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        
        $repeater->add_control(
			'price_label',
			[
				'label' => esc_html__( 'Price Label', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'price',
			[
				'label' => esc_html__( 'Price', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'rate',
			[
				'label' => esc_html__( 'Rate', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'rate_percent',
			[
				'label' => esc_html__( 'Rate Percent', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        
        $repeater->add_control(
			'link',
			[
				'label' => esc_html__( 'Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'topauthoress',
			[
				'label' => esc_html__( 'Add Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ authore_title }}}',
			]
		);
        $this->add_control(
			'btn_label',
			[
				'label' => esc_html__( 'Button Label', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_control(
			'btn_link',
			[
				'label' => esc_html__( 'Button Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
		$this->end_controls_section();
        $this->start_controls_section(
            'feature_settings_style',
            [
                'label' => __( 'Content Style 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_color',
            [
                'label'     => esc_html__( 'Description Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-section-title-2 .subtitle' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-nft-section-title-2 .subtitle',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'main_title_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'title_cl',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-section-title-2 h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'ttl_bg_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .xis-nft-section-title-2 h2 span
                ',
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-market-text-wrapper .xis-nft-section-title-2 h2
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        
        $this->add_control(
            'auth_title_desc',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Authore Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'auth_title_color',
            [
                'label'     => esc_html__( 'Authore Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-top-col-inner-item .inner-text-wrap .title-serial h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'auth_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-top-col-inner-item .inner-text-wrap .title-serial h3
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        

        $this->add_control(
            'ct_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Count Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'count_cl',
            [
                'label'     => esc_html__( 'Count Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-top-col-inner-item .inner-text-wrap .title-serial span' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'count_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-top-col-inner-item .inner-text-wrap .title-serial span
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'price_info_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Price Info Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'price_label_cl',
            [
                'label'     => esc_html__( 'Price Label Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-top-col-inner-item .inner-text-wrap .inner-price span' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'price__cl',
            [
                'label'     => esc_html__( 'Price Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-top-col-inner-item .inner-text-wrap .inner-price p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'price_info_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-top-col-inner-item .inner-text-wrap .inner-price p
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'like_info_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Like Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'rating_cl',
            [
                'label'     => esc_html__( 'Rating Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-top-col-inner-item .inner-text-wrap .ratting-1' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'rating_cl2',
            [
                'label'     => esc_html__( 'Rating 2 Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-top-col-inner-item .inner-text-wrap .ratting-2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'like_info_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-top-col-inner-item .inner-text-wrap .ratting-2,
                    .xis-nft-top-col-inner-item .inner-text-wrap .ratting-1
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'box_date_desc',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'CountDown Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'box-bg-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'classic', 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-nft-top-col-inner-item:before',
			]
		);
        $this->add_control(
            'box_bg_cl',
            [
                'label'     => esc_html__( 'Box Background Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-top-col-inner-item:after' => 'background: {{VALUE}} ',
                ],
            ]
        );
       
		$this->end_controls_section();
	}
		


	protected function render() {	
	$settings = $this->get_settings_for_display();?>        
        <!-- Start of Top collection section
        ============================================= -->
        <section id="xis-nft-top-collection" class="xis-nft-top-collection-section position-relative">
            <span class="xis-nft-side-shape1 position-absolute"><img src="<?php echo esc_url($settings['circle_shape']['url']);?>" alt=""></span>
            <div class="container">
                <div class="xis-nft-section-title-2 text-center xis-nft-headline wow fadeInUp"  data-wow-delay="0ms" data-wow-duration="1000ms">
                    <div class="subtitle position-relative">
                        <img src="<?php echo esc_url($settings['subtitle_shape']['url']);?>" alt=""><?php echo esc_html($settings['subtitle']);?> <span><img src="<?php echo esc_url($settings['subtitle_line']['url']);?>" alt=""></span>
                    </div>
                    <h2><?php echo wp_kses( $settings['title_main'], true );?></h2>
                </div>
                <div class="xis-nft-top-collection-content">
                    <div class="row">
                        <?php foreach($settings['topauthoress'] as $item):?>
                        <div class="col-lg-4 col-md-6 wow fadeInUp"  data-wow-delay="1000ms" data-wow-duration="1000ms">
                            <div class="xis-nft-top-col-inner-item d-flex aling-items-center">
                                <div class="inner-img-wrap position-relative">
                                    <div class="inner-img position-relative">
                                        <img src="<?php echo esc_url($item['authore_img']['url']);?>" alt="">
                                    </div>
                                </div>
                                <div class="inner-text-wrap xis-nft-headline pera-content">
                                    <div class="title-serial d-flex justify-content-between aling-items-center">
                                        <h3><a href="<?php echo esc_url($item['link']['url']);?>"><?php echo esc_html($item['authore_title']);?></a></h3>
                                        <span><?php echo esc_html($item['count']);?></span>
                                    </div>
                                    <div class="inner-price">
                                        <p><span><?php echo esc_html($item['price_label']);?></span> <i class="fab fa-ethereum"></i> <?php echo esc_html($item['price']);?></p>
                                    </div>
                                    <div class="inner-rate-wrap d-flex justify-content-between aling-items-center">
                                        <div class="ratting-1">
                                            <i class="fab fa-ethereum"></i><?php echo esc_html($item['rate']);?>
                                        </div>
                                        <div class="ratting-2">
                                            <?php echo esc_html($item['rate_percent']);?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php endforeach;?>
                    </div>
                    <div class="xis-nft-btn-2 d-flex justify-content-center">
                        <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']);?></a>
                    </div>
                </div>
            </div>
        </section>
    <!-- End of Top Collection section
        ============================================= -->
    <?php  
    }
	
}

