<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
Use Elementor\Core\Schemes\Typography;
use Elementor\Utils;
use Elementor\Group_Control_Border;
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
/**
 *
 * Course Banner widget.
 *
 * @since 1.0.0
 */
class Widgetkit_Pro_LearnDash_Course_Banner extends Widget_Base {

	public function get_name() {
		return 'widgetkit-pro-learndash-course-banner';
	}

	public function get_title() {
		return __( 'Learndash Course Banner', 'widgetkit-pro' );
	}

	public function get_icon() {
		return 'eicon-banner';
	}

	public function get_categories() {
		return [ 'widgetkit_pro_learndash_elements' ];
    }
    
	public function get_style_depends() {
        return [
            'widgetkit_pro_default',
        ];
    }

	protected function register_controls() {

		$this->start_controls_section(
            'section_control_button',
            [
                'label' => __('Button', 'widgetkit-pro'),
            ]
		);
		
        $this->add_control(
            'button_trigger',
            [
                'label' => __( 'Show Button', 'widgetkit-pro' ),
				'type' => Controls_Manager::SWITCHER,
				'label_on' => __( 'Show', 'widgetkit-pro' ),
				'label_off' => __( 'Hide', 'widgetkit-pro' ),
				'return_value' => 'yes',
				'default' => 'yes',
            ]
		);
		
		$this->end_controls_section();

		$this->start_controls_section(
			'title_style',
			[
				'label' => esc_html__( 'Title', 'widgetkit-pro' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_control(
			'title_color',
			[
				'label'     => esc_html__( 'Color', 'widgetkit-pro' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner h1' => 'color: {{VALUE}};',
				]
			]
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
				[
					'name'     => 'title_typography',
					'label'    => esc_html__( 'Typography', 'widgetkit-pro' ),
					'selector' => '{{WRAPPER}} .learndash-course-banner h1',
				]
		);


		$this->add_responsive_control(
			'title_spacing',
				[
					'label'   => esc_html__( 'Spacing', 'widgetkit-pro' ),
					'type'    => Controls_Manager::SLIDER,
					'range'  => [
						'px' => [
							'min' => 0,
							'max' => 200,
						]
					],
					'selectors' => [
						'{{WRAPPER}} .learndash-course-banner h1' => 'margin-bottom: {{SIZE}}{{UNIT}};',
					]
				]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'desc_style',
			[
				'label' => esc_html__( 'Description', 'widgetkit-pro' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_control(
			'course_short_desc_color',
			[
				'label'     => esc_html__( 'Color', 'widgetkit-pro' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner p' => 'color: {{VALUE}};',
					'{{WRAPPER}} .learndash-course-banner .course-author .author-name' => 'color: {{VALUE}};',
				]
			]
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
				[
					'name'     => 'course_short_desc_typography',
					'label'    => esc_html__( 'Typography', 'widgetkit-pro' ),
					'selector' => '{{WRAPPER}} .learndash-course-banner p',
				]
		);


		$this->add_responsive_control(
			'course_short_desc_spacing',
				[
					'label'   => esc_html__( 'Spacing', 'widgetkit-pro' ),
					'type'    => Controls_Manager::SLIDER,
					'range'  => [
						'px' => [
							'min' => 0,
							'max' => 200,
						]
					],
					'selectors' => [
						'{{WRAPPER}} .learndash-course-banner p' => 'margin-bottom: {{SIZE}}{{UNIT}};',
					]
				]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'author_name_image_style',
			[
				'label' => esc_html__( 'Name & Image', 'widgetkit-pro' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_control(
			'author_name_color',
			[
				'label'     => esc_html__( 'Color', 'widgetkit-pro' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner p' => 'color: {{VALUE}};',
					'{{WRAPPER}} .learndash-course-banner .course-author .author-name' => 'color: {{VALUE}};',
				]
			]
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
				[
					'name'     => 'author_name_typography',
					'label'    => esc_html__( 'Typography', 'widgetkit-pro' ),
					'selector' => '{{WRAPPER}} .learndash-course-banner .course-author .author-name',
				]
		);

		$this->add_responsive_control(
			'author_name_image_spacing',
				[
					'label'   => esc_html__( 'Spacing', 'widgetkit-pro' ),
					'type'    => Controls_Manager::SLIDER,
					'range'  => [
						'px' => [
							'min' => 0,
							'max' => 200,
						]
					],
					'selectors' => [
						'{{WRAPPER}} .learndash-course-banner .course-author .author-image' => 'margin-right: {{SIZE}}{{UNIT}};',
					]
				]
		);

		$this->add_responsive_control(
			'author_name_image_width',
			[
				'label'   => esc_html__( 'Image Width', 'widgetkit-pro' ),
				'type'    => Controls_Manager::SLIDER,
				'range'  => [
					'px' => [
						'min' => 0,
						'max' => 200,
					]
				],
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner .course-author .author-image' => 'width: {{SIZE}}{{UNIT}};',
				]
			]
		);

		$this->add_control(
			'author_name_image_border_radius',
			[
				'label' => esc_html__( 'Border Radius', 'widgetkit-pro' ),
				'type'  => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%' ],
				'selectors'  => [
					'{{WRAPPER}} .learndash-course-banner .course-author .author-image img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
				]
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'button_style',
			[
				'label' => __( 'Button', 'widgetkit-pro' ),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name' => 'button_typography',
				'selector' => '{{WRAPPER}} .learndash-course-banner .course-banner-right .btn-join',
			]
		);

		$this->start_controls_tabs( 'tabs_button_style' );

		$this->start_controls_tab(
			'tab_button_normal',
			[
				'label' => __( 'Normal', 'widgetkit-pro' ),
			]
		);

		$this->add_control(
			'button_text_color',
			[
				'label' => __( 'Text Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner .course-banner-right .btn-join' => 'color: {{VALUE}}!important;'
				]
			]
		);

		$this->add_control(
			'button_background_color',
			[
				'label' => __( 'Background Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner .course-banner-right .btn-join' => 'background-color: {{VALUE}}!important;'
				]
			]
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'tab_button_hover',
			[
				'label' => __( 'Hover', 'widgetkit-pro' ),
			]
		);

		$this->add_control(
			'button_hover_color',
			[
				'label' => __( 'Text Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner .course-banner-right .btn-join:hover' => 'color: {{VALUE}}!important;'
				]
			]
		);

		$this->add_control(
			'button_background_hover_color',
			[
				'label' => __( 'Background Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner .course-banner-right .btn-join:hover' => 'background-color: {{VALUE}}!important;'
				]
			]
        );

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_group_control(
			Group_Control_Border::get_type(),
			[
				'name' => 'button_border',
				'selector' => '{{WRAPPER}} .learndash-course-banner .course-banner-right .btn-join',
				'separator' => 'before',
			]
		);

		$this->add_control(
			'button_border_radius',
			[
				'label' => __( 'Border Radius', 'widgetkit-pro' ),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%' ],
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner .course-banner-right .btn-join' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;'
				]
			]
		);

		$this->add_responsive_control(
			'button_text_padding',
			[
				'label' => __( 'Padding', 'widgetkit-pro' ),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', 'em', '%' ],
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner .course-banner-right .btn-join' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;'
				],
				'separator' => 'before'
			]
		);

		$this->end_controls_section();


		$this->start_controls_section(
			'global_style',
			[
				'label' => esc_html__( 'Global', 'widgetkit-pro' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_responsive_control(
			'content_padding',
			[
				'label' => esc_html__( 'Padding', 'widgetkit-pro' ),
				'type'  => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%' ],
				'selectors'  => [
					'{{WRAPPER}} .learndash-course-banner' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				]
			]
		);

		$this->add_control(
			'content_item_bg_color',
			[
				'label'     => esc_html__( 'Background Color', 'widgetkit-pro' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => [
					'{{WRAPPER}} .learndash-course-banner' => 'background: {{VALUE}};',
				]
			]
		);

		$this->end_controls_section();

	}

	protected function render() {
		include( plugin_dir_path( __FILE__ ) . '../layout/learndash-course-banner.php');
	}

}