<?php
/**
 * Review Form Widget - Style Controls
 *
 * @package GGM_Commerce
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// $this is the GGM_Commerce_Widget_Review_Form instance.

// Form Style Section
$this->start_controls_section(
	'form_style_section',
	[
		'label' => 'Form Style',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

$this->add_control(
	'form_background',
	[
		'label'     => 'Background Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-review-form' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_responsive_control(
	'form_padding',
	[
		'label'      => 'Padding',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', 'em', '%' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-review-form' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'     => 'form_border',
		'selector' => '{{WRAPPER}} .ggmc-review-form',
	]
);

$this->add_control(
	'form_border_radius',
	[
		'label'      => 'Border Radius',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-review-form' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->end_controls_section();

// Title Style Section
$this->start_controls_section(
	'title_style_section',
	[
		'label' => 'Form Title Style',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

$this->add_control(
	'title_color',
	[
		'label'     => 'Title Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-review-form-title' => 'color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	[
		'name'     => 'title_typography',
		'selector' => '{{WRAPPER}} .ggmc-review-form-title',
	]
);

$this->add_responsive_control(
	'title_margin',
	[
		'label'      => 'Margin',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-review-form-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->end_controls_section();

// Star Rating Style Section
$this->start_controls_section(
	'stars_style_section',
	[
		'label' => 'Star Rating Style',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

$this->add_control(
	'star_size',
	[
		'label'      => 'Star Size',
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => [ 'px', 'em' ],
		'range'      => [
			'px' => [
				'min' => 16,
				'max' => 60,
			],
			'em' => [
				'min' => 1,
				'max' => 4,
			],
		],
		'default'   => [
			'unit' => 'px',
			'size' => 32,
		],
		'selectors' => [
			'{{WRAPPER}} .ggmc-star-rating-input .star' => 'font-size: {{SIZE}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'star_color_empty',
	[
		'label'     => 'Empty Star Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-star-rating-input .star' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'star_color_filled',
	[
		'label'     => 'Filled Star Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-star-rating-input .star.active, {{WRAPPER}} .ggmc-star-rating-input .star.hover' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'star_spacing',
	[
		'label'      => 'Star Spacing',
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => [ 'px' ],
		'range'      => [
			'px' => [
				'min' => 0,
				'max' => 20,
			],
		],
		'default'   => [
			'unit' => 'px',
			'size' => 4,
		],
		'selectors' => [
			'{{WRAPPER}} .ggmc-star-rating-input .star' => 'margin-right: {{SIZE}}{{UNIT}};',
		],
	]
);

$this->end_controls_section();

// Field Style Section
$this->start_controls_section(
	'field_style_section',
	[
		'label' => 'Field Style',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

$this->add_control(
	'label_color',
	[
		'label'     => 'Label Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-form-field label' => 'color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	[
		'name'     => 'label_typography',
		'label'    => 'Label Typography',
		'selector' => '{{WRAPPER}} .ggmc-form-field label',
	]
);

$this->add_control(
	'input_background',
	[
		'label'     => 'Input Background',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field textarea' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'input_text_color',
	[
		'label'     => 'Input Text Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field textarea' => 'color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'     => 'input_border',
		'selector' => '{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field textarea',
	]
);

$this->add_control(
	'input_border_radius',
	[
		'label'      => 'Input Border Radius',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field textarea' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_responsive_control(
	'input_padding',
	[
		'label'      => 'Input Padding',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field textarea' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_responsive_control(
	'field_spacing',
	[
		'label'      => 'Field Spacing',
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => [ 'px', 'em' ],
		'range'      => [
			'px' => [
				'min' => 0,
				'max' => 40,
			],
		],
		'default'   => [
			'unit' => 'px',
			'size' => 15,
		],
		'selectors' => [
			'{{WRAPPER}} .ggmc-form-field' => 'margin-bottom: {{SIZE}}{{UNIT}};',
		],
	]
);

$this->end_controls_section();

// Button Style Section
$this->start_controls_section(
	'button_style_section',
	[
		'label' => 'Submit Button Style',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	[
		'name'     => 'button_typography',
		'selector' => '{{WRAPPER}} .ggmc-submit-review-btn',
	]
);

$this->start_controls_tabs( 'button_tabs' );

$this->start_controls_tab(
	'button_normal_tab',
	[
		'label' => 'Normal',
	]
);

$this->add_control(
	'button_text_color',
	[
		'label'     => 'Text Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-submit-review-btn' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'button_background',
	[
		'label'     => 'Background Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-submit-review-btn' => 'background-color: {{VALUE}};',
		],
	]
);

$this->end_controls_tab();

$this->start_controls_tab(
	'button_hover_tab',
	[
		'label' => 'Hover',
	]
);

$this->add_control(
	'button_text_color_hover',
	[
		'label'     => 'Text Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-submit-review-btn:hover' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'button_background_hover',
	[
		'label'     => 'Background Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-submit-review-btn:hover' => 'background-color: {{VALUE}};',
		],
	]
);

$this->end_controls_tab();

$this->end_controls_tabs();

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'      => 'button_border',
		'selector'  => '{{WRAPPER}} .ggmc-submit-review-btn',
		'separator' => 'before',
	]
);

$this->add_control(
	'button_border_radius',
	[
		'label'      => 'Border Radius',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-submit-review-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_responsive_control(
	'button_padding',
	[
		'label'      => 'Padding',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-submit-review-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'button_width',
	[
		'label'        => 'Full Width',
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => 'Yes',
		'label_off'    => 'No',
		'return_value' => 'yes',
		'default'      => '',
		'selectors'    => [
			'{{WRAPPER}} .ggmc-submit-review-btn' => 'width: 100%;',
		],
	]
);

$this->end_controls_section();

// Message Style Section
$this->start_controls_section(
	'message_style_section',
	[
		'label' => 'Message Style',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

$this->add_control(
	'success_message_color',
	[
		'label'     => 'Success Message Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-review-success' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'success_message_background',
	[
		'label'     => 'Success Message Background',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-review-success' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'error_message_color',
	[
		'label'     => 'Error Message Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-review-error' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'error_message_background',
	[
		'label'     => 'Error Message Background',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-review-error' => 'background-color: {{VALUE}};',
		],
	]
);

$this->end_controls_section();
