<?php

namespace Gigneo\Elementor\Widgets;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

use Elementor\Controls_Manager;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Plugin;
use WP_Post;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Widget_Base;

/**
 * Gigneo Elementor Service_Grid Widget
 *
 * @since 0.0.1
 */
class Service_Grid extends Widget_Base {


	/**
	 * Get widget unique name.
	 *
	 * @return string
	 */
	public function get_name() {
		return 'gigneo-service-grid';
	}

	/**
	 * Get widget title.
	 *
	 * @return string
	 */
	public function get_title() {
		return esc_html__( 'Service Grid', 'gigneo' );
	}

	/**
	 * Get widget icon.
	 *
	 * @return string
	 */
	public function get_icon() {
		return 'eicon-posts-grid gn-label';
	}

	/**
	 * Get widget categories.
	 *
	 * @return array
	 */
	public function get_categories() {
		return array( 'gigneo-widgets' );
	}

	/**
	 * Get widget keywords.
	 *
	 * @return array
	 */
	public function get_keywords() {
		return array( 'service', 'services', 'grid' );
	}

	/**
	 * Retrieve the list of scripts the widget depended on.
	 *
	 * @return array Widget scripts dependencies.
	 */
	public function get_script_depends() {
		return array( 'isotope', 'gigneo-elementor' );
	}

