<?php
namespace Softech_Addons_for_Elementor\Widgets;

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

if ( ! class_exists( '\\Softech_Addons_for_Elementor\\Includes\\Softech_Post_Query_Manager' ) ) {
    require_once SITS_ELEMENTOR_ADDONS_PLUGIN_PATH . 'includes/class-post-query-manager.php';
}

use Elementor\Controls_Manager;
use Elementor\Repeater;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Css_Filter;
use Elementor\Utils;
use Softech_Addons_for_Elementor\Includes\Softech_Post_Query_Manager;


class sitsel_hero_slider extends \Elementor\Widget_Base {

    public function get_name()       { return 'sitsel_hero_slider'; }
    public function get_title()      { return __( 'SITS Hero Slider', 'softech-addons-for-elementor' ); }
    public function get_icon()       { return 'eicon-slides'; }
    public function get_categories() { return [ 'sits-category' ]; }
    public function get_keywords()   { return [ 'slider', 'hero', 'banner', 'carousel', 'static', 'slides', 'dynamic', 'posts' ]; }

    // ─── Asset registration ────────────────────────────────────────────────────

    private function register_widget_assets() {
        $url     = SITS_ELEMENTOR_ADDONS_PLUGIN_URL;
        $version = SITS_ELEMENTOR_ADDONS_VERSION;

        if ( ! wp_style_is( 'sitsel-hero-slider-css', 'registered' ) ) {
            wp_register_style( 'sitsel-hero-slider-css', $url . 'assets/css/sitsel-hero-slider.css', [], $version );
        }
        if ( ! wp_script_is( 'sitsel-hero-slider-js', 'registered' ) ) {
            wp_register_script( 'sitsel-hero-slider-js', $url . 'assets/js/sitsel-hero-slider.js', [ 'jquery' ], $version, true );
        }
    }

    public function get_style_depends() {
        $this->register_widget_assets();
        return [ 'sits-swiper', 'sitsel-hero-slider-css' ];
    }

    public function get_script_depends() {
        return [ 'sits-swiper', 'sitsel-hero-slider-js' ];
    }

    // ─── Layouts helper ────────────────────────────────────────────────────────

    // private function get_layouts() {
    //     return [
    //         'classic' => esc_html__( 'Classic (Full Overlay)', 'softech-addons-for-elementor' ),
    //         'split'   => esc_html__( 'Split (Image + Content)', 'softech-addons-for-elementor' ),
    //         'card'    => esc_html__( 'Card', 'softech-addons-for-elementor' ),
    //     ];
    // }

    // ─── Controls ──────────────────────────────────────────────────────────────

    protected function register_controls() {
        $this->register_source_control();    
        $this->register_slides_section();      
        $this->register_dynamic_controls();    
        $this->register_settings_section();
        $this->register_style_wrapper();
        $this->register_style_image();
        $this->register_style_content();
        $this->register_style_subheading();
        $this->register_style_title();
        $this->register_style_slide_link();
        $this->register_style_paragraph();
        $this->register_style_button();
        $this->register_style_navigation();
        $this->register_style_dots();
        $this->register_style_scrollbar();
    }

    // ── SOURCE CONTROL (new) ────────────────────────────────────────────────────

