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

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

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

	public function get_icon() {
		return 'eicon-user-circle-o';
	}

	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(
			'general_section',
			[
				'label' => __( 'General', 'widgetkit-pro' ),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
        );

        $this->add_control(
            'course_period',
            [
            	'label' => __( 'Course Period', 'widgetkit-pro' ),
                'type' => Controls_Manager::TEXTAREA,
                'default'  => __('3 months access', 'widgetkit-pro')
            ]
        );

        $this->add_control(
            'course_enrollment_descrition',
            [
            	'label' => __( 'Enrollment Description', 'widgetkit-pro' ),
                'type' => Controls_Manager::TEXTAREA,
                'default'  => __('Start Learning Today! Get maximum flexibility to learn at your own pace.', 'widgetkit-pro')
            ]
        );
        
        $this->add_control(
            'course_enrollment_back_text',
            [
            	'label' => __( 'Policy Text', 'widgetkit-pro' ),
                'type' => Controls_Manager::TEXTAREA,
                'default'  => __('30-Day Money-Back Guarantee.', 'widgetkit-pro')
            ]
        );
        
        $this->end_controls_section();

		// Course Period Style
		$this->start_controls_section(
			'course_period_style_section',
			[
				'label' => __( 'Course Period', 'widgetkit-pro' ),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'course_period_typography',
				'selector' => '{{WRAPPER}} .ld-course-enrollment-top > span',
            ]
        );

        $this->add_control(
			'course_period_color',
			[
				'label' => __( 'Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .ld-course-enrollment-top > span' => 'color: {{VALUE}}'
				]
			]
        );

		$this->end_controls_section();

		// Course Period Style
		$this->start_controls_section(
			'course_price_style_section',
			[
				'label' => __( 'Course Price', 'widgetkit-pro' ),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);


		$this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'course_price_typography',
				'selector' => '{{WRAPPER}} .ld-course-enrollment-top h3',
            ]
        );
			
		$this->add_control(
			'course_price_color',
			[
				'label' => __( 'Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .ld-course-enrollment-top h3' => 'color: {{VALUE}}'
				]
			]
		);

		$this->add_responsive_control(
			'course_price_spacing',
			[
				'label' => __( 'Bottom Spacing', 'widgetkit-pro' ),
				'type' => Controls_Manager::SLIDER,
                'range' => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                        'step' => 1,
                    ],
                ],
                'size_units' => [ 'px' ],
				'selectors' => [
					'{{WRAPPER}} .ld-course-enrollment-top h3' => 'margin-bottom: {{SIZE}}{{UNIT}};',
				]
			]
		);


		$this->end_controls_section();
		
		// Course description Style
		$this->start_controls_section(
			'course_description_style_section',
			[
				'label' => __( 'Description', 'widgetkit-pro' ),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);
		
		$this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'course_enrollment_descrition_title_typography',
				'selector' => '{{WRAPPER}} .ld-course-enrollment-description p,{{WRAPPER}} .ld-course-enrollment-description h3 span,.ld-course-enrollment-user span.course-members',
            ]
        );
			
		$this->add_control(
			'course_enrollment_descrition_color',
			[
				'label' => __( 'Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .ld-course-enrollment-description p' => 'color: {{VALUE}}'
				]
			]
		);

		$this->add_responsive_control(
			'course_enrollment_descrition_spacing',
			[
				'label' => __( 'Bottom Spacing', 'widgetkit-pro' ),
				'type' => Controls_Manager::SLIDER,
                'range' => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                        'step' => 1,
                    ],
                ],
                'size_units' => [ 'px' ],
				'selectors' => [
					'{{WRAPPER}} .ld-course-enrollment-description' => 'margin-bottom: {{SIZE}}{{UNIT}};',
				]
			]
		);
		
		$this->end_controls_section();
        
        
		// Policy text Style
		$this->start_controls_section(
			'course_policy_text_style_section',
			[
				'label' => __( 'Policy Text', 'widgetkit-pro' ),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);
		
		$this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'button_buttom_text_typography',
				'selector' => '{{WRAPPER}} .ld-course-enrollment-bottom p',
            ]
        );
			
		$this->add_control(
			'button_buttom_text_color',
			[
				'label' => __( 'Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .ld-course-enrollment-bottom p' => 'color: {{VALUE}}'
				]
			]
		);

		$this->add_responsive_control(
			'button_buttom_text_spacing',
			[
				'label' => __( 'Bottom Spacing', 'widgetkit-pro' ),
				'type' => Controls_Manager::SLIDER,
                'range' => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                        'step' => 1,
                    ],
                ],
                'size_units' => [ 'px' ],
				'selectors' => [
					'{{WRAPPER}} .ld-course-enrollment-bottom p' => 'margin-top: {{SIZE}}{{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}} .ld-course-enrollment-bottom .btn-join,{{WRAPPER}} .ld-course-enrollment-bottom .course-status',
			]
		);

		$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}} .ld-course-enrollment-bottom .btn-join' => 'color: {{VALUE}}!important;',
					'{{WRAPPER}} .ld-course-enrollment-bottom .course-status' => 'color: {{VALUE}}!important;',
				]
			]
		);

		$this->add_control(
			'button_background_color',
			[
				'label' => __( 'Background Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .ld-course-enrollment-bottom .btn-join' => 'background-color: {{VALUE}}!important;',
					'{{WRAPPER}} .ld-course-enrollment-bottom .course-status' => '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}} .ld-course-enrollment-bottom .btn-join:hover' => 'color: {{VALUE}}!important;',
					'{{WRAPPER}} .ld-course-enrollment-bottom .course-status:hover' => 'color: {{VALUE}}!important;',
				]
			]
		);

		$this->add_control(
			'button_background_hover_color',
			[
				'label' => __( 'Background Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .ld-course-enrollment-bottom .btn-join:hover' => 'background-color: {{VALUE}}!important;',
					'{{WRAPPER}} .ld-course-enrollment-bottom .course-status: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}} .ld-course-enrollment-bottom .btn-join,{{WRAPPER}} .ld-course-enrollment-bottom .course-status',
				'separator' => 'before',
			]
		);

		$this->add_control(
			'button_border_radius',
			[
				'label' => __( 'Border Radius', 'widgetkit-pro' ),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%' ],
				'selectors' => [
					'{{WRAPPER}} .ld-course-enrollment-bottom .btn-join' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
					'{{WRAPPER}} .ld-course-enrollment-bottom .course-status' => '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}} .ld-course-enrollment-bottom .btn-join' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
					'{{WRAPPER}} .ld-course-enrollment-bottom .course-status' => '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(
            'global_content_padding',
            [
                'label' => esc_html__( 'Padding', 'widgetkit-pro' ),
                'type'  => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%' ],
                'selectors'  => [
                    '{{WRAPPER}} .ld-course-enrollment-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ]
            ]
        );

        $this->add_control(
            'global_content_border_radius',
            [
                'label' => esc_html__( 'Border Radius', 'widgetkit-pro' ),
                'type'  => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%' ],
                'selectors'  => [
                    '{{WRAPPER}} .ld-course-enrollment-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ]
            ]
        );

        $this->add_control(
            'global_content_item_bg_color',
            [
                'label'     => esc_html__( 'Background Color', 'widgetkit-pro' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '',
                'selectors' => [
                    '{{WRAPPER}} .ld-course-enrollment-wrapper' => 'background: {{VALUE}};'
                ]
            ]
		);
		
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			[
				'name' => 'global_box_shadow',
				'selector' => '{{WRAPPER}} .ld-course-enrollment-wrapper',
			]
		);
        
        $this->end_controls_section();

	}

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

}