<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Border;
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
/**
 *
 * Course Curriculum widget.
 *
 * @since 1.0.0
 */
class Widgetkit_Pro_LearnDash_Course_Curriculum extends Widget_Base {

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

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

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

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

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

	public function get_script_depends() {
        return [
            'wk-pro-js'
        ];
    }

	protected function register_controls() {

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

		
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'label' => __( 'Typography', 'widgetkit-pro' ),
				'name' => 'section_title_typography',
				'selector' => '{{WRAPPER}} .learndash-wrapper .ld-section-heading',
			]
		);

		$this->add_control(
			'section_title_color',
			[
				'label' => __( 'Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .learndash-wrapper .ld-section-heading h2' => 'color: {{VALUE}} !important;'
				]
			]
		);

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

		$this->end_controls_section();

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

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				[
					'label' => __( 'Typography', 'widgetkit-pro' ),
					'name' => 'lesson_title_typography',
					'selector' => '{{WRAPPER}} .learndash-wrapper .ld-item-list .ld-item-list-item .ld-item-list-item-preview .ld-item-title,{{WRAPPER}} .learndash-wrapper .ld-item-list .ld-item-list-item .ld-item-list-item-preview .ld-item-title .ld-item-components',
				]
			);

			// title color tabs
			$this->start_controls_tabs('lesson_title_color_tabs');
				$this->start_controls_tab(
					'lesson_title_style_normal',
					[
						'label' => __( 'Normal', 'widgetkit-pro' ),
					]
				);
					$this->add_control(
						'lesson_title_color',
						[
							'label' => __( 'Color', 'widgetkit-pro' ),
							'type' => Controls_Manager::COLOR,
							'selectors' => [
								'{{WRAPPER}} .learndash-wrapper .ld-item-list .ld-item-list-item .ld-item-list-item-preview .ld-item-title' => 'color: {{VALUE}} !important;'
							]
						]
					);
				$this->end_controls_tab();
				
				//hover style
				$this->start_controls_tab(
					'lesson_title_style_hover',
					[
						'label' => __( 'Hover', 'widgetkit-pro' ),
					]
				);
				

					$this->add_control(
						'lesson_title_hover_color',
						[
							'label' => __( 'Hover Color', 'widgetkit-pro' ),
							'type' => Controls_Manager::COLOR,
							'selectors' => [
								'{{WRAPPER}} .learndash-wrapper .ld-item-list .ld-item-list-item .ld-item-list-item-preview a:hover .ld-item-title' => 'color: {{VALUE}} !important;'
							]
						]
					);

				$this->end_controls_tab();
			$this->end_controls_tabs();
			
			$this->add_control(
				'lesson_title_background_color',
				[
					'label' => __( 'Background Color', 'widgetkit-pro' ),
					'type' => Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .learndash-wrapper .ld-item-list .ld-item-list-item .ld-item-list-item-preview' => 'background-color: {{VALUE}} !important;'
					]
				]
			);

			$this->add_control(
				'lesson_title_icon_color',
				[
					'label' => __( 'Icon Color', 'widgetkit-pro' ),
					'type' => Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .learndash-wrapper .ld-expand-button.ld-button-alternate .ld-icon' => 'color: {{VALUE}} !important;'
					]
				]
			);

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

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

		$this->end_controls_section();

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

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				[
					'label' => __( 'Typography', 'widgetkit-pro' ),
					'name' => 'topic_header_typography',
					'selector' => '{{WRAPPER}} .learndash-wrapper .ld-table-list .ld-table-list-header',
				]
			);
				
			$this->add_control(
				'topic_header_color',
				[
					'label' => __( 'Color', 'widgetkit-pro' ),
					'type' => Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .learndash-wrapper .ld-table-list .ld-table-list-header' => 'color: {{VALUE}}!important;'
					]
				]
			);
				
			$this->add_control(
				'topic_header_background_color',
				[
					'label' => __( 'Background Color', 'widgetkit-pro' ),
					'type' => Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .learndash-wrapper .ld-table-list .ld-table-list-header' => 'background-color: {{VALUE}}!important;'
					]
				]
			);
			
			$this->add_control(
				'topic_header_margin',
				[
					'label' => __( 'Margin', 'widgetkit-pro' ),
					'type' => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%', 'em' ],
					'selectors' => [
						'{{WRAPPER}} .learndash-wrapper .ld-table-list .ld-table-list-header' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
					]
				]
			);

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

		$this->end_controls_section();

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

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				[
					'label' => __( 'Typography', 'widgetkit-pro' ),
					'name' => 'topic_typography',
					'selector' => '{{WRAPPER}} .learndash-wrapper .ld-table-list a.ld-table-list-item-preview',
				]
			);

			// title color tabs
			$this->start_controls_tabs('topic_color_tabs');
				$this->start_controls_tab(
					'topic_color_style_normal',
					[
						'label' => __( 'Normal', 'widgetkit-pro' ),
					]
				);
					$this->add_control(
						'topic_color',
						[
							'label' => __( 'Color', 'widgetkit-pro' ),
							'type' => Controls_Manager::COLOR,
							'selectors' => [
								'{{WRAPPER}} .learndash-wrapper .ld-table-list a.ld-table-list-item-preview' => 'color: {{VALUE}} !important;'
							]
						]
					);
				$this->end_controls_tab();
				
				//hover style
				$this->start_controls_tab(
					'topic_style_hover',
					[
						'label' => __( 'Hover', 'widgetkit-pro' ),
					]
				);
				

					$this->add_control(
						'topic_hover_color',
						[
							'label' => __( 'Hover Color', 'widgetkit-pro' ),
							'type' => Controls_Manager::COLOR,
							'selectors' => [
								'{{WRAPPER}} .learndash-wrapper .ld-table-list a.ld-table-list-item-preview:hover' => 'color: {{VALUE}} !important;'
							]
						]
					);

				$this->end_controls_tab();
			$this->end_controls_tabs();

			$this->add_group_control(
				Group_Control_Border::get_type(),
				[
					'name' => 'topic_border',
					'selector' => '{{WRAPPER}} .learndash-wrapper .ld-table-list .ld-table-list-item',
					'separator' => 'before',
				]
			);

			$this->add_control(
				'topic_margin',
				[
					'label' => __( 'Margin', 'widgetkit-pro' ),
					'type' => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%', 'em' ],
					'selectors' => [
						'{{WRAPPER}} .learndash-wrapper .ld-table-list a.ld-table-list-item-preview' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
					]
				]
			);

			$this->add_control(
				'topic_padding',
				[
					'label' => __( 'Padding', 'widgetkit-pro' ),
					'type' => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%', 'em' ],
					'selectors' => [
						'{{WRAPPER}} .learndash-wrapper .ld-table-list a.ld-table-list-item-preview' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
					]
				]
			);

		$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(
			'curriculum_style',
			[
				'label' => __( 'Curriculum Style', 'widgetkit-pro' ),
				'type' => Controls_Manager::SELECT,
				'default' => 'collapse',
				'options' => [
					'collapse'  => __( 'Collapse', 'widgetkit-pro' ),
					'grid' => __( 'Grid', 'widgetkit-pro' )
				],
			]
		);

		$this->end_controls_section();
	}

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

}