    /**
     * Top-level section that lets users choose Static or Dynamic content.
     * Placed above the Slides section so it appears first in the panel.
     */
    private function register_source_control() {
        $this->start_controls_section(
            'section_source',
            [
                'label' => __( 'Content Source', 'softech-addons-for-elementor' ),
                'tab'   => Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'slides_source',
            [
                'label'   => __( 'Source', 'softech-addons-for-elementor' ),
                'type'    => Controls_Manager::SELECT,
                'options' => [
                    'static'  => __( 'Static', 'softech-addons-for-elementor' ),
                    'dynamic' => __( 'Dynamic', 'softech-addons-for-elementor' ),
                ],
                'default' => 'static',
            ]
        );

       

        $this->end_controls_section();
    }

    // ── SLIDES (static) ─────────────────────────────────────────────────────────

    private function register_slides_section() {
        $this->start_controls_section(
            'section_slides',
            [
                'label'     => __( 'Slides', 'softech-addons-for-elementor' ),
                'tab'       => Controls_Manager::TAB_CONTENT,
                // Only visible when source is "static"
                'condition' => [ 'slides_source' => 'static' ],
            ]
        );

        $repeater = new Repeater();

        // ── Slide Image
        $repeater->add_control(
            'slide_image',
            [
                'label'   => __( 'Image', 'softech-addons-for-elementor' ),
                'type'    => Controls_Manager::MEDIA,
                'default' => [ 'url' => Utils::get_placeholder_image_src() ],
            ]
        );

        // ── Subheading
        $repeater->add_control(
            'show_subheading',
            [
                'label'        => __( 'Show Sub Heading', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'label_on'     => __( 'Yes', 'softech-addons-for-elementor' ),
                'label_off'    => __( 'No', 'softech-addons-for-elementor' ),
                'return_value' => 'yes',
                'default'      => 'yes',
            ]
        );

        $repeater->add_control(
            'subheading',
            [
                'label'       => __( 'Sub Heading', 'softech-addons-for-elementor' ),
                'type'        => Controls_Manager::TEXT,
                'default'     => __( 'Welcome to our world', 'softech-addons-for-elementor' ),
                'label_block' => true,
                'condition'   => [ 'show_subheading' => 'yes' ],
            ]
        );

        $repeater->add_control(
            'subheading_color',
            [
                'label'     => __( 'Sub Heading Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'condition' => [ 'show_subheading' => 'yes' ],
            ]
        );

        // ── Title
        $repeater->add_control(
            'show_title',
            [
                'label'        => __( 'Show Title', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'label_on'     => __( 'Yes', 'softech-addons-for-elementor' ),
                'label_off'    => __( 'No', 'softech-addons-for-elementor' ),
                'return_value' => 'yes',
                'default'      => 'yes',
                'separator'    => 'before',
            ]
        );

        $repeater->add_control(
            'title',
            [
                'label'       => __( 'Title', 'softech-addons-for-elementor' ),
                'type'        => Controls_Manager::TEXT,
                'default'     => __( 'Powerful Hero Slider', 'softech-addons-for-elementor' ),
                'label_block' => true,
                'condition'   => [ 'show_title' => 'yes' ],
            ]
        );

        $repeater->add_control(
            'title_tag',
            [
                'label'     => __( 'Title Tag', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::SELECT,
                'default'   => 'h2',
                'options'   => [
                    'h1' => 'H1', 'h2' => 'H2', 'h3' => 'H3',
                    'h4' => 'H4', 'h5' => 'H5', 'h6' => 'H6',
                    'div' => 'div', 'p' => 'p',
                ],
                'condition' => [ 'show_title' => 'yes' ],
            ]
        );

        $repeater->add_control(
            'title_color',
            [
                'label'     => __( 'Title Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'condition' => [ 'show_title' => 'yes' ],
            ]
        );

        // ── Paragraph
        $repeater->add_control(
            'show_paragraph',
            [
                'label'        => __( 'Show Paragraph', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'label_on'     => __( 'Yes', 'softech-addons-for-elementor' ),
                'label_off'    => __( 'No', 'softech-addons-for-elementor' ),
                'return_value' => 'yes',
                'default'      => 'yes',
                'separator'    => 'before',
            ]
        );

        $repeater->add_control(
            'paragraph',
            [
                'label'     => __( 'Paragraph', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::WYSIWYG,
                'rows'      => 4,
                'default'   => __( 'Build stunning hero sliders for your WordPress site.', 'softech-addons-for-elementor' ),
                'condition' => [ 'show_paragraph' => 'yes' ],
            ]
        );

        $repeater->add_control(
            'paragraph_color',
            [
                'label'     => __( 'Paragraph Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'condition' => [ 'show_paragraph' => 'yes' ],
            ]
        );

        // ── Button 1
        $repeater->add_control(
            'show_button',
            [
                'label'        => __( 'Show Button', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'label_on'     => __( 'Yes', 'softech-addons-for-elementor' ),
                'label_off'    => __( 'No', 'softech-addons-for-elementor' ),
                'return_value' => 'yes',
                'default'      => 'yes',
                'separator'    => 'before',
            ]
        );

        $repeater->add_control(
            'button_text',
            [
                'label'     => __( 'Button Text', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::TEXT,
                'default'   => __( 'Get Started', 'softech-addons-for-elementor' ),
                'condition' => [ 'show_button' => 'yes' ],
            ]
        );

        $repeater->add_control(
            'button_link',
            [
                'label'         => __( 'Button Link', 'softech-addons-for-elementor' ),
                'type'          => Controls_Manager::URL,
                'placeholder'   => 'https://your-link.com',
                'show_external' => true,
                'default'       => [ 'url' => '#' ],
                'condition'     => [ 'show_button' => 'yes' ],
            ]
        );

        $repeater->add_control(
            'button_icon',
            [
                'label'     => __( 'Button Icon', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::ICONS,
                'skin'      => 'inline',
                'condition' => [ 'show_button' => 'yes' ],
            ]
        );

        $repeater->add_control(
            'button_icon_position',
            [
                'label'     => __( 'Icon Position', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::SELECT,
                'default'   => 'after',
                'options'   => [
                    'before' => __( 'Before Text', 'softech-addons-for-elementor' ),
                    'after'  => __( 'After Text', 'softech-addons-for-elementor' ),
                ],
                'condition' => [ 'show_button' => 'yes' ],
            ]
        );

        $repeater->add_control(
            'button_bg_color',
            [
                'label'     => __( 'Button BG Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'condition' => [ 'show_button' => 'yes' ],
            ]
        );

        $repeater->add_control(
            'button_text_color',
            [
                'label'     => __( 'Button Text Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'condition' => [ 'show_button' => 'yes' ],
            ]
        );

        // ── Button 2
        $repeater->add_control(
            'show_button_2',
            [
                'label'        => __( 'Show Secondary Button', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'label_on'     => __( 'Yes', 'softech-addons-for-elementor' ),
                'label_off'    => __( 'No', 'softech-addons-for-elementor' ),
                'return_value' => 'yes',
                'default'      => '',
                'separator'    => 'before',
            ]
        );

        $repeater->add_control(
            'button_2_text',
            [
                'label'     => __( 'Secondary Button Text', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::TEXT,
                'default'   => __( 'Learn More', 'softech-addons-for-elementor' ),
                'condition' => [ 'show_button_2' => 'yes' ],
            ]
        );

        $repeater->add_control(
            'button_2_link',
            [
                'label'         => __( 'Secondary Button Link', 'softech-addons-for-elementor' ),
                'type'          => Controls_Manager::URL,
                'placeholder'   => 'https://your-link.com',
                'show_external' => true,
                'default'       => [ 'url' => '#' ],
                'condition'     => [ 'show_button_2' => 'yes' ],
            ]
        );

        // ── Overlay override per slide
        $repeater->add_control(
            'overlay_color',
            [
                'label'     => __( 'Slide Overlay Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'separator' => 'before',
            ]
        );

        // ── Slide Link
        $repeater->add_control(
            'slide_link',
            [
                'label'         => __( 'Slide Link', 'softech-addons-for-elementor' ),
                'type'          => Controls_Manager::URL,
                'placeholder'   => 'https://your-link.com',
                'show_external' => true,
                'default'       => [ 'url' => '' ],
                'separator'     => 'before',
            ]
        );

        $repeater->add_control(
            'link_apply_image',
            [
                'label'        => __( 'Apply Link on Image', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'label_on'     => __( 'Yes', 'softech-addons-for-elementor' ),
                'label_off'    => __( 'No', 'softech-addons-for-elementor' ),
                'return_value' => 'yes',
                'default'      => 'yes',
                'description'  => __( 'Yes = link on image + title. No = link on title only.', 'softech-addons-for-elementor' ),
                'condition'    => [ 'slide_link[url]!' => '' ],
            ]
        );

        $this->add_control(
            'slides',
            [
                'label'       => __( 'Slides', 'softech-addons-for-elementor' ),
                'type'        => Controls_Manager::REPEATER,
                'fields'      => $repeater->get_controls(),
                'title_field' => '{{{ title }}}',
                'default'     => [
                    [
                        'title'       => __( 'Slide One — Make an Impact', 'softech-addons-for-elementor' ),
                        'subheading'  => __( 'Welcome to excellence', 'softech-addons-for-elementor' ),
                        'paragraph'   => __( 'Craft stunning slider sections with full control over imagery, typography, and CTAs.', 'softech-addons-for-elementor' ),
                        'button_text' => __( 'Get Started', 'softech-addons-for-elementor' ),
                    ],
                    [
                        'title'       => __( 'Slide Two — Your Vision', 'softech-addons-for-elementor' ),
                        'subheading'  => __( 'Design without limits', 'softech-addons-for-elementor' ),
                        'paragraph'   => __( 'Three beautiful layouts — Classic, Split, and Card — to match any brand.', 'softech-addons-for-elementor' ),
                        'button_text' => __( 'Explore Now', 'softech-addons-for-elementor' ),
                    ],
                ],
            ]
        );

        $this->end_controls_section();
    }

    // ── DYNAMIC CONTROLS (new) ──────────────────────────────────────────────────

    /**
     * Registers two sections that only appear in Dynamic mode:
     *   1. Query section — delegates entirely to Post Query Manager
     *   2. Dynamic Fields section — controls what post data maps to each slide area
     */
    private function register_dynamic_controls() {

        Softech_Post_Query_Manager::register_controls( $this, [
            'source_control' => '',   // no extra source condition from the manager
            'section_id'     => 'section_dynamic_query',
            'section_label'  => esc_html__( 'Query', 'softech-addons-for-elementor' ),
            'mode'           => 'post_only',  
            
        ] );
        $this->update_control(
            'section_dynamic_query',   // must match the section_id passed above
            [
                'condition' => [ 'slides_source' => 'dynamic' ],
            ]
        );

        // ── 2. Dynamic field-mapping section ─────────────────────────────────
        $this->start_controls_section(
            'section_dynamic_fields',
            [
                'label'     => __( 'Dynamic — Fields', 'softech-addons-for-elementor' ),
                'tab'       => Controls_Manager::TAB_CONTENT,
                'condition' => [ 'slides_source' => 'dynamic' ],
            ]
        );

        // ── Image ─────────────────────────────────────────────────────────────
        $this->add_control(
            'dyn_image_heading',
            [
                'label' => __( 'Slide Image', 'softech-addons-for-elementor' ),
                'type'  => Controls_Manager::HEADING,
            ]
        );

        $this->add_control(
            'dyn_image_source',
            [
                'label'   => __( 'Image Source', 'softech-addons-for-elementor' ),
                'type'    => Controls_Manager::SELECT,
                'default' => 'featured',
                'options' => [
                    'featured'  => __( 'Featured Image', 'softech-addons-for-elementor' ),
                    'acf_image' => __( 'ACF / Custom Field (Image URL)', 'softech-addons-for-elementor' ),
                    'none'      => __( 'No Image', 'softech-addons-for-elementor' ),
                ],
            ]
        );
        $this->add_control(
            'dyn_image_link',
            [
                'label'        => __( 'Link Image to Post', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => '',
                'condition'    => [ 'dyn_image_source!' => 'none' ],
            ]
        );

        $this->add_control(
            'dyn_image_field_key',
            [
                'label'       => __( 'Field Key', 'softech-addons-for-elementor' ),
                'type'        => Controls_Manager::TEXT,
                'placeholder' => 'e.g. my_slide_image',
                'label_block' => true,
                'condition'   => [ 'dyn_image_source' => 'acf_image' ],
            ]
        );

        // ── Sub Heading ───────────────────────────────────────────────────────
        $this->add_control(
            'dyn_subheading_heading',
            [
                'label'     => __( 'Sub Heading', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'dyn_show_subheading',
            [
                'label'        => __( 'Show Sub Heading', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => 'yes',
            ]
        );

        $this->add_control(
            'dyn_subheading_source',
            [
                'label'     => __( 'Sub Heading Source', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::SELECT,
                'default'   => 'category',
                'options'   => [
                    'category'     => __( 'First Category', 'softech-addons-for-elementor' ),
                    'date'         => __( 'Post Date', 'softech-addons-for-elementor' ),
                    'author'       => __( 'Author Name', 'softech-addons-for-elementor' ),
                    'custom_field' => __( 'Custom Field (text)', 'softech-addons-for-elementor' ),
                    'custom_text'  => __( 'Fixed Text', 'softech-addons-for-elementor' ),
                ],
                'condition' => [ 'dyn_show_subheading' => 'yes' ],
            ]
        );

        $this->add_control(
            'dyn_subheading_field_key',
            [
                'label'       => __( 'Field Key', 'softech-addons-for-elementor' ),
                'type'        => Controls_Manager::TEXT,
                'placeholder' => 'e.g. my_subheading_field',
                'label_block' => true,
                'condition'   => [
                    'dyn_show_subheading'   => 'yes',
                    'dyn_subheading_source' => 'custom_field',
                ],
            ]
        );

        $this->add_control(
            'dyn_subheading_fixed_text',
            [
                'label'     => __( 'Fixed Text', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::TEXT,
                'default'   => __( 'Latest Post', 'softech-addons-for-elementor' ),
                'condition' => [
                    'dyn_show_subheading'   => 'yes',
                    'dyn_subheading_source' => 'custom_text',
                ],
            ]
        );

        $this->add_control(
            'dyn_date_format',
            [
                'label'       => __( 'Date Format', 'softech-addons-for-elementor' ),
                'type'        => Controls_Manager::TEXT,
                'default'     => 'F j, Y',
                'description' => __( 'PHP date format string, e.g. F j, Y', 'softech-addons-for-elementor' ),
                'condition'   => [
                    'dyn_show_subheading'   => 'yes',
                    'dyn_subheading_source' => 'date',
                ],
            ]
        );

        // ── Title ─────────────────────────────────────────────────────────────
        $this->add_control(
            'dyn_title_heading',
            [
                'label'     => __( 'Title', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'dyn_show_title',
            [
                'label'        => __( 'Show Title', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => 'yes',
            ]
        );

        $this->add_control(
            'dyn_title_tag',
            [
                'label'     => __( 'Title HTML Tag', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::SELECT,
                'default'   => 'h2',
                'options'   => [
                    'h1' => 'H1', 'h2' => 'H2', 'h3' => 'H3',
                    'h4' => 'H4', 'h5' => 'H5', 'h6' => 'H6',
                    'div' => 'div', 'p' => 'p',
                ],
                'condition' => [ 'dyn_show_title' => 'yes' ],
            ]
        );
        $this->add_control(
            'dyn_title_link',
            [
                'label'        => __( 'Link Title to Post', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => 'yes',
                'condition'    => [ 'dyn_show_title' => 'yes' ],
            ]
        );

        // ── Paragraph / Excerpt ───────────────────────────────────────────────
        $this->add_control(
            'dyn_paragraph_heading',
            [
                'label'     => __( 'Paragraph', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'dyn_show_paragraph',
            [
                'label'        => __( 'Show Paragraph', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => 'yes',
            ]
        );

        $this->add_control(
            'dyn_paragraph_source',
            [
                'label'     => __( 'Paragraph Source', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::SELECT,
                'default'   => 'excerpt',
                'options'   => [
                    'excerpt'      => __( 'Post Excerpt', 'softech-addons-for-elementor' ),
                    'content'      => __( 'Post Content (trimmed)', 'softech-addons-for-elementor' ),
                    'custom_field' => __( 'Custom Field (text)', 'softech-addons-for-elementor' ),
                ],
                'condition' => [ 'dyn_show_paragraph' => 'yes' ],
            ]
        );

        $this->add_control(
            'dyn_paragraph_field_key',
            [
                'label'       => __( 'Field Key', 'softech-addons-for-elementor' ),
                'type'        => Controls_Manager::TEXT,
                'placeholder' => 'e.g. my_description',
                'label_block' => true,
                'condition'   => [
                    'dyn_show_paragraph'   => 'yes',
                    'dyn_paragraph_source' => 'custom_field',
                ],
            ]
        );

        $this->add_control(
            'dyn_excerpt_length',
            [
                'label'     => __( 'Word Limit', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::NUMBER,
                'default'   => 20,
                'min'       => 5,
                'max'       => 200,
                'condition' => [
                    'dyn_show_paragraph'   => 'yes',
                    'dyn_paragraph_source' => [ 'excerpt', 'content' ],
                ],
            ]
        );

        // ── Primary Button ────────────────────────────────────────────────────
        $this->add_control(
            'dyn_button_heading',
            [
                'label'     => __( 'Button', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'dyn_show_button',
            [
                'label'        => __( 'Show Button', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => 'yes',
            ]
        );

        $this->add_control(
            'dyn_button_text',
            [
                'label'     => __( 'Button Text', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::TEXT,
                'default'   => __( 'Read More', 'softech-addons-for-elementor' ),
                'condition' => [ 'dyn_show_button' => 'yes' ],
            ]
        );

        $this->add_control(
            'dyn_button_icon',
            [
                'label'     => __( 'Button Icon', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::ICONS,
                'skin'      => 'inline',
                'condition' => [ 'dyn_show_button' => 'yes' ],
            ]
        );

        $this->add_control(
            'dyn_button_icon_position',
            [
                'label'     => __( 'Icon Position', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::SELECT,
                'default'   => 'after',
                'options'   => [
                    'before' => __( 'Before Text', 'softech-addons-for-elementor' ),
                    'after'  => __( 'After Text', 'softech-addons-for-elementor' ),
                ],
                'condition' => [ 'dyn_show_button' => 'yes' ],
            ]
        );

        $this->end_controls_section();
    }

    // ── SETTINGS ────────────────────────────────────────────────────────────────

    private function register_settings_section() {
       $this->start_controls_section(
        'section_settings',
        [
            'label' => __( 'Slider Settings', 'softech-addons-for-elementor' ),
            'tab'   => Controls_Manager::TAB_CONTENT,
        ]
    );
    
    $this->add_control(
    'layout',
    [
        'label'   => __( 'Slide Layout', 'softech-addons-for-elementor' ),
        'type'    => Controls_Manager::SELECT,
        'default' => 'card',
        'options' => [
            'card'    => __( 'Card (Image + Content Below)', 'softech-addons-for-elementor' ),
            'overlay' => __( 'Overlay (Content Over Image)', 'softech-addons-for-elementor' ),
            'split'   => __( 'Split (50/50 Side by Side)', 'softech-addons-for-elementor' ),
        ],
    ]
);

$this->add_control(
    'split_image_position',
    [
        'label'     => __( 'Image Side', 'softech-addons-for-elementor' ),
        'type'      => Controls_Manager::CHOOSE,
        'options'   => [
            'left'  => [ 'title' => __( 'Left', 'softech-addons-for-elementor' ),  'icon' => 'eicon-h-align-left' ],
            'right' => [ 'title' => __( 'Right', 'softech-addons-for-elementor' ), 'icon' => 'eicon-h-align-right' ],
        ],
        'default'   => 'left',
        'condition' => [ 'layout' => 'split' ],
    ]
);

    $this->add_responsive_control(
        'content_align',
        [
            'label'   => __( 'Content Alignment', 'softech-addons-for-elementor' ),
            'type'    => Controls_Manager::CHOOSE,
            'options' => [
                'left'   => [ 'title' => __( 'Left', 'softech-addons-for-elementor' ),   'icon' => 'eicon-text-align-left' ],
                'center' => [ 'title' => __( 'Center', 'softech-addons-for-elementor' ), 'icon' => 'eicon-text-align-center' ],
                'right'  => [ 'title' => __( 'Right', 'softech-addons-for-elementor' ),  'icon' => 'eicon-text-align-right' ],
            ],
            'default'   => 'left',
            'selectors' => [
                '{{WRAPPER}} .sitsel-slide-content'   => 'text-align: {{VALUE}};',
                '{{WRAPPER}} .sitsel-slide-btn-group' => 'justify-content: {{VALUE}};',
            ],
        ]
    );

    $this->add_control(
        'carousel_heading',
        [
            'label'     => __( 'Carousel', 'softech-addons-for-elementor' ),
            'type'      => Controls_Manager::HEADING,
            'separator' => 'before',
        ]
    );

    $this->add_responsive_control(
        'slides_per_view',
        [
            'label'          => __( 'Slides Per View', 'softech-addons-for-elementor' ),
            'type'           => Controls_Manager::NUMBER,
            'default'        => 3,
            'tablet_default' => 2,
            'mobile_default' => 1,
            'min'            => 1,
            'max'            => 6,
            'step'           => 1,
        ]
    );

    $this->add_responsive_control(
        'slides_space_between',
        [
            'label'          => __( 'Space Between', 'softech-addons-for-elementor' ),
            'type'           => Controls_Manager::SLIDER,
            'size_units'     => [ 'px', 'em', 'rem', 'custom' ],
            'default'        => [ 'size' => 20, 'unit' => 'px' ],
            'tablet_default' => [ 'size' => 20, 'unit' => 'px' ],
            'mobile_default' => [ 'size' => 20, 'unit' => 'px' ],
            'range'          => [ 'px' => [ 'min' => 0, 'max' => 200 ] ],
        ]
    );

    $this->add_control(
        'centered_slides',
        [
            'label'        => __( 'Centered Slides', 'softech-addons-for-elementor' ),
            'type'         => Controls_Manager::SWITCHER,
            'return_value' => 'yes',
            'default'      => '',
        ]
    );

        $this->add_control(
            'autoplay',
            [
                'label'        => __( 'Autoplay', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'label_on'     => __( 'Yes', 'softech-addons-for-elementor' ),
                'label_off'    => __( 'No', 'softech-addons-for-elementor' ),
                'return_value' => 'yes',
                'default'      => 'yes',
                'separator'    => 'before',
            ]
        );

        $this->add_control(
            'autoplay_speed',
            [
                'label'     => __( 'Autoplay Delay (ms)', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::NUMBER,
                'default'   => 4000,
                'min'       => 1000,
                'step'      => 500,
                'condition' => [ 'autoplay' => 'yes' ],
            ]
        );

        $this->add_control(
            'transition',
            [
                'label'     => __( 'Transition Effect', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::SELECT,
                'default'   => 'slide',
                'options'   => [
                    'fade'  => __( 'Fade', 'softech-addons-for-elementor' ),
                    'slide' => __( 'Slide', 'softech-addons-for-elementor' ),
                    'zoom'  => __( 'Zoom', 'softech-addons-for-elementor' ),
                ],
                'separator' => 'before',
                'conditions' => [
                    'terms' => [
                        [
                            'name'     => 'slides_per_view',
                            'operator' => '==',
                            'value'    => '1',
                        ],
                    ],
                ],
            ]
        );

        $this->add_control(
            'transition_speed',
            [
                'label'   => __( 'Transition Speed (ms)', 'softech-addons-for-elementor' ),
                'type'    => Controls_Manager::NUMBER,
                'default' => 700,
                'min'     => 100,
                'step'    => 100,
            ]
        );

        $this->add_control(
            'show_arrows',
            [
                'label'        => __( 'Show Arrows', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => 'yes',
                'separator'    => 'before',
            ]
        );

        $this->add_control(
            'prev_icon',
            [
                'label'     => __( 'Prev Icon', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::ICONS,
                'default'   => [ 'value' => 'fas fa-chevron-left', 'library' => 'fa-solid' ],
                'condition' => [ 'show_arrows' => 'yes' ],
            ]
        );

        $this->add_control(
            'next_icon',
            [
                'label'     => __( 'Next Icon', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::ICONS,
                'default'   => [ 'value' => 'fas fa-chevron-right', 'library' => 'fa-solid' ],
                'condition' => [ 'show_arrows' => 'yes' ],
            ]
        );

        $this->add_control(
            'show_dots',
            [
                'label'        => __( 'Show Dots', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => 'yes',
            ]
        );
        $this->add_control(
    'show_scrollbar',
    [
        'label'        => __( 'Show Scrollbar', 'softech-addons-for-elementor' ),
        'type'         => Controls_Manager::SWITCHER,
        'return_value' => 'yes',
        'default'      => '',
    ]
);

        $this->add_control(
            'pause_on_hover',
            [
                'label'        => __( 'Pause on Hover', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => 'yes',
            ]
        );

        $this->add_control(
            'loop',
            [
                'label'        => __( 'Infinite Loop', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => 'yes',
            ]
        );

        $this->end_controls_section();
    }

    // ────────────────────────────────────────────────────────────── STYLE ──────
    // (All style sections are unchanged from the original)

    private function register_style_wrapper() {
        $this->start_controls_section(
            'style_wrapper',
            [
                'label' => __( 'Slider Wrapper', 'softech-addons-for-elementor' ),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_responsive_control(
    'slider_height',
    [
        'label'      => __( 'Slide Height', 'softech-addons-for-elementor' ),
        'type'       => Controls_Manager::SLIDER,
        'size_units' => [ 'px', '%', 'vh', 'em', 'rem', 'custom' ],
        'range'      => [
            'px' => [ 'min' => 100, 'max' => 1200 ],
            'vh' => [ 'min' => 10,  'max' => 100  ],
        ],
        'selectors'  => [
            '{{WRAPPER}} .sitsel-slide'                => 'min-height: {{SIZE}}{{UNIT}};',
            
        ],
    ]
);

        $this->add_group_control(
            Group_Control_Border::get_type(),
            [
                'name'     => 'slider_border',
                'selector' => '{{WRAPPER}} .sitsel-hero-slider',
            ]
        );

        $this->add_responsive_control(
            'slider_border_radius',
            [
                'label'      => __( 'Border Radius', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-hero-slider' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; overflow: hidden;',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Box_Shadow::get_type(),
            [
                'name'     => 'slider_box_shadow',
                'selector' => '{{WRAPPER}} .sitsel-hero-slider',
            ]
        );
        $this->add_responsive_control(
            'slider_wrapper_padding',
            [
                'label'      => __( 'Wrapper padding', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
              
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-hero-slider .swiper-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        
        $this->add_responsive_control(
            'slider_wrapper_margin',
            [
                'label'      => __( 'Wrapper Margin', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
                'default'    => [ 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, 'unit' => 'px' ],
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-hero-slider .swiper-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

        $this->end_controls_section();
    }

    private function register_style_image() {
        $this->start_controls_section(
            'style_image',
            [
                'label' => __( 'Image', 'softech-addons-for-elementor' ),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_responsive_control(
            'image_height',
            [
                'label'      => __( 'Image Height', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', '%', 'vh', 'em', 'rem', 'custom' ],
                'default'    => [ 'size' => 100, 'unit' => '%' ],
                'selectors'  => [
                    '{{WRAPPER}}  .sitsel-slide-image-wrap img' => 'height: {{SIZE}}{{UNIT}};',
                ],
               'condition' => [ 'layout' => [ 'card', 'split' ] ],
                'separator'  => 'before',
            ]
        );
        $this->add_responsive_control(
    'card_inner_gap',
    [
        'label'      => __( 'Image & Content Gap', 'softech-addons-for-elementor' ),
        'type'       => Controls_Manager::SLIDER,
        'size_units' => [ 'px', 'em', 'rem', 'custom' ],
        'default'    => [ 'size' => 0, 'unit' => 'px' ],
        'selectors'  => [
            '{{WRAPPER}} .sitsel-slide-inner' => 'gap: {{SIZE}}{{UNIT}};',
        ],
        'condition' => [ 'layout' => 'card' ],
    ]
);
$this->add_responsive_control(
    'image_wrap_padding',
    [
        'label'      => __( 'Image Wrap Padding', 'softech-addons-for-elementor' ),
        'type'       => Controls_Manager::DIMENSIONS,
        'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
        'selectors'  => [
            '{{WRAPPER}} .sitsel-slide-image-wrap' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);
        $this->add_responsive_control(
            'image_object_fit',
            [
                'label'     => __( 'Object Fit', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::SELECT,
                'default'   => 'cover',
                'options'   => [
                    'cover'      => 'Cover',
                    'contain'    => 'Contain',
                    'fill'       => 'Fill',
                    'none'       => 'None',
                    'scale-down' => 'Scale Down',
                ],
                'selectors' => [
                    '{{WRAPPER}} .sitsel-slide-image-wrap img' => 'object-fit: {{VALUE}};',
                ],
            ]
        );

        $this->add_responsive_control(
            'image_object_position',
            [
                'label'     => __( 'Object Position', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::SELECT,
                'default'   => 'center center',
                'options'   => [
                    'center center' => 'Center',
                    'top center'    => 'Top',
                    'bottom center' => 'Bottom',
                    'left center'   => 'Left',
                    'right center'  => 'Right',
                ],
                'selectors' => [
                    '{{WRAPPER}} .sitsel-slide-image-wrap img' => 'object-position: {{VALUE}};',
                ],
            ]
        );
		
		$this->add_group_control(
				Group_Control_Border::get_type(),
				[
					'name'     => 'image_border',
					'selector' => '{{WRAPPER}} .sitsel-slide-image-wrap img',
					'separator' => 'before',
				]
			);

			$this->add_responsive_control(
				'image_border_radius',
				[
					'label'      => __( 'Border Radius', 'softech-addons-for-elementor' ),
					'type'       => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
					'selectors'  => [
						'{{WRAPPER}} .sitsel-slide-image-wrap img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; overflow: hidden;',
						'{{WRAPPER}} .sitsel-slide-image-wrap'     => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; overflow: hidden;',
					],
				]
			);

        $this->add_control(
            'overlay_heading',
            [
                'label'     => __( 'Overlay', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::HEADING,
                'separator' => 'before',
                'condition' => [ 'layout' => 'overlay' ],
            ]
        );

        $this->add_control(
            'overlay_color',
            [
                'label'     => __( 'Overlay Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => 'rgba(0,0,0,0.45)',
                'selectors' => [
                    '{{WRAPPER}} .sitsel-slide-overlay' => 'background-color: {{VALUE}};',
                ],
                'condition' => [ 'layout' => 'overlay' ],
            ]
        );

        $this->add_group_control(
            Group_Control_Css_Filter::get_type(),
            [
                'name'     => 'image_css_filter',
                'selector' => '{{WRAPPER}} .sitsel-slide-image-wrap img',
            ]
        );
		

        $this->add_responsive_control(
            'split_image_width',
            [
                'label'      => __( 'Image Width (%)', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', '%', 'vw', 'em', 'rem', 'custom' ],
                'default'    => [ 'size' => 50, 'unit' => '%' ],
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-slide-layout-split .sitsel-slide-image-wrap'    => 'width: {{SIZE}}{{UNIT}};',
                    // '{{WRAPPER}} .sitsel-slide-layout-split .sitsel-slide-content'  => 'width: calc(100% - {{SIZE}}{{UNIT}});',
                ],
                'condition'  => [ 'layout' => 'split' ],
                'separator'  => 'before',
            ]
        );

        $this->end_controls_section();
    }

    private function register_style_content() {
        $this->start_controls_section(
            'style_content',
            [
                'label' => __( 'Content Box', 'softech-addons-for-elementor' ),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'content_bg_color',
            [
                'label'     => __( 'Background Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sitsel-slide-content-wrap' => 'background-color: {{VALUE}};',
                ],
            ]
        );

        $this->add_responsive_control(
            'content_padding',
            [
                'label'      => __( 'Padding', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
                'default'    => [ 'top' => 40, 'right' => 40, 'bottom' => 40, 'left' => 40, 'unit' => 'px' ],
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-slide-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

        $this->add_responsive_control(
            'content_max_width',
            [
                'label'      => __( 'Max Width', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', '%', 'vw', 'em', 'rem', 'custom' ],
                'default'    => [ 'size' => 100, 'unit' => '%' ],
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-slide-content' => 'max-width: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        
        $this->add_responsive_control(
    'content_valign',
    [
        'label'   => __( 'Vertical Alignment', 'softech-addons-for-elementor' ),
        'type'    => Controls_Manager::CHOOSE,
        'options' => [
            'flex-start' => [ 'title' => __( 'Top', 'softech-addons-for-elementor' ),    'icon' => 'eicon-v-align-top' ],
            'center'     => [ 'title' => __( 'Middle', 'softech-addons-for-elementor' ), 'icon' => 'eicon-v-align-middle' ],
            'flex-end'   => [ 'title' => __( 'Bottom', 'softech-addons-for-elementor' ), 'icon' => 'eicon-v-align-bottom' ],
        ],
        'default'   => 'center',
        'selectors' => [
            '{{WRAPPER}} .sitsel-slide-content-wrap' => 'align-items: {{VALUE}};',
        ],
    ]
);



        $this->add_group_control(
            Group_Control_Border::get_type(),
            [
                'name'      => 'content_border',
                'selector'  => '{{WRAPPER}} .sitsel-slide-content',
                'separator' => 'before',
            ]
        );

        $this->add_responsive_control(
            'content_border_radius',
            [
                'label'      => __( 'Border Radius', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'vw', 'em', 'rem', 'custom' ],
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-slide-content' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Box_Shadow::get_type(),
            [
                'name'     => 'content_box_shadow',
                'selector' => '{{WRAPPER}} .sitsel-slide-content',
            ]
        );

        $this->end_controls_section();
    }

    private function register_style_subheading() {
        $this->start_controls_section(
            'style_subheading',
            [
                'label' => __( 'Sub Heading', 'softech-addons-for-elementor' ),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'subheading_color',
            [
                'label'     => __( 'Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '#000',
                'selectors' => [ '{{WRAPPER}} .sitsel-slide-subheading' => 'color: {{VALUE}};' ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [ 'name' => 'subheading_typography', 'selector' => '{{WRAPPER}} .sitsel-slide-subheading' ]
        );

        $this->add_group_control(
            Group_Control_Text_Shadow::get_type(),
            [ 'name' => 'subheading_text_shadow', 'selector' => '{{WRAPPER}} .sitsel-slide-subheading' ]
        );

        $this->add_responsive_control(
            'subheading_spacing',
            [
                'label'      => __( 'Bottom Spacing', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'vh', 'custom' ],
                'default'    => [ 'size' => 12 ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slide-subheading' => 'margin-bottom: {{SIZE}}{{UNIT}};' ],
            ]
        );

        $this->add_control(
            'subheading_border_bottom',
            [
                'label'        => __( 'Show Decorator Line', 'softech-addons-for-elementor' ),
                'type'         => Controls_Manager::SWITCHER,
                'return_value' => 'yes',
                'default'      => '',
            ]
        );

        $this->add_control(
            'subheading_decorator_color',
            [
                'label'     => __( 'Decorator Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '#e74c3c',
                'selectors' => [
                    '{{WRAPPER}} .sitsel-slide-subheading' => 'border-bottom: 2px solid {{VALUE}}; display: inline-block; padding-bottom: 4px;',
                ],
                'condition' => [ 'subheading_border_bottom' => 'yes' ],
            ]
        );

        $this->end_controls_section();
    }

    private function register_style_title() {
        $this->start_controls_section(
            'style_title',
            [
                'label' => __( 'Title', 'softech-addons-for-elementor' ),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'title_color',
            [
                'label'     => __( 'Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '#4f46e5',
                'selectors' => [ '{{WRAPPER}} .sitsel-slide-title' => 'color: {{VALUE}};' ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [ 'name' => 'title_typography', 'selector' => '{{WRAPPER}} .sitsel-slide-title' ]
        );

        $this->add_group_control(
            Group_Control_Text_Shadow::get_type(),
            [ 'name' => 'title_text_shadow', 'selector' => '{{WRAPPER}} .sitsel-slide-title' ]
        );

        $this->add_responsive_control(
            'title_spacing',
            [
                'label'      => __( 'Bottom Spacing', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'vh', 'custom' ],
                'default'    => [ 'size' => 16 ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slide-title' => 'margin-bottom: {{SIZE}}{{UNIT}};' ],
            ]
        );

        $this->end_controls_section();
    }

    private function register_style_slide_link() {
        $this->start_controls_section(
            'style_slide_link',
            [
                'label' => __( 'Slide Link', 'softech-addons-for-elementor' ),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'slide_link_note',
            [
                'type'            => Controls_Manager::RAW_HTML,
                'raw'             => __( 'Controls the link color applied via the <strong>Slide Link</strong> field in each slide. Only visible when a slide link URL is set.', 'softech-addons-for-elementor' ),
                'content_classes' => 'elementor-descriptor',
            ]
        );

        $this->start_controls_tabs( 'slide_link_tabs' );

        $this->start_controls_tab(
            'slide_link_tab_normal',
            [ 'label' => __( 'Normal', 'softech-addons-for-elementor' ) ]
        );

        $this->add_control(
            'slide_link_color',
            [
                'label'     => __( 'Link Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sitsel-slide-title a.sitsel-slide-link'       => 'color: {{VALUE}} !important;',
                    '{{WRAPPER}} .sitsel-slide-image-wrap a.sitsel-slide-link'  => 'color: {{VALUE}} !important;',
                ],
            ]
        );

        $this->end_controls_tab();

        $this->start_controls_tab(
            'slide_link_tab_hover',
            [ 'label' => __( 'Hover', 'softech-addons-for-elementor' ) ]
        );

        $this->add_control(
            'slide_link_hover_color',
            [
                'label'     => __( 'Link Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sitsel-slide-title a.sitsel-slide-link:hover'      => 'color: {{VALUE}} !important;',
                    '{{WRAPPER}} .sitsel-slide-image-wrap a.sitsel-slide-link:hover' => 'color: {{VALUE}} !important;',
                ],
            ]
        );

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

        $this->end_controls_section();
    }

    private function register_style_paragraph() {
        $this->start_controls_section(
            'style_paragraph',
            [
                'label' => __( 'Paragraph', 'softech-addons-for-elementor' ),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'paragraph_color',
            [
                'label'     => __( 'Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '#000',
                'selectors' => [ 
    '{{WRAPPER}} .sitsel-slide-paragraph' => 'color: {{VALUE}};',
    '{{WRAPPER}} .sitsel-slide-paragraph *' => 'color: {{VALUE}} !important;',
    '{{WRAPPER}} .sitsel-slide-paragraph a' => 'color: {{VALUE}} !important;',
],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [ 'name' => 'paragraph_typography', 'selector' => '{{WRAPPER}} .sitsel-slide-paragraph' ]
        );

        $this->add_responsive_control(
            'paragraph_spacing',
            [
                'label'      => __( 'Bottom Spacing', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'vh', 'custom' ],
                'default'    => [ 'size' => 24 ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slide-paragraph' => 'margin-bottom: {{SIZE}}{{UNIT}};' ],
            ]
        );

        $this->end_controls_section();
    }

    private function register_style_button() {
        $this->start_controls_section(
            'style_button',
            [
                'label' => __( 'Button', 'softech-addons-for-elementor' ),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'btn_heading_primary',
            [ 'label' => __( 'Primary Button', 'softech-addons-for-elementor' ), 'type' => Controls_Manager::HEADING ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [ 'name' => 'button_typography', 'selector' => '{{WRAPPER}} .sitsel-slide-btn' ]
        );

        $this->start_controls_tabs( 'btn_tabs_normal_hover' );

        $this->start_controls_tab( 'btn_tab_normal', [ 'label' => __( 'Normal', 'softech-addons-for-elementor' ) ] );

        $this->add_control(
            'btn_text_color',
            [
                'label'     => __( 'Text Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '#000',
                'selectors' => [ '{{WRAPPER}} .sitsel-slide-btn' => 'color: {{VALUE}};' ],
            ]
        );

        $this->add_group_control(
            Group_Control_Background::get_type(),
            [ 'name' => 'btn_bg_normal', 'types' => [ 'classic', 'gradient' ], 'selector' => '{{WRAPPER}} .sitsel-slide-btn' ]
        );

        $this->add_group_control(
            Group_Control_Border::get_type(),
            [
                'name'           => 'btn_border',
                'selector'       => '{{WRAPPER}} .sitsel-slide-btn',
                'fields_options' => [
                    'border' => [ 'default' => 'solid' ],
                    'width'  => [ 'default' => [ 'top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1, 'isLinked' => true ] ],
                    'color'  => [ 'default' => '#000' ],
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Box_Shadow::get_type(),
            [ 'name' => 'btn_box_shadow', 'selector' => '{{WRAPPER}} .sitsel-slide-btn' ]
        );

        $this->end_controls_tab();

        $this->start_controls_tab( 'btn_tab_hover', [ 'label' => __( 'Hover', 'softech-addons-for-elementor' ) ] );

        $this->add_control(
            'btn_text_hover_color',
            [
                'label'     => __( 'Text Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [ '{{WRAPPER}} .sitsel-slide-btn:hover' => 'color: {{VALUE}};' ],
            ]
        );

        $this->add_group_control(
            Group_Control_Background::get_type(),
            [ 'name' => 'btn_bg_hover', 'types' => [ 'classic', 'gradient' ], 'selector' => '{{WRAPPER}} .sitsel-slide-btn:hover' ]
        );

        $this->add_control(
            'btn_border_hover_color',
            [
                'label'     => __( 'Border Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [ '{{WRAPPER}} .sitsel-slide-btn:hover' => 'border-color: {{VALUE}};' ],
            ]
        );

        $this->add_control(
            'btn_transition',
            [
                'label'     => __( 'Transition Duration (s)', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::SLIDER,
                'range'     => [ 'px' => [ 'min' => 0, 'max' => 3, 'step' => 0.1 ] ],
                'default'   => [ 'size' => 0.3 ],
                'selectors' => [ '{{WRAPPER}} .sitsel-slide-btn' => 'transition: all {{SIZE}}s ease;' ],
            ]
        );

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

        $this->add_responsive_control(
            'btn_padding',
            [
                'label'      => __( 'Padding', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
                'default'    => [ 'top' => 12, 'right' => 28, 'bottom' => 12, 'left' => 28, 'unit' => 'px' ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slide-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ],
                'separator'  => 'before',
            ]
        );

        $this->add_responsive_control(
            'btn_border_radius',
            [
                'label'      => __( 'Border Radius', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
                'default'    => [ 'top' => 4, 'right' => 4, 'bottom' => 4, 'left' => 4, 'unit' => 'px' ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slide-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ],
            ]
        );

        $this->add_responsive_control(
            'btn_gap',
            [
                'label'      => __( 'Gap Between Buttons', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'custom' ],
                'default'    => [ 'size' => 12 ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slide-btn-group' => 'gap: {{SIZE}}{{UNIT}};' ],
            ]
        );

        $this->add_control(
            'btn_icon_heading',
            [ 'label' => __( 'Button Icon', 'softech-addons-for-elementor' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before' ]
        );

        $this->add_responsive_control(
            'btn_icon_size',
            [
                'label'      => __( 'Icon Size', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ],
                'default'    => [ 'size' => 16, 'unit' => 'px' ],
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-slide-btn i'   => 'font-size: {{SIZE}}{{UNIT}};',
                    '{{WRAPPER}} .sitsel-slide-btn svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
                ],
            ]
        );

        $this->add_control(
            'btn_icon_color',
            [
                'label'     => __( 'Icon Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sitsel-slide-btn i'   => 'color: {{VALUE}};',
                    '{{WRAPPER}} .sitsel-slide-btn svg' => 'fill: {{VALUE}};',
                ],
            ]
        );

        $this->add_control(
            'btn_icon_hover_color',
            [
                'label'     => __( 'Icon Hover Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sitsel-slide-btn:hover i'   => 'color: {{VALUE}};',
                    '{{WRAPPER}} .sitsel-slide-btn:hover svg' => 'fill: {{VALUE}};',
                ],
            ]
        );

        $this->add_responsive_control(
            'btn_icon_gap',
            [
                'label'      => __( 'Icon Gap', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'custom' ],
                'default'    => [ 'size' => 8 ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slide-btn' => 'gap: {{SIZE}}{{UNIT}};' ],
            ]
        );

        // Secondary Button
        $this->add_control(
            'btn_heading_secondary',
            [ 'label' => __( 'Secondary Button', 'softech-addons-for-elementor' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before' ]
        );

        $this->add_control(
            'btn2_text_color',
            [
                'label'     => __( 'Text Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '#000',
                'selectors' => [ '{{WRAPPER}} .sitsel-slide-btn-secondary' => 'color: {{VALUE}};' ],
            ]
        );

        $this->add_group_control(
            Group_Control_Background::get_type(),
            [ 'name' => 'btn2_bg', 'types' => [ 'classic', 'gradient' ], 'selector' => '{{WRAPPER}} .sitsel-slide-btn-secondary' ]
        );

        $this->add_group_control(
            Group_Control_Border::get_type(),
            [ 'name' => 'btn2_border', 'selector' => '{{WRAPPER}} .sitsel-slide-btn-secondary' ]
        );

        $this->add_responsive_control(
            'btn2_border_radius',
            [
                'label'      => __( 'Border Radius', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
                'default'    => [ 'top' => 4, 'right' => 4, 'bottom' => 4, 'left' => 4, 'unit' => 'px' ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slide-btn-secondary' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ],
            ]
        );

        $this->end_controls_section();
    }

    private function register_style_navigation() {
        $this->start_controls_section(
            'style_navigation',
            [
                'label'     => __( 'Navigation Arrows', 'softech-addons-for-elementor' ),
                'tab'       => Controls_Manager::TAB_STYLE,
                'condition' => [ 'show_arrows' => 'yes' ],
            ]
        );

        $this->add_responsive_control(
            'arrow_size',
            [
                'label'      => __( 'Arrow Size', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'custom' ],
                'default'    => [ 'size' => 18 ],
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-slider-arrow i, {{WRAPPER}} .sitsel-slider-arrow svg' => 'font-size: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
                ],
            ]
        );

        $this->add_responsive_control(
            'arrow_btn_size',
            [
                'label'      => __( 'Button Size', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'custom' ],
                'range'      => [ 'px' => [ 'min' => 20, 'max' => 100 ] ],
                'default'    => [ 'size' => 48 ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slider-arrow' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};' ],
            ]
        );

        $this->start_controls_tabs( 'arrow_tabs' );

        $this->start_controls_tab( 'arrow_tab_normal', [ 'label' => __( 'Normal', 'softech-addons-for-elementor' ) ] );

        $this->add_control(
            'arrow_color',
            [
                'label'     => __( 'Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '#000',
                'selectors' => [ '{{WRAPPER}} .sitsel-slider-arrow' => 'color: {{VALUE}};' ],
            ]
        );

        $this->add_control(
            'arrow_bg_color',
            [
                'label'     => __( 'Background', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => 'rgb(255 255 255)',
                'selectors' => [ '{{WRAPPER}} .sitsel-slider-arrow' => 'background-color: {{VALUE}};' ],
            ]
        );

        $this->end_controls_tab();

        $this->start_controls_tab( 'arrow_tab_hover', [ 'label' => __( 'Hover', 'softech-addons-for-elementor' ) ] );

        $this->add_control(
            'arrow_hover_color',
            [
                'label'     => __( 'Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '#fff',
                'selectors' => [ '{{WRAPPER}} .sitsel-slider-arrow:hover' => 'color: {{VALUE}};' ],
            ]
        );

        $this->add_control(
            'arrow_hover_bg_color',
            [
                'label'     => __( 'Background', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '#0f3d4a',
                'selectors' => [ '{{WRAPPER}} .sitsel-slider-arrow:hover' => 'background-color: {{VALUE}};' ],
            ]
        );
        $this->add_control(
            'arrow_border_hover_color',
            [
                'label'     => __( 'Border Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [ '{{WRAPPER}} .sitsel-slider-arrow:hover' => 'border-color: {{VALUE}};' ],
            ]
        );

        $this->end_controls_tab();
        $this->end_controls_tabs();
        $this->add_group_control(
            Group_Control_Border::get_type(),
            [
                'name'           => 'arrow_border',
                'selector'       => '{{WRAPPER}} .sitsel-slider-arrow',
                'separator'      => 'before',
                'fields_options' => [
                    'border' => [ 'default' => 'solid' ],
                    'width'  => [ 'default' => [ 'top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1, 'isLinked' => true ] ],
                    'color'  => [ 'default' => '#000' ],
                ],
            ]
        );
        $this->add_responsive_control(
            'arrow_border_radius',
            [
                'label'      => __( 'Border Radius', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
                'default'    => [ 'top' => 50, 'right' => 50, 'bottom' => 50, 'left' => 50, 'unit' => '%' ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slider-arrow' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ],
                'separator'  => 'before',
            ]
        );

		$this->add_responsive_control(
    'arrow_padding',
    [
        'label'      => __( 'Padding', 'softech-addons-for-elementor' ),
        'type'       => Controls_Manager::DIMENSIONS,
        'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
        'selectors'  => [
            '{{WRAPPER}} .sitsel-slider-arrow' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);
        $this->add_responsive_control(
            'arrow_offset_horizontal',
            [
                'label'      => __( 'Horizontal Offset', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],				
                'default'    => [ 'size' => 0, 'unit' => 'px' ],
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-slider-prev' => 'left: {{SIZE}}{{UNIT}};',
                    '{{WRAPPER}} .sitsel-slider-next' => 'right: {{SIZE}}{{UNIT}};',
                ],
            ]
        );

        $this->add_responsive_control(
            'arrow_vertical_position',
            [
                'label'          => __( 'Vertical Position', 'softech-addons-for-elementor' ),
                'type'           => Controls_Manager::CHOOSE,
                'options'        => [
                    'top'    => [ 'title' => __( 'Top', 'softech-addons-for-elementor' ),    'icon' => 'eicon-v-align-top' ],
                    'center' => [ 'title' => __( 'Center', 'softech-addons-for-elementor' ), 'icon' => 'eicon-v-align-middle' ],
                    'bottom' => [ 'title' => __( 'Bottom', 'softech-addons-for-elementor' ), 'icon' => 'eicon-v-align-bottom' ],
                ],
                'default'        => 'center',
                'tablet_default' => 'center',
                'mobile_default' => 'bottom',
            ]
        );

        $this->add_control(
            'arrow_group_position',
            [
                'label'   => __( 'Arrow Group Position', 'softech-addons-for-elementor' ),
                'type'    => Controls_Manager::CHOOSE,
                'options' => [
                    'left'    => [ 'title' => __( 'Both Left',     'softech-addons-for-elementor' ), 'icon' => 'eicon-h-align-left' ],
                    'center'  => [ 'title' => __( 'Both Center',   'softech-addons-for-elementor' ), 'icon' => 'eicon-h-align-center' ],
                    'right'   => [ 'title' => __( 'Both Right',    'softech-addons-for-elementor' ), 'icon' => 'eicon-h-align-right' ],
                    'between' => [ 'title' => __( 'Space Between', 'softech-addons-for-elementor' ), 'icon' => 'eicon-h-align-stretch' ],
                ],
                'default'   => 'between',
                'toggle'    => false,
                'separator' => 'before',
            ]
        );

        $this->add_responsive_control(
            'arrow_group_offset',
            [
                'label'      => __( 'Group Offset', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
                'default'    => [ 'size' => 15, 'unit' => 'px' ],
                'condition'  => [ 'arrow_group_position!' => 'between' ],
                // FIND the arrow_group_offset selectors and REPLACE with:
                'selectors' => [
                    '{{WRAPPER}} .sitsel-slider-layout-arrows-left  .sitsel-slider-prev' => 'left: {{SIZE}}{{UNIT}};',
                    '{{WRAPPER}} .sitsel-slider-layout-arrows-left  .sitsel-slider-next' => 'left: calc({{SIZE}}{{UNIT}} + 48px + 8px);',
                    '{{WRAPPER}} .sitsel-slider-layout-arrows-right .sitsel-slider-next' => 'right: {{SIZE}}{{UNIT}};',
                    '{{WRAPPER}} .sitsel-slider-layout-arrows-right .sitsel-slider-prev' => 'right: calc({{SIZE}}{{UNIT}} + 48px + 8px);',
                    '{{WRAPPER}} .sitsel-slider-layout-arrows-center .sitsel-slider-prev' => 'left: calc(50% - 48px - 4px);',
                    '{{WRAPPER}} .sitsel-slider-layout-arrows-center .sitsel-slider-next' => 'left: calc(50% + 4px);',
                ],
            ]
        );

        $this->add_responsive_control(
            'arrow_offset_vertical',
            [
                'label'      => __( 'Vertical Offset', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
                'range'      => [ 'px' => [ 'min' => -200, 'max' => 200 ] ],
                'default'    => [ 'size' => 50, 'unit' => '%' ],
                'selectors'  => [
                    '{{WRAPPER}} .sitsel-slider-arrow' => 'top: {{SIZE}}{{UNIT}}; ',
                    
                ],
                'condition' => [ 'arrow_vertical_position' => 'center' ],
            ]
        );

        $this->end_controls_section();
    }

    private function register_style_dots() {
        $this->start_controls_section(
            'style_dots',
            [
                'label'     => __( 'Dots', 'softech-addons-for-elementor' ),
                'tab'       => Controls_Manager::TAB_STYLE,
                'condition' => [ 'show_dots' => 'yes' ],
            ]
        );

        $this->add_responsive_control(
            'dot_size',
            [
                'label'      => __( 'Size', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'custom' ],
                'default'    => [ 'size' => 10, 'unit' => 'px' ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slider-dot' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};' ],
            ]
        );

        $this->add_control(
            'dot_color',
            [
                'label'     => __( 'Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => 'rgba(126, 119, 119, 0.5)',
                'selectors' => [ '{{WRAPPER}} .sitsel-slider-dot' => 'background-color: {{VALUE}};' ],
            ]
        );

        $this->add_control(
            'dot_active_color',
            [
                'label'     => __( 'Active Color', 'softech-addons-for-elementor' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '#4f46e5',
                'selectors' => [ '{{WRAPPER}} .sitsel-slider-dot.sitsel-active' => 'background-color: {{VALUE}};' ],
            ]
        );

        $this->add_responsive_control(
            'dot_active_width',
            [
                'label'      => __( 'Active Width', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'custom' ],
                'default'    => [ 'size' => 28, 'unit' => 'px' ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slider-dot.sitsel-active' => 'width: {{SIZE}}{{UNIT}};' ],
            ]
        );

        $this->add_responsive_control(
            'dot_border_radius',
            [
                'label'      => __( 'Border Radius', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slider-dot' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ],
            ]
        );

        $this->add_responsive_control(
            'dots_gap',
            [
                'label'      => __( 'Gap Between Dots', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', 'em', 'rem', 'custom' ],
                'default'    => [ 'size' => 6, 'unit' => 'px' ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slider-dots' => 'gap: {{SIZE}}{{UNIT}};' ],
            ]
        );

        $this->add_responsive_control(
            'dots_offset',
            [
                'label'      => __( 'Bottom Offset', 'softech-addons-for-elementor' ),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ],
                'default'    => [ 'size' => 20, 'unit' => 'px' ],
                'selectors'  => [ '{{WRAPPER}} .sitsel-slider-dots' => 'bottom: {{SIZE}}{{UNIT}};' ],
            ]
        );

        $this->end_controls_section();
    }
    
   private function register_style_scrollbar() {

    $this->start_controls_section(
        'style_scrollbar',
        [
            'label'     => __( 'Scrollbar', 'softech-addons-for-elementor' ),
            'tab'       => Controls_Manager::TAB_STYLE,
            'condition' => [ 'show_scrollbar' => 'yes' ],
        ]
    );

    $this->add_control(
        'scrollbar_color',
        [
            'label'     => __( 'Track Color', 'softech-addons-for-elementor' ),
            'type'      => Controls_Manager::COLOR,
            'default'   => 'rgba(0,0,0,0.1)',
            'selectors' => [
                '{{WRAPPER}} .sitsel-slider-scrollbar:before' => 'background: {{VALUE}};',
            ],
        ]
    );

    $this->add_control(
        'scrollbar_drag_color',
        [
            'label'     => __( 'Drag Color', 'softech-addons-for-elementor' ),
            'type'      => Controls_Manager::COLOR,
            'default'   => '#4f46e5',
            'selectors' => [
                '{{WRAPPER}} .sitsel-slider-scrollbar .swiper-scrollbar-drag' => 'background: {{VALUE}};',
            ],
        ]
    );

    // TRACK HEIGHT
    $this->add_responsive_control(
        'scrollbar_track_height',
        [
            'label'      => __( 'Track Height', 'softech-addons-for-elementor' ),
            'type'       => Controls_Manager::SLIDER,
            'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
            'default'    => [
                'size' => 4,
                'unit' => 'px',
            ],
            'selectors'  => [
                '{{WRAPPER}} .sitsel-slider-scrollbar:before' => 'height: {{SIZE}}{{UNIT}};',
            ],
        ]
    );

    // DRAG HEIGHT
    $this->add_responsive_control(
        'scrollbar_drag_height',
        [
            'label'      => __( 'Drag Height', 'softech-addons-for-elementor' ),
            'type'       => Controls_Manager::SLIDER,
            'size_units' =>[ 'px', '%', 'em', 'rem', 'custom' ],
            'default'    => [
                'size' => 4,
                'unit' => 'px',
            ],
            'selectors'  => [
                '{{WRAPPER}} .sitsel-slider-scrollbar .swiper-scrollbar-drag' => 'height: {{SIZE}}{{UNIT}};',
            ],
        ]
    );

    $this->add_responsive_control(
        'scrollbar_margin_top',
        [
            'label'      => __( 'Top Spacing', 'softech-addons-for-elementor' ),
            'type'       => Controls_Manager::SLIDER,
            'size_units' =>[ 'px', '%', 'em', 'rem', 'custom' ],
            'default'    => [
                'size' => 16,
                'unit' => 'px',
            ],
            'selectors'  => [
                '{{WRAPPER}} .sitsel-slider-scrollbar' => 'margin-top: {{SIZE}}{{UNIT}};',
            ],
        ]
    );
	  
	   $this->add_responsive_control(
    'scrollbar_width',
    [
        'label'      => __( 'Width', 'softech-addons-for-elementor' ),
        'type'       => Controls_Manager::SLIDER,
        'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
        'default'    => [ 'size' => 100, 'unit' => '%' ],
        'selectors'  => [
            '{{WRAPPER}} .sitsel-slider-scrollbar-wrapper' => 'width: {{SIZE}}{{UNIT}};',
        ],
    ]
);

    $this->add_responsive_control(
        'scrollbar_border_radius',
        [
            'label'      => __( 'Border Radius', 'softech-addons-for-elementor' ),
            'type'       => Controls_Manager::DIMENSIONS,
            'size_units' => [ 'px', '%', 'em', 'rem' ],
            'selectors'  => [
                '{{WRAPPER}} .sitsel-slider-scrollbar:before' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                '{{WRAPPER}} .sitsel-slider-scrollbar .swiper-scrollbar-drag' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
            ],
        ]
    );
	   
	    $this->add_control(
    'scrollbar_position',
    [
        'label'   => __( 'Position', 'softech-addons-for-elementor' ),
        'type'    => Controls_Manager::SELECT,
        'default' => 'outer',
        'options' => [
            'outer' => __( 'Outer (Below Slider)', 'softech-addons-for-elementor' ),
            'inner' => __( 'Inner (Inside Slider)', 'softech-addons-for-elementor' ),
        ],
    ]
);
	   // ── Outer absolute positioning controls ──────────────────────────────

$this->add_control(
    'scrollbar_outer_pos_heading',
    [
        'label'     => __( 'Scrollbar Position', 'softech-addons-for-elementor' ),
        'type'      => Controls_Manager::HEADING,
        'separator' => 'before',
        'condition' => [ 'scrollbar_position' => 'outer' ],
    ]
);

$this->add_control(
    'scrollbar_h_orient',
    [
        'label'   => __( 'Horizontal Orientation', 'softech-addons-for-elementor' ),
        'type'    => Controls_Manager::CHOOSE,
        'options' => [
            'left'  => [ 'title' => __( 'Left',  'softech-addons-for-elementor' ), 'icon' => 'eicon-h-align-left' ],
            'right' => [ 'title' => __( 'Right', 'softech-addons-for-elementor' ), 'icon' => 'eicon-h-align-right' ],
        ],
        'default'   => 'left',
        'toggle'    => false,
        'condition' => [ 'scrollbar_position' => 'outer' ],
    ]
);

$this->add_responsive_control(
    'scrollbar_offset_h',
    [
        'label'      => __( 'Offset', 'softech-addons-for-elementor' ),
        'type'       => Controls_Manager::SLIDER,
        'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
        'default'    => [ 'size' => 0, 'unit' => 'px' ],
        'selectors'  => [
            '{{WRAPPER}} .sitsel-scrollbar-outer' => 'left: {{SIZE}}{{UNIT}};',
        ],
        'condition'  => [ 'scrollbar_position' => 'outer', 'scrollbar_h_orient' => 'left' ],
    ]
);

$this->add_responsive_control(
    'scrollbar_offset_h_right',
    [
        'label'      => __( 'Offset', 'softech-addons-for-elementor' ),
        'type'       => Controls_Manager::SLIDER,
        'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
        'default'    => [ 'size' => 0, 'unit' => 'px' ],
        'selectors'  => [
            '{{WRAPPER}} .sitsel-scrollbar-outer' => 'right: {{SIZE}}{{UNIT}}; left: auto;',
        ],
        'condition'  => [ 'scrollbar_position' => 'outer', 'scrollbar_h_orient' => 'right' ],
    ]
);

$this->add_control(
    'scrollbar_v_orient',
    [
        'label'   => __( 'Vertical Orientation', 'softech-addons-for-elementor' ),
        'type'    => Controls_Manager::CHOOSE,
        'options' => [
            'top'    => [ 'title' => __( 'Top',    'softech-addons-for-elementor' ), 'icon' => 'eicon-v-align-top' ],
            'bottom' => [ 'title' => __( 'Bottom', 'softech-addons-for-elementor' ), 'icon' => 'eicon-v-align-bottom' ],
        ],
        'default'   => 'bottom',
        'toggle'    => false,
        'condition' => [ 'scrollbar_position' => 'outer' ],
    ]
);

$this->add_responsive_control(
    'scrollbar_offset_top',
    [
        'label'      => __( 'Offset', 'softech-addons-for-elementor' ),
        'type'       => Controls_Manager::SLIDER,
        'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
        'default'    => [ 'size' => 0, 'unit' => 'px' ],
        'selectors'  => [
            '{{WRAPPER}} .sitsel-scrollbar-outer' => 'position: absolute; top: {{SIZE}}{{UNIT}}; bottom: auto;',
        ],
        'condition'  => [ 'scrollbar_position' => 'outer', 'scrollbar_v_orient' => 'top' ],
    ]
);

$this->add_responsive_control(
    'scrollbar_offset_bottom',
    [
        'label'      => __( 'Offset', 'softech-addons-for-elementor' ),
        'type'       => Controls_Manager::SLIDER,
        'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
        'default'    => [ 'size' => 0, 'unit' => 'px' ],
        'selectors'  => [
            '{{WRAPPER}} .sitsel-scrollbar-outer' => 'position: absolute; bottom: {{SIZE}}{{UNIT}}; top: auto;',
        ],
        'condition'  => [ 'scrollbar_position' => 'outer', 'scrollbar_v_orient' => 'bottom' ],
    ]
);
	   
	  
    $this->end_controls_section();

}

    // ─── Render ────────────────────────────────────────────────────────────────

    protected function render() {
    $settings = $this->get_settings_for_display();
    $source   = $settings['slides_source'] ?? 'static';
    $slides   = 'dynamic' === $source ? $this->build_dynamic_slides($settings) : ($settings['slides'] ?? []);

    if (empty($slides)) {
        echo '<div class="sitsel-no-slides">' . esc_html__('No slides found.', 'softech-addons-for-elementor') . '</div>';
        return;
    }
    $layout = $settings['layout'] ?? 'card';
    $show_arrows    = 'yes' === ($settings['show_arrows'] ?? '');
    $show_dots      = 'yes' === ($settings['show_dots'] ?? '');
    $autoplay       = 'yes' === ($settings['autoplay'] ?? '');
    $autoplay_speed = intval($settings['autoplay_speed'] ?? 4000);
    $speed          = intval($settings['transition_speed'] ?? 700);
    $loop           = 'yes' === ($settings['loop'] ?? '');
    $pause_on_hover = 'yes' === ($settings['pause_on_hover'] ?? '');
    $widget_id      = $this->get_id();
    $show_scrollbar = 'yes' === ($settings['show_scrollbar'] ?? '');
    
    

    $slider_data = wp_json_encode([
        'autoplay'            => $autoplay,
        'autoplaySpeed'       => $autoplay_speed,
        'transitionSpeed'     => $speed,
        'loop'                => $loop,
        'pauseOnHover'        => $pause_on_hover,
        'slidesPerView'       => $settings['slides_per_view']        ?? 1,
        'slidesPerViewTablet' => $settings['slides_per_view_tablet'] ?? 1,
        'slidesPerViewMobile' => $settings['slides_per_view_mobile'] ?? 1,
        'spaceBetween'        => $settings['slides_space_between']['size']        ?? 20,
        'spaceBetweenUnit'    => $settings['slides_space_between']['unit']        ?? 'px',
        'spaceBetweenTablet'  => $settings['slides_space_between_tablet']['size'] ?? 20,
        'spaceBetweenTabletUnit' => $settings['slides_space_between_tablet']['unit'] ?? 'px',
        'spaceBetweenMobile'  => $settings['slides_space_between_mobile']['size'] ?? 20,
        'spaceBetweenMobileUnit' => $settings['slides_space_between_mobile']['unit'] ?? 'px',
        'centeredSlides'      => 'yes' === ($settings['centered_slides'] ?? ''),
        'showScrollbar' => 'yes' === ($settings['show_scrollbar'] ?? ''),
    ]);
    ?>

   <?php
        $arrow_group_pos  = $settings['arrow_group_position'] ?? 'between';
        $wrapper_classes  = implode( ' ', array_filter( [
            'sitsel-hero-slider',
            'swiper',
            $show_arrows ? 'sitsel-slider-layout-arrows-' . esc_attr( $arrow_group_pos ) : '',
        ] ) );
        ?>
        <div class="<?php echo esc_attr( $wrapper_classes ); ?>"
             id="sitsel-hero-slider-<?php echo esc_attr($widget_id); ?>"
             data-slider='<?php echo esc_attr($slider_data); ?>'>

        <div class="sitsel-slides-track swiper-wrapper">
           <?php foreach ($slides as $index => $slide) :
            $overlay_style = '';
            if ( ! empty( $slide['overlay_color'] ) ) {
                $overlay_style = 'style="background-color:' . esc_attr( $slide['overlay_color'] ) . ';"';
            }
        ?>
            <div class="sitsel-slide swiper-slide sitsel-slide-layout-<?php echo esc_attr( $layout ); ?>">
        
                <?php if ( 'split' === $layout ) : ?>
        
                    <div class="sitsel-slide-inner sitsel-split-<?php echo esc_attr( $settings['split_image_position'] ?? 'left' ); ?>">
                        <div class="sitsel-slide-image-wrap">
                            <?php $this->render_slide_image( $slide ); ?>
                        </div>
                        <div class="sitsel-slide-content-wrap">
                            <?php $this->render_slide_content( $slide, $settings ); ?>
                        </div>
                    </div>
        
                <?php elseif ( 'overlay' === $layout ) : ?>
        
                    <div class="sitsel-slide-inner">
                        <div class="sitsel-slide-image-wrap">
                            <?php $this->render_slide_image( $slide ); ?>
                            <div class="sitsel-slide-overlay" <?php echo $overlay_style; // phpcs:ignore ?>></div>
                        </div>
                        <div class="sitsel-slide-content-wrap">
                            <?php $this->render_slide_content( $slide, $settings ); ?>
                        </div>
                    </div>
        
                <?php else : // card ?>
        
                    <div class="sitsel-slide-inner">
                        <div class="sitsel-slide-image-wrap">
                            <?php $this->render_slide_image( $slide ); ?>
                        </div>
                        <div class="sitsel-slide-content-wrap">
                            <?php $this->render_slide_content( $slide, $settings ); ?>
                        </div>
                    </div>
        
                <?php endif; ?>
        
            </div>
        <?php endforeach; ?>
        </div>

       <?php if ($show_arrows) :
    $arrow_v_pos   = $settings['arrow_vertical_position'] ?? 'center';
    $arrow_v_class = ( 'center' !== $arrow_v_pos ) ? ' sitsel-arrow-' . esc_attr( $arrow_v_pos ) : '';
?>
    <button class="sitsel-slider-arrow sitsel-slider-prev swiper-button-prev<?php echo esc_attr( $arrow_v_class ); ?>" aria-label="<?php esc_attr_e('Previous', 'softech-addons-for-elementor'); ?>">
        <?php \Elementor\Icons_Manager::render_icon($settings['prev_icon'], ['aria-hidden' => 'true']); ?>
    </button>
    <button class="sitsel-slider-arrow sitsel-slider-next swiper-button-next<?php echo esc_attr( $arrow_v_class ); ?>" aria-label="<?php esc_attr_e('Next', 'softech-addons-for-elementor'); ?>">
        <?php \Elementor\Icons_Manager::render_icon($settings['next_icon'], ['aria-hidden' => 'true']); ?>
    </button>
<?php endif; ?>

        <?php if ($show_dots) : ?>
            <div class="sitsel-slider-dots swiper-pagination"></div>
        <?php endif; ?>
        <?php if ( $show_scrollbar && 'inner' === ( $settings['scrollbar_position'] ?? 'outer' ) ) : ?>
            <div class="sitsel-slider-scrollbar-wrapper sitsel-scrollbar-inner">
                <div class="sitsel-slider-scrollbar swiper-scrollbar"></div>
            </div>
        <?php endif; ?>

    </div>

 <?php if ( $show_scrollbar && 'outer' === ( $settings['scrollbar_position'] ?? 'outer' ) ) : ?>
        <div class="sitsel-slider-scrollbar-wrapper sitsel-scrollbar-outer">
            <div class="sitsel-slider-scrollbar swiper-scrollbar"></div>
        </div>
    <?php endif; ?>

    <?php
}

    // ─── Dynamic slides builder ────────────────────────────────────────────────

    /**
     * Query posts using Post Query Manager and map each post's fields
     * to the normalised slide array that render_slide_content() expects.
     *
     * @param  array $settings Widget settings.
     * @return array           Array of slide arrays (same shape as the static repeater).
     */
    private function build_dynamic_slides( array $settings ): array {

        $paged      = Softech_Post_Query_Manager::get_paged();
        $query_args = Softech_Post_Query_Manager::build_query_args( $settings, $paged );

        // build_query_args() returns a taxonomy marker when the source type is a
        // taxonomy — hero slider only supports post types in dynamic mode.
        if ( isset( $query_args['_query_type'] ) && 'taxonomy' === $query_args['_query_type'] ) {
            return [];
        }

        $query = new \WP_Query( $query_args );

        if ( ! $query->have_posts() ) {
            wp_reset_postdata();
            return [];
        }

        $slides = [];

        while ( $query->have_posts() ) {
            $query->the_post();

            $post_id   = get_the_ID();
            $permalink = get_permalink( $post_id );

            // ── Image ───────────────────────────────────────────────────────
            $img_url = '';
            $img_src = $settings['dyn_image_source'] ?? 'featured';

            if ( 'featured' === $img_src ) {
                $img_url = get_the_post_thumbnail_url( $post_id, 'full' ) ?: '';
            } elseif ( 'acf_image' === $img_src && ! empty( $settings['dyn_image_field_key'] ) ) {
                $img_url = $this->get_dynamic_image_url( $settings['dyn_image_field_key'], $post_id );
            }

            // ── Sub Heading ─────────────────────────────────────────────────
            $subheading      = '';
            $show_subheading = ( 'yes' === ( $settings['dyn_show_subheading'] ?? 'yes' ) );

            if ( $show_subheading ) {
                $sub_src = $settings['dyn_subheading_source'] ?? 'category';

                if ( 'category' === $sub_src ) {
                    $cats = get_the_category( $post_id );
                    $subheading = ! empty( $cats ) ? $cats[0]->name : '';
                } elseif ( 'date' === $sub_src ) {
                    $fmt        = $settings['dyn_date_format'] ?? 'F j, Y';
                    $subheading = get_the_date( $fmt, $post_id );
                } elseif ( 'author' === $sub_src ) {
                    $subheading = get_the_author_meta( 'display_name', (int) get_post_field( 'post_author', $post_id ) );
                } elseif ( 'custom_field' === $sub_src && ! empty( $settings['dyn_subheading_field_key'] ) ) {
                    $subheading = (string) get_post_meta( $post_id, $settings['dyn_subheading_field_key'], true );
                } elseif ( 'custom_text' === $sub_src ) {
                    $subheading = $settings['dyn_subheading_fixed_text'] ?? '';
                }
            }

            // ── Title ───────────────────────────────────────────────────────
            $show_title = ( 'yes' === ( $settings['dyn_show_title'] ?? 'yes' ) );
            $title      = $show_title ? get_the_title( $post_id ) : '';
            $title_tag  = $settings['dyn_title_tag'] ?? 'h2';
            

            // ── Paragraph ───────────────────────────────────────────────────
            $paragraph      = '';
            $show_paragraph = ( 'yes' === ( $settings['dyn_show_paragraph'] ?? 'yes' ) );

            if ( $show_paragraph ) {
                $para_src    = $settings['dyn_paragraph_source'] ?? 'excerpt';
                $word_limit  = absint( $settings['dyn_excerpt_length'] ?? 20 );

                if ( 'excerpt' === $para_src ) {
                    $paragraph = has_excerpt( $post_id )
                        ? wp_trim_words( get_the_excerpt(), $word_limit )
                        : wp_trim_words( get_the_content( null, false, $post_id ), $word_limit );
                } elseif ( 'content' === $para_src ) {
                    $paragraph = wp_trim_words( get_the_content( null, false, $post_id ), $word_limit );
                } elseif ( 'custom_field' === $para_src && ! empty( $settings['dyn_paragraph_field_key'] ) ) {
                    $paragraph = (string) get_post_meta( $post_id, $settings['dyn_paragraph_field_key'], true );
                }
            }

            // ── Button ──────────────────────────────────────────────────────
            $show_button = ( 'yes' === ( $settings['dyn_show_button'] ?? 'yes' ) );
            $button_text = $settings['dyn_button_text'] ?? __( 'Read More', 'softech-addons-for-elementor' );
            $button_icon = $settings['dyn_button_icon'] ?? [];
            $icon_pos    = $settings['dyn_button_icon_position'] ?? 'after';

            // ── Assemble slide array (matches static repeater shape) ─────────
            $slides[] = [
                // Image
                'slide_image'           => [ 'url' => $img_url ],
                'image_link'            => ( 'yes' === ( $settings['dyn_image_link'] ?? '' ) ) ? $permalink : '',

                // Sub heading
                'show_subheading'       => $show_subheading ? 'yes' : '',
                'subheading'            => $subheading,
                'subheading_color'      => '',   // global style controls it

                // Title
                'show_title'            => $show_title ? 'yes' : '',
                'title'                 => $title,
                'title_tag'             => $title_tag,
                'title_link'            => ( 'yes' === ( $settings['dyn_title_link'] ?? 'yes' ) ) ? $permalink : '',

                'title_color'           => '',   // global style controls it

                // Paragraph
                'show_paragraph'        => $show_paragraph ? 'yes' : '',
                'paragraph'             => wp_kses_post( $paragraph ),
                'paragraph_color'       => '',   // global style controls it

                // Primary button — links to the post permalink
                'show_button'           => $show_button ? 'yes' : '',
                'button_text'           => $button_text,
                'button_link'           => [ 'url' => $permalink, 'is_external' => false, 'nofollow' => false ],
                'button_icon'           => $button_icon,
                'button_icon_position'  => $icon_pos,
                'button_bg_color'       => '',
                'button_text_color'     => '',

                // Secondary button — not used in dynamic mode
                'show_button_2'         => '',

                // Overlay — use global setting (no per-slide override in dynamic)
                'overlay_color'         => '',
            ];
        }

        wp_reset_postdata();
        return $slides;
    }

    /**
     * Retrieve an image URL from an ACF image field or plain meta key.
     * Handles both ACF array return type (url key) and plain URL string.
     *
     * @param string $field_key Meta / ACF field key.
     * @param int    $post_id   Post ID.
     * @return string           Image URL or empty string.
     */
    private function get_dynamic_image_url( string $field_key, int $post_id ): string {
        if ( function_exists( 'get_field' ) ) {
            $value = get_field( $field_key, $post_id );
            if ( is_array( $value ) && ! empty( $value['url'] ) ) {
                return $value['url'];
            }
            if ( is_string( $value ) && ! empty( $value ) ) {
                return $value;
            }
        }

        // Fallback: plain post meta
        $value = get_post_meta( $post_id, $field_key, true );
        if ( is_string( $value ) && ! empty( $value ) ) {
            return $value;
        }

        return '';
    }

    // ─── Shared render helpers (unchanged from original) ──────────────────────

    /**
     * Build anchor attributes from Elementor URL control value.
     */
    private function get_link_attrs( array $link ): string {
        $url    = esc_url( $link['url'] ?? '#' );
        $target = ! empty( $link['is_external'] ) ? '_blank' : '_self';
        $rel    = ! empty( $link['nofollow'] )    ? 'nofollow' : '';
        return sprintf( 'href="%s" target="%s" rel="%s"', $url, $target, $rel );
    }

    /**
     * Render a single slide's image tag.
     *
     * @param array $slide Slide data array.
     */
    private function render_slide_image( array $slide ): void {
        $img_url = $slide['slide_image']['url'] ?? '';
        if ( empty( $img_url ) ) {
            return;
        }
        $alt        = $slide['title'] ?? '';
        $image_link = $slide['image_link'] ?? '';

        // Slide-level link: apply on image only when link_apply_image === 'yes'
        $slide_link_url    = $slide['slide_link']['url'] ?? '';
        $apply_on_image    = 'yes' === ( $slide['link_apply_image'] ?? 'yes' );
        $slide_link_attrs  = ! empty( $slide_link_url ) ? $this->get_link_attrs( $slide['slide_link'] ) : '';

        $img_tag = '<img src="' . esc_url( $img_url ) . '" alt="' . esc_attr( $alt ) . '" loading="lazy" decoding="async" />';

        if ( ! empty( $slide_link_url ) && $apply_on_image ) {
            echo '<a ' . $slide_link_attrs . ' class="sitsel-slide-link">' . $img_tag . '</a>'; // phpcs:ignore
        } elseif ( ! empty( $image_link ) ) {
            echo '<a href="' . esc_url( $image_link ) . '">' . $img_tag . '</a>'; // phpcs:ignore
        } else {
            echo $img_tag; // phpcs:ignore
        }
    }

    /**
     * Render the content block of a single slide.
     * Works identically for both static and dynamic slides because dynamic
     * slides are normalised to the same array shape.
     *
     * @param array $slide    Slide data array.
     * @param array $settings Widget settings.
     */
    private function render_slide_content( array $slide, array $settings ): void {
        echo '<div class="sitsel-slide-content">';

        // ── Sub Heading
        if ( 'yes' === ( $slide['show_subheading'] ?? '' ) && ! empty( $slide['subheading'] ) ) {
            $sub_style = ! empty( $slide['subheading_color'] )
                ? 'style="color:' . esc_attr( $slide['subheading_color'] ) . ';"'
                : '';
            echo '<span class="sitsel-slide-subheading" ' . $sub_style . '>' // phpcs:ignore
               . esc_html( $slide['subheading'] )
               . '</span>';
        }

        // ── Title
        if ( 'yes' === ( $slide['show_title'] ?? '' ) && ! empty( $slide['title'] ) ) {
            $tag          = sanitize_key( $slide['title_tag'] ?? 'h2' );
            $allowed_tags = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'p' ];
            if ( ! in_array( $tag, $allowed_tags, true ) ) {
                $tag = 'h2';
            }
            $title_style = ! empty( $slide['title_color'] )
                ? 'style="color:' . esc_attr( $slide['title_color'] ) . ';"'
                : '';
            $title_link     = $slide['title_link'] ?? '';
            $slide_link_url = $slide['slide_link']['url'] ?? '';

            // Slide-level link takes priority over dynamic title_link
            if ( ! empty( $slide_link_url ) ) {
                $title_inner = '<a ' . $this->get_link_attrs( $slide['slide_link'] ) . ' class="sitsel-slide-link">' . esc_html( $slide['title'] ) . '</a>';
            } elseif ( ! empty( $title_link ) ) {
                $title_inner = '<a href="' . esc_url( $title_link ) . '">' . esc_html( $slide['title'] ) . '</a>';
            } else {
                $title_inner = esc_html( $slide['title'] );
            }
            
            printf(
                '<%1$s class="sitsel-slide-title" %2$s>%3$s</%1$s>',
                esc_attr( $tag ),
                $title_style, // phpcs:ignore
                $title_inner  // phpcs:ignore
            );
        }

        // ── Paragraph
        if ( 'yes' === ( $slide['show_paragraph'] ?? '' ) && ! empty( $slide['paragraph'] ) ) {
            $para_style = ! empty( $slide['paragraph_color'] )
                ? 'style="color:' . esc_attr( $slide['paragraph_color'] ) . ';"'
                : '';
            echo '<div class="sitsel-slide-paragraph" ' . $para_style . '>' // phpcs:ignore
               . wp_kses_post( $slide['paragraph'] )
               . '</div>';
        }

        // ── Buttons
        $has_btn  = 'yes' === ( $slide['show_button'] ?? '' ) && ! empty( $slide['button_text'] );
        $has_btn2 = 'yes' === ( $slide['show_button_2'] ?? '' ) && ! empty( $slide['button_2_text'] );

        if ( $has_btn || $has_btn2 ) {
            echo '<div class="sitsel-slide-btn-group">';

            // Primary Button
            if ( $has_btn ) {
                $btn_style_parts = [];
                if ( ! empty( $slide['button_bg_color'] ) )   $btn_style_parts[] = 'background-color:' . esc_attr( $slide['button_bg_color'] );
                if ( ! empty( $slide['button_text_color'] ) )  $btn_style_parts[] = 'color:' . esc_attr( $slide['button_text_color'] );
                $btn_style = $btn_style_parts ? 'style="' . implode( ';', $btn_style_parts ) . '"' : '';

                $icon_pos = $slide['button_icon_position'] ?? 'after';

                echo '<a ' . $this->get_link_attrs( $slide['button_link'] ?? [] ) . ' class="sitsel-slide-btn" ' . $btn_style . '>'; // phpcs:ignore
                if ( 'before' === $icon_pos && ! empty( $slide['button_icon']['value'] ) ) {
                    \Elementor\Icons_Manager::render_icon( $slide['button_icon'], [ 'aria-hidden' => 'true' ] );
                }
                echo esc_html( $slide['button_text'] );
                if ( 'after' === $icon_pos && ! empty( $slide['button_icon']['value'] ) ) {
                    \Elementor\Icons_Manager::render_icon( $slide['button_icon'], [ 'aria-hidden' => 'true' ] );
                }
                echo '</a>';
            }

            // Secondary Button
            if ( $has_btn2 ) {
                echo '<a ' . $this->get_link_attrs( $slide['button_2_link'] ?? [] ) . ' class="sitsel-slide-btn sitsel-slide-btn-secondary">'; // phpcs:ignore
                echo esc_html( $slide['button_2_text'] );
                echo '</a>';
            }

            echo '</div>'; // .sitsel-slide-btn-group
        }

        echo '</div>'; // .sitsel-slide-content
    }
}