<?php
namespace Sifency\Traits;
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Typography;
trait Sifency_Product_Rating_Controls {

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

        if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
            $this->add_control(
                'editor_preview_rating',
                [
                    'label' => __('Preview Rating', 'sifency-addons'),
                    'type' => Controls_Manager::SLIDER,
                    'size_units' => [''],
                    'range' => ['' => ['min' => 0, 'max' => 5, 'step' => 0.1]],
                    'default' => ['size' => 4],
                    'description' => __('Set the star rating for editor preview.', 'sifency-addons'),
                ]
            );
             $this->add_control(
                'editor_preview_count',
                [
                    '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',
			[
				'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();


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