<?php
namespace Sifency\Traits;

if ( ! defined( 'ABSPATH' ) ) {
	exit;  }
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
trait Sifency_Product_Rating_Controls {

	protected function add_sifency_product_rating_controls( $args = array() ) {
		$this->start_controls_section(
			'section_content',
			array( 'label' => __( 'Content', 'sifency-addons' ) )
		);

		if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
			$this->add_control(
				'editor_preview_rating',
				array(
					'label'       => __( 'Preview Rating', 'sifency-addons' ),
					'type'        => Controls_Manager::SLIDER,
					'size_units'  => array( '' ),
					'range'       => array(
						'' => array(
							'min'  => 0,
							'max'  => 5,
							'step' => 0.1,
						),
					),
					'default'     => array( 'size' => 4 ),
					'description' => __( 'Set the star rating for editor preview.', 'sifency-addons' ),
				)
			);
			$this->add_control(
				'editor_preview_count',
				array(
					'label'       => __( 'Preview Review Count', 'sifency-addons' ),
					'type'        => Controls_Manager::NUMBER,
					'default'     => 3,
					'description' => __( 'Set the review count for editor preview.', 'sifency-addons' ),
				)
			);
		}

		$this->add_control(
			'show_review_link',
			array(
				'label'        => __( 'Show Review Link', 'sifency-addons' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => __( 'Show', 'sifency-addons' ),
				'label_off'    => __( 'Hide', 'sifency-addons' ),
				'return_value' => 'yes',
				'default'      => 'yes',
			)
		);
		$this->end_controls_section();
		$this->start_controls_section(
			'section_rating_style',
			array(
				'label' => __( 'Style', 'sifency-addons' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_control(
			'stars_heading',
			array(
				'label'     => 'Stars',
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);
		$this->add_responsive_control(
			'star_size',
			array(
				'label'     => 'Size',
				'type'      => Controls_Manager::SLIDER,
				'range'     => array(
					'px' => array(
						'min' => 10,
						'max' => 50,
					),
				),
				'selectors' => array( '{{WRAPPER}} .star-rating' => 'font-size: {{SIZE}}px;' ),
			)
		);
		$this->add_control(
			'link_heading',
			array(
				'label'     => 'Review Link',
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
				'condition' => array( 'show_review_link' => 'yes' ),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'      => 'link_typography',
				'selector'  => '{{WRAPPER}} .woocommerce-review-link',
				'condition' => array( 'show_review_link' => 'yes' ),
			)
		);
		$this->start_controls_tabs( 'link_color_tabs', array( 'condition' => array( 'show_review_link' => 'yes' ) ) );
		$this->start_controls_tab( 'link_normal_tab', array( 'label' => 'Normal' ) );
		$this->add_control(
			'link_color',
			array(
				'label'     => 'Text Color',
				'type'      => Controls_Manager::COLOR,
				'selectors' => array( '{{WRAPPER}} .woocommerce-review-link' => 'color: {{VALUE}};' ),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab( 'link_hover_tab', array( 'label' => 'Hover' ) );
		$this->add_control(
			'link_hover_color',
			array(
				'label'     => 'Text Color',
				'type'      => Controls_Manager::COLOR,
				'selectors' => array( '{{WRAPPER}} .woocommerce-review-link:hover' => 'color: {{VALUE}};' ),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
	}
}
