<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Border;
Use Elementor\Core\Schemes\Typography;

defined( 'ABSPATH' ) || exit; // Exit if accessed directly
/**
 *
 * Course Payments Button widget.
 *
 * @since 1.0.0
 */
class Widgetkit_Pro_LearnDash_Course_Payments_Button extends Widget_Base {

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

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

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

	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(
			'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}} .btn-join',
			]
		);

		$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}} .btn-join' => 'color: {{VALUE}}!important;'
				]
			]
		);

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

		$this->add_control(
			'button_background_hover_color',
			[
				'label' => __( 'Background Color', 'widgetkit-pro' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .btn-join: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}} .btn-join',
				'separator' => 'before',
			]
		);

		$this->add_control(
			'button_border_radius',
			[
				'label' => __( 'Border Radius', 'widgetkit-pro' ),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%' ],
				'selectors' => [
					'{{WRAPPER}} .btn-join' => '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}} .btn-join' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;'
				],
				'separator' => 'before'
			]
        );
        
        $this->add_responsive_control(
        'button_width',
            [
                'label'  => esc_html__( 'Button Width', 'widgetkit-pro' ),
                'type'   => Controls_Manager::SLIDER,
                'range'  => [
                    'px' => [
                        'min' =>0,
                        'max' => 1500,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .btn-join' => 'width: {{SIZE}}{{UNIT}} !important;',
                ],
            ]
		);
		
		$this->add_responsive_control(
		'button_alignment',
			[
				'label'  => esc_html__( 'Alignment', 'widgetkit-pro' ),
				'type'  => Controls_Manager::CHOOSE,
                'default' => 'center',
                'options' => [
                    'start' => [
                        'title' => esc_html__( 'Left', 'widgetkit-pro' ),
                        'icon'  => 'fa fa-align-left',
                    ],
                    'center' => [
                        'title' => esc_html__( 'Center', 'widgetkit-pro' ),
                        'icon'  => 'fa fa-align-center',
                    ],
                    'end' => [
                        'title' => esc_html__( 'Right', 'widgetkit-pro' ),
                        'icon'  => 'fa fa-align-right',
                    ],
                   	'justify' => [
						'title' => __( 'Justified', 'widgetkit-pro' ),
						'icon' => 'fa fa-align-justify',
					],
                ],
                'selectors' => [
                    '{{WRAPPER}}  .wk-learndash-payment-btn-wrapper' => 'display: flex;justify-content: {{VALUE}};',
                ],
			]
		);

		$this->end_controls_section();

	}

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

}