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

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

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

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

	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_section',
			[
				'label' => __( 'Title', 'widgetkit-pro' ),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				[
					'label' => __( 'Typography', 'widgetkit-pro' ),
					'name' => 'course_meta_title_typography',
					'selector' => '{{WRAPPER}} .wkld-course-meta-info .wkld-course-meta .meta-title',
				]
			);

			$this->add_control(
				'course_meta_title_color',
				[
					'label' => __( 'Color', 'widgetkit-pro' ),
					'type' => Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .wkld-course-meta-info .wkld-course-meta .meta-title' => 'color: {{VALUE}}'
					]
				]
			);

			$this->add_control(
				'course_meta_title_bottom_spacing',
				[
					'label' => __( 'Bottom Spacing', 'widgetkit-pro' ),
					'type' => Controls_Manager::SLIDER,
					'range' => [
						'px' => [
							'min' => -20,
							'max' => 100,
							'step' => 1,
						],
					],
					'size_units' => [ 'px' ],
					'selectors' => [
						'{{WRAPPER}} .wkld-course-meta-info .wkld-course-meta .meta-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
					]
				]
			);

		$this->end_controls_section();

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

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

			$this->add_control(
				'meta_info_spacing',
				[
					'label' => __( 'Spacing', 'widgetkit-pro' ),
					'type' => Controls_Manager::SLIDER,
					'range' => [
						'px' => [
							'min' => -20,
							'max' => 100,
							'step' => 1,
						],
					],
					'size_units' => [ 'px' ],
					'selectors' => [
						'{{WRAPPER}} .wkld-course-meta-info h4' => 'margin-top: {{SIZE}}{{UNIT}};',
					]
				]
			);

		$this->end_controls_section();

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

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				[
					'label' => __( 'Typography', 'widgetkit-pro' ),
					'name' => 'meta_desc_typography',
					'selector' => '{{WRAPPER}} .wkld-course-meta-info .meta-desc',
				]
			);
				
			$this->add_control(
				'meta_desc_color',
				[
					'label' => __( 'Color', 'widgetkit-pro' ),
					'type' => Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .wkld-course-meta-info .meta-desc' => 'color: {{VALUE}}'
					]
				]
			);

			$this->add_control(
				'meta_desc_spacing',
				[
					'label' => __( 'Spacing', 'widgetkit-pro' ),
					'type' => Controls_Manager::SLIDER,
					'range' => [
						'px' => [
							'min' => -20,
							'max' => 100,
							'step' => 1,
						],
					],
					'size_units' => [ 'px' ],
					'selectors' => [
						'{{WRAPPER}} .wkld-course-meta-info .meta-desc' => 'margin-top: {{SIZE}}{{UNIT}};',
					]
				]
			);


		$this->end_controls_section();

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

		$this->add_group_control(
			Group_Control_Border::get_type(),
			[
				'name' => 'content_border',
				'selector' => '{{WRAPPER}} .wkld-course-meta-info > div:not(:last-child):after',
				'separator' => 'before',
			]
		);

		$this->end_controls_section();

	}

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

}