<?php
/**
 * Logo Showcase widget.
 *
 * @package IMPACT_WIDGETS_ELEMENTOR
 */

namespace ImpactAddons\ImpactWidgetsForElementor\Widgets;

use Elementor\Controls_Manager;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Icons_Manager;
use Elementor\Repeater;
use Elementor\Utils;
use Elementor\Widget_Base;

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

class Logo_Showcase extends Widget_Base {
	public function get_name(): string {
		return 'impact_widgets_elementor_logo-showcase';
	}

	public function get_title(): string {
		return esc_html__( 'Logo Showcase', 'impact-widgets-for-elementor' );
	}

	public function get_icon(): string {
		return 'eicon-logo';
	}

	public function get_categories(): array {
		return array( 'impact-widgets-elementor' );
	}

	public function get_style_depends(): array {
		return array( 'impact_widgets_elementor_logo-showcase' );
	}

	public function get_script_depends(): array {
		return array( 'impact_widgets_elementor_logo-showcase' );
	}

	protected function register_controls(): void {
		$this->register_content_controls();
		$this->register_style_controls();
	}

	private function register_content_controls(): void {
		$this->start_controls_section(
			'section_layout',
			array(
				'label' => esc_html__( 'Layout', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'layout_style',
			array(
				'label'   => esc_html__( 'Display Type', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'grid',
				'options' => array(
					'grid'              => esc_html__( 'Grid Logos', 'impact-widgets-for-elementor' ),
					'masonry'           => esc_html__( 'Masonry Logos', 'impact-widgets-for-elementor' ),
					'filter'            => esc_html__( 'Filter Logos', 'impact-widgets-for-elementor' ),
					'slider'            => esc_html__( 'Slider Logos', 'impact-widgets-for-elementor' ),
					'scroll-horizontal' => esc_html__( 'Scrolling Images Horizontal', 'impact-widgets-for-elementor' ),
					'scroll-vertical'   => esc_html__( 'Scrolling Images Vertical', 'impact-widgets-for-elementor' ),
				),
			)
		);

		$this->add_control(
			'show_heading_block',
			array(
				'label'        => esc_html__( 'Show Heading', 'impact-widgets-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'impact-widgets-for-elementor' ),
				'label_off'    => esc_html__( 'No', 'impact-widgets-for-elementor' ),
				'return_value' => 'yes',
				'default'      => 'yes',
			)
		);

		$this->add_control(
			'heading',
			array(
				'label'       => esc_html__( 'Heading', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Trusted by brands worldwide.', 'impact-widgets-for-elementor' ),
				'label_block' => true,
				'condition'   => array(
					'show_heading_block' => 'yes',
				),
			)
		);

		$this->add_control(
			'description',
			array(
				'label'     => esc_html__( 'Description', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::TEXTAREA,
				'default'   => esc_html__( 'Use one widget for logo grids, partner sliders, filtered collections, and animated image walls.', 'impact-widgets-for-elementor' ),
				'rows'      => 3,
				'condition' => array(
					'show_heading_block' => 'yes',
				),
			)
		);

		$this->add_responsive_control(
			'columns',
			array(
				'label'          => esc_html__( 'Columns', 'impact-widgets-for-elementor' ),
				'type'           => Controls_Manager::SELECT,
				'default'        => '4',
				'tablet_default' => '3',
				'mobile_default' => '2',
				'options'        => array(
					'1' => '1',
					'2' => '2',
					'3' => '3',
					'4' => '4',
					'5' => '5',
					'6' => '6',
				),
				'selectors'      => array(
					'{{WRAPPER}} .iaew-logo-showcase' => '--iaew-logo-columns: {{VALUE}};',
				),
				'condition'      => array(
					'layout_style' => array( 'grid', 'masonry', 'filter' ),
				),
			)
		);

		$this->add_responsive_control(
			'slides_to_show',
			array(
				'label'          => esc_html__( 'Slides Visible', 'impact-widgets-for-elementor' ),
				'type'           => Controls_Manager::SELECT,
				'default'        => '4',
				'tablet_default' => '3',
				'mobile_default' => '1',
				'options'        => array(
					'1' => '1',
					'2' => '2',
					'3' => '3',
					'4' => '4',
					'5' => '5',
					'6' => '6',
				),
				'selectors'      => array(
					'{{WRAPPER}} .iaew-logo-showcase' => '--iaew-logo-slides: {{VALUE}};',
				),
				'condition'      => array(
					'layout_style' => 'slider',
				),
			)
		);

		$this->add_responsive_control(
			'item_gap',
			array(
				'label'      => esc_html__( 'Gap', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 80,
					),
				),
				'default'    => array(
					'size' => 24,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase' => '--iaew-logo-gap: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'show_item_title',
			array(
				'label'        => esc_html__( 'Show Item Title', 'impact-widgets-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'impact-widgets-for-elementor' ),
				'label_off'    => esc_html__( 'No', 'impact-widgets-for-elementor' ),
				'return_value' => 'yes',
				'default'      => '',
			)
		);

		$this->add_control(
			'show_item_caption',
			array(
				'label'        => esc_html__( 'Show Item Caption', 'impact-widgets-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'impact-widgets-for-elementor' ),
				'label_off'    => esc_html__( 'No', 'impact-widgets-for-elementor' ),
				'return_value' => 'yes',
				'default'      => 'yes',
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_behavior_filter',
			array(
				'label'     => esc_html__( 'Filter Behavior', 'impact-widgets-for-elementor' ),
				'condition' => array(
					'layout_style' => 'filter',
				),
			)
		);

		$this->add_control(
			'filter_default',
			array(
				'label'     => esc_html__( 'Default Filter Label', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::TEXT,
				'default'   => esc_html__( 'All', 'impact-widgets-for-elementor' ),
				'condition' => array(
					'layout_style' => 'filter',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_behavior_slider',
			array(
				'label'     => esc_html__( 'Slider Behavior', 'impact-widgets-for-elementor' ),
				'condition' => array(
					'layout_style' => 'slider',
				),
			)
		);

		$this->add_control(
			'show_slider_dots',
			array(
				'label'        => esc_html__( 'Show Slider Dots', 'impact-widgets-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'impact-widgets-for-elementor' ),
				'label_off'    => esc_html__( 'No', 'impact-widgets-for-elementor' ),
				'return_value' => 'yes',
				'default'      => 'yes',
			)
		);

		$this->add_control(
			'show_slider_arrows',
			array(
				'label'        => esc_html__( 'Show Slider Arrows', 'impact-widgets-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'impact-widgets-for-elementor' ),
				'label_off'    => esc_html__( 'No', 'impact-widgets-for-elementor' ),
				'return_value' => 'yes',
				'default'      => 'yes',
			)
		);

		$this->add_control(
			'slider_autoplay',
			array(
				'label'        => esc_html__( 'Autoplay Slider', 'impact-widgets-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'impact-widgets-for-elementor' ),
				'label_off'    => esc_html__( 'No', 'impact-widgets-for-elementor' ),
				'return_value' => 'yes',
				'default'      => 'yes',
				'condition'    => array(
					'layout_style' => 'slider',
				),
			)
		);

		$this->add_control(
			'slider_autoplay_speed',
			array(
				'label'      => esc_html__( 'Slider Autoplay Delay', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::NUMBER,
				'default'    => 3500,
				'min'        => 1000,
				'step'       => 100,
				'condition'  => array(
					'slider_autoplay' => 'yes',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_behavior_scroll',
			array(
				'label'     => esc_html__( 'Scrolling Behavior', 'impact-widgets-for-elementor' ),
				'condition' => array(
					'layout_style' => array( 'scroll-horizontal', 'scroll-vertical' ),
				),
			)
		);

		$this->add_control(
			'scroll_speed',
			array(
				'label'     => esc_html__( 'Scroll Speed', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::NUMBER,
				'default'   => 24,
				'min'       => 8,
				'max'       => 80,
			)
		);

		$this->add_control(
			'scroll_track_count',
			array(
				'label'       => esc_html__( 'Rows / Columns', 'impact-widgets-for-elementor' ),
				'description' => esc_html__( 'Horizontal scrolling uses rows. Vertical scrolling uses columns.', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::NUMBER,
				'default'     => 2,
				'min'         => 1,
				'max'         => 6,
				'step'        => 1,
			)
		);

		$this->add_control(
			'pause_on_hover',
			array(
				'label'        => esc_html__( 'Pause On Hover', 'impact-widgets-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'impact-widgets-for-elementor' ),
				'label_off'    => esc_html__( 'No', 'impact-widgets-for-elementor' ),
				'return_value' => 'yes',
				'default'      => 'yes',
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_items',
			array(
				'label' => esc_html__( 'Items', 'impact-widgets-for-elementor' ),
			)
		);

		$repeater = new Repeater();

		$repeater->add_control(
			'item_title',
			array(
				'label'       => esc_html__( 'Title', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Logoipsum', 'impact-widgets-for-elementor' ),
				'label_block' => true,
			)
		);

		$repeater->add_control(
			'item_caption',
			array(
				'label'       => esc_html__( 'Caption', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Partner Brand', 'impact-widgets-for-elementor' ),
				'label_block' => true,
			)
		);

		$repeater->add_control(
			'item_category',
			array(
				'label'       => esc_html__( 'Filter Category', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'All', 'impact-widgets-for-elementor' ),
				'description' => esc_html__( 'Use the same text on multiple items to group them in filter mode.', 'impact-widgets-for-elementor' ),
			)
		);

		$repeater->add_control(
			'item_link',
			array(
				'label'         => esc_html__( 'Link', 'impact-widgets-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => esc_html__( 'https://your-link.com', 'impact-widgets-for-elementor' ),
				'show_external' => true,
			)
		);

		$repeater->add_control(
			'item_image',
			array(
				'label'   => esc_html__( 'Logo / Image', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::MEDIA,
				'dynamic' => array(
					'active' => true,
				),
				'default' => array(
					'url' => Utils::get_placeholder_image_src(),
				),
			)
		);

		$this->add_control(
			'items',
			array(
				'label'       => esc_html__( 'Showcase Items', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::REPEATER,
				'fields'      => $repeater->get_controls(),
				'title_field' => '{{{ item_title }}}',
				'default'     => $this->get_default_items(),
			)
		);

		$this->end_controls_section();
	}

	private function register_style_controls(): void {
		$this->start_controls_section(
			'section_style_wrapper',
			array(
				'label' => esc_html__( 'Wrapper', 'impact-widgets-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_responsive_control(
			'wrapper_padding',
			array(
				'label'      => esc_html__( 'Padding', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'wrapper_background',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase',
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_style_heading',
			array(
				'label' => esc_html__( 'Heading', 'impact-widgets-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'heading_color',
			array(
				'label'     => esc_html__( 'Heading Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__heading' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'heading_typography',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__heading',
			)
		);

		$this->add_control(
			'description_color',
			array(
				'label'     => esc_html__( 'Description Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__description' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'description_typography',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__description',
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_style_card',
			array(
				'label' => esc_html__( 'Logo Box', 'impact-widgets-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_responsive_control(
			'card_padding',
			array(
				'label'      => esc_html__( 'Box Padding', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__card' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'card_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__card' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'card_min_height',
			array(
				'label'      => esc_html__( 'Minimum Height', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 80,
						'max' => 420,
					),
				),
				'default'    => array(
					'size' => 160,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase' => '--iaew-logo-card-height: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->start_controls_tabs( 'card_style_tabs' );

		$this->start_controls_tab(
			'card_style_normal',
			array(
				'label' => esc_html__( 'Normal', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'card_background',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__card',
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'card_border',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__card',
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'card_shadow',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__card',
			)
		);

		$this->add_control(
			'card_opacity',
			array(
				'label'      => esc_html__( 'Box Opacity', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'%' => array(
						'min' => 10,
						'max' => 100,
					),
				),
				'default'    => array(
					'size' => 100,
					'unit' => '%',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__card' => 'opacity: calc({{SIZE}} / 100);',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'card_style_hover',
			array(
				'label' => esc_html__( 'Hover', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'card_hover_background',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__item:hover .iaew-logo-showcase__card',
			)
		);

		$this->add_control(
			'card_hover_border_color',
			array(
				'label'     => esc_html__( 'Border Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__item:hover .iaew-logo-showcase__card' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'card_hover_shadow',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__item:hover .iaew-logo-showcase__card',
			)
		);

		$this->add_control(
			'card_hover_transform',
			array(
				'label'      => esc_html__( 'Hover Lift', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => -30,
						'max' => 30,
					),
				),
				'default'    => array(
					'size' => -6,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__item:hover .iaew-logo-showcase__card' => 'transform: translateY({{SIZE}}{{UNIT}});',
				),
			)
		);

		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();

		$this->start_controls_section(
			'section_style_logo',
			array(
				'label' => esc_html__( 'Logo / Image', 'impact-widgets-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_responsive_control(
			'logo_max_width',
			array(
				'label'      => esc_html__( 'Max Width', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 40,
						'max' => 480,
					),
					'%'  => array(
						'min' => 10,
						'max' => 100,
					),
				),
				'default'    => array(
					'size' => 100,
					'unit' => '%',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__image' => 'max-width: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'logo_height',
			array(
				'label'      => esc_html__( 'Max Height', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 40,
						'max' => 320,
					),
				),
				'default'    => array(
					'size' => 104,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase' => '--iaew-logo-image-height: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'logo_object_fit',
			array(
				'label'     => esc_html__( 'Object Fit', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'contain',
				'options'   => array(
					'contain'    => esc_html__( 'Contain', 'impact-widgets-for-elementor' ),
					'cover'      => esc_html__( 'Cover', 'impact-widgets-for-elementor' ),
					'fill'       => esc_html__( 'Fill', 'impact-widgets-for-elementor' ),
					'none'       => esc_html__( 'None', 'impact-widgets-for-elementor' ),
					'scale-down' => esc_html__( 'Scale Down', 'impact-widgets-for-elementor' ),
				),
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__image' => 'object-fit: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'logo_object_position',
			array(
				'label'     => esc_html__( 'Object Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'center center',
				'options'   => array(
					'left top'      => esc_html__( 'Left Top', 'impact-widgets-for-elementor' ),
					'left center'   => esc_html__( 'Left Center', 'impact-widgets-for-elementor' ),
					'left bottom'   => esc_html__( 'Left Bottom', 'impact-widgets-for-elementor' ),
					'center top'    => esc_html__( 'Center Top', 'impact-widgets-for-elementor' ),
					'center center' => esc_html__( 'Center Center', 'impact-widgets-for-elementor' ),
					'center bottom' => esc_html__( 'Center Bottom', 'impact-widgets-for-elementor' ),
					'right top'     => esc_html__( 'Right Top', 'impact-widgets-for-elementor' ),
					'right center'  => esc_html__( 'Right Center', 'impact-widgets-for-elementor' ),
					'right bottom'  => esc_html__( 'Right Bottom', 'impact-widgets-for-elementor' ),
				),
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__image' => 'object-position: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'logo_border',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__media',
			)
		);

		$this->add_responsive_control(
			'logo_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__media' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->start_controls_tabs( 'logo_style_tabs' );

		$this->start_controls_tab(
			'logo_style_normal',
			array(
				'label' => esc_html__( 'Normal', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'logo_opacity',
			array(
				'label'      => esc_html__( 'Opacity', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'%' => array(
						'min' => 0,
						'max' => 100,
					),
				),
				'default'    => array(
					'size' => 100,
					'unit' => '%',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__image' => 'opacity: calc({{SIZE}} / 100);',
				),
			)
		);

		$this->add_control(
			'logo_grayscale',
			array(
				'label'      => esc_html__( 'Grayscale', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'%' => array(
						'min' => 0,
						'max' => 100,
					),
				),
				'default'    => array(
					'size' => 0,
					'unit' => '%',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__image' => 'filter: grayscale(calc({{SIZE}} * 1%));',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'logo_style_hover',
			array(
				'label' => esc_html__( 'Hover', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'logo_hover_opacity',
			array(
				'label'      => esc_html__( 'Opacity', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'%' => array(
						'min' => 0,
						'max' => 100,
					),
				),
				'default'    => array(
					'size' => 100,
					'unit' => '%',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__item:hover .iaew-logo-showcase__image' => 'opacity: calc({{SIZE}} / 100);',
				),
			)
		);

		$this->add_control(
			'logo_hover_grayscale',
			array(
				'label'      => esc_html__( 'Grayscale', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'%' => array(
						'min' => 0,
						'max' => 100,
					),
				),
				'default'    => array(
					'size' => 0,
					'unit' => '%',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__item:hover .iaew-logo-showcase__image' => 'filter: grayscale(calc({{SIZE}} * 1%));',
				),
			)
		);

		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();

		$this->start_controls_section(
			'section_style_text',
			array(
				'label' => esc_html__( 'Item Text', 'impact-widgets-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'item_title_color',
			array(
				'label'     => esc_html__( 'Title Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__item-title' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'item_title_typography',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__item-title',
			)
		);

		$this->add_control(
			'item_caption_color',
			array(
				'label'     => esc_html__( 'Caption Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__item-caption' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'item_caption_typography',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__item-caption',
			)
		);

		$this->add_control(
			'item_text_overlay',
			array(
				'label'        => esc_html__( 'Show Text On Image', 'impact-widgets-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'impact-widgets-for-elementor' ),
				'label_off'    => esc_html__( 'No', 'impact-widgets-for-elementor' ),
				'return_value' => 'yes',
				'default'      => '',
			)
		);

		$this->add_control(
			'item_text_overlay_horizontal',
			array(
				'label'     => esc_html__( 'Overlay Horizontal Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'left',
				'options'   => array(
					'left'   => esc_html__( 'Left', 'impact-widgets-for-elementor' ),
					'center' => esc_html__( 'Center', 'impact-widgets-for-elementor' ),
					'right'  => esc_html__( 'Right', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'item_text_overlay' => 'yes',
				),
			)
		);

		$this->add_control(
			'item_text_overlay_vertical',
			array(
				'label'     => esc_html__( 'Overlay Vertical Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'bottom',
				'options'   => array(
					'top'    => esc_html__( 'Top', 'impact-widgets-for-elementor' ),
					'center' => esc_html__( 'Center', 'impact-widgets-for-elementor' ),
					'bottom' => esc_html__( 'Bottom', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'item_text_overlay' => 'yes',
				),
			)
		);

		$this->add_responsive_control(
			'item_text_overlay_padding',
			array(
				'label'      => esc_html__( 'Overlay Padding', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem' ),
				'condition'  => array(
					'item_text_overlay' => 'yes',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__content--overlay' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'item_text_overlay_background',
			array(
				'label'     => esc_html__( 'Overlay Background', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array(
					'item_text_overlay' => 'yes',
				),
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__content--overlay' => 'background: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'item_text_overlay_border_radius',
			array(
				'label'      => esc_html__( 'Overlay Border Radius', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'condition'  => array(
					'item_text_overlay' => 'yes',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__content--overlay' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_style_filter',
			array(
				'label' => esc_html__( 'Filter', 'impact-widgets-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_responsive_control(
			'filter_gap',
			array(
				'label'      => esc_html__( 'Chips Gap', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 48,
					),
				),
				'default'    => array(
					'size' => 12,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__filters' => 'gap: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'filter_margin',
			array(
				'label'      => esc_html__( 'Filter Margin', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__filters' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'filter_chip_padding',
			array(
				'label'      => esc_html__( 'Chip Padding', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__filter-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'filter_typography',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__filter-button',
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'filter_chip_border',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__filter-button',
			)
		);

		$this->add_responsive_control(
			'filter_chip_border_radius',
			array(
				'label'      => esc_html__( 'Chip Border Radius', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__filter-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->start_controls_tabs( 'filter_tabs' );

		$this->start_controls_tab(
			'filter_normal',
			array(
				'label' => esc_html__( 'Normal', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'filter_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__filter-button' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'filter_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__filter-button' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'filter_active',
			array(
				'label' => esc_html__( 'Active / Hover', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'filter_active_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__filter-button:hover, {{WRAPPER}} .iaew-logo-showcase__filter-button.is-active' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'filter_active_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__filter-button:hover, {{WRAPPER}} .iaew-logo-showcase__filter-button.is-active' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'filter_active_border_color',
			array(
				'label'     => esc_html__( 'Border Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__filter-button:hover, {{WRAPPER}} .iaew-logo-showcase__filter-button.is-active' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();

		$this->start_controls_section(
			'section_style_slider_dots',
			array(
				'label'     => esc_html__( 'Slider Dots', 'impact-widgets-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'layout_style'     => 'slider',
					'show_slider_dots' => 'yes',
				),
			)
		);

		$this->add_responsive_control(
			'dots_alignment',
			array(
				'label'     => esc_html__( 'Alignment', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => array(
						'title' => esc_html__( 'Left', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-h-align-left',
					),
					'center'     => array(
						'title' => esc_html__( 'Center', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-h-align-center',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-h-align-right',
					),
				),
				'default'   => 'center',
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__dots' => 'justify-content: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'dots_gap',
			array(
				'label'      => esc_html__( 'Gap', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 40,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__dots' => 'gap: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'dots_margin',
			array(
				'label'      => esc_html__( 'Margin', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__dots' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'dots_size',
			array(
				'label'      => esc_html__( 'Size', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 4,
						'max' => 40,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__dot' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'dots_active_width',
			array(
				'label'      => esc_html__( 'Active Width', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 4,
						'max' => 80,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__dot.is-active' => 'width: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'dots_border',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__dot',
			)
		);

		$this->add_responsive_control(
			'dots_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__dot' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'dots_box_shadow',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__dot',
			)
		);

		$this->start_controls_tabs( 'dots_tabs' );

		$this->start_controls_tab(
			'dots_normal',
			array(
				'label' => esc_html__( 'Normal', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'dots_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__dot' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'dots_border_color',
			array(
				'label'     => esc_html__( 'Border Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__dot' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'dots_active',
			array(
				'label' => esc_html__( 'Active', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'dots_active_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__dot.is-active' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'dots_active_border_color',
			array(
				'label'     => esc_html__( 'Border Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__dot.is-active' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();

		$this->start_controls_section(
			'section_style_navigation',
			array(
				'label' => esc_html__( 'Navigation', 'impact-widgets-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_responsive_control(
			'navigation_alignment',
			array(
				'label'     => esc_html__( 'Navigation Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => array(
						'title' => esc_html__( 'Left', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-h-align-left',
					),
					'center'     => array(
						'title' => esc_html__( 'Center', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-h-align-center',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-h-align-right',
					),
				),
				'default'   => 'flex-end',
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-controls' => 'justify-content: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'navigation_vertical_position',
			array(
				'label'   => esc_html__( 'Navigation Vertical Position', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::CHOOSE,
				'options' => array(
					'top'    => array(
						'title' => esc_html__( 'Top', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-v-align-top',
					),
					'center' => array(
						'title' => esc_html__( 'Center', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-v-align-middle',
					),
					'bottom' => array(
						'title' => esc_html__( 'Bottom', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-v-align-bottom',
					),
				),
				'default' => 'top',
				'toggle'  => false,
			)
		);

		$this->add_control(
			'navigation_layout',
			array(
				'label'   => esc_html__( 'Navigation Layout', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'grouped',
				'options' => array(
					'grouped' => esc_html__( 'Together', 'impact-widgets-for-elementor' ),
					'split'   => esc_html__( 'Split Sides', 'impact-widgets-for-elementor' ),
				),
			)
		);

		$this->add_responsive_control(
			'navigation_gap',
			array(
				'label'      => esc_html__( 'Buttons Gap', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 48,
					),
				),
				'default'    => array(
					'size' => 12,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-controls' => 'gap: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'navigation_prev_icon',
			array(
				'label'   => esc_html__( 'Previous Icon', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::ICONS,
				'default' => array(
					'value'   => 'fas fa-arrow-left',
					'library' => 'fa-solid',
				),
			)
		);

		$this->add_control(
			'navigation_next_icon',
			array(
				'label'   => esc_html__( 'Next Icon', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::ICONS,
				'default' => array(
					'value'   => 'fas fa-arrow-right',
					'library' => 'fa-solid',
				),
			)
		);

		$this->add_responsive_control(
			'navigation_margin',
			array(
				'label'      => esc_html__( 'Navigation Margin', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-controls' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'navigation_button_padding',
			array(
				'label'      => esc_html__( 'Button Padding', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'navigation_button_margin',
			array(
				'label'      => esc_html__( 'Button Margin', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-button' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'navigation_icon_size',
			array(
				'label'      => esc_html__( 'Icon Size', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 8,
						'max' => 64,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-button i' => 'font-size: {{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .iaew-logo-showcase__slider-button svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'navigation_button_border',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__slider-button',
			)
		);

		$this->add_responsive_control(
			'navigation_button_border_radius',
			array(
				'label'      => esc_html__( 'Button Border Radius', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'navigation_button_box_shadow',
				'selector' => '{{WRAPPER}} .iaew-logo-showcase__slider-button',
			)
		);

		$this->start_controls_tabs( 'navigation_tabs' );

		$this->start_controls_tab(
			'navigation_normal',
			array(
				'label' => esc_html__( 'Normal', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'navigation_text_color',
			array(
				'label'     => esc_html__( 'Text / Icon Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-button' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'navigation_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-button' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'navigation_active',
			array(
				'label' => esc_html__( 'Active / Hover', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'navigation_active_text_color',
			array(
				'label'     => esc_html__( 'Text / Icon Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-button:hover' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'navigation_active_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-button:hover' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'navigation_active_border_color',
			array(
				'label'     => esc_html__( 'Border Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .iaew-logo-showcase__slider-button:hover' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
	}

	protected function render(): void {
		$settings = $this->get_settings_for_display();
		$items    = isset( $settings['items'] ) && is_array( $settings['items'] ) ? $settings['items'] : array();

		if ( empty( $items ) ) {
			return;
		}

		$layout = isset( $settings['layout_style'] ) ? sanitize_key( $settings['layout_style'] ) : 'grid';
		$allowed_layouts = array( 'grid', 'masonry', 'filter', 'slider', 'scroll-horizontal', 'scroll-vertical' );
		if ( ! in_array( $layout, $allowed_layouts, true ) ) {
			$layout = 'grid';
		}

		$heading            = isset( $settings['heading'] ) ? sanitize_text_field( $settings['heading'] ) : '';
		$description        = isset( $settings['description'] ) ? sanitize_textarea_field( $settings['description'] ) : '';
		$show_heading_block = isset( $settings['show_heading_block'] ) && 'yes' === $settings['show_heading_block'];
		$filter_default     = isset( $settings['filter_default'] ) ? sanitize_text_field( $settings['filter_default'] ) : esc_html__( 'All', 'impact-widgets-for-elementor' );
		$show_item_title    = isset( $settings['show_item_title'] ) && 'yes' === $settings['show_item_title'];
		$show_item_caption  = isset( $settings['show_item_caption'] ) && 'yes' === $settings['show_item_caption'];
		$item_text_overlay  = isset( $settings['item_text_overlay'] ) && 'yes' === $settings['item_text_overlay'];
		$overlay_horizontal = ! empty( $settings['item_text_overlay_horizontal'] ) ? sanitize_key( $settings['item_text_overlay_horizontal'] ) : 'left';
		$overlay_vertical   = ! empty( $settings['item_text_overlay_vertical'] ) ? sanitize_key( $settings['item_text_overlay_vertical'] ) : 'bottom';
		$pause_on_hover     = isset( $settings['pause_on_hover'] ) && 'yes' === $settings['pause_on_hover'];
		$scroll_speed       = isset( $settings['scroll_speed'] ) ? absint( $settings['scroll_speed'] ) : 24;
		$scroll_track_count = isset( $settings['scroll_track_count'] ) ? absint( $settings['scroll_track_count'] ) : 2;
		$scroll_track_count = max( 1, min( 6, $scroll_track_count ) );
		$slider_autoplay    = isset( $settings['slider_autoplay'] ) && 'yes' === $settings['slider_autoplay'];
		$slider_delay       = isset( $settings['slider_autoplay_speed'] ) ? absint( $settings['slider_autoplay_speed'] ) : 3500;
		$show_slider_dots   = isset( $settings['show_slider_dots'] ) && 'yes' === $settings['show_slider_dots'];
		$show_slider_arrows = isset( $settings['show_slider_arrows'] ) && 'yes' === $settings['show_slider_arrows'];
		$prev_icon          = isset( $settings['navigation_prev_icon'] ) && is_array( $settings['navigation_prev_icon'] ) ? $settings['navigation_prev_icon'] : array();
		$next_icon          = isset( $settings['navigation_next_icon'] ) && is_array( $settings['navigation_next_icon'] ) ? $settings['navigation_next_icon'] : array();
		$navigation_vertical_position = ! empty( $settings['navigation_vertical_position'] ) ? sanitize_key( $settings['navigation_vertical_position'] ) : 'top';
		if ( ! in_array( $navigation_vertical_position, array( 'top', 'center', 'bottom' ), true ) ) {
			$navigation_vertical_position = 'top';
		}
		$navigation_layout            = ! empty( $settings['navigation_layout'] ) ? sanitize_key( $settings['navigation_layout'] ) : 'grouped';
		if ( ! in_array( $navigation_layout, array( 'grouped', 'split' ), true ) ) {
			$navigation_layout = 'grouped';
		}

		$wrapper_classes = array(
			'iaew-logo-showcase',
			'iaew-logo-showcase--' . sanitize_html_class( $layout ),
		);

		if ( $pause_on_hover ) {
			$wrapper_classes[] = 'iaew-logo-showcase--pause-hover';
		}

		if ( $item_text_overlay ) {
			$wrapper_classes[] = 'iaew-logo-showcase--text-overlay';
			$wrapper_classes[] = 'iaew-logo-showcase--overlay-h-' . sanitize_html_class( $overlay_horizontal );
			$wrapper_classes[] = 'iaew-logo-showcase--overlay-v-' . sanitize_html_class( $overlay_vertical );
		}

		$this->add_render_attribute( 'wrapper', 'class', $wrapper_classes );
		$this->add_render_attribute( 'wrapper', 'data-layout', $layout );

		if ( 'slider' === $layout ) {
			$this->add_render_attribute( 'wrapper', 'data-autoplay', $slider_autoplay ? 'true' : 'false' );
			$this->add_render_attribute( 'wrapper', 'data-autoplay-delay', (string) max( 1000, $slider_delay ) );
		}

		if ( 'scroll-horizontal' === $layout || 'scroll-vertical' === $layout ) {
			$this->add_render_attribute( 'wrapper', 'style', '--iaew-marquee-duration: ' . esc_attr( max( 8, $scroll_speed ) ) . 's;' );
		}

		?>
		<div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
			<?php if ( $show_heading_block && ( '' !== $heading || '' !== $description ) ) : ?>
				<div class="iaew-logo-showcase__header">
					<?php if ( '' !== $heading ) : ?>
						<h2 class="iaew-logo-showcase__heading"><?php echo esc_html( $heading ); ?></h2>
					<?php endif; ?>

					<?php if ( '' !== $description ) : ?>
						<p class="iaew-logo-showcase__description"><?php echo esc_html( $description ); ?></p>
					<?php endif; ?>
				</div>
			<?php endif; ?>

			<?php if ( 'filter' === $layout ) : ?>
				<?php $this->render_filter_controls( $items, $filter_default ); ?>
			<?php endif; ?>

			<?php if ( 'slider' === $layout ) : ?>
				<div class="iaew-logo-showcase__slider iaew-logo-showcase__slider--nav-<?php echo esc_attr( $navigation_vertical_position ); ?> iaew-logo-showcase__slider--nav-layout-<?php echo esc_attr( $navigation_layout ); ?>">
					<?php if ( $show_slider_arrows ) : ?>
						<div class="iaew-logo-showcase__slider-controls">
							<button type="button" class="iaew-logo-showcase__slider-button" data-slider-prev aria-label="<?php echo esc_attr__( 'Previous logos', 'impact-widgets-for-elementor' ); ?>">
								<span class="iaew-logo-showcase__slider-icon" aria-hidden="true">
									<?php
									if ( ! empty( $prev_icon['value'] ) ) {
										Icons_Manager::render_icon( $prev_icon, array( 'aria-hidden' => 'true' ) );
									} else {
										?>
										&larr;
										<?php
									}
									?>
								</span>
							</button>
							<button type="button" class="iaew-logo-showcase__slider-button" data-slider-next aria-label="<?php echo esc_attr__( 'Next logos', 'impact-widgets-for-elementor' ); ?>">
								<span class="iaew-logo-showcase__slider-icon" aria-hidden="true">
									<?php
									if ( ! empty( $next_icon['value'] ) ) {
										Icons_Manager::render_icon( $next_icon, array( 'aria-hidden' => 'true' ) );
									} else {
										?>
										&rarr;
										<?php
									}
									?>
								</span>
							</button>
						</div>
					<?php endif; ?>

					<div class="iaew-logo-showcase__slider-viewport" data-slider-viewport>
						<div class="iaew-logo-showcase__slider-track">
							<?php foreach ( $items as $index => $item ) : ?>
								<?php $this->render_logo_item( $item, $index, $show_item_title, $show_item_caption, 'slider', $item_text_overlay ); ?>
							<?php endforeach; ?>
						</div>
					</div>

					<?php if ( $show_slider_dots ) : ?>
						<div class="iaew-logo-showcase__dots" data-slider-dots></div>
					<?php endif; ?>
				</div>
			<?php elseif ( 'scroll-horizontal' === $layout || 'scroll-vertical' === $layout ) : ?>
				<?php $this->render_scrolling_layout( $items, $show_item_title, $show_item_caption, $layout, $item_text_overlay, $scroll_track_count ); ?>
			<?php else : ?>
				<div class="iaew-logo-showcase__items">
					<?php foreach ( $items as $index => $item ) : ?>
						<?php $this->render_logo_item( $item, $index, $show_item_title, $show_item_caption, 'default', $item_text_overlay ); ?>
					<?php endforeach; ?>
				</div>
			<?php endif; ?>
		</div>
		<?php
	}

	/**
	 * Render scrolling rows or columns with alternating directions.
	 *
	 * @param array<int, array<string, mixed>> $items Items.
	 * @param bool                             $show_title Show title.
	 * @param bool                             $show_caption Show caption.
	 * @param string                           $layout Layout.
	 * @param bool                             $overlay_text Show text over image.
	 * @param int                              $track_count Number of scrolling rows or columns.
	 */
	private function render_scrolling_layout( array $items, bool $show_title, bool $show_caption, string $layout, bool $overlay_text, int $track_count ): void {
		$track_sets = $this->split_items_for_scroll( $items, $track_count );
		$axis_class = 'scroll-vertical' === $layout ? 'iaew-logo-showcase__marquee-stack--vertical' : 'iaew-logo-showcase__marquee-stack--horizontal';
		?>
		<div class="iaew-logo-showcase__marquee-stack <?php echo esc_attr( $axis_class ); ?>">
			<?php foreach ( $track_sets as $track_index => $track_items ) : ?>
				<?php $direction_class = 0 === $track_index % 2 ? 'iaew-logo-showcase__marquee-line--forward' : 'iaew-logo-showcase__marquee-line--reverse'; ?>
				<div class="iaew-logo-showcase__marquee-line <?php echo esc_attr( $direction_class ); ?>">
					<div class="iaew-logo-showcase__marquee-group">
						<?php foreach ( $track_items as $item_index => $item ) : ?>
							<?php $this->render_logo_item( $item, ( $track_index * 100 ) + $item_index, $show_title, $show_caption, 'marquee', $overlay_text ); ?>
						<?php endforeach; ?>
					</div>
					<div class="iaew-logo-showcase__marquee-group" aria-hidden="true">
						<?php foreach ( $track_items as $item_index => $item ) : ?>
							<?php $this->render_logo_item( $item, ( $track_index * 1000 ) + $item_index, $show_title, $show_caption, 'marquee', $overlay_text ); ?>
						<?php endforeach; ?>
					</div>
				</div>
			<?php endforeach; ?>
		</div>
		<?php
	}

	/**
	 * Split items into balanced scroll tracks.
	 *
	 * @param array<int, array<string, mixed>> $items Items.
	 * @param int                              $track_count Number of tracks.
	 * @return array<int, array<int, array<string, mixed>>>
	 */
	private function split_items_for_scroll( array $items, int $track_count ): array {
		$track_count = max( 1, min( $track_count, count( $items ) ) );
		$tracks      = array_fill( 0, $track_count, array() );

		foreach ( array_values( $items ) as $index => $item ) {
			$tracks[ $index % $track_count ][] = $item;
		}

		return array_values(
			array_filter(
				$tracks,
				static function ( array $track ): bool {
					return ! empty( $track );
				}
			)
		);
	}

	/**
	 * Render filter buttons.
	 *
	 * @param array<int, array<string, mixed>> $items Items.
	 * @param string                           $all_label All label.
	 */
	private function render_filter_controls( array $items, string $all_label ): void {
		$terms = $this->get_filter_terms( $items );

		if ( empty( $terms ) ) {
			return;
		}

		?>
		<div class="iaew-logo-showcase__filters" data-filter-controls>
			<button type="button" class="iaew-logo-showcase__filter-button is-active" data-filter="all"><?php echo esc_html( $all_label ); ?></button>
			<?php foreach ( $terms as $term ) : ?>
				<button type="button" class="iaew-logo-showcase__filter-button" data-filter="<?php echo esc_attr( $term['slug'] ); ?>"><?php echo esc_html( $term['label'] ); ?></button>
			<?php endforeach; ?>
		</div>
		<?php
	}

	/**
	 * Render a single showcase item.
	 *
	 * @param array<string, mixed> $item Item data.
	 * @param int                  $index Item index.
	 * @param bool                 $show_title Show title.
	 * @param bool                 $show_caption Show caption.
	 * @param string               $context Render context.
	 * @param bool                 $overlay_text Show text over image.
	 */
	private function render_logo_item( array $item, int $index, bool $show_title, bool $show_caption, string $context, bool $overlay_text ): void {
		$image_url = ! empty( $item['item_image']['url'] ) ? esc_url( $item['item_image']['url'] ) : Utils::get_placeholder_image_src();
		$title     = isset( $item['item_title'] ) ? sanitize_text_field( $item['item_title'] ) : '';
		$caption   = isset( $item['item_caption'] ) ? sanitize_text_field( $item['item_caption'] ) : '';
		$link      = ! empty( $item['item_link']['url'] ) ? $item['item_link'] : array();
		$category  = isset( $item['item_category'] ) ? sanitize_text_field( $item['item_category'] ) : '';
		$slug      = sanitize_title( $category );
		$tag       = ! empty( $link['url'] ) ? 'a' : 'div';
		$item_key  = 'logo_item_' . $index . '_' . $context;
		$item_attr = array( 'iaew-logo-showcase__card' );
		$has_text  = ( $show_title && '' !== $title ) || ( $show_caption && '' !== $caption );

		if ( 'marquee' === $context ) {
			$item_attr[] = 'iaew-logo-showcase__card--marquee';
		}

		$this->add_render_attribute( $item_key, 'class', $item_attr );

		if ( ! empty( $link['url'] ) ) {
			$this->add_link_attributes( $item_key, $link );
		}

		?>
		<div class="iaew-logo-showcase__item<?php echo 'slider' === $context ? ' iaew-logo-showcase__item--slide' : ''; ?>"<?php echo '' !== $slug ? ' data-category="' . esc_attr( $slug ) . '"' : ''; ?>>
			<<?php echo esc_html( $tag ); ?> <?php $this->print_render_attribute_string( $item_key ); ?>>
				<div class="iaew-logo-showcase__media<?php echo $overlay_text && $has_text ? ' iaew-logo-showcase__media--has-overlay' : ''; ?>">
					<img class="iaew-logo-showcase__image" src="<?php echo esc_url( $image_url ); ?>" alt="<?php echo esc_attr( $title ); ?>" loading="lazy" />
					<?php if ( $overlay_text && $has_text ) : ?>
						<div class="iaew-logo-showcase__content iaew-logo-showcase__content--overlay">
							<?php if ( $show_title && '' !== $title ) : ?>
								<div class="iaew-logo-showcase__item-title"><?php echo esc_html( $title ); ?></div>
							<?php endif; ?>
							<?php if ( $show_caption && '' !== $caption ) : ?>
								<div class="iaew-logo-showcase__item-caption"><?php echo esc_html( $caption ); ?></div>
							<?php endif; ?>
						</div>
					<?php endif; ?>
				</div>
				<?php if ( ! $overlay_text && $has_text ) : ?>
					<div class="iaew-logo-showcase__content">
						<?php if ( $show_title && '' !== $title ) : ?>
							<div class="iaew-logo-showcase__item-title"><?php echo esc_html( $title ); ?></div>
						<?php endif; ?>
						<?php if ( $show_caption && '' !== $caption ) : ?>
							<div class="iaew-logo-showcase__item-caption"><?php echo esc_html( $caption ); ?></div>
						<?php endif; ?>
					</div>
				<?php endif; ?>
			</<?php echo esc_html( $tag ); ?>>
		</div>
		<?php
	}

	/**
	 * Build unique filter terms.
	 *
	 * @param array<int, array<string, mixed>> $items Items.
	 * @return array<int, array<string, string>>
	 */
	private function get_filter_terms( array $items ): array {
		$terms = array();

		foreach ( $items as $item ) {
			$label = isset( $item['item_category'] ) ? sanitize_text_field( $item['item_category'] ) : '';
			$slug  = sanitize_title( $label );

			if ( '' === $label || '' === $slug || isset( $terms[ $slug ] ) ) {
				continue;
			}

			$terms[ $slug ] = array(
				'label' => $label,
				'slug'  => $slug,
			);
		}

		return array_values( $terms );
	}

	/**
	 * Default repeater items.
	 *
	 * @return array<int, array<string, mixed>>
	 */
	private function get_default_items(): array {
		$placeholder = Utils::get_placeholder_image_src();

		return array(
			array(
				'item_title'    => esc_html__( 'Logo One', 'impact-widgets-for-elementor' ),
				'item_caption'  => esc_html__( 'Europe', 'impact-widgets-for-elementor' ),
				'item_category' => esc_html__( 'Europe', 'impact-widgets-for-elementor' ),
				'item_image'    => array( 'url' => $placeholder ),
			),
			array(
				'item_title'    => esc_html__( 'Logo Two', 'impact-widgets-for-elementor' ),
				'item_caption'  => esc_html__( 'Asia', 'impact-widgets-for-elementor' ),
				'item_category' => esc_html__( 'Asia', 'impact-widgets-for-elementor' ),
				'item_image'    => array( 'url' => $placeholder ),
			),
			array(
				'item_title'    => esc_html__( 'Logo Three', 'impact-widgets-for-elementor' ),
				'item_caption'  => esc_html__( 'America', 'impact-widgets-for-elementor' ),
				'item_category' => esc_html__( 'America', 'impact-widgets-for-elementor' ),
				'item_image'    => array( 'url' => $placeholder ),
			),
			array(
				'item_title'    => esc_html__( 'Logo Four', 'impact-widgets-for-elementor' ),
				'item_caption'  => esc_html__( 'Australia', 'impact-widgets-for-elementor' ),
				'item_category' => esc_html__( 'Australia', 'impact-widgets-for-elementor' ),
				'item_image'    => array( 'url' => $placeholder ),
			),
			array(
				'item_title'    => esc_html__( 'Logo Five', 'impact-widgets-for-elementor' ),
				'item_caption'  => esc_html__( 'Featured', 'impact-widgets-for-elementor' ),
				'item_category' => esc_html__( 'Featured', 'impact-widgets-for-elementor' ),
				'item_image'    => array( 'url' => $placeholder ),
			),
			array(
				'item_title'    => esc_html__( 'Logo Six', 'impact-widgets-for-elementor' ),
				'item_caption'  => esc_html__( 'Partner', 'impact-widgets-for-elementor' ),
				'item_category' => esc_html__( 'Partner', 'impact-widgets-for-elementor' ),
				'item_image'    => array( 'url' => $placeholder ),
			),
		);
	}
}
