<?php

namespace Calio\Widgets;

use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Repeater;

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

/**
 * Renders a Swiper-powered team slider with card skins and editor-friendly controls.
 */
class TeamSliderWidget extends BaseWidget
{
    public function get_name(): string
    {
        return 'calio-team-slider';
    }

    public function get_title(): string
    {
        return esc_html__('Team Slider', 'calio-addon');
    }

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

    public function get_style_depends(): array
    {
        $depends = $this->resolve_widget_style_depends('calio-widget-team-slider');
        $depends[] = 'swiper';

        return array_values(array_unique($depends));
    }

    public function get_script_depends(): array
    {
        return $this->resolve_widget_script_depends('calio-widget-team-slider');
    }

    protected function register_controls(): void
    {
        $this->register_members_controls();
        $this->register_slider_controls();
        $this->register_card_style_controls();
        $this->register_content_style_controls();
        $this->register_image_style_controls();
        $this->register_social_style_controls();
        $this->register_button_style_controls();
        $this->register_navigation_style_controls();
        $this->register_popup_style_controls();
    }

    private function register_members_controls(): void
    {
        $this->start_controls_section('team_slider_members_section', [
            'label' => esc_html__('Team Members', 'calio-addon'),
        ]);

        $this->add_control('show_description', [
            'label' => esc_html__('Show Description', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
        ]);

        $this->add_control('show_socials', [
            'label' => esc_html__('Show Social Profiles', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
        ]);

        $this->add_control('show_button', [
            'label' => esc_html__('Show Button', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
        ]);
        $this->add_control('show_details_popup', [
            'label' => esc_html__('Enable Details Popup', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => '',
        ]);
        $this->add_control('popup_trigger', [
            'label' => esc_html__('Popup Trigger', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'card',
            'options' => [
                'card' => esc_html__('Card Click', 'calio-addon'),
                'button' => esc_html__('Popup Button', 'calio-addon'),
            ],
            'condition' => ['show_details_popup' => 'yes'],
        ]);
        $this->add_control('popup_button_text', [
            'label' => esc_html__('Popup Button Text', 'calio-addon'),
            'type' => Controls_Manager::TEXT,
            'default' => esc_html__('Read Bio', 'calio-addon'),
            'condition' => [
                'show_details_popup' => 'yes',
                'popup_trigger' => 'button',
            ],
        ]);
        $this->add_control('popup_animation', [
            'label' => esc_html__('Popup Animation', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'zoom',
            'options' => [
                'zoom' => esc_html__('Zoom', 'calio-addon'),
                'fade' => esc_html__('Fade', 'calio-addon'),
                'slide' => esc_html__('Slide Up', 'calio-addon'),
            ],
            'condition' => ['show_details_popup' => 'yes'],
        ]);
        $this->add_control('popup_close_on_overlay', [
            'label' => esc_html__('Close On Overlay Click', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
            'condition' => ['show_details_popup' => 'yes'],
        ]);
        $this->add_control('popup_close_on_esc', [
            'label' => esc_html__('Close On ESC', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
            'condition' => ['show_details_popup' => 'yes'],
        ]);
        $this->add_control('popup_pause_slider', [
            'label' => esc_html__('Pause Slider While Popup Open', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
            'condition' => ['show_details_popup' => 'yes'],
        ]);
        $this->add_control('popup_show_nav', [
            'label' => esc_html__('Popup Prev/Next Navigation', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
            'condition' => ['show_details_popup' => 'yes'],
        ]);
        $this->add_control('popup_show_counter', [
            'label' => esc_html__('Show Member Counter', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
            'condition' => ['show_details_popup' => 'yes'],
        ]);
        $this->add_control('popup_prev_text', [
            'label' => esc_html__('Popup Prev Text', 'calio-addon'),
            'type' => Controls_Manager::TEXT,
            'default' => esc_html__('Previous Member', 'calio-addon'),
            'condition' => [
                'show_details_popup' => 'yes',
                'popup_show_nav' => 'yes',
            ],
        ]);
        $this->add_control('popup_next_text', [
            'label' => esc_html__('Popup Next Text', 'calio-addon'),
            'type' => Controls_Manager::TEXT,
            'default' => esc_html__('Next Member', 'calio-addon'),
            'condition' => [
                'show_details_popup' => 'yes',
                'popup_show_nav' => 'yes',
            ],
        ]);

        $this->add_control('card_skin', [
            'label' => esc_html__('Card Skin', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'default',
            'options' => [
                'default' => esc_html__('Default', 'calio-addon'),
                'overlay' => esc_html__('Overlay', 'calio-addon'),
                'minimal' => esc_html__('Minimal', 'calio-addon'),
            ],
        ]);
        $this->add_control('visual_preset', [
            'label' => esc_html__('Preset Pack', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'custom',
            'options' => [
                'custom' => esc_html__('Custom', 'calio-addon'),
                'clean' => esc_html__('Clean', 'calio-addon'),
                'vivid' => esc_html__('Vivid', 'calio-addon'),
                'glass' => esc_html__('Glass', 'calio-addon'),
            ],
        ]);

        $this->add_control('social_mode', [
            'label' => esc_html__('Social Mode', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'inline',
            'options' => [
                'inline' => esc_html__('Inline', 'calio-addon'),
                'hover' => esc_html__('Reveal On Hover', 'calio-addon'),
                'floating' => esc_html__('Floating On Image', 'calio-addon'),
            ],
            'condition' => ['show_socials' => 'yes'],
        ]);

        $this->add_control('image_hover_effect', [
            'label' => esc_html__('Image Hover Effect', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'zoom',
            'options' => [
                'none' => esc_html__('None', 'calio-addon'),
                'zoom' => esc_html__('Zoom', 'calio-addon'),
                'grayscale' => esc_html__('Grayscale', 'calio-addon'),
            ],
        ]);

        $this->add_control('content_alignment', [
            'label' => esc_html__('Content Alignment', 'calio-addon'),
            'type' => Controls_Manager::CHOOSE,
            'default' => 'left',
            'toggle' => false,
            'options' => [
                'left' => [
                    'title' => esc_html__('Left', 'calio-addon'),
                    'icon' => 'eicon-text-align-left',
                ],
                'center' => [
                    'title' => esc_html__('Center', 'calio-addon'),
                    'icon' => 'eicon-text-align-center',
                ],
                'right' => [
                    'title' => esc_html__('Right', 'calio-addon'),
                    'icon' => 'eicon-text-align-right',
                ],
            ],
            'prefix_class' => 'calio-team-slider-content-align-',
        ]);

        $repeater = new Repeater();
        $repeater->add_control('member_image', [
            'label' => esc_html__('Member Image', 'calio-addon'),
            'type' => Controls_Manager::MEDIA,
        ]);
        $repeater->add_control('member_name', [
            'label' => esc_html__('Member Name', 'calio-addon'),
            'type' => Controls_Manager::TEXT,
            'default' => esc_html__('John Doe', 'calio-addon'),
        ]);
        $repeater->add_control('member_position', [
            'label' => esc_html__('Member Position', 'calio-addon'),
            'type' => Controls_Manager::TEXT,
            'default' => esc_html__('Lead Designer', 'calio-addon'),
        ]);
        $repeater->add_control('member_description', [
            'label' => esc_html__('About Member', 'calio-addon'),
            'type' => Controls_Manager::TEXTAREA,
            'default' => esc_html__('Crafts polished visual systems and guides the UI direction across product teams.', 'calio-addon'),
        ]);
        $repeater->add_control('member_details', [
            'label' => esc_html__('Popup Details', 'calio-addon'),
            'type' => Controls_Manager::WYSIWYG,
            'default' => esc_html__('Add extended biography, achievements, specialties and contact context for this member.', 'calio-addon'),
        ]);
        $repeater->add_control('member_button_text', [
            'label' => esc_html__('Button Text', 'calio-addon'),
            'type' => Controls_Manager::TEXT,
            'default' => esc_html__('View Profile', 'calio-addon'),
        ]);
        $repeater->add_control('member_button_url', [
            'label' => esc_html__('Button URL', 'calio-addon'),
            'type' => Controls_Manager::URL,
            'default' => ['url' => ''],
        ]);

        $this->add_member_social_controls($repeater, 1, 'fab fa-facebook-f', 'https://facebook.com');
        $this->add_member_social_controls($repeater, 2, 'fab fa-twitter', 'https://x.com');
        $this->add_member_social_controls($repeater, 3, 'fab fa-linkedin-in', 'https://linkedin.com');

        $this->add_control('members', [
            'label' => esc_html__('Members', 'calio-addon'),
            'type' => Controls_Manager::REPEATER,
            'fields' => $repeater->get_controls(),
            'title_field' => '{{{ member_name }}}',
            'default' => [
                [
                    'member_name' => esc_html__('Anna Rivera', 'calio-addon'),
                    'member_position' => esc_html__('Lead Designer', 'calio-addon'),
                    'member_description' => esc_html__('Builds clean product interfaces with strong typography and micro-interaction systems.', 'calio-addon'),
                ],
                [
                    'member_name' => esc_html__('Mark Stone', 'calio-addon'),
                    'member_position' => esc_html__('Marketing Strategist', 'calio-addon'),
                    'member_description' => esc_html__('Turns product messaging into growth campaigns and content funnels that convert.', 'calio-addon'),
                ],
                [
                    'member_name' => esc_html__('Nora Blake', 'calio-addon'),
                    'member_position' => esc_html__('Frontend Engineer', 'calio-addon'),
                    'member_description' => esc_html__('Implements reusable component systems and keeps performance stable at scale.', 'calio-addon'),
                ],
            ],
        ]);

        $this->end_controls_section();
    }

    private function register_slider_controls(): void
    {
        $this->start_controls_section('team_slider_settings_section', [
            'label' => esc_html__('Slider Settings', 'calio-addon'),
        ]);

        $this->add_control('space_between', [
            'label' => esc_html__('Spacing', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 0,
                    'max' => 80,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 24,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider' => '--calio-team-slider-space: {{SIZE}}{{UNIT}};',
            ],
        ]);

        $this->add_control('slides_to_show_desktop', [
            'label' => esc_html__('Slides To Show (Desktop)', 'calio-addon'),
            'type' => Controls_Manager::NUMBER,
            'default' => 3,
            'min' => 1,
            'max' => 6,
        ]);
        $this->add_control('slides_to_show_tablet', [
            'label' => esc_html__('Slides To Show (Tablet)', 'calio-addon'),
            'type' => Controls_Manager::NUMBER,
            'default' => 2,
            'min' => 1,
            'max' => 4,
        ]);
        $this->add_control('slides_to_show_mobile', [
            'label' => esc_html__('Slides To Show (Mobile)', 'calio-addon'),
            'type' => Controls_Manager::NUMBER,
            'default' => 1,
            'min' => 1,
            'max' => 3,
        ]);
        $this->add_control('slides_to_scroll', [
            'label' => esc_html__('Slides To Scroll', 'calio-addon'),
            'type' => Controls_Manager::NUMBER,
            'default' => 1,
            'min' => 1,
            'max' => 3,
        ]);

        $this->add_control('loop', [
            'label' => esc_html__('Loop', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
        ]);
        $this->add_control('autoplay', [
            'label' => esc_html__('Autoplay', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => '',
        ]);
        $this->add_control('autoplay_speed', [
            'label' => esc_html__('Autoplay Speed (ms)', 'calio-addon'),
            'type' => Controls_Manager::NUMBER,
            'default' => 3200,
            'min' => 1000,
            'max' => 15000,
            'step' => 100,
            'condition' => ['autoplay' => 'yes'],
        ]);
        $this->add_control('transition_speed', [
            'label' => esc_html__('Transition Speed (ms)', 'calio-addon'),
            'type' => Controls_Manager::NUMBER,
            'default' => 600,
            'min' => 100,
            'max' => 4000,
            'step' => 50,
        ]);
        $this->add_control('pause_on_hover', [
            'label' => esc_html__('Pause On Hover', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
            'condition' => ['autoplay' => 'yes'],
        ]);
        $this->add_control('pause_on_interaction', [
            'label' => esc_html__('Pause On Interaction', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
            'condition' => ['autoplay' => 'yes'],
        ]);

        $this->add_control('show_arrows', [
            'label' => esc_html__('Show Arrows', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
        ]);
        $this->add_control('show_arrows_on_hover', [
            'label' => esc_html__('Show Arrows On Hover', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => '',
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_control('arrow_type', [
            'label' => esc_html__('Arrow Type', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'icon',
            'options' => [
                'icon' => esc_html__('Arrow', 'calio-addon'),
                'text' => esc_html__('Text', 'calio-addon'),
                'text-icon' => esc_html__('Text With Arrow', 'calio-addon'),
            ],
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_control('left_arrow_text', [
            'label' => esc_html__('Left Arrow Text', 'calio-addon'),
            'type' => Controls_Manager::TEXT,
            'default' => esc_html__('Prev', 'calio-addon'),
            'condition' => [
                'show_arrows' => 'yes',
                'arrow_type' => ['text', 'text-icon'],
            ],
        ]);
        $this->add_control('right_arrow_text', [
            'label' => esc_html__('Right Arrow Text', 'calio-addon'),
            'type' => Controls_Manager::TEXT,
            'default' => esc_html__('Next', 'calio-addon'),
            'condition' => [
                'show_arrows' => 'yes',
                'arrow_type' => ['text', 'text-icon'],
            ],
        ]);
        $this->add_control('show_dots', [
            'label' => esc_html__('Show Dots', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
        ]);
        $this->add_control('show_dots_on_hover', [
            'label' => esc_html__('Show Dots On Hover', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => '',
            'condition' => ['show_dots' => 'yes'],
        ]);
        $this->add_control('hover_trigger_area', [
            'label' => esc_html__('Hover Trigger Area', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'widget',
            'options' => [
                'widget' => esc_html__('Whole Widget', 'calio-addon'),
                'slider' => esc_html__('Slider Area Only', 'calio-addon'),
            ],
        ]);
        $this->add_control('controls_layout', [
            'label' => esc_html__('Controls Layout', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'stack',
            'options' => [
                'stack' => esc_html__('Stacked', 'calio-addon'),
                'inline' => esc_html__('Inline', 'calio-addon'),
            ],
        ]);
        $this->add_control('controls_placement', [
            'label' => esc_html__('Controls Placement', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'bottom',
            'options' => [
                'bottom' => esc_html__('Below Slider', 'calio-addon'),
                'top' => esc_html__('Above Slider', 'calio-addon'),
                'inside' => esc_html__('Inside Slider', 'calio-addon'),
            ],
        ]);
        $this->add_control('controls_alignment', [
            'label' => esc_html__('Controls Alignment', 'calio-addon'),
            'type' => Controls_Manager::CHOOSE,
            'default' => 'left',
            'toggle' => false,
            'options' => [
                'left' => [
                    'title' => esc_html__('Left', 'calio-addon'),
                    'icon' => 'eicon-text-align-left',
                ],
                'center' => [
                    'title' => esc_html__('Center', 'calio-addon'),
                    'icon' => 'eicon-text-align-center',
                ],
                'right' => [
                    'title' => esc_html__('Right', 'calio-addon'),
                    'icon' => 'eicon-text-align-right',
                ],
            ],
        ]);
        $this->add_control('controls_inside_vertical', [
            'label' => esc_html__('Inside Vertical Position', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'bottom',
            'options' => [
                'top' => esc_html__('Top', 'calio-addon'),
                'bottom' => esc_html__('Bottom', 'calio-addon'),
            ],
        ]);
        $this->add_control('arrows_placement', [
            'label' => esc_html__('Arrows Placement', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'inherit',
            'options' => [
                'inherit' => esc_html__('Inherit Controls Placement', 'calio-addon'),
                'top' => esc_html__('Above Slider', 'calio-addon'),
                'inside' => esc_html__('Inside Slider', 'calio-addon'),
                'bottom' => esc_html__('Below Slider', 'calio-addon'),
            ],
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_control('arrows_inside_vertical', [
            'label' => esc_html__('Arrows Inside Vertical', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'inherit',
            'options' => [
                'inherit' => esc_html__('Inherit Inside Position', 'calio-addon'),
                'top' => esc_html__('Top', 'calio-addon'),
                'bottom' => esc_html__('Bottom', 'calio-addon'),
            ],
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_control('arrows_alignment', [
            'label' => esc_html__('Arrows Alignment', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'inherit',
            'options' => [
                'inherit' => esc_html__('Inherit Controls Alignment', 'calio-addon'),
                'left' => esc_html__('Left', 'calio-addon'),
                'center' => esc_html__('Center', 'calio-addon'),
                'right' => esc_html__('Right', 'calio-addon'),
            ],
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_control('dots_placement', [
            'label' => esc_html__('Dots Placement', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'inherit',
            'options' => [
                'inherit' => esc_html__('Inherit Controls Placement', 'calio-addon'),
                'top' => esc_html__('Above Slider', 'calio-addon'),
                'inside' => esc_html__('Inside Slider', 'calio-addon'),
                'bottom' => esc_html__('Below Slider', 'calio-addon'),
            ],
            'condition' => ['show_dots' => 'yes'],
        ]);
        $this->add_control('dots_inside_vertical', [
            'label' => esc_html__('Dots Inside Vertical', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'inherit',
            'options' => [
                'inherit' => esc_html__('Inherit Inside Position', 'calio-addon'),
                'top' => esc_html__('Top', 'calio-addon'),
                'bottom' => esc_html__('Bottom', 'calio-addon'),
            ],
            'condition' => ['show_dots' => 'yes'],
        ]);
        $this->add_control('dots_alignment', [
            'label' => esc_html__('Dots Alignment', 'calio-addon'),
            'type' => Controls_Manager::SELECT,
            'default' => 'inherit',
            'options' => [
                'inherit' => esc_html__('Inherit Controls Alignment', 'calio-addon'),
                'left' => esc_html__('Left', 'calio-addon'),
                'center' => esc_html__('Center', 'calio-addon'),
                'right' => esc_html__('Right', 'calio-addon'),
            ],
            'condition' => ['show_dots' => 'yes'],
        ]);
        $this->add_control('grab_cursor', [
            'label' => esc_html__('Grab Cursor', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
        ]);
        $this->add_control('centered_slides', [
            'label' => esc_html__('Centered Slides', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => '',
        ]);
        $this->add_control('equal_height', [
            'label' => esc_html__('Equal Height Cards', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
        ]);
        $this->add_control('highlight_active_slide', [
            'label' => esc_html__('Highlight Active Slide', 'calio-addon'),
            'type' => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default' => 'yes',
        ]);

        $this->end_controls_section();
    }

    private function register_card_style_controls(): void
    {
        $this->start_controls_section('team_slider_style_card_section', [
            'label' => esc_html__('Card', 'calio-addon'),
            'tab' => Controls_Manager::TAB_STYLE,
        ]);

        $this->start_controls_tabs('team_slider_card_tabs');
        $this->start_controls_tab('team_slider_card_tab_normal', ['label' => esc_html__('Normal', 'calio-addon')]);
        $this->add_background_type_control('team_slider_card_bg', '{{WRAPPER}} .calio-team-slider-card');
        $this->add_border_paint_controls('team_slider_card_border_color', esc_html__('Border Color', 'calio-addon'), '{{WRAPPER}} .calio-team-slider-card');
        $this->end_controls_tab();
        $this->start_controls_tab('team_slider_card_tab_hover', ['label' => esc_html__('Hover', 'calio-addon')]);
        $this->add_background_type_control('team_slider_card_bg_hover', [
            '{{WRAPPER}} .calio-team-slider-card:hover',
            '{{WRAPPER}} .calio-team-slider .swiper-slide-active .calio-team-slider-card',
        ]);
        $this->add_border_paint_controls('team_slider_card_border_color_hover', esc_html__('Border Color', 'calio-addon'), [
            '{{WRAPPER}} .calio-team-slider-card:hover',
            '{{WRAPPER}} .calio-team-slider .swiper-slide-active .calio-team-slider-card',
        ]);
        $this->end_controls_tab();
        $this->end_controls_tabs();

        $this->add_group_control(Group_Control_Border::get_type(), [
            'name' => 'team_slider_card_border',
            'selector' => '{{WRAPPER}} .calio-team-slider-card',
        ]);
        $this->add_group_control(Group_Control_Box_Shadow::get_type(), [
            'name' => 'team_slider_card_shadow',
            'selector' => '{{WRAPPER}} .calio-team-slider-card',
        ]);
        $this->add_dimensions_control(
            'team_slider_card_radius',
            esc_html__('Border Radius', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-card',
            'border-radius',
            ['size_units' => ['px', '%']]
        );
        $this->add_dimensions_control(
            'team_slider_card_padding',
            esc_html__('Padding', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-card',
            'padding'
        );

        $this->end_controls_section();
    }

    private function register_content_style_controls(): void
    {
        $this->start_controls_section('team_slider_style_content_section', [
            'label' => esc_html__('Content', 'calio-addon'),
            'tab' => Controls_Manager::TAB_STYLE,
        ]);

        $this->add_group_control(Group_Control_Typography::get_type(), [
            'name' => 'team_slider_name_typography',
            'selector' => '{{WRAPPER}} .calio-team-slider-name',
        ]);
        $this->add_text_paint_controls('team_slider_name_text', esc_html__('Name Color', 'calio-addon'), '{{WRAPPER}} .calio-team-slider-name');

        $this->add_group_control(Group_Control_Typography::get_type(), [
            'name' => 'team_slider_position_typography',
            'selector' => '{{WRAPPER}} .calio-team-slider-position',
        ]);
        $this->add_text_paint_controls('team_slider_position_text', esc_html__('Position Color', 'calio-addon'), '{{WRAPPER}} .calio-team-slider-position');

        $this->add_group_control(Group_Control_Typography::get_type(), [
            'name' => 'team_slider_description_typography',
            'selector' => '{{WRAPPER}} .calio-team-slider-description',
        ]);
        $this->add_text_paint_controls('team_slider_description_text', esc_html__('Description Color', 'calio-addon'), '{{WRAPPER}} .calio-team-slider-description');

        $this->add_background_type_control('team_slider_content_bg', '{{WRAPPER}} .calio-team-slider-content');
        $this->add_group_control(Group_Control_Border::get_type(), [
            'name' => 'team_slider_content_border',
            'selector' => '{{WRAPPER}} .calio-team-slider-content',
        ]);
        $this->add_dimensions_control(
            'team_slider_content_radius',
            esc_html__('Content Radius', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-content',
            'border-radius',
            ['size_units' => ['px', '%']]
        );
        $this->add_dimensions_control(
            'team_slider_content_padding',
            esc_html__('Content Padding', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-content',
            'padding'
        );

        $this->end_controls_section();
    }

    private function register_image_style_controls(): void
    {
        $this->start_controls_section('team_slider_style_image_section', [
            'label' => esc_html__('Image', 'calio-addon'),
            'tab' => Controls_Manager::TAB_STYLE,
        ]);

        $this->add_control('team_slider_image_height', [
            'label' => esc_html__('Height', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 120,
                    'max' => 520,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 260,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider-image img' => 'height: {{SIZE}}{{UNIT}};',
            ],
        ]);

        $this->add_dimensions_control(
            'team_slider_image_radius',
            esc_html__('Border Radius', 'calio-addon'),
            [
                '{{WRAPPER}} .calio-team-slider-image',
                '{{WRAPPER}} .calio-team-slider-image img',
            ],
            'border-radius',
            ['size_units' => ['px', '%']]
        );
        $this->add_group_control(Group_Control_Border::get_type(), [
            'name' => 'team_slider_image_border',
            'selector' => '{{WRAPPER}} .calio-team-slider-image',
        ]);
        $this->add_group_control(Group_Control_Box_Shadow::get_type(), [
            'name' => 'team_slider_image_shadow',
            'selector' => '{{WRAPPER}} .calio-team-slider-image',
        ]);
        $this->add_background_type_control('team_slider_image_bg', '{{WRAPPER}} .calio-team-slider-image');
        $this->add_dimensions_control(
            'team_slider_image_padding',
            esc_html__('Padding', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-image',
            'padding'
        );
        $this->add_dimensions_control(
            'team_slider_image_margin',
            esc_html__('Margin', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-image',
            'margin'
        );

        $this->end_controls_section();
    }

    private function register_social_style_controls(): void
    {
        $this->start_controls_section('team_slider_style_socials_section', [
            'label' => esc_html__('Social Profiles', 'calio-addon'),
            'tab' => Controls_Manager::TAB_STYLE,
            'condition' => ['show_socials' => 'yes'],
        ]);

        $this->add_control('team_slider_social_size', [
            'label' => esc_html__('Icon Size', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 10,
                    'max' => 40,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 14,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider-social-link' => 'font-size: {{SIZE}}{{UNIT}};',
            ],
        ]);
        $this->add_control('team_slider_social_box_size', [
            'label' => esc_html__('Box Size', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 24,
                    'max' => 70,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 36,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider-social-link' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
            ],
        ]);
        $this->add_control('team_slider_social_gap', [
            'label' => esc_html__('Gap', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 0,
                    'max' => 40,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 10,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider-socials' => 'gap: {{SIZE}}{{UNIT}};',
            ],
        ]);

        $this->start_controls_tabs('team_slider_social_tabs');
        $this->start_controls_tab('team_slider_social_tab_normal', ['label' => esc_html__('Normal', 'calio-addon')]);
        $this->add_text_paint_controls('team_slider_social_text', esc_html__('Icon Color', 'calio-addon'), '{{WRAPPER}} .calio-team-slider-social-link');
        $this->add_background_type_control('team_slider_social_bg', '{{WRAPPER}} .calio-team-slider-social-link');
        $this->end_controls_tab();
        $this->start_controls_tab('team_slider_social_tab_hover', ['label' => esc_html__('Hover', 'calio-addon')]);
        $this->add_text_paint_controls('team_slider_social_text_hover', esc_html__('Icon Color', 'calio-addon'), '{{WRAPPER}} .calio-team-slider-social-link:hover');
        $this->add_background_type_control('team_slider_social_bg_hover', '{{WRAPPER}} .calio-team-slider-social-link:hover');
        $this->end_controls_tab();
        $this->end_controls_tabs();

        $this->add_group_control(Group_Control_Border::get_type(), [
            'name' => 'team_slider_social_border',
            'selector' => '{{WRAPPER}} .calio-team-slider-social-link',
        ]);
        $this->add_dimensions_control(
            'team_slider_social_radius',
            esc_html__('Radius', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-social-link',
            'border-radius',
            ['size_units' => ['px', '%']]
        );

        $this->end_controls_section();
    }

    private function register_button_style_controls(): void
    {
        $this->start_controls_section('team_slider_style_button_section', [
            'label' => esc_html__('Button', 'calio-addon'),
            'tab' => Controls_Manager::TAB_STYLE,
            'condition' => ['show_button' => 'yes'],
        ]);

        $this->add_group_control(Group_Control_Typography::get_type(), [
            'name' => 'team_slider_button_typography',
            'selector' => '{{WRAPPER}} .calio-team-slider-button',
        ]);

        $this->start_controls_tabs('team_slider_button_tabs');
        $this->start_controls_tab('team_slider_button_tab_normal', ['label' => esc_html__('Normal', 'calio-addon')]);
        $this->add_text_paint_controls('team_slider_button_text', esc_html__('Text Color', 'calio-addon'), '{{WRAPPER}} .calio-team-slider-button');
        $this->add_background_type_control('team_slider_button_bg', '{{WRAPPER}} .calio-team-slider-button');
        $this->end_controls_tab();
        $this->start_controls_tab('team_slider_button_tab_hover', ['label' => esc_html__('Hover', 'calio-addon')]);
        $this->add_text_paint_controls('team_slider_button_text_hover', esc_html__('Text Color', 'calio-addon'), '{{WRAPPER}} .calio-team-slider-button:hover');
        $this->add_background_type_control('team_slider_button_bg_hover', '{{WRAPPER}} .calio-team-slider-button:hover');
        $this->end_controls_tab();
        $this->end_controls_tabs();

        $this->add_group_control(Group_Control_Border::get_type(), [
            'name' => 'team_slider_button_border',
            'selector' => '{{WRAPPER}} .calio-team-slider-button',
        ]);
        $this->add_dimensions_control(
            'team_slider_button_radius',
            esc_html__('Radius', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-button',
            'border-radius',
            ['size_units' => ['px', '%']]
        );
        $this->add_dimensions_control(
            'team_slider_button_padding',
            esc_html__('Padding', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-button',
            'padding'
        );

        $this->end_controls_section();
    }

    private function register_navigation_style_controls(): void
    {
        $this->start_controls_section('team_slider_style_navigation_section', [
            'label' => esc_html__('Navigation', 'calio-addon'),
            'tab' => Controls_Manager::TAB_STYLE,
        ]);

        $this->add_style_heading('team_slider_controls_layout_heading', esc_html__('Controls Container', 'calio-addon'));
        $this->add_control('team_slider_controls_gap', [
            'label' => esc_html__('Controls Gap', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 0,
                    'max' => 50,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 10,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider-controls' => 'gap: {{SIZE}}{{UNIT}};',
            ],
        ]);
        $this->add_control('team_slider_controls_inside_offset', [
            'label' => esc_html__('Inside Horizontal Offset', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 0,
                    'max' => 120,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 16,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider' => '--calio-team-slider-controls-inside-offset: {{SIZE}}{{UNIT}};',
            ],
        ]);
        $this->add_control('team_slider_controls_inside_offset_y', [
            'label' => esc_html__('Inside Vertical Offset', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 0,
                    'max' => 120,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 16,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider' => '--calio-team-slider-controls-inside-offset-y: {{SIZE}}{{UNIT}};',
            ],
        ]);
        $this->add_control('team_slider_arrows_inside_offset_x', [
            'label' => esc_html__('Arrows Inside X Offset', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => -120,
                    'max' => 120,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 0,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider' => '--calio-team-slider-arrows-inside-offset-x: {{SIZE}}{{UNIT}};',
            ],
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_control('team_slider_arrows_inside_offset_y', [
            'label' => esc_html__('Arrows Inside Y Offset', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => -120,
                    'max' => 120,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 0,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider' => '--calio-team-slider-arrows-inside-offset-y: {{SIZE}}{{UNIT}};',
            ],
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_control('team_slider_dots_inside_offset_x', [
            'label' => esc_html__('Dots Inside X Offset', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => -120,
                    'max' => 120,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 0,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider' => '--calio-team-slider-dots-inside-offset-x: {{SIZE}}{{UNIT}};',
            ],
            'condition' => ['show_dots' => 'yes'],
        ]);
        $this->add_control('team_slider_dots_inside_offset_y', [
            'label' => esc_html__('Dots Inside Y Offset', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => -120,
                    'max' => 120,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 0,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider' => '--calio-team-slider-dots-inside-offset-y: {{SIZE}}{{UNIT}};',
            ],
            'condition' => ['show_dots' => 'yes'],
        ]);

        $this->add_control('team_slider_nav_size', [
            'label' => esc_html__('Arrow Size', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 28,
                    'max' => 72,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 42,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider-arrow' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
            ],
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_control('team_slider_nav_icon_size', [
            'label' => esc_html__('Arrow Icon Size', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 8,
                    'max' => 40,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 16,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider-arrow-icon' => 'font-size: {{SIZE}}{{UNIT}};',
            ],
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_control('team_slider_nav_gap', [
            'label' => esc_html__('Arrows Gap', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 0,
                    'max' => 40,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 12,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider-nav' => 'gap: {{SIZE}}{{UNIT}};',
            ],
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_control('team_slider_dots_gap', [
            'label' => esc_html__('Dots Gap', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 0,
                    'max' => 26,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 8,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider-pagination' => 'gap: {{SIZE}}{{UNIT}};',
            ],
            'condition' => ['show_dots' => 'yes'],
        ]);
        $this->add_control('team_slider_dot_size', [
            'label' => esc_html__('Dot Size', 'calio-addon'),
            'type' => Controls_Manager::SLIDER,
            'size_units' => ['px'],
            'range' => [
                'px' => [
                    'min' => 6,
                    'max' => 24,
                ],
            ],
            'default' => [
                'unit' => 'px',
                'size' => 10,
            ],
            'selectors' => [
                '{{WRAPPER}} .calio-team-slider-pagination .swiper-pagination-bullet' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
            ],
            'condition' => ['show_dots' => 'yes'],
        ]);

        $this->add_style_heading('team_slider_nav_surface_heading', esc_html__('Arrow Colors', 'calio-addon'), [
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_text_paint_controls('team_slider_nav_text', esc_html__('Arrow Icon Color', 'calio-addon'), '{{WRAPPER}} .calio-team-slider-arrow');
        $this->add_background_type_control('team_slider_nav_bg', '{{WRAPPER}} .calio-team-slider-arrow', [
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_background_type_control('team_slider_nav_bg_hover', '{{WRAPPER}} .calio-team-slider-arrow:hover', [
            'condition' => ['show_arrows' => 'yes'],
        ]);
        $this->add_group_control(Group_Control_Border::get_type(), [
            'name' => 'team_slider_nav_border',
            'selector' => '{{WRAPPER}} .calio-team-slider-arrow',
            'condition' => ['show_arrows' => 'yes'],
        ]);

        $this->add_style_heading('team_slider_dot_surface_heading', esc_html__('Dot Colors', 'calio-addon'), [
            'condition' => ['show_dots' => 'yes'],
        ]);
        $this->add_background_type_control('team_slider_dot_bg', '{{WRAPPER}} .calio-team-slider-pagination .swiper-pagination-bullet', [
            'condition' => ['show_dots' => 'yes'],
        ]);
        $this->add_background_type_control('team_slider_dot_bg_active', '{{WRAPPER}} .calio-team-slider-pagination .swiper-pagination-bullet.swiper-pagination-bullet-active', [
            'condition' => ['show_dots' => 'yes'],
        ]);

        $this->end_controls_section();
    }

    private function register_popup_style_controls(): void
    {
        $this->start_controls_section('team_slider_style_popup_section', [
            'label' => esc_html__('Popup', 'calio-addon'),
            'tab' => Controls_Manager::TAB_STYLE,
            'condition' => ['show_details_popup' => 'yes'],
        ]);

        $this->add_group_control(Group_Control_Typography::get_type(), [
            'name' => 'team_slider_popup_name_typography',
            'selector' => '{{WRAPPER}} .calio-team-slider-modal-name',
        ]);
        $this->add_text_paint_controls(
            'team_slider_popup_name_text',
            esc_html__('Name Color', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-name'
        );
        $this->add_group_control(Group_Control_Typography::get_type(), [
            'name' => 'team_slider_popup_position_typography',
            'selector' => '{{WRAPPER}} .calio-team-slider-modal-position',
        ]);
        $this->add_text_paint_controls(
            'team_slider_popup_position_text',
            esc_html__('Position Color', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-position'
        );
        $this->add_group_control(Group_Control_Typography::get_type(), [
            'name' => 'team_slider_popup_body_typography',
            'selector' => '{{WRAPPER}} .calio-team-slider-modal-body',
        ]);
        $this->add_text_paint_controls(
            'team_slider_popup_body_text',
            esc_html__('Body Color', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-body'
        );

        $this->add_background_type_control(
            'team_slider_popup_overlay_bg',
            '{{WRAPPER}} .calio-team-slider-modal.is-open'
        );
        $this->add_background_type_control(
            'team_slider_popup_panel_bg',
            '{{WRAPPER}} .calio-team-slider-modal-panel'
        );
        $this->add_group_control(Group_Control_Border::get_type(), [
            'name' => 'team_slider_popup_panel_border',
            'selector' => '{{WRAPPER}} .calio-team-slider-modal-panel',
        ]);
        $this->add_group_control(Group_Control_Box_Shadow::get_type(), [
            'name' => 'team_slider_popup_panel_shadow',
            'selector' => '{{WRAPPER}} .calio-team-slider-modal-panel',
        ]);
        $this->add_dimensions_control(
            'team_slider_popup_panel_radius',
            esc_html__('Panel Radius', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-panel',
            'border-radius',
            ['size_units' => ['px', '%']]
        );
        $this->add_dimensions_control(
            'team_slider_popup_panel_padding',
            esc_html__('Panel Padding', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-panel',
            'padding'
        );

        $this->add_text_paint_controls(
            'team_slider_popup_close_text',
            esc_html__('Close Button Color', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-close'
        );
        $this->add_background_type_control(
            'team_slider_popup_close_bg',
            '{{WRAPPER}} .calio-team-slider-modal-close'
        );

        $this->add_style_heading(
            'team_slider_popup_counter_heading',
            esc_html__('Member Counter', 'calio-addon'),
            ['condition' => ['popup_show_counter' => 'yes']]
        );
        $this->add_group_control(Group_Control_Typography::get_type(), [
            'name' => 'team_slider_popup_counter_typography',
            'selector' => '{{WRAPPER}} .calio-team-slider-modal-counter',
            'condition' => ['popup_show_counter' => 'yes'],
        ]);
        $this->add_text_paint_controls(
            'team_slider_popup_counter_text',
            esc_html__('Counter Text Color', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-counter',
            ['condition' => ['popup_show_counter' => 'yes']]
        );
        $this->add_background_type_control(
            'team_slider_popup_counter_bg',
            '{{WRAPPER}} .calio-team-slider-modal-counter',
            ['condition' => ['popup_show_counter' => 'yes']]
        );
        $this->add_group_control(Group_Control_Border::get_type(), [
            'name' => 'team_slider_popup_counter_border',
            'selector' => '{{WRAPPER}} .calio-team-slider-modal-counter',
            'condition' => ['popup_show_counter' => 'yes'],
        ]);
        $this->add_dimensions_control(
            'team_slider_popup_counter_radius',
            esc_html__('Counter Radius', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-counter',
            'border-radius',
            [
                'size_units' => ['px', '%'],
                'condition' => ['popup_show_counter' => 'yes'],
            ]
        );
        $this->add_dimensions_control(
            'team_slider_popup_counter_padding',
            esc_html__('Counter Padding', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-counter',
            'padding',
            ['condition' => ['popup_show_counter' => 'yes']]
        );

        $this->add_style_heading(
            'team_slider_popup_nav_heading',
            esc_html__('Prev/Next Buttons', 'calio-addon'),
            ['condition' => ['popup_show_nav' => 'yes']]
        );
        $this->add_group_control(Group_Control_Typography::get_type(), [
            'name' => 'team_slider_popup_nav_typography',
            'selector' => '{{WRAPPER}} .calio-team-slider-modal-nav-btn',
            'condition' => ['popup_show_nav' => 'yes'],
        ]);
        $this->add_text_paint_controls(
            'team_slider_popup_nav_text',
            esc_html__('Text Color', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-nav-btn',
            ['condition' => ['popup_show_nav' => 'yes']]
        );
        $this->add_background_type_control(
            'team_slider_popup_nav_bg',
            '{{WRAPPER}} .calio-team-slider-modal-nav-btn',
            ['condition' => ['popup_show_nav' => 'yes']]
        );
        $this->add_group_control(Group_Control_Border::get_type(), [
            'name' => 'team_slider_popup_nav_border',
            'selector' => '{{WRAPPER}} .calio-team-slider-modal-nav-btn',
            'condition' => ['popup_show_nav' => 'yes'],
        ]);
        $this->add_dimensions_control(
            'team_slider_popup_nav_radius',
            esc_html__('Button Radius', 'calio-addon'),
            '{{WRAPPER}} .calio-team-slider-modal-nav-btn',
            'border-radius',
            [
                'size_units' => ['px', '%'],
                'condition' => ['popup_show_nav' => 'yes'],
            ]
        );

        $this->end_controls_section();
    }

    protected function render(): void
    {
        $settings = $this->get_settings_for_display();
        $members = $settings['members'] ?? [];

        if (!is_array($members) || empty($members)) {
            echo '<div class="calio-team-slider-empty">' . esc_html__('Add at least one team member item.', 'calio-addon') . '</div>';
            return;
        }

        $slider_id = 'calio-team-slider-' . $this->get_id();
        $wrapper_classes = [
            'calio-team-slider',
            'skin-' . sanitize_html_class((string) ($settings['card_skin'] ?? 'default')),
            'preset-' . sanitize_html_class((string) ($settings['visual_preset'] ?? 'custom')),
            'social-mode-' . sanitize_html_class((string) ($settings['social_mode'] ?? 'inline')),
            'image-hover-' . sanitize_html_class((string) ($settings['image_hover_effect'] ?? 'zoom')),
            'popup-anim-' . sanitize_html_class((string) ($settings['popup_animation'] ?? 'zoom')),
            'controls-layout-' . sanitize_html_class((string) ($settings['controls_layout'] ?? 'stack')),
            'controls-place-' . sanitize_html_class((string) ($settings['controls_placement'] ?? 'bottom')),
            'controls-align-' . sanitize_html_class((string) ($settings['controls_alignment'] ?? 'left')),
            'hover-trigger-' . sanitize_html_class((string) ($settings['hover_trigger_area'] ?? 'widget')),
        ];
        if (($settings['show_arrows_on_hover'] ?? '') === 'yes') {
            $wrapper_classes[] = 'is-arrows-hover';
        }
        if (($settings['show_dots_on_hover'] ?? '') === 'yes') {
            $wrapper_classes[] = 'is-dots-hover';
        }
        if (($settings['equal_height'] ?? 'yes') === 'yes') {
            $wrapper_classes[] = 'is-equal-height';
        }
        if (($settings['highlight_active_slide'] ?? 'yes') === 'yes') {
            $wrapper_classes[] = 'is-highlight-active';
        }

        $space_between = $this->normalize_slider_size($settings['space_between'] ?? null, 24, 0, 80);
        $slides_desktop = $this->normalize_number($settings['slides_to_show_desktop'] ?? 3, 3, 1, 6);
        $slides_tablet = $this->normalize_number($settings['slides_to_show_tablet'] ?? 2, 2, 1, 4);
        $slides_mobile = $this->normalize_number($settings['slides_to_show_mobile'] ?? 1, 1, 1, 3);
        $slides_to_scroll = $this->normalize_number($settings['slides_to_scroll'] ?? 1, 1, 1, 3);
        $transition_speed = $this->normalize_number($settings['transition_speed'] ?? 600, 600, 100, 4000);
        $autoplay_speed = $this->normalize_number($settings['autoplay_speed'] ?? 3200, 3200, 1000, 15000);

        echo '<div id="' . esc_attr($slider_id) . '" class="' . esc_attr(implode(' ', $wrapper_classes)) . '"'
            . ' data-space-between="' . esc_attr((string) $space_between) . '"'
            . ' data-slides-desktop="' . esc_attr((string) $slides_desktop) . '"'
            . ' data-slides-tablet="' . esc_attr((string) $slides_tablet) . '"'
            . ' data-slides-mobile="' . esc_attr((string) $slides_mobile) . '"'
            . ' data-slides-scroll="' . esc_attr((string) $slides_to_scroll) . '"'
            . ' data-loop="' . esc_attr((string) ($settings['loop'] ?? 'yes')) . '"'
            . ' data-autoplay="' . esc_attr((string) ($settings['autoplay'] ?? '')) . '"'
            . ' data-autoplay-speed="' . esc_attr((string) $autoplay_speed) . '"'
            . ' data-transition-speed="' . esc_attr((string) $transition_speed) . '"'
            . ' data-pause-on-hover="' . esc_attr((string) ($settings['pause_on_hover'] ?? 'yes')) . '"'
            . ' data-pause-on-interaction="' . esc_attr((string) ($settings['pause_on_interaction'] ?? 'yes')) . '"'
            . ' data-show-arrows="' . esc_attr((string) ($settings['show_arrows'] ?? 'yes')) . '"'
            . ' data-show-dots="' . esc_attr((string) ($settings['show_dots'] ?? 'yes')) . '"'
            . ' data-grab-cursor="' . esc_attr((string) ($settings['grab_cursor'] ?? 'yes')) . '"'
            . ' data-centered-slides="' . esc_attr((string) ($settings['centered_slides'] ?? '')) . '"'
            . ' data-highlight-active="' . esc_attr((string) ($settings['highlight_active_slide'] ?? 'yes')) . '"'
            . ' data-hover-trigger="' . esc_attr((string) ($settings['hover_trigger_area'] ?? 'widget')) . '"'
            . ' data-arrows-hover="' . esc_attr((string) ($settings['show_arrows_on_hover'] ?? '')) . '"'
            . ' data-dots-hover="' . esc_attr((string) ($settings['show_dots_on_hover'] ?? '')) . '"'
            . ' data-popup-enabled="' . esc_attr((string) ($settings['show_details_popup'] ?? '')) . '"'
            . ' data-popup-trigger="' . esc_attr((string) ($settings['popup_trigger'] ?? 'card')) . '"'
            . ' data-popup-close-overlay="' . esc_attr((string) ($settings['popup_close_on_overlay'] ?? 'yes')) . '"'
            . ' data-popup-close-esc="' . esc_attr((string) ($settings['popup_close_on_esc'] ?? 'yes')) . '"'
            . ' data-popup-pause-slider="' . esc_attr((string) ($settings['popup_pause_slider'] ?? 'yes')) . '">';

        $controls_markup = $this->build_controls_markup($settings);
        if ($controls_markup['top'] !== '') {
            echo '<div class="calio-team-slider-controls controls-zone-top">' . wp_kses_post($controls_markup['top']) . '</div>';
        }

        echo '<div class="swiper calio-team-slider-swiper">';
        echo '<div class="swiper-wrapper">';
        $member_count = count($members);
        $modal_markup = '';
        foreach ($members as $member_index => $member) {
            if (!is_array($member)) {
                continue;
            }
            $modal_markup .= $this->render_member_slide($member, $settings, (int) $member_index, $member_count);
        }
        echo '</div>';
        echo '</div>';

        if ($controls_markup['inside_top'] !== '') {
            echo '<div class="calio-team-slider-controls controls-zone-inside controls-zone-inside-top">' . wp_kses_post($controls_markup['inside_top']) . '</div>';
        }
        if ($controls_markup['inside_bottom'] !== '') {
            echo '<div class="calio-team-slider-controls controls-zone-inside controls-zone-inside-bottom">' . wp_kses_post($controls_markup['inside_bottom']) . '</div>';
        }
        if ($controls_markup['bottom'] !== '') {
            echo '<div class="calio-team-slider-controls controls-zone-bottom">' . wp_kses_post($controls_markup['bottom']) . '</div>';
        }

        if ($modal_markup !== '') {
            echo wp_kses($modal_markup, $this->allowed_team_slider_markup());
        }

        echo '</div>';
    }

    /**
     * Builds navigation and dots markup grouped by controls zone.
     *
     * @param array<string, mixed> $settings Widget settings.
     * @return array<string, string>
     */
    private function build_controls_markup(array $settings): array
    {
        $zones = [
            'top' => '',
            'inside_top' => '',
            'inside_bottom' => '',
            'bottom' => '',
        ];

        if (($settings['show_arrows'] ?? 'yes') === 'yes') {
            $zone = $this->resolve_controls_zone($settings, 'arrows_placement', 'arrows_inside_vertical');
            $alignment = $this->resolve_controls_alignment($settings, 'arrows_alignment');
            if (isset($zones[$zone])) {
                ob_start();
                echo '<div class="calio-team-slider-nav is-align-' . esc_attr($alignment) . '">';
                echo '<button class="calio-team-slider-arrow is-prev" type="button" aria-label="' . esc_attr__('Previous member', 'calio-addon') . '">';
                $this->render_arrow_content($settings, true);
                echo '</button>';
                echo '<button class="calio-team-slider-arrow is-next" type="button" aria-label="' . esc_attr__('Next member', 'calio-addon') . '">';
                $this->render_arrow_content($settings, false);
                echo '</button>';
                echo '</div>';
                $zones[$zone] .= (string) ob_get_clean();
            }
        }

        if (($settings['show_dots'] ?? 'yes') === 'yes') {
            $zone = $this->resolve_controls_zone($settings, 'dots_placement', 'dots_inside_vertical');
            $alignment = $this->resolve_controls_alignment($settings, 'dots_alignment');
            if (isset($zones[$zone])) {
                $zones[$zone] .= '<div class="calio-team-slider-pagination is-align-' . esc_attr($alignment)
                    . '" aria-label="' . esc_attr__('Team slider pagination', 'calio-addon') . '"></div>';
            }
        }

        return $zones;
    }

    /**
     * Resolves one controls zone from custom key with global fallback.
     *
     * @param array<string, mixed> $settings Widget settings.
     */
    private function resolve_controls_zone(array $settings, string $setting_key, string $inside_vertical_key = ''): string
    {
        $zone = sanitize_key((string) ($settings[$setting_key] ?? 'inherit'));
        if ($zone === '' || $zone === 'inherit') {
            $zone = sanitize_key((string) ($settings['controls_placement'] ?? 'bottom'));
        }

        if (!in_array($zone, ['top', 'inside', 'bottom'], true)) {
            return 'bottom';
        }

        if ($zone !== 'inside') {
            return $zone;
        }

        $vertical = 'inherit';
        if ($inside_vertical_key !== '') {
            $vertical = sanitize_key((string) ($settings[$inside_vertical_key] ?? 'inherit'));
        }
        if ($vertical === '' || $vertical === 'inherit') {
            $vertical = sanitize_key((string) ($settings['controls_inside_vertical'] ?? 'bottom'));
        }

        return $vertical === 'top' ? 'inside_top' : 'inside_bottom';
    }

    /**
     * Resolves one controls alignment from custom key with global fallback.
     *
     * @param array<string, mixed> $settings Widget settings.
     */
    private function resolve_controls_alignment(array $settings, string $setting_key): string
    {
        $alignment = sanitize_key((string) ($settings[$setting_key] ?? 'inherit'));
        if ($alignment === '' || $alignment === 'inherit') {
            $alignment = sanitize_key((string) ($settings['controls_alignment'] ?? 'left'));
        }

        if (!in_array($alignment, ['left', 'center', 'right'], true)) {
            return 'left';
        }

        return $alignment;
    }

    /**
     * Prints one team member slide.
     *
     * @param array<string, mixed> $member   Repeater item.
     * @param array<string, mixed> $settings Widget settings.
     * @param int                  $member_index Current member index.
     * @param int                  $member_count Total member count.
     * @return string Modal markup that should be printed outside the Swiper slide tree.
     */
    private function render_member_slide(array $member, array $settings, int $member_index, int $member_count): string
    {
        $popup_enabled = ($settings['show_details_popup'] ?? '') === 'yes';
        $popup_trigger = (string) ($settings['popup_trigger'] ?? 'card');
        $popup_content_html = $this->build_popup_content($member);
        $popup_id = $this->build_member_popup_id($member);
        $has_popup = $popup_enabled && $popup_id !== '' && $popup_content_html !== '';
        $modal_markup = '';

        $has_image = !empty($member['member_image']['url']);
        $card_classes = ['calio-team-slider-card'];
        $card_classes[] = $has_image ? 'has-image' : 'no-image';
        if ($has_popup && $popup_trigger === 'card') {
            $card_classes[] = 'has-popup-card-trigger';
        }

        echo '<div class="swiper-slide">';
        echo '<article class="' . esc_attr(implode(' ', $card_classes)) . '"';
        if ($has_popup && $popup_trigger === 'card') {
            echo ' role="button" tabindex="0" data-calio-modal-target="' . esc_attr($popup_id) . '"';
            echo ' aria-label="' . esc_attr__('Open member details', 'calio-addon') . '"';
        }
        echo '>';

        if ($has_image) {
            echo '<div class="calio-team-slider-image">';
            $this->render_member_image($member);
            echo '</div>';
        }

        echo '<div class="calio-team-slider-content">';
        if (!empty($member['member_name'])) {
            echo '<h3 class="calio-team-slider-name">' . esc_html((string) $member['member_name']) . '</h3>';
        }
        if (!empty($member['member_position'])) {
            echo '<div class="calio-team-slider-position">' . esc_html((string) $member['member_position']) . '</div>';
        }
        if (($settings['show_description'] ?? 'yes') === 'yes' && !empty($member['member_description'])) {
            echo '<div class="calio-team-slider-description">' . esc_html((string) $member['member_description']) . '</div>';
        }

        if (($settings['show_socials'] ?? 'yes') === 'yes') {
            $this->render_member_socials($member);
        }

        if (($settings['show_button'] ?? 'yes') === 'yes' && !empty($member['member_button_text'])) {
            $this->render_member_button($member);
        }
        if ($has_popup && $popup_trigger === 'button') {
            $popup_button_text = trim((string) ($settings['popup_button_text'] ?? esc_html__('Read Bio', 'calio-addon')));
            if ($popup_button_text !== '') {
                echo '<button class="calio-team-slider-popup-button" type="button" data-calio-modal-target="' . esc_attr($popup_id) . '">'
                    . esc_html($popup_button_text) . '</button>';
            }
        }

        echo '</div>';
        echo '</article>';
        if ($has_popup) {
            ob_start();
            $this->render_member_modal($member, $settings, $popup_id, $popup_content_html, $member_index, $member_count);
            $modal_markup = (string) ob_get_clean();
        }
        echo '</div>';

        return $modal_markup;
    }

    /**
     * Builds the popup body HTML for one member entry.
     *
     * @param array<string, mixed> $member Repeater item.
     */
    private function build_popup_content(array $member): string
    {
        $details = trim((string) ($member['member_details'] ?? ''));
        if ($details !== '') {
            $allowed = wp_kses_allowed_html('post');
            return (string) wp_kses($details, $allowed);
        }

        $description = trim((string) ($member['member_description'] ?? ''));
        if ($description !== '') {
            return '<p>' . esc_html($description) . '</p>';
        }

        return '';
    }

    /**
     * Creates a stable popup id for each repeater member.
     *
     * @param array<string, mixed> $member Repeater item.
     */
    private function build_member_popup_id(array $member): string
    {
        $seed = sanitize_key((string) ($member['_id'] ?? ''));
        if ($seed === '') {
            $seed = sanitize_key(wp_unique_id('member-'));
        }

        if ($seed === '') {
            return '';
        }

        return 'calio-team-slider-modal-' . sanitize_key($this->get_id()) . '-' . $seed;
    }

    /**
     * Renders modal dialog markup for member details.
     *
     * @param array<string, mixed> $member            Repeater item.
     * @param array<string, mixed> $settings          Widget settings.
     * @param string               $popup_id          Modal id token.
     * @param string               $popup_content_html Sanitized popup content.
     * @param int                  $member_index      Current member index.
     * @param int                  $member_count      Total member count.
     */
    private function render_member_modal(
        array $member,
        array $settings,
        string $popup_id,
        string $popup_content_html,
        int $member_index,
        int $member_count
    ): void
    {
        echo '<div class="calio-team-slider-modal" data-calio-modal-id="' . esc_attr($popup_id) . '" data-calio-modal-index="' . esc_attr((string) $member_index) . '" aria-hidden="true">';
        echo '<div class="calio-team-slider-modal-panel" role="dialog" aria-modal="true" tabindex="-1" aria-label="' . esc_attr__('Member details', 'calio-addon') . '">';
        echo '<button type="button" class="calio-team-slider-modal-close" data-calio-modal-close aria-label="' . esc_attr__('Close', 'calio-addon') . '">&times;</button>';
        echo '<div class="calio-team-slider-modal-grid">';
        if (!empty($member['member_image']['url'])) {
            echo '<div class="calio-team-slider-modal-media">';
            $this->render_member_image($member);
            echo '</div>';
        }
        echo '<div class="calio-team-slider-modal-content">';
        if (!empty($member['member_name'])) {
            echo '<h3 class="calio-team-slider-modal-name">' . esc_html((string) $member['member_name']) . '</h3>';
        }
        if (!empty($member['member_position'])) {
            echo '<div class="calio-team-slider-modal-position">' . esc_html((string) $member['member_position']) . '</div>';
        }
        if (($settings['popup_show_counter'] ?? 'yes') === 'yes' && $member_count > 1) {
            echo '<div class="calio-team-slider-modal-counter">';
            echo '<span class="calio-team-slider-modal-counter-current">' . esc_html((string) ($member_index + 1)) . '</span>';
            echo '<span class="calio-team-slider-modal-counter-separator">/</span>';
            echo '<span class="calio-team-slider-modal-counter-total">' . esc_html((string) $member_count) . '</span>';
            echo '</div>';
        }
        echo '<div class="calio-team-slider-modal-body">' . wp_kses($popup_content_html, wp_kses_allowed_html('post')) . '</div>';
        if (($settings['show_socials'] ?? 'yes') === 'yes') {
            $this->render_member_socials($member);
        }
        echo '</div>';
        echo '</div>';
        if (($settings['popup_show_nav'] ?? 'yes') === 'yes' && $member_count > 1) {
            $prev_text = trim((string) ($settings['popup_prev_text'] ?? esc_html__('Previous Member', 'calio-addon')));
            $next_text = trim((string) ($settings['popup_next_text'] ?? esc_html__('Next Member', 'calio-addon')));
            if ($prev_text === '') {
                $prev_text = esc_html__('Previous Member', 'calio-addon');
            }
            if ($next_text === '') {
                $next_text = esc_html__('Next Member', 'calio-addon');
            }

            echo '<div class="calio-team-slider-modal-nav">';
            echo '<button type="button" class="calio-team-slider-modal-nav-btn is-prev" data-calio-modal-prev>'
                . esc_html($prev_text) . '</button>';
            echo '<button type="button" class="calio-team-slider-modal-nav-btn is-next" data-calio-modal-next>'
                . esc_html($next_text) . '</button>';
            echo '</div>';
        }
        echo '</div>';
        echo '</div>';
    }

    /**
     * Prints member image using attachment id when possible.
     *
     * @param array<string, mixed> $member Repeater item.
     */
    private function render_member_image(array $member): void
    {
        $image_id = (int) ($member['member_image']['id'] ?? 0);
        if ($image_id > 0) {
            $html = wp_get_attachment_image($image_id, 'large', false, [
                'loading' => 'lazy',
                'class' => 'calio-team-slider-image-tag',
            ]);
            if (is_string($html) && $html !== '') {
                echo wp_kses_post($html);
                return;
            }
        }

        $url = (string) ($member['member_image']['url'] ?? '');
        if ($url !== '') {
            echo '<img class="calio-team-slider-image-tag" src="' . esc_url($url) . '" alt="' . esc_attr((string) ($member['member_name'] ?? '')) . '" loading="lazy">';
        }
    }

    /**
     * Prints social links for available icon/url slots.
     *
     * @param array<string, mixed> $member Repeater item.
     */
    private function render_member_socials(array $member): void
    {
        $markup = '';
        for ($slot = 1; $slot <= 3; $slot++) {
            $url = (string) ($member['social_' . $slot . '_url']['url'] ?? '');
            $icon = $member['social_' . $slot . '_icon'] ?? null;
            if ($url === '' || !is_array($icon)) {
                continue;
            }

            $target = !empty($member['social_' . $slot . '_url']['is_external']) ? '_blank' : '';
            $rel_parts = [];
            if (!empty($member['social_' . $slot . '_url']['is_external'])) {
                $rel_parts[] = 'noopener';
                $rel_parts[] = 'noreferrer';
            }
            if (!empty($member['social_' . $slot . '_url']['nofollow'])) {
                $rel_parts[] = 'nofollow';
            }
            $markup .= '<a class="calio-team-slider-social-link" href="' . esc_url($url) . '"';
            if ($target !== '') {
                $markup .= ' target="' . esc_attr($target) . '"';
            }
            if (!empty($rel_parts)) {
                $markup .= ' rel="' . esc_attr(implode(' ', array_unique($rel_parts))) . '"';
            }
            $markup .= ' aria-label="' . esc_attr__('Social profile', 'calio-addon') . '">';
            $icon_html = $this->get_icon_markup($icon, ['class' => 'calio-team-slider-social-glyph']);
            if ($icon_html !== '') {
                $markup .= $icon_html;
            }
            $markup .= '</a>';
        }

        if ($markup !== '') {
            echo '<div class="calio-team-slider-socials">' . wp_kses($markup, $this->allowed_team_slider_markup()) . '</div>';
        }
    }

    /**
     * Prints member button link.
     *
     * @param array<string, mixed> $member Repeater item.
     */
    private function render_member_button(array $member): void
    {
        $button_text = trim((string) ($member['member_button_text'] ?? ''));
        if ($button_text === '') {
            return;
        }

        $url = (string) ($member['member_button_url']['url'] ?? '');
        if ($url === '') {
            echo '<span class="calio-team-slider-button is-disabled">' . esc_html($button_text) . '</span>';
            return;
        }

        $target = !empty($member['member_button_url']['is_external']) ? '_blank' : '';
        $rel_parts = [];
        if (!empty($member['member_button_url']['is_external'])) {
            $rel_parts[] = 'noopener';
            $rel_parts[] = 'noreferrer';
        }
        if (!empty($member['member_button_url']['nofollow'])) {
            $rel_parts[] = 'nofollow';
        }
        echo '<a class="calio-team-slider-button" href="' . esc_url($url) . '"';
        if ($target !== '') {
            echo ' target="' . esc_attr($target) . '"';
        }
        if (!empty($rel_parts)) {
            echo ' rel="' . esc_attr(implode(' ', array_unique($rel_parts))) . '"';
        }
        echo '>' . esc_html($button_text) . '</a>';
    }

    /**
     * @return array<string, array<string, bool>>
     */
    private function allowed_team_slider_markup(): array
    {
        $allowed = wp_kses_allowed_html('post');
        $common = [
            'aria-hidden' => true,
            'aria-label' => true,
            'aria-modal' => true,
            'class' => true,
            'data-calio-modal-close' => true,
            'data-calio-modal-id' => true,
            'data-calio-modal-index' => true,
            'data-calio-modal-next' => true,
            'data-calio-modal-prev' => true,
            'data-calio-modal-target' => true,
            'href' => true,
            'rel' => true,
            'role' => true,
            'tabindex' => true,
            'target' => true,
            'type' => true,
        ];

        foreach (['a', 'article', 'button', 'div', 'h3', 'span'] as $tag) {
            $allowed[$tag] = array_merge($allowed[$tag] ?? [], $common);
        }

        $allowed['img'] = array_merge(
            $allowed['img'] ?? [],
            [
                'alt' => true,
                'class' => true,
                'height' => true,
                'loading' => true,
                'sizes' => true,
                'src' => true,
                'srcset' => true,
                'width' => true,
            ]
        );

        foreach ($this->calio_allowed_icon_markup() as $tag => $attributes) {
            $allowed[$tag] = array_merge($allowed[$tag] ?? [], $attributes);
        }

        return $allowed;
    }

    /**
     * Prints arrow contents by selected arrow mode.
     *
     * @param array<string, mixed> $settings Widget settings.
     * @param bool                 $is_left  Whether this is the left arrow.
     */
    private function render_arrow_content(array $settings, bool $is_left): void
    {
        $arrow_type = (string) ($settings['arrow_type'] ?? 'icon');
        $text_key = $is_left ? 'left_arrow_text' : 'right_arrow_text';
        $text = trim((string) ($settings[$text_key] ?? ($is_left ? esc_html__('Prev', 'calio-addon') : esc_html__('Next', 'calio-addon'))));

        if ($arrow_type === 'text' || $arrow_type === 'text-icon') {
            echo '<span class="calio-team-slider-arrow-text">' . esc_html($text) . '</span>';
        }

        if ($arrow_type === 'icon' || $arrow_type === 'text-icon') {
            echo '<span class="calio-team-slider-arrow-icon" aria-hidden="true">';
            $this->render_default_arrow_icon($is_left);
            echo '</span>';
        }
    }

    /**
     * Prints a small inline SVG chevron so arrows remain visible without icon font dependencies.
     */
    private function render_default_arrow_icon(bool $is_left): void
    {
        $rotation = $is_left ? '180' : '0';
        echo '<svg class="calio-team-slider-arrow-glyph" viewBox="0 0 20 20" width="20" height="20" focusable="false" aria-hidden="true" style="transform: rotate(' . esc_attr($rotation) . 'deg)">';
        echo '<path d="M7 4L13 10L7 16" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round"></path>';
        echo '</svg>';
    }

    /**
     * Adds icon and URL controls for one social slot.
     */
    private function add_member_social_controls(Repeater $repeater, int $slot, string $default_icon, string $placeholder_url): void
    {
        $repeater->add_control('social_' . $slot . '_icon', [
            'label' => sprintf(
                /* translators: %d: social slot index */
                esc_html__('Social Icon %d', 'calio-addon'),
                $slot
            ),
            'type' => Controls_Manager::ICONS,
            'default' => [
                'value' => $default_icon,
                'library' => 'fa-brands',
            ],
        ]);
        $repeater->add_control('social_' . $slot . '_url', [
            'label' => sprintf(
                /* translators: %d: social slot index */
                esc_html__('Social URL %d', 'calio-addon'),
                $slot
            ),
            'type' => Controls_Manager::URL,
            'placeholder' => $placeholder_url,
            'default' => [
                'url' => '',
                'is_external' => true,
            ],
        ]);
    }

    /**
     * Normalizes a scalar numeric input.
     *
     * @param mixed $value Raw value.
     */
    private function normalize_number($value, int $fallback, int $min, int $max): int
    {
        $number = is_numeric($value) ? (int) $value : $fallback;
        return max($min, min($max, $number));
    }

    /**
     * Normalizes a slider control payload.
     *
     * @param mixed $value Raw slider value.
     */
    private function normalize_slider_size($value, int $fallback, int $min, int $max): int
    {
        if (is_array($value) && isset($value['size']) && is_numeric($value['size'])) {
            $number = (int) $value['size'];
            return max($min, min($max, $number));
        }

        return $fallback;
    }
}
