<?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 Resource widget.
 *
 * @since 1.0.0
 */
class Widgetkit_Pro_LearnDash_Course_Resource extends Widget_Base {

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

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

	public function get_icon() {
		return 'eicon-table-of-contents';
	}

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

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

	protected function register_controls() {

		//title style
		$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-resource-wrapper ul li .course-resource .resource-title' => 'color: {{VALUE}};',
						'{{WRAPPER}} .learndash-course-resource-wrapper ul li .course-resource .resource-title i' => 'color: {{VALUE}};',
					]
				]
			);
			$this->add_group_control(
				Group_Control_Typography::get_type(),
					[
						'name'     => 'title_typography',
						'label'    => esc_html__( 'Typography', 'widgetkit-pro' ),
						'selector' => '{{WRAPPER}} .learndash-course-resource-wrapper ul li .course-resource .resource-title',
					]
			);
			
			$this->add_group_control(
				Group_Control_Border::get_type(),
				[
					'name' => 'title_border',
					'selector' => '{{WRAPPER}} .learndash-course-resource-wrapper ul li',
					'separator' => 'before',
				]
			);


			$this->add_responsive_control(
				'title_padding',
				[
					'label' => esc_html__( 'Padding', 'widgetkit-pro' ),
					'type'  => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%' ],
					'selectors'  => [
						'{{WRAPPER}} .learndash-course-resource-wrapper ul li' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					]
				]
			);
			
			$this->add_responsive_control(
				'title_margin',
				[
					'label' => esc_html__( 'Margin', 'widgetkit-pro' ),
					'type'  => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%' ],
					'selectors'  => [
						'{{WRAPPER}} .learndash-course-resource-wrapper ul li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					]
				]
			);

		$this->end_controls_section();

		//info style
		$this->start_controls_section(
			'course_resource_info_style',
			[
				'label' => esc_html__( 'Info', 'widgetkit-pro' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

			$this->add_control(
				'course_resource_info_color',
				[
					'label'     => esc_html__( 'Color', 'widgetkit-pro' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .learndash-course-resource-wrapper ul li .course-resource .resource-desc ' => 'color: {{VALUE}};',
					]
				]
			);

			$this->add_group_control(
				Group_Control_Typography::get_type(),
					[
						'name'     => 'course_short_desc_typography',
						'label'    => esc_html__( 'Typography', 'widgetkit-pro' ),
						'selector' => '.learndash-course-resource-wrapper ul li .course-resource .resource-desc',
					]
			);


		$this->end_controls_section();

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

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

                $this->add_control(
		            'content_border_radius',
		            [
		                'label' => esc_html__( 'Border Radius', 'widgetkit-pro' ),
		                'type'  => Controls_Manager::DIMENSIONS,
		                'size_units' => [ 'px', '%' ],
		                'selectors'  => [
		                    '{{WRAPPER}} .learndash-course-resource-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		                ]
		            ]
                );
                
                
                $this->add_group_control(
                    Group_Control_Box_Shadow::get_type(),
                    [
                        'name' => 'content_box_shadow',
                        'selector' => '{{WRAPPER}} .learndash-course-resource-wrapper',
                    ]
                );

		$this->end_controls_section();

	}

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

}