<?php
/**
 * Product Rating Widget - Content Controls
 *
 * @package GGM_Commerce
 */

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

// $this is the GGM_Commerce_Widget_Product_Rating instance.

$this->start_controls_section(
	'content_section',
	array(
		'label' => __( 'Content', 'ggm-commerce' ),
		'tab'   => \Elementor\Controls_Manager::TAB_CONTENT,
	)
);

$this->add_control(
	'product_source',
	array(
		'label'   => __( 'Product Source', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::SELECT,
		'default' => 'current',
		'options' => array(
			'current' => __( 'Current Product (Auto-detect)', 'ggm-commerce' ),
			'custom'  => __( 'Select Product', 'ggm-commerce' ),
		),
	)
);

$this->add_control(
	'product_id',
	array(
		'label'       => __( 'Product', 'ggm-commerce' ),
		'type'        => \Elementor\Controls_Manager::NUMBER,
		'default'     => '',
		'condition'   => array(
			'product_source' => 'custom',
		),
		'description' => __( 'Start typing product name to search', 'ggm-commerce' ),
	)
);

$this->add_control(
	'display_style',
	array(
		'label'   => __( 'Display Style', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::SELECT,
		'default' => 'stars_count',
		'options' => array(
			'stars_only'    => __( 'Stars Only', 'ggm-commerce' ),
			'stars_count'   => __( 'Stars + Review Count', 'ggm-commerce' ),
			'stars_average' => __( 'Stars + Average Rating', 'ggm-commerce' ),
			'stars_full'    => __( 'Stars + Average + Count', 'ggm-commerce' ),
		),
	)
);

$this->add_control(
	'star_style',
	array(
		'label'   => __( 'Star Style', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::SELECT,
		'default' => 'filled',
		'options' => array(
			'filled'  => __( 'Filled Stars', 'ggm-commerce' ),
			'outline' => __( 'Outline Stars', 'ggm-commerce' ),
		),
	)
);

$this->add_control(
	'show_empty_stars',
	array(
		'label'        => __( 'Show Empty Stars', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'      => 'yes',
	)
);

$this->add_control(
	'link_to_reviews',
	array(
		'label'       => __( 'Link to Reviews', 'ggm-commerce' ),
		'type'        => \Elementor\Controls_Manager::SWITCHER,
		'label_on'    => __( 'Yes', 'ggm-commerce' ),
		'label_off'   => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'     => '',
		'description' => __( 'Make the rating clickable to scroll to reviews section', 'ggm-commerce' ),
	)
);

$this->add_control(
	'reviews_anchor',
	array(
		'label'       => __( 'Reviews Section ID', 'ggm-commerce' ),
		'type'        => \Elementor\Controls_Manager::TEXT,
		'default'     => 'product-reviews',
		'condition'   => array(
			'link_to_reviews' => 'yes',
		),
		'description' => __( 'The ID of the reviews section to scroll to', 'ggm-commerce' ),
	)
);

$this->add_control(
	'no_reviews_text',
	array(
		'label'       => __( 'No Reviews Text', 'ggm-commerce' ),
		'type'        => \Elementor\Controls_Manager::TEXT,
		'default'     => 'No reviews yet',
		'description' => __( 'Text to display when there are no reviews', 'ggm-commerce' ),
	)
);

$this->add_control(
	'hide_if_no_reviews',
	array(
		'label'        => __( 'Hide if No Reviews', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'      => '',
	)
);

$this->add_responsive_control(
	'alignment',
	array(
		'label'   => __( 'Alignment', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::CHOOSE,
		'options' => array(
			'left'   => array(
				'title' => __( 'Left', 'ggm-commerce' ),
				'icon'  => 'eicon-text-align-left',
			),
			'center' => array(
				'title' => __( 'Center', 'ggm-commerce' ),
				'icon'  => 'eicon-text-align-center',
			),
			'right'  => array(
				'title' => __( 'Right', 'ggm-commerce' ),
				'icon'  => 'eicon-text-align-right',
			),
		),
		'selectors' => array(
			'{{WRAPPER}} .ggmc-product-rating' => 'text-align: {{VALUE}}; justify-content: {{VALUE}};',
		),
	)
);

$this->end_controls_section();
