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

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

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

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

	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(
            'title_control',
            [
                'label' => __('Title', 'widgetkit-pro'),
            ]
        );
        $this->add_control(
            'section_title',
            [
                'label'       => __( 'Title', 'widgetkit-pro' ),
                'type' => Controls_Manager::TEXT,
                'default' => __( 'Instructor', 'plugin-domain' ),
            ]
        );

        $this->end_controls_section();


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

		$this->add_control(
            'title_section',
            [
            	'label' => __( 'Title', 'widgetkit-pro' ),
            	'type' => Controls_Manager::HEADING
            ]
        );

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

        $this->add_control(
			'title_margin',
			[
				'label' => __( 'Margin', 'widgetkit-pro' ),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%', 'em' ],
				'selectors' => [
					'{{WRAPPER}} .learndash-course-instructor h4' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
				]
			]
		);

        $this->add_control(
			'title_padding',
			[
				'label' => __( 'Padding', 'widgetkit-pro' ),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%', 'em' ],
				'selectors' => [
					'{{WRAPPER}} .learndash-course-instructor h4' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
				]
			]
        );
        
        $this->end_controls_section();

    
		// Author Name Style
		$this->start_controls_section(
			'author_name_style_section',
			[
				'label' => __( 'Name', 'widgetkit-pro' ),
				'tab' => Controls_Manager::TAB_STYLE,
			]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'author_name_typography',
                'selector' => '{{WRAPPER}} .learndash-course-instructor .course-author .author-name',
            ]
        );

        $this->add_control(
			'author_name_color',
			[
				'label' => __( 'Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .learndash-course-instructor .course-author .author-name' => 'color: {{VALUE}};'
				]
			]
        );
        
        $this->add_responsive_control(
            'author_name_spacing',
            [
                'label'   => esc_html__( 'Spacing', 'widgetkit-pro' ),
                'type'    => Controls_Manager::SLIDER,
                'default' => [
                    'size'    => 15,
                ],
                'range'  => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .learndash-course-instructor .course-author .author-image' => 'margin-right: {{SIZE}}{{UNIT}};',
                ]
            ]
        );

        
        $this->end_controls_section();

        // Author Bio Style
		$this->start_controls_section(
			'author_bio_style_section',
			[
				'label' => __( 'Bio', 'widgetkit-pro' ),
				'tab' => Controls_Manager::TAB_STYLE,
			]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'author_bio_typography',
                'selector' => '{{WRAPPER}} .learndash-course-instructor .course-author-description',
            ]
        );

        $this->add_control(
			'author_bio_color',
			[
				'label' => __( 'Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .learndash-course-instructor .course-author-description' => 'color: {{VALUE}};'
				]
			]
        );
        
        $this->add_responsive_control(
            'author_bio_spacing',
            [
                'label'   => esc_html__( 'Spacing', 'widgetkit-pro' ),
                'type'    => Controls_Manager::SLIDER,
                'range'  => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .learndash-course-instructor .course-author-description' => 'margin-top: {{SIZE}}{{UNIT}};',
                ]
            ]
        );

        
        $this->end_controls_section();

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

        $this->add_control(
			'global_padding',
			[
				'label' => __( 'Padding', 'widgetkit-pro' ),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%', 'em' ],
				'selectors' => [
					'{{WRAPPER}} .learndash-course-instructor' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
				]
			]
        );

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

        $this->add_group_control(
            Group_Control_Box_Shadow::get_type(),
            [
                'label' => __( 'Box Shadow', 'widgetkit-pro' ),
                'type' => Group_Control_Box_Shadow::get_type(),
                'name' => 'global_box_shadow',
                'selector' => '{{WRAPPER}} .learndash-course-instructor',
            ]
        );

        $this->add_group_control(
            Group_Control_Border::get_type(),
            [
                'label' => __( 'Border', 'widgetkit-pro' ),
                'name' => 'global_box_border',
                'selector' => '{{WRAPPER}} .learndash-course-instructor',
            ]
        );

        $this->end_controls_section();
	}

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

}