<?php
if (!defined('ABSPATH')) {
    exit;
}

use Elementor\Controls_Manager;

class Elementor_Vertical_Separator extends \Elementor\Widget_Base {

	public function get_name() {
		return 'Vertical_Separator';
	}

	public function get_title() {
		return esc_html__( 'Vertical Separator', 'elementor-addon' );
	}

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

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

	public function get_keywords() {
		return [ 'vertical', 'separator' ];
	}

	public function get_style_depends() {
		return [ 'elementor-addon-main-css' ];
	}

	public function get_script_depends() {
		return [ 'elementor-addon-main-js' ];
	}

	protected function register_controls() {
        $this->start_controls_section(
			'section_setting',
			[
				'label' => esc_html__( 'Settings', 'elementor' ),
                'tab'   => Controls_Manager::TAB_CONTENT,
			]
		);

		$this->add_control(
			'line_color',
			[
				'label' => esc_html__( 'Color', 'elementor-addon' ),
				'type' => Controls_Manager::COLOR,
				'default' => '#000000',
				'selectors' => [
					'{{WRAPPER}} .elementor-vertical-separator__line' => 'background: {{VALUE}};'
				],
			]
		);

		$this->add_responsive_control(
			'line_thickness',
			[
				'label' => esc_html__( 'Thickness', 'elementor-addon' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px' ],
				'range' => [
					'px' => [
						'min' => 1,
						'max' => 20,
					],
				],
				'default' => [
					'size' => 1,
					'unit' => 'px',
				],
				'selectors' => [
					'{{WRAPPER}} .elementor-vertical-separator__line' => 'width: {{SIZE}}{{UNIT}};'
				],
			]
		);

		$this->add_responsive_control(
			'line_height',
			[
				'label' => esc_html__( 'Height', 'elementor-addon' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%' ],
				'range' => [
					'px' => [
						'min' => 10,
						'max' => 600,
					],
					'%' => [
						'min' => 10,
						'max' => 100,
					],
				],
				'default' => [
					'size' => 100,
					'unit' => 'px',
				],
				'selectors' => [
					'{{WRAPPER}} .elementor-vertical-separator__line' => 'height: {{SIZE}}{{UNIT}};'
				],
			]
		);

		$this->add_responsive_control(
			'line_alignment',
			[
				'label' => esc_html__( 'Alignment', 'elementor-addon' ),
				'type' => Controls_Manager::CHOOSE,
				'default' => 'center',
				'options' => [
					'flex-start' => [
						'title' => esc_html__( 'Left', 'elementor-addon' ),
						'icon' => 'eicon-text-align-left',
					],
					'center' => [
						'title' => esc_html__( 'Center', 'elementor-addon' ),
						'icon' => 'eicon-text-align-center',
					],
					'flex-end' => [
						'title' => esc_html__( 'Right', 'elementor-addon' ),
						'icon' => 'eicon-text-align-right',
					],
				],
				'selectors' => [
					'{{WRAPPER}} .elementor-vertical-separator' => 'justify-content: {{VALUE}};'
				],
			]
		);

        $this->end_controls_section();
	}

    protected function render() {
        ?>
		<div class="elementor-vertical-separator">
			<span class="elementor-vertical-separator__line"></span>
		</div>
        <?php
    }
}