	/**
	 * Register widget controls.
	 */
	protected function register_controls() {

		$this->start_controls_section(
			'section_general',
			array(
				'label' => esc_html__( 'General', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);

		$this->add_control(
			'show_save_button',
			array(
				'label'        => esc_html__( 'Save Button', 'gigneo' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Show', 'gigneo' ),
				'label_off'    => esc_html__( 'Hide', 'gigneo' ),
				'return_value' => 'yes',
				'default'      => 'yes',
			)
		);

		$this->add_control(
			'show_meta',
			array(
				'label'        => esc_html__( 'Meta', 'gigneo' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Show', 'gigneo' ),
				'label_off'    => esc_html__( 'Hide', 'gigneo' ),
				'return_value' => 'yes',
				'default'      => 'yes',
			)
		);

		$this->add_control(
			'show_status',
			array(
				'label'        => esc_html__( 'Status', 'gigneo' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Show', 'gigneo' ),
				'label_off'    => esc_html__( 'Hide', 'gigneo' ),
				'return_value' => 'yes',
				'default'      => 'yes',
			)
		);

		$this->add_control(
			'show_rating',
			array(
				'label'        => esc_html__( 'Rating', 'gigneo' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Show', 'gigneo' ),
				'label_off'    => esc_html__( 'Hide', 'gigneo' ),
				'return_value' => 'yes',
				'default'      => 'yes',
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_filters',
			array(
				'label' => esc_html__( 'Filters', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);

		$this->add_control(
			'enable_filters',
			array(
				'label'        => esc_html__( 'Enable', 'gigneo' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Show', 'gigneo' ),
				'label_off'    => esc_html__( 'Hide', 'gigneo' ),
				'return_value' => 'yes',
				'default'      => 'no',
			)
		);

		$this->add_control(
			'filter_all_text',
			array(
				'label'       => esc_html__( 'Filter "All" text', 'gigneo' ),
				'type'        => Controls_Manager::TEXT,
				'label_block' => true,
				'default'     => esc_html__( 'All', 'gigneo' ),
				'condition'   => array(
					'enable_filters' => 'yes',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_query',
			array(
				'label' => esc_html__( 'Query', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);

		$query_by_options = array(
			'term'    => esc_html__( 'Term', 'gigneo' ),
			'author'  => esc_html__( 'Author', 'gigneo' ),
			'service' => esc_html__( 'Name / ID', 'gigneo' ),
		);

		$taxonomy_labels = array(
			'gigneo_facet' => esc_html__( 'Categories', 'gigneo' ),
			'gigneo_skill' => esc_html__( 'Skills', 'gigneo' ),
		);

		$term_options = array();

		foreach ( array_keys( $taxonomy_labels ) as $taxonomy ) {
			$terms = get_terms(
				array(
					'taxonomy'   => $taxonomy,
					'hide_empty' => false,
				)
			);

			if ( is_wp_error( $terms ) || empty( $terms ) ) {
				continue;
			}

			foreach ( $terms as $term ) {
				$term_options[ $taxonomy . ':' . $term->term_id ] = $taxonomy_labels[ $taxonomy ] . ': ' . $term->name;
			}
		}

		$author_options  = $this->get_author_select_options();
		$service_options = array();
		$service_ids     = get_posts(
			array(
				'post_type'      => 'gigneo_service',
				'post_status'    => 'publish',
				'posts_per_page' => -1,
				'fields'         => 'ids',
			)
		);

		foreach ( $service_ids as $post_id ) {
			$service_options[ (string) $post_id ] = sprintf(
				'%1$s (#%2$d)',
				get_the_title( $post_id ),
				$post_id
			);
		}

		asort( $service_options );

		$orderby_options = array(
			'date'        => esc_html__( 'Date', 'gigneo' ),
			'title'       => esc_html__( 'Title', 'gigneo' ),
			'menu_order'  => esc_html__( 'Menu Order', 'gigneo' ),
			'rand'        => esc_html__( 'Random', 'gigneo' ),
			'recommended' => esc_html__( 'Recommended', 'gigneo' ),
			'top_rated'   => esc_html__( 'Top Rated', 'gigneo' ),
			'price'       => esc_html__( 'Price', 'gigneo' ),
		);

		$this->start_controls_tabs( 'query_include_exclude_tabs' );

		$this->start_controls_tab(
			'query_include_tab',
			array(
				'label' => esc_html__( 'Include', 'gigneo' ),
			)
		);

		$this->add_control(
			'include_by',
			array(
				'label'       => esc_html__( 'Include By', 'gigneo' ),
				'type'        => Controls_Manager::SELECT2,
				'multiple'    => true,
				'label_block' => true,
				'options'     => $query_by_options,
				'default'     => array(),
			)
		);

		$this->add_control(
			'include_term_ids',
			array(
				'label'       => esc_html__( 'Terms', 'gigneo' ),
				'type'        => Controls_Manager::SELECT2,
				'options'     => $term_options,
				'multiple'    => true,
				'label_block' => true,
				'condition'   => array(
					'include_by' => 'term',
				),
			)
		);

		$this->add_control(
			'include_authors',
			array(
				'label'       => esc_html__( 'Authors', 'gigneo' ),
				'type'        => Controls_Manager::SELECT2,
				'options'     => $author_options,
				'multiple'    => true,
				'label_block' => true,
				'condition'   => array(
					'include_by' => 'author',
				),
			)
		);

		$this->add_control(
			'include_services',
			array(
				'label'       => esc_html__( 'Name / ID', 'gigneo' ),
				'type'        => Controls_Manager::SELECT2,
				'options'     => $service_options,
				'multiple'    => true,
				'label_block' => true,
				'condition'   => array(
					'include_by' => 'service',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'query_exclude_tab',
			array(
				'label' => esc_html__( 'Exclude', 'gigneo' ),
			)
		);

		$this->add_control(
			'exclude_by',
			array(
				'label'       => esc_html__( 'Exclude By', 'gigneo' ),
				'type'        => Controls_Manager::SELECT2,
				'multiple'    => true,
				'label_block' => true,
				'options'     => $query_by_options,
				'default'     => array(),
			)
		);

		$this->add_control(
			'exclude_term_ids',
			array(
				'label'       => esc_html__( 'Terms', 'gigneo' ),
				'type'        => Controls_Manager::SELECT2,
				'options'     => $term_options,
				'multiple'    => true,
				'label_block' => true,
				'condition'   => array(
					'exclude_by' => 'term',
				),
			)
		);

		$this->add_control(
			'exclude_authors',
			array(
				'label'       => esc_html__( 'Authors', 'gigneo' ),
				'type'        => Controls_Manager::SELECT2,
				'options'     => $author_options,
				'multiple'    => true,
				'label_block' => true,
				'condition'   => array(
					'exclude_by' => 'author',
				),
			)
		);

		$this->add_control(
			'exclude_services',
			array(
				'label'       => esc_html__( 'Name / ID', 'gigneo' ),
				'type'        => Controls_Manager::SELECT2,
				'options'     => $service_options,
				'multiple'    => true,
				'label_block' => true,
				'condition'   => array(
					'exclude_by' => 'service',
				),
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_control(
			'orderby',
			array(
				'label'     => esc_html__( 'Order By', 'gigneo' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'date',
				'options'   => $orderby_options,
				'separator' => 'before',
			)
		);

		$this->add_control(
			'order',
			array(
				'label'   => esc_html__( 'Order', 'gigneo' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'DESC',
				'options' => array(
					'ASC'  => esc_html__( 'ASC', 'gigneo' ),
					'DESC' => esc_html__( 'DESC', 'gigneo' ),
				),
			)
		);

		$this->add_control(
			'posts_per_page',
			array(
				'label'   => esc_html__( 'Per Page', 'gigneo' ),
				'type'    => Controls_Manager::NUMBER,
				'default' => (int) gigneo_option( '_gigneo_ts_services_per_page', 9 ),
				'min'     => 1,
				'max'     => 100,
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'general_style',
			array(
				'label' => esc_html__( 'General', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'general_bg_color',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'general_box_shadow',
				'selector' => '{{WRAPPER}} .gn-service-card',
			)
		);

		$this->add_responsive_control(
			'items_per_row',
			array(
				'label'     => esc_html__( 'Per Row', 'gigneo' ),
				'type'      => Controls_Manager::SELECT,
				'options'   => array(
					'1' => esc_html__( '1 Item', 'gigneo' ),
					'2' => esc_html__( '2 Items', 'gigneo' ),
					'3' => esc_html__( '3 Items', 'gigneo' ),
					'4' => esc_html__( '4 Items', 'gigneo' ),
				),
				'default'   => '3',
				'selectors' => array(
					'{{WRAPPER}} .gn-ele-service-grid-wrapper' => 'grid-template-columns: repeat({{VALUE}}, 1fr); --gn-grid-cols: {{VALUE}};',
                    '{{WRAPPER}} .gn-ele-service-grid-wrapper.gn-active .gn-service-card-item' => 'width: calc(100% / {{VALUE}});',
				),
			)
		);

        $this->add_responsive_control(
            'general_min_height',
            array(
                'label'      => esc_html__( 'Min Height', 'gigneo' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => array( 'px', '%', 'vh', 'em', 'rem' ),
                'range'      => array(
                    'px' => array(
                        'min'  => 100,
                        'max'  => 250,
                        'step' => 1,
                    ),
                ),
                'selectors'  => array(
                    '{{WRAPPER}} .gn-service-card>.gn-body' => 'min-height: {{SIZE}}{{UNIT}};',
                ),
            )
        );

        $this->add_responsive_control(
            'general_horizontal_space',
            array(
                'type'       => Controls_Manager::SLIDER,
                'label'      => esc_html__( 'Horizontal Space', 'gigneo' ),
                'size_units' => array( 'px', '%', 'em', 'rem', 'custom' ),
                'range'      => array(
                    'px' => array(
                        'min'  => 0,
                        'max'  => 30,
                        'step' => 1,
                    ),
                ),
                'selectors'  => array(
                    '{{WRAPPER}} .gn-service-card-item' => 'padding-left: {{SIZE}}{{UNIT}}; padding-right: {{SIZE}}{{UNIT}};',
                    '{{WRAPPER}} .gn-ele-service-grid-wrapper' => 'margin-left: calc(-1 * {{SIZE}}{{UNIT}}); margin-right: calc(-1 * {{SIZE}}{{UNIT}});',
                ),
                'render_type' => 'template',
            )
        );

        $this->add_responsive_control(
            'general_vertical_space',
            array(
                'type'       => Controls_Manager::SLIDER,
                'label'      => esc_html__( 'Vertical Space', 'gigneo' ),
                'size_units' => array( 'px', '%', 'em', 'rem' ),
                'range'      => array(
                    'px' => array(
                        'min'  => 0,
                        'max'  => 30,
                        'step' => 1,
                    ),
                ),
                'selectors'  => array(
                    '{{WRAPPER}} .gn-service-card-item' => 'margin-bottom: {{SIZE}}{{UNIT}}; margin-top: {{SIZE}}{{UNIT}};',
                ),
            )
        );

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'general_border',
				'selector' => '{{WRAPPER}} .gn-service-card',
			)
		);

		$this->add_responsive_control(
			'general_border_radius',
			array(
				'label'     => esc_html__( 'Border Radius', 'gigneo' ),
				'type'      => Controls_Manager::DIMENSIONS,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'general_padding',
			array(
				'label'      => esc_html__( 'Padding', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'general_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'cover_style',
			array(
				'label' => esc_html__( 'Cover', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'archive_card_cover_image_background',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-service-media' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'archive_card_cover_image_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card .gn-service-media, .gn-service-card .gn-service-media img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'archive_card_save_button_heading',
			array(
				'label'     => esc_html__( 'Save Button', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'separator' => 'before',
			)
		);

		$this->add_responsive_control(
			'save_btn_size',
			array(
				'label'      => __( 'Size', 'gigneo' ),
				'type'       => \Elementor\Controls_Manager::SLIDER,
				'condition'  => array(
					'show_save_button' => 'yes',
				),
				'size_units' => array( 'px', '%', 'em' ),
				'range'      => array(
					'px' => array(
						'min'  => 20,
						'max'  => 50,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-save-btn'            => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .gn-save-btn svg'        => 'width: calc({{SIZE}}{{UNIT}} - 12px); height: calc({{SIZE}}{{UNIT}} - 12px);',
					'{{WRAPPER}} button.gn-loading:after' => 'width: calc({{SIZE}}{{UNIT}} - 14px); height: calc({{SIZE}}{{UNIT}} - 14px);',
				),
			)
		);

		$this->start_controls_tabs( 'save_btn_tabs' );

		$this->start_controls_tab(
			'save_btn_normal',
			array(
				'label'     => esc_html__( 'Normal', 'gigneo' ),
				'condition' => array(
					'show_save_button' => 'yes',
				),
			)
		);

		$this->add_control(
			'save_btn_icon_color',
			array(
				'label'     => esc_html__( 'Icon Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selectors' => array( '{{WRAPPER}} .gn-archive-main .gn-save-btn svg path' => 'stroke: {{VALUE}};' ),
			)
		);

		$this->add_control(
			'save_btn_bg_color',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selectors' => array( '{{WRAPPER}} .gn-save-btn' => 'background-color: {{VALUE}};' ),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'      => 'save_btn_shadow',
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selector'  => '{{WRAPPER}} .gn-save-btn',
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'save_btn_hover',
			array(
				'label'     => esc_html__( 'Hover', 'gigneo' ),
				'condition' => array(
					'show_save_button' => 'yes',
				),
			)
		);

		$this->add_control(
			'save_btn_icon_color_hover',
			array(
				'label'     => esc_html__( 'Icon Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selectors' => array( '{{WRAPPER}} .gn-archive-main .gn-save-btn:hover svg path' => 'stroke: {{VALUE}};' ),
			)
		);

		$this->add_control(
			'save_btn_bg_color_hover',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selectors' => array( '{{WRAPPER}} .gn-save-btn:hover' => 'background-color: {{VALUE}};' ),
			)
		);

		$this->add_control(
			'save_btn_border_color_hover',
			array(
				'label'     => esc_html__( 'Border Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selectors' => array(
					'.gn-save-btn:hover' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'      => 'save_btn_shadow_hover',
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selector'  => '{{WRAPPER}} .gn-save-btn:hover',
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'save_btn_loader',
			array(
				'label'     => esc_html__( 'Loader', 'gigneo' ),
				'condition' => array(
					'show_save_button' => 'yes',
				),
			)
		);

		$this->add_control(
			'fav_btn_loader_border_color',
			array(
				'label'     => __( 'Border Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selectors' => array(
					'{{WRAPPER}} button.gn-loading:after' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'fav_btn_loader_border_top_color',
			array(
				'label'     => __( 'Border Top Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selectors' => array(
					'{{WRAPPER}} button.gn-loading:after' => 'border-top-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tabs();

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'      => 'save_btn_border',
				'separator' => 'before',
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selector'  => '{{WRAPPER}} .gn-save-btn',
			)
		);

		$this->add_responsive_control(
			'save_btn_radius',
			array(
				'label'     => esc_html__( 'Border Radius', 'gigneo' ),
				'type'      => Controls_Manager::DIMENSIONS,
				'condition' => array(
					'show_save_button' => 'yes',
				),
				'selectors' => array(
					'{{WRAPPER}} .gn-save-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'save_btn_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'condition'  => array(
					'show_save_button' => 'yes',
				),
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-save-btn' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'title_style',
			array(
				'label' => esc_html__( 'Title', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'archive_card_title_typography',
				'label'    => esc_html__( 'Typography', 'gigneo' ),
				'selector' => '{{WRAPPER}} .gn-service-card>.gn-body .gn-title',
			)
		);

		$this->add_control(
			'archive_card_title_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card>.gn-body .gn-title a' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Text_Shadow::get_type(),
			array(
				'name'     => 'archive_card_title_text_shadow',
				'selector' => '{{WRAPPER}} .gn-service-card>.gn-body .gn-title',
			)
		);

		$this->add_responsive_control(
			'archive_card_title_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card>.gn-body .gn-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'price_style',
			array(
				'label' => esc_html__( 'Price', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'archive_card_price_typography',
				'label'    => esc_html__( 'Typography', 'gigneo' ),
				'selector' => '{{WRAPPER}} .gn-service-card>.gn-body .gn-price',
			)
		);

		$this->add_control(
			'archive_card_price_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card>.gn-body .gn-price' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'archive_card_price_value_color',
			array(
				'label'     => esc_html__( 'Value Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card>.gn-body .gn-price .gn-value' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'archive_card_price_space_between',
			array(
				'label'      => esc_html__( 'Space Between', 'gigneo' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%', 'em' ),
				'range'      => array(
					'px' => array(
						'min'  => 0,
						'max'  => 30,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card>.gn-body .gn-price' => 'gap: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'meta_style',
			array(
				'label'     => esc_html__( 'Meta', 'gigneo' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'show_meta' => 'yes',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'      => 'archive_card_meta_typography',
				'condition' => array(
					'show_meta' => 'yes',
				),
				'label'     => esc_html__( 'Typography', 'gigneo' ),
				'selector'  => '
                    {{WRAPPER}} .gn-service-card>.gn-body .gn-meta>div',
			)
		);

		$this->add_control(
			'archive_card_meta_color',
			array(
				'label'     => esc_html__( 'Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_meta' => 'yes',
				),
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card>.gn-body .gn-meta>div' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'archive_card_meta_size',
			array(
				'label'      => __( 'Icon Size', 'gigneo' ),
				'type'       => \Elementor\Controls_Manager::SLIDER,
				'condition'  => array(
					'show_meta' => 'yes',
				),
				'size_units' => array( 'px', '%', 'em' ),
				'range'      => array(
					'px' => array(
						'min'  => 15,
						'max'  => 30,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card>.gn-body .gn-meta i' => 'font-size: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'archive_card_meta_space_between',
			array(
				'label'      => esc_html__( 'Space Between', 'gigneo' ),
				'type'       => Controls_Manager::SLIDER,
				'condition'  => array(
					'show_meta' => 'yes',
				),
				'size_units' => array( 'px', '%', 'em' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 30,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card>.gn-body .gn-meta' => 'gap: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'archive_card_meta_spacing',
			array(
				'label'      => esc_html__( 'Spacing', 'gigneo' ),
				'type'       => Controls_Manager::SLIDER,
				'condition'  => array(
					'show_meta' => 'yes',
				),
				'size_units' => array( 'px', '%', 'em' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 30,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card>.gn-body .gn-meta>div' => 'gap: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'footer_style',
			array(
				'label' => esc_html__( 'Footer', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'archive_card_footer_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'archive_card_footer_border',
				'selector' => '{{WRAPPER}} .gn-service-card .gn-footer',
			)
		);

		$this->add_responsive_control(
			'archive_card_footer_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card .gn-footer' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'archive_card_footer_padding',
			array(
				'label'      => esc_html__( 'Padding', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card .gn-footer' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'archive_card_avatar_heading',
			array(
				'label'     => esc_html__( 'Avatar', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_responsive_control(
			'avatar_size',
			array(
				'label'      => __( 'Size', 'gigneo' ),
				'type'       => \Elementor\Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%', 'em' ),
				'range'      => array(
					'px' => array(
						'min'  => 20,
						'max'  => 80,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card .gn-avatar' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'avatar_border',
				'selector' => '{{WRAPPER}} .gn-service-card .gn-avatar',
			)
		);

		$this->add_responsive_control(
			'avatar_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card .gn-avatar' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'status_indicator',
			array(
				'label'     => esc_html__( 'Status', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'status_indicator_box_shadow',
				'label'    => esc_html__( 'Box Shadow', 'gigneo' ),
				'selector' => '{{WRAPPER}} .gn-service-card .gn-avatar:before',
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'status_indicator_border',
				'selector' => '{{WRAPPER}} .gn-service-card .gn-avatar:before',
			)
		);

		$this->add_responsive_control(
			'status_indicator_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card .gn-avatar:before' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'archive_card_profile_name_heading',
			array(
				'label'     => esc_html__( 'Name', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'profile_name_typography',
				'global'   => array(
					'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
				),
				'selector' => '{{WRAPPER}} .gn-info .gn-name',
			)
		);

		$this->add_control(
			'profile_name_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-info .gn-name' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Text_Shadow::get_type(),
			array(
				'name'     => 'profile_name_text_shadow',
				'selector' => '{{WRAPPER}} .gn-info .gn-name',
			)
		);

		$this->add_responsive_control(
			'profile_name_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-info .gn-name' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'archive_card_rating_heading',
			array(
				'label'     => esc_html__( 'Rating', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'condition' => array(
					'show_rating' => 'yes',
				),
				'separator' => 'before',
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'      => 'archive_card_rating_typography',
				'condition' => array(
					'show_rating' => 'yes',
				),
				'selector'  => '{{WRAPPER}} .gn-service-card .gn-footer .gn-info .gn-ratings',
			)
		);

		$this->add_control(
			'archive_card_rating_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_rating' => 'yes',
				),
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-info .gn-ratings' => 'color: {{VALUE}};',
				),
			)
		);

		$this->start_controls_tabs( 'archive_card_style_tabs' );

		$this->start_controls_tab(
			'archive_card_rating_icon_tab',
			array(
				'label'     => esc_html__( 'Icon', 'gigneo' ),
				'condition' => array(
					'show_rating' => 'yes',
				),
			)
		);

		$this->add_responsive_control(
			'rating_icon_size',
			array(
				'label'      => esc_html__( 'Size', 'gigneo' ),
				'type'       => Controls_Manager::SLIDER,
				'condition'  => array(
					'show_rating' => 'yes',
				),
				'size_units' => array( 'px', 'em', 'rem' ),
				'range'      => array(
					'px' => array(
						'min'  => 15,
						'max'  => 30,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-info .gn-ratings i' => 'font-size: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'rating_icon_icon_color',
			array(
				'label'     => esc_html__( 'Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_rating' => 'yes',
				),
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-info .gn-ratings i' => 'color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'archive_card_rating_count_tab',
			array(
				'label'     => esc_html__( 'Count', 'gigneo' ),
				'condition' => array(
					'show_rating' => 'yes',
				),
			)
		);

		$this->add_control(
			'archive_card_rating_count_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'show_rating' => 'yes',
				),
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-info .gn-ratings .gn-count' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'archive_card_rating_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'condition'  => array(
					'show_rating' => 'yes',
				),
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-info .gn-ratings .gn-count' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_control(
			'archive_card_view_button_heading',
			array(
				'label'     => esc_html__( 'View Button', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_responsive_control(
			'view_btn_icon_size',
			array(
				'label'      => esc_html__( 'Icon Size', 'gigneo' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em', 'rem' ),
				'range'      => array(
					'px' => array(
						'min'  => 10,
						'max'  => 30,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn i' => 'font-size: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->start_controls_tabs( 'view_btn_tabs' );

		$this->start_controls_tab(
			'view_btn_normal',
			array(
				'label' => esc_html__( 'Normal', 'gigneo' ),
			)
		);

		$this->add_control(
			'view_btn_icon_color',
			array(
				'label'     => esc_html__( 'Icon Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn i' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'view_btn_bg_color',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'view_btn_shadow',
				'selector' => '{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn',
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'view_btn_hover',
			array(
				'label' => esc_html__( 'Hover', 'gigneo' ),
			)
		);

		$this->add_control(
			'view_btn_text_color_hover',
			array(
				'label'     => esc_html__( 'Icon Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn i' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'view_btn_bg_color_hover',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn:hover' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'view_btn_border_color_hover',
			array(
				'label'     => __( 'Border Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn:hover' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'view_btn_shadow_hover',
				'selector' => '{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn:hover',
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'      => 'view_btn_border',
				'separator' => 'before',
				'selector'  => '{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn',
			)
		);

		$this->add_responsive_control(
			'viw_btn_padding',
			array(
				'label'     => esc_html__( 'Padding', 'gigneo' ),
				'type'      => Controls_Manager::DIMENSIONS,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'view_radius',
			array(
				'label'     => esc_html__( 'Border Radius', 'gigneo' ),
				'type'      => Controls_Manager::DIMENSIONS,
				'selectors' => array(
					'{{WRAPPER}} .gn-service-card .gn-footer .gn-actions .gn-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_filters_style',
			array(
				'label'     => esc_html__( 'Filters', 'gigneo' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'enable_filters' => 'yes',
				),
			)
		);

		$this->add_responsive_control(
			'filter_alignment',
			array(
				'label'     => esc_html__( 'Alignment', 'gigneo' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => array(
						'title' => esc_html__( 'Left', 'gigneo' ),
						'icon'  => 'eicon-h-align-left',
					),
					'center'     => array(
						'title' => esc_html__( 'Center', 'gigneo' ),
						'icon'  => 'eicon-h-align-center',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'gigneo' ),
						'icon'  => 'eicon-h-align-right',
					),
				),
				'selectors' => array(
					'{{WRAPPER}} .gn-services-grid-filter-list' => 'justify-content: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'filter_space_between',
			array(
				'label'      => esc_html__( 'Space between', 'gigneo' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em', 'rem' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 30,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-services-grid-filter-list' => 'gap: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'filter_typo',
				'label'    => esc_html__( 'Typography', 'gigneo' ),
				'selector' => '{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item',
			)
		);

		$this->start_controls_tabs( 'tabs_filter_style' );

		$this->start_controls_tab(
			'tab_filter_normal',
			array(
				'label' => esc_html__( 'Normal', 'gigneo' ),
			)
		);

		$this->add_control(
			'filter_color',
			array(
				'label'     => esc_html__( 'Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'filter_bg_color',
			array(
				'label'     => esc_html__( 'Background color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'filter_normal_shadow',
				'selector' => '{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item',
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'tab_filter_hover',
			array(
				'label' => esc_html__( 'Hover', 'gigneo' ),
			)
		);

		$this->add_control(
			'filter_hover_color',
			array(
				'label'     => esc_html__( 'Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item:hover' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'filter_bg_hover_color',
			array(
				'label'     => esc_html__( 'Background color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item:hover' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'filter_border_hover_color',
			array(
				'label'     => esc_html__( 'Border color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item:hover' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'filter_hover_shadow',
				'selector' => '{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item:hover',
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'tab_filter_active',
			array(
				'label' => esc_html__( 'Active', 'gigneo' ),
			)
		);

		$this->add_control(
			'filter_active_color',
			array(
				'label'     => esc_html__( 'Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item.active' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'filter_bg_active_color',
			array(
				'label'     => esc_html__( 'Background color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item.active' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'filter_border_active_color',
			array(
				'label'     => esc_html__( 'Border color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item.active' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'filter_active_shadow',
				'selector' => '{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item.active',
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'      => 'filter_button_border',
				'selector'  => '{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item',
				'separator' => 'before',
			)
		);

        $this->add_responsive_control(
            'filter_button_radius',
            array(
                'label'      => esc_html__( 'Border radius', 'gigneo' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => array( 'px', '%', 'em', 'rem', 'custom' ),
                'selectors'  => array(
                    '{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ),
            )
        );

		$this->add_responsive_control(
			'filter_button_padding',
			array(
				'label'      => esc_html__( 'Padding', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem', 'custom' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-services-grid-filter-list .gn-services-grid-filter-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

        $this->add_responsive_control(
            'filter_button_margin',
            array(
                'label'      => esc_html__( 'Margin', 'gigneo' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => array( 'px', '%', 'em', 'rem', 'custom' ),
                'selectors'  => array(
                    '{{WRAPPER}} .gn-services-grid-filter-list' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ),
            )
        );

		$this->end_controls_section();
	}

	/**
	 * Authors Select2 options (dynamic + users).
	 *
	 * @return array<string, string>
	 */
	private function get_author_select_options() {
		$user_author_options = array();

		$freelancer_ids = get_posts(
			array(
				'post_type'      => 'gigneo_freelancer',
				'post_status'    => 'publish',
				'posts_per_page' => -1,
				'fields'         => 'ids',
			)
		);

		foreach ( $freelancer_ids as $profile_id ) {
			$author_id = (int) get_post_field( 'post_author', $profile_id );
			if ( $author_id > 0 ) {
				$user_author_options[ (string) $author_id ] = get_the_author_meta( 'display_name', $author_id );
			}
		}

		$service_ids = get_posts(
			array(
				'post_type'      => 'gigneo_service',
				'post_status'    => 'publish',
				'posts_per_page' => -1,
				'fields'         => 'ids',
			)
		);

		foreach ( $service_ids as $post_id ) {
			$author_id = (int) get_post_field( 'post_author', $post_id );
			if ( $author_id > 0 ) {
				$user_author_options[ (string) $author_id ] = get_the_author_meta( 'display_name', $author_id );
			}
		}

		asort( $user_author_options );

		return array(
			'gn_current_author' => esc_html__( 'Current Author', 'gigneo' ),
			'gn_post_author'    => esc_html__( 'Post Author', 'gigneo' ),
		) + $user_author_options;
	}

	/**
	 * Resolve author filter values to WordPress user IDs.
	 *
	 * @param array $author_values Selected author control values.
	 * @return int[]
	 */
	public function resolve_query_author_ids( $author_values ) {
		$author_ids = array();

		foreach ( (array) $author_values as $value ) {
			$value = (string) $value;

			if ( in_array( $value, array( 'gn_current_author', 'current' ), true ) ) {
				$user_id = get_current_user_id();
				if ( $user_id > 0 ) {
					$author_ids[] = $user_id;
				}
				continue;
			}

			if ( in_array( $value, array( 'gn_post_author', 'post_author' ), true ) ) {
				$post_author_id = $this->get_context_post_author_id();
				if ( $post_author_id > 0 ) {
					$author_ids[] = $post_author_id;
				}
				continue;
			}

			$numeric_id = absint( $value );
			if ( $numeric_id > 0 ) {
				$author_ids[] = $numeric_id;
			}
		}

		return array_values( array_unique( $author_ids ) );
	}

	/**
	 * Author user ID for the post in the current template context.
	 *
	 * @return int
	 */
	private function get_context_post_author_id() {
		$post = $this->get_context_post();

		if ( ! $post instanceof WP_Post || empty( $post->post_author ) ) {
			return 0;
		}

		return (int) $post->post_author;
	}

	/**
	 * Post being viewed (not the gigneo_layout template on singular pages).
	 *
	 * @return WP_Post|null
	 */
	private function get_context_post() {
		if ( ! is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && is_singular() ) {
			$queried = get_queried_object();

			if ( $queried instanceof WP_Post && $this->is_gigneo_singular_post_type( $queried->post_type ) ) {
				$global = get_post();

				if ( ! $global || 'gigneo_layout' === $global->post_type || (int) $global->ID !== (int) $queried->ID ) {
					return $queried;
				}
			}
		}

		$preview = $this->get_layout_preview_post();
		if ( $preview instanceof WP_Post ) {
			return $preview;
		}

		$post = get_post();

		return ( $post instanceof WP_Post ) ? $post : null;
	}

	/**
	 * Preview post when editing a gigneo_layout in Elementor.
	 *
	 * @return WP_Post|null
	 */
	private function get_layout_preview_post() {
		if ( ! is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
			return null;
		}

		$current_id = get_the_ID();

		if ( ! $current_id || 'gigneo_layout' !== get_post_type( $current_id ) ) {
			return null;
		}

		$document = Plugin::$instance->documents->get_doc_for_frontend( $current_id );

		if ( ! $document ) {
			return null;
		}

		$args = Plugin::$instance->preview->is_preview_mode()
			? $document->get_preview_query_args()
			: $document->get_document_query_args();

		if ( empty( $args['p'] ) ) {
			return null;
		}

		$post = get_post( $args['p'] );

		return ( $post instanceof WP_Post ) ? $post : null;
	}

	/**
	 * @param string $post_type Post type slug.
	 * @return bool
	 */
	private function is_gigneo_singular_post_type( $post_type ) {
		return in_array(
			$post_type,
			array(
				'gigneo_freelancer',
				'gigneo_employer',
				'gigneo_service',
				'gigneo_job',
			),
			true
		);
	}

	/**
	 * Render widget output on the frontend.
	 */
	protected function render() {
		require gigneo_get_template( 'elementor/widgets/service-grid' );
	}
}
