<?php
/**
 * Product Filter Widget - Style Controls
 *
 * Included via require inside register_controls(). $this refers to the widget instance.
 *
 * @package GGM_Commerce
 */

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

// $this is the GGM_Commerce_Product_Filter_Widget instance.

// -------------------------------------------------------------------------
// Container Style
// -------------------------------------------------------------------------

$this->start_controls_section(
	'container_style',
	[
		'label' => __( 'Container', 'ggm-commerce' ),
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Background::get_type(),
	[
		'name'     => 'container_background',
		'label'    => __( 'Background', 'ggm-commerce' ),
		'types'    => [ 'classic', 'gradient' ],
		'selector' => '{{WRAPPER}} .ggmc-product-filter',
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'     => 'container_border',
		'label'    => __( 'Border', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .ggmc-product-filter',
	]
);

$this->add_responsive_control(
	'container_border_radius',
	[
		'label'      => __( 'Border Radius', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-product-filter' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

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

$this->add_group_control(
	\Elementor\Group_Control_Box_Shadow::get_type(),
	[
		'name'     => 'container_box_shadow',
		'label'    => __( 'Box Shadow', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .ggmc-product-filter',
	]
);

$this->end_controls_section();

// -------------------------------------------------------------------------
// Title Style
// -------------------------------------------------------------------------

$this->start_controls_section(
	'title_style',
	[
		'label' => __( 'Title', 'ggm-commerce' ),
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

$this->add_control(
	'title_html_tag',
	[
		'label'   => __( 'HTML Tag', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::SELECT,
		'default' => 'h3',
		'options' => [
			'h1'   => 'H1',
			'h2'   => 'H2',
			'h3'   => 'H3',
			'h4'   => 'H4',
			'h5'   => 'H5',
			'h6'   => 'H6',
			'div'  => 'div',
			'span' => 'span',
			'p'    => 'p',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	[
		'name'     => 'title_typography',
		'label'    => __( 'Typography', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-title',
	]
);

$this->add_control(
	'title_color',
	[
		'label'     => __( 'Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-title' => 'color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'     => 'title_border',
		'label'    => __( 'Border', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-title',
	]
);

$this->add_responsive_control(
	'title_border_radius',
	[
		'label'      => __( 'Border Radius', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .filter-title' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_responsive_control(
	'title_padding',
	[
		'label'      => __( 'Padding', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .filter-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

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

$this->end_controls_section();

// -------------------------------------------------------------------------
// Form Labels Style
// -------------------------------------------------------------------------

$this->start_controls_section(
	'form_labels_style',
	[
		'label' => __( 'Form Labels', 'ggm-commerce' ),
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

$this->add_control(
	'show_labels',
	[
		'label'              => __( 'Show Labels', 'ggm-commerce' ),
		'type'               => \Elementor\Controls_Manager::SWITCHER,
		'label_on'           => __( 'Show', 'ggm-commerce' ),
		'label_off'          => __( 'Hide', 'ggm-commerce' ),
		'return_value'       => 'yes',
		'default'            => 'yes',
		'selectors'          => [
			'{{WRAPPER}} .filter-group label' => 'display: {{VALUE}} !important;',
		],
		'selectors_dictionary' => [
			'yes' => 'block',
			''    => 'none',
		],
	]
);

$this->add_control(
	'label_html_tag',
	[
		'label'     => __( 'HTML Tag', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::SELECT,
		'default'   => 'label',
		'options'   => [
			'label' => 'label',
			'div'   => 'div',
			'span'  => 'span',
			'p'     => 'p',
		],
		'condition' => [
			'show_labels' => 'yes',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	[
		'name'      => 'label_typography',
		'label'     => __( 'Typography', 'ggm-commerce' ),
		'selector'  => '{{WRAPPER}} .filter-group label',
		'condition' => [
			'show_labels' => 'yes',
		],
	]
);

$this->add_control(
	'label_color',
	[
		'label'     => __( 'Text Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-group label' => 'color: {{VALUE}};',
		],
		'condition' => [
			'show_labels' => 'yes',
		],
	]
);

$this->add_control(
	'label_background',
	[
		'label'     => __( 'Background Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-group label' => 'background-color: {{VALUE}};',
		],
		'condition' => [
			'show_labels' => 'yes',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'      => 'label_border',
		'label'     => __( 'Border', 'ggm-commerce' ),
		'selector'  => '{{WRAPPER}} .filter-group label',
		'condition' => [
			'show_labels' => 'yes',
		],
	]
);

$this->add_control(
	'label_border_radius',
	[
		'label'      => __( 'Border Radius', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .filter-group label' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
		'condition'  => [
			'show_labels' => 'yes',
		],
	]
);

$this->add_control(
	'label_padding',
	[
		'label'      => __( 'Padding', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .filter-group label' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
		'condition'  => [
			'show_labels' => 'yes',
		],
	]
);

$this->add_control(
	'label_margin',
	[
		'label'      => __( 'Margin', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .filter-group label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
		'condition'  => [
			'show_labels' => 'yes',
		],
	]
);

$this->end_controls_section();

// -------------------------------------------------------------------------
// Form Inputs Style
// -------------------------------------------------------------------------

$this->start_controls_section(
	'form_inputs_style',
	[
		'label' => __( 'Form Inputs', 'ggm-commerce' ),
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	[
		'name'     => 'input_typography',
		'label'    => __( 'Typography', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-input, {{WRAPPER}} .filter-select',
	]
);

$this->start_controls_tabs( 'input_style_tabs' );

// Normal State
$this->start_controls_tab(
	'input_normal_tab',
	[
		'label' => __( 'Normal', 'ggm-commerce' ),
	]
);

$this->add_control(
	'input_text_color',
	[
		'label'     => __( 'Text Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-input, {{WRAPPER}} .filter-select' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'input_background',
	[
		'label'     => __( 'Background Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-input, {{WRAPPER}} .filter-select' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'     => 'input_border',
		'label'    => __( 'Border', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-input, {{WRAPPER}} .filter-select',
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Box_Shadow::get_type(),
	[
		'name'     => 'input_box_shadow',
		'label'    => __( 'Box Shadow', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-input, {{WRAPPER}} .filter-select',
	]
);

$this->end_controls_tab();

// Hover State
$this->start_controls_tab(
	'input_hover_tab',
	[
		'label' => __( 'Hover', 'ggm-commerce' ),
	]
);

$this->add_control(
	'input_hover_text_color',
	[
		'label'     => __( 'Text Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-input:hover, {{WRAPPER}} .filter-select:hover' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'input_hover_background',
	[
		'label'     => __( 'Background Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-input:hover, {{WRAPPER}} .filter-select:hover' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'input_hover_border_color',
	[
		'label'     => __( 'Border Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-input:hover, {{WRAPPER}} .filter-select:hover' => 'border-color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Box_Shadow::get_type(),
	[
		'name'     => 'input_hover_box_shadow',
		'label'    => __( 'Box Shadow', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-input:hover, {{WRAPPER}} .filter-select:hover',
	]
);

$this->end_controls_tab();

// Focus State
$this->start_controls_tab(
	'input_focus_tab',
	[
		'label' => __( 'Focus', 'ggm-commerce' ),
	]
);

$this->add_control(
	'input_focus_text_color',
	[
		'label'     => __( 'Text Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-input:focus, {{WRAPPER}} .filter-select:focus' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'input_focus_background',
	[
		'label'     => __( 'Background Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-input:focus, {{WRAPPER}} .filter-select:focus' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'input_focus_border_color',
	[
		'label'     => __( 'Border Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-input:focus, {{WRAPPER}} .filter-select:focus' => 'border-color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Box_Shadow::get_type(),
	[
		'name'     => 'input_focus_box_shadow',
		'label'    => __( 'Box Shadow', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-input:focus, {{WRAPPER}} .filter-select:focus',
	]
);

$this->end_controls_tab();

$this->end_controls_tabs();

$this->add_control(
	'input_border_radius',
	[
		'label'      => __( 'Border Radius', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'separator'  => 'before',
		'selectors'  => [
			'{{WRAPPER}} .filter-input, {{WRAPPER}} .filter-select' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'input_padding',
	[
		'label'      => __( 'Padding', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .filter-input, {{WRAPPER}} .filter-select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'input_margin',
	[
		'label'      => __( 'Margin', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .filter-input, {{WRAPPER}} .filter-select' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

// Spacing Heading
$this->add_control(
	'spacing_heading',
	[
		'label'     => __( 'Spacing', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::HEADING,
		'separator' => 'before',
	]
);

$this->add_responsive_control(
	'filter_group_spacing',
	[
		'label'      => __( 'Between Filter Groups', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => [ 'px' ],
		'range'      => [
			'px' => [
				'min' => 0,
				'max' => 100,
			],
		],
		'default'    => [
			'size' => 15,
			'unit' => 'px',
		],
		// Selectors removed - spacing handled in inline CSS for layout-specific logic
	]
);

$this->add_responsive_control(
	'filter_button_spacing',
	[
		'label'      => __( 'Filters to Buttons', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => [ 'px' ],
		'range'      => [
			'px' => [
				'min' => 0,
				'max' => 100,
			],
		],
		'default'    => [
			'size' => 15,
			'unit' => 'px',
		],
		'selectors'  => [
			'{{WRAPPER}} .filter-actions' => 'margin-top: {{SIZE}}{{UNIT}};',
		],
	]
);

$this->end_controls_section();

// -------------------------------------------------------------------------
// Range Sliders Style
// -------------------------------------------------------------------------

$this->start_controls_section(
	'slider_style',
	[
		'label'       => __( 'Range Sliders', 'ggm-commerce' ),
		'tab'         => \Elementor\Controls_Manager::TAB_STYLE,
		'description' => __( 'These styles apply to both price range and attribute range sliders', 'ggm-commerce' ),
	]
);

$this->add_control(
	'slider_style_description',
	[
		'type' => \Elementor\Controls_Manager::RAW_HTML,
		'raw'  => '<div style="font-size: 12px; color: #666; margin-bottom: 10px;">' . __( 'These settings apply to all range sliders (price and number attributes).', 'ggm-commerce' ) . '</div>',
	]
);

// Value Text Styling
$this->add_control(
	'slider_text_heading',
	[
		'label' => __( 'Value Display Text', 'ggm-commerce' ),
		'type'  => \Elementor\Controls_Manager::HEADING,
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	[
		'name'     => 'slider_text_typography',
		'label'    => __( 'Typography', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .price-min, {{WRAPPER}} .price-max, {{WRAPPER}} .price-separator, {{WRAPPER}} .attr-range-min, {{WRAPPER}} .attr-range-max, {{WRAPPER}} .attr-separator',
	]
);

$this->add_control(
	'slider_text_color',
	[
		'label'     => __( 'Text Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .price-min, {{WRAPPER}} .price-max, {{WRAPPER}} .attr-range-min, {{WRAPPER}} .attr-range-max' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'slider_separator_color',
	[
		'label'     => __( 'Separator Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .price-separator, {{WRAPPER}} .attr-separator' => 'color: {{VALUE}};',
		],
	]
);

// Slider Track
$this->add_control(
	'slider_track_heading',
	[
		'label'     => __( 'Slider Track', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::HEADING,
		'separator' => 'before',
	]
);

$this->add_control(
	'slider_track_height',
	[
		'label'      => __( 'Track Height', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => [ 'px' ],
		'range'      => [
			'px' => [
				'min' => 1,
				'max' => 20,
			],
		],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-product-filter .price-slider, {{WRAPPER}} .ggmc-product-filter .attribute-slider' => 'height: {{SIZE}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'slider_track_color',
	[
		'label'     => __( 'Track Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-product-filter .price-slider, {{WRAPPER}} .ggmc-product-filter .attribute-slider' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'     => 'slider_track_border',
		'label'    => __( 'Border', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .ggmc-product-filter .price-slider, {{WRAPPER}} .ggmc-product-filter .attribute-slider',
	]
);

$this->add_control(
	'slider_track_border_radius',
	[
		'label'      => __( 'Border Radius', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-product-filter .price-slider, {{WRAPPER}} .ggmc-product-filter .attribute-slider' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'slider_track_padding',
	[
		'label'      => __( 'Padding', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-product-filter .price-slider, {{WRAPPER}} .ggmc-product-filter .attribute-slider' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'slider_track_margin',
	[
		'label'      => __( 'Margin', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-product-filter .price-slider, {{WRAPPER}} .ggmc-product-filter .attribute-slider' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

// Slider Handle
$this->add_control(
	'slider_handle_heading',
	[
		'label'     => __( 'Slider Handle', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::HEADING,
		'separator' => 'before',
	]
);

$this->add_control(
	'slider_handle_size',
	[
		'label'      => __( 'Handle Size', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => [ 'px' ],
		'range'      => [
			'px' => [
				'min' => 10,
				'max' => 40,
			],
		],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-product-filter .price-slider .ui-slider-handle, {{WRAPPER}} .ggmc-product-filter .attribute-slider .ui-slider-handle' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'slider_handle_color',
	[
		'label'     => __( 'Handle Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-product-filter .price-slider .ui-slider-handle, {{WRAPPER}} .ggmc-product-filter .attribute-slider .ui-slider-handle' => 'background: {{VALUE}} !important;',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'     => 'slider_handle_border',
		'label'    => __( 'Border', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .ggmc-product-filter .price-slider .ui-slider-handle, {{WRAPPER}} .ggmc-product-filter .attribute-slider .ui-slider-handle',
	]
);

$this->add_control(
	'slider_handle_border_radius',
	[
		'label'      => __( 'Border Radius', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-product-filter .price-slider .ui-slider-handle, {{WRAPPER}} .ggmc-product-filter .attribute-slider .ui-slider-handle' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Box_Shadow::get_type(),
	[
		'name'     => 'slider_handle_box_shadow',
		'label'    => __( 'Box Shadow', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .ggmc-product-filter .price-slider .ui-slider-handle, {{WRAPPER}} .ggmc-product-filter .attribute-slider .ui-slider-handle',
	]
);

// Slider Range Fill
$this->add_control(
	'slider_range_heading',
	[
		'label'     => __( 'Range Fill', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::HEADING,
		'separator' => 'before',
	]
);

$this->add_control(
	'slider_range_color',
	[
		'label'     => __( 'Range Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .ggmc-product-filter .price-slider .ui-slider-range, {{WRAPPER}} .ggmc-product-filter .attribute-slider .ui-slider-range' => 'background: {{VALUE}} !important;',
		],
	]
);

$this->add_control(
	'slider_range_border_radius',
	[
		'label'      => __( 'Border Radius', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%' ],
		'selectors'  => [
			'{{WRAPPER}} .ggmc-product-filter .price-slider .ui-slider-range, {{WRAPPER}} .ggmc-product-filter .attribute-slider .ui-slider-range' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->end_controls_section();

// -------------------------------------------------------------------------
// Button Style
// -------------------------------------------------------------------------

$this->start_controls_section(
	'button_style',
	[
		'label' => __( 'Buttons', 'ggm-commerce' ),
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	]
);

// Apply Button
$this->add_control(
	'apply_button_heading',
	[
		'label' => __( 'Apply Button', 'ggm-commerce' ),
		'type'  => \Elementor\Controls_Manager::HEADING,
	]
);

$this->add_responsive_control(
	'apply_button_text',
	[
		'label'   => __( 'Button Text', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::TEXT,
		'default' => __( 'Apply Filters', 'ggm-commerce' ),
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	[
		'name'     => 'apply_button_typography',
		'label'    => __( 'Typography', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-apply-btn',
	]
);

$this->start_controls_tabs( 'apply_button_tabs' );

// Apply Normal State
$this->start_controls_tab(
	'apply_button_normal',
	[
		'label' => __( 'Normal', 'ggm-commerce' ),
	]
);

$this->add_control(
	'apply_button_color',
	[
		'label'     => __( 'Text Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-apply-btn' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'apply_button_background',
	[
		'label'     => __( 'Background Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-apply-btn' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'     => 'apply_button_border',
		'label'    => __( 'Border', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-apply-btn',
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Box_Shadow::get_type(),
	[
		'name'     => 'apply_button_box_shadow',
		'label'    => __( 'Box Shadow', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-apply-btn',
	]
);

$this->end_controls_tab();

// Apply Hover State
$this->start_controls_tab(
	'apply_button_hover',
	[
		'label' => __( 'Hover', 'ggm-commerce' ),
	]
);

$this->add_control(
	'apply_button_hover_color',
	[
		'label'     => __( 'Text Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-apply-btn:hover' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'apply_button_hover_background',
	[
		'label'     => __( 'Background Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-apply-btn:hover' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'apply_button_hover_border_color',
	[
		'label'     => __( 'Border Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-apply-btn:hover' => 'border-color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Box_Shadow::get_type(),
	[
		'name'     => 'apply_button_hover_box_shadow',
		'label'    => __( 'Box Shadow', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-apply-btn:hover',
	]
);

$this->end_controls_tab();

$this->end_controls_tabs();

$this->add_control(
	'apply_button_border_radius',
	[
		'label'      => __( 'Border Radius', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%' ],
		'separator'  => 'before',
		'selectors'  => [
			'{{WRAPPER}} .filter-apply-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'apply_button_padding',
	[
		'label'      => __( 'Padding', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .filter-apply-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_responsive_control(
	'apply_button_width',
	[
		'label'      => __( 'Width', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => [ 'px', '%' ],
		'range'      => [
			'px' => [
				'min' => 0,
				'max' => 500,
			],
			'%'  => [
				'min' => 0,
				'max' => 100,
			],
		],
		'selectors'  => [
			'{{WRAPPER}} .filter-apply-btn' => 'width: {{SIZE}}{{UNIT}}; flex: none;',
		],
	]
);

// Reset Button
$this->add_control(
	'reset_button_heading',
	[
		'label'     => __( 'Reset Button', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::HEADING,
		'separator' => 'before',
	]
);

$this->add_responsive_control(
	'reset_button_text',
	[
		'label'   => __( 'Button Text', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::TEXT,
		'default' => __( 'Reset', 'ggm-commerce' ),
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	[
		'name'     => 'reset_button_typography',
		'label'    => __( 'Typography', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-reset-btn',
	]
);

$this->start_controls_tabs( 'reset_button_tabs' );

// Reset Normal State
$this->start_controls_tab(
	'reset_button_normal',
	[
		'label' => __( 'Normal', 'ggm-commerce' ),
	]
);

$this->add_control(
	'reset_button_color',
	[
		'label'     => __( 'Text Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-reset-btn' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'reset_button_background',
	[
		'label'     => __( 'Background Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-reset-btn' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	[
		'name'     => 'reset_button_border',
		'label'    => __( 'Border', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-reset-btn',
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Box_Shadow::get_type(),
	[
		'name'     => 'reset_button_box_shadow',
		'label'    => __( 'Box Shadow', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-reset-btn',
	]
);

$this->end_controls_tab();

// Reset Hover State
$this->start_controls_tab(
	'reset_button_hover',
	[
		'label' => __( 'Hover', 'ggm-commerce' ),
	]
);

$this->add_control(
	'reset_button_hover_color',
	[
		'label'     => __( 'Text Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-reset-btn:hover' => 'color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'reset_button_hover_background',
	[
		'label'     => __( 'Background Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-reset-btn:hover' => 'background-color: {{VALUE}};',
		],
	]
);

$this->add_control(
	'reset_button_hover_border_color',
	[
		'label'     => __( 'Border Color', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .filter-reset-btn:hover' => 'border-color: {{VALUE}};',
		],
	]
);

$this->add_group_control(
	\Elementor\Group_Control_Box_Shadow::get_type(),
	[
		'name'     => 'reset_button_hover_box_shadow',
		'label'    => __( 'Box Shadow', 'ggm-commerce' ),
		'selector' => '{{WRAPPER}} .filter-reset-btn:hover',
	]
);

$this->end_controls_tab();

$this->end_controls_tabs();

$this->add_control(
	'reset_button_border_radius',
	[
		'label'      => __( 'Border Radius', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%' ],
		'separator'  => 'before',
		'selectors'  => [
			'{{WRAPPER}} .filter-reset-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'reset_button_padding',
	[
		'label'      => __( 'Padding', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .filter-reset-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_responsive_control(
	'reset_button_width',
	[
		'label'      => __( 'Width', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => [ 'px', '%' ],
		'range'      => [
			'px' => [
				'min' => 0,
				'max' => 500,
			],
			'%'  => [
				'min' => 0,
				'max' => 100,
			],
		],
		'selectors'  => [
			'{{WRAPPER}} .filter-reset-btn' => 'width: {{SIZE}}{{UNIT}}; flex: none;',
		],
	]
);

// Button Group Spacing
$this->add_control(
	'button_group_heading',
	[
		'label'     => __( 'Button Group', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::HEADING,
		'separator' => 'before',
	]
);

$this->add_control(
	'button_gap',
	[
		'label'      => __( 'Gap Between Buttons', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::SLIDER,
		'size_units' => [ 'px' ],
		'range'      => [
			'px' => [
				'min' => 0,
				'max' => 50,
			],
		],
		'selectors'  => [
			'{{WRAPPER}} .filter-actions' => 'gap: {{SIZE}}{{UNIT}};',
		],
	]
);

$this->add_control(
	'button_group_margin',
	[
		'label'      => __( 'Margin', 'ggm-commerce' ),
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em' ],
		'selectors'  => [
			'{{WRAPPER}} .filter-actions' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$this->add_responsive_control(
	'button_group_alignment',
	[
		'label'     => __( 'Alignment', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::SELECT,
		'default'   => 'flex-start',
		'options'   => [
			'flex-start'    => __( 'Left', 'ggm-commerce' ),
			'center'        => __( 'Center', 'ggm-commerce' ),
			'flex-end'      => __( 'Right', 'ggm-commerce' ),
			'space-between' => __( 'Space Between', 'ggm-commerce' ),
			'space-around'  => __( 'Space Around', 'ggm-commerce' ),
			'space-evenly'  => __( 'Space Evenly', 'ggm-commerce' ),
		],
		'selectors' => [
			'{{WRAPPER}} .filter-actions' => 'justify-content: {{VALUE}};',
		],
	]
);

$this->end_controls_section();

// -------------------------------------------------------------------------
// Attribute Filters Style (only when premium is active)
// -------------------------------------------------------------------------

if ( class_exists( 'GGM_Commerce_License' ) ) {
	$license = GGM_Commerce_License::instance();

	if ( $license->is_widget_activated( 'custom-attributes' ) ) {
		$this->start_controls_section(
			'attribute_filter_style',
			[
				'label'     => __( 'Attribute Filters', 'ggm-commerce' ),
				'tab'       => \Elementor\Controls_Manager::TAB_STYLE,
				'condition' => [
					'show_attribute_filters' => 'yes',
				],
			]
		);

		$this->add_control(
			'attribute_label_color',
			[
				'label'     => __( 'Label Color', 'ggm-commerce' ),
				'type'      => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .attribute-filter-label' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_group_control(
			\Elementor\Group_Control_Typography::get_type(),
			[
				'name'     => 'attribute_label_typography',
				'label'    => __( 'Label Typography', 'ggm-commerce' ),
				'selector' => '{{WRAPPER}} .attribute-filter-label',
			]
		);

		$this->add_responsive_control(
			'attribute_icon_size',
			[
				'label'      => __( 'Icon Size', 'ggm-commerce' ),
				'type'       => \Elementor\Controls_Manager::SLIDER,
				'size_units' => [ 'px', 'em' ],
				'range'      => [
					'px' => [
						'min' => 8,
						'max' => 64,
					],
					'em' => [
						'min'  => 0.5,
						'max'  => 4,
						'step' => 0.1,
					],
				],
				'selectors'  => [
					'{{WRAPPER}} .attribute-filter-label i'   => 'font-size: {{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .attribute-filter-label svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
				],
			]
		);

		$this->add_control(
			'attribute_icon_color',
			[
				'label'     => __( 'Icon Color', 'ggm-commerce' ),
				'type'      => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .attribute-filter-label i'   => 'color: {{VALUE}};',
					'{{WRAPPER}} .attribute-filter-label svg' => 'fill: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'attribute_checkbox_color',
			[
				'label'     => __( 'Checkbox Color', 'ggm-commerce' ),
				'type'      => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .attribute-checkbox-item input[type="checkbox"]:checked' => 'background-color: {{VALUE}}; border-color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'attribute_count_color',
			[
				'label'     => __( 'Count Color', 'ggm-commerce' ),
				'type'      => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .attribute-count' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'attribute_slider_color',
			[
				'label'     => __( 'Slider Color', 'ggm-commerce' ),
				'type'      => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .ggmc-product-filter .attribute-slider .ui-slider-range'  => 'background: {{VALUE}};',
					'{{WRAPPER}} .ggmc-product-filter .attribute-slider .ui-slider-handle' => 'background: {{VALUE}}; border-color: {{VALUE}};',
				],
			]
		);

		$this->add_responsive_control(
			'attribute_filter_spacing',
			[
				'label'      => __( 'Filter Spacing', 'ggm-commerce' ),
				'type'       => \Elementor\Controls_Manager::SLIDER,
				'size_units' => [ 'px', 'em' ],
				'range'      => [
					'px' => [
						'min' => 0,
						'max' => 60,
					],
				],
				'selectors'  => [
					'{{WRAPPER}} .attribute-filter-group'              => 'margin-bottom: {{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .attribute-filter-group:last-child'   => 'margin-bottom: 0;',
				],
			]
		);

		$this->end_controls_section();
	}
}
