
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
 * Frontpage Main Slider Options.
 *
 * @package pawfect
 */

if ( ! class_exists( 'Pawfect_Options_Slider' ) ) :

    class Pawfect_Options_Slider extends pawfect_Customize_Base_Option {

        /**
         * Arguments for options.
         *
         * @return array
         */
        public function elements() {

            return array(
                
                'pawfect_frontpage_setup_info'  => array(
                    'setting' => array(),
                    'control' => array(
                        'type'     => 'heading', 
                        'priority' => 1,
                        'label'    => esc_html__( 'Setup Instructions', 'pawfect' ),
                        'description' => esc_html__( 'To display the Frontpage sections on your site, you must create a new page, set its Template to "Front Page" on the right sidebar, and assign it as your Static Homepage in Settings > Reading.', 'pawfect' ),
                        'section'  => 'pawfect_frontpage_instructions',
                    ),
                ),

                'pawfect_main_slider_heading'  => array(
                    'setting' => array(),
                    'control' => array(
                        'type'     => 'heading', 
                        'priority' => 1,
                        'label'    => esc_html__( 'Slider Options', 'pawfect' ),
                        'section'  => 'pawfect_main_theme_slider',
                    ),
                ),

                'pawfect_main_slider_enabled'  => array(
                    'setting' => array( 
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'priority' => 2,
                        'label'    => esc_html__( 'Show Slider', 'pawfect' ),
                        'description' => esc_html__( 'Turn on to show the slider. Turn off to hide it.', 'pawfect' ),
                        'section'  => 'pawfect_main_theme_slider',
                    ),
                ),




                'pawfect_main_slider_content' => array(
                    'setting' => array(
                        'transport' => 'refresh',
                    ),
                    'control' => array(
                        'type'              => 'repeater',
                        'label'             => esc_html__( 'Slider Items Content', 'pawfect' ),
                        'section'           => 'pawfect_main_theme_slider',
                        'priority'          => 3,
                        'add_field_label'   => esc_html__( 'Add new slide', 'pawfect' ),
                        'item_name'         => esc_html__( 'Slide Item', 'pawfect' ),
                        'customizer_repeater_title_control'       => true,
                        'customizer_repeater_subtitle_control'    => true,
                        'customizer_repeater_text_control'        => true,
                        'customizer_repeater_button_text_control' => true,
                        'customizer_repeater_link_control'        => true,
                        'customizer_repeater_image_control'       => true,
                        'customizer_repeater_checkbox_control'    => true,
                        'customizer_repeater_slide_content_format_type' => true,
                        'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),

                // Upgrade control for slider limitation
                'pawfect_main_slider_content_upsale' => array(
                    'setting' => array(
                        'sanitize_callback' => 'sanitize_text_field',
                    ),
                    'control' => array(
                        'type' => 'pawfect-upgrade',
                        'priority' => 4,
                        'label' => esc_html__('Slider Features', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),

                'pawfect_main_slider_animation' => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'priority' => 12,
                        'label'    => esc_html__( 'Fade Animation Enable/Disable', 'pawfect' ),
                        'section'  => 'pawfect_main_theme_slider',
                       'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),
                
                'pawfect_main_slider_overlay_disable'  => array(
                    'setting' => array(
                        'default'           => true,
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_checkbox' ),
                    ),
                    'control' => array(
                        'type'     => 'toggle',
                        'priority' => 14,
                        'label'    => esc_html__( 'Overlay Enable/Disable', 'pawfect' ),
                        'section'  => 'pawfect_main_theme_slider',
                        'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),
                
                'pawfect_main_slider_overlay_color' => array(
                    'setting' => array(
                        'default'           => 'rgba(0,0,0,0.6)',
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_alpha_color' ),
                    ),
                    'control' => array(
                        'type'            => 'color',
                        'priority'        => 16,
                        'label'           => esc_html__( 'Slider Overlay Color', 'pawfect' ),
                        'section'         => 'pawfect_main_theme_slider',
                        'choices'         => array(
                            'alpha' => true,
                        ),
                       'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ), 

                'pawfect_main_slider_caption_title_color' => array(
                    'setting' => array(
                        'default'           => '#fff',
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_alpha_color' ),
                    ),
                    'control' => array(
                        'type'            => 'color',
                        'priority'        => 25,
                        'label'           => esc_html__( 'Slide Title Color', 'pawfect' ),
                        'description'     => esc_html__( 'Set the color for slide title.', 'pawfect' ),
                        'section'         => 'pawfect_main_theme_slider',
                        'choices'         => array(
                            'alpha' => true,
                        ),
                        'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ), 

                'pawfect_main_slider_caption_subtitle_title_color' => array(
                    'setting' => array(
                        'default'           => '#F4A259',
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_alpha_color' ),
                    ),
                    'control' => array(
                        'type'            => 'color',
                        'priority'        => 30,
                        'label'           => esc_html__( 'Slide Subtitle Color', 'pawfect' ),
                        'description'     => esc_html__( 'Set the color for slide subtitle.', 'pawfect' ),
                        'section'         => 'pawfect_main_theme_slider',
                        'choices'         => array(
                            'alpha' => true,
                        ),
                       'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ), 

                'pawfect_main_slider_caption_descrption_title_color' => array(
                    'setting' => array(
                        'default'           => '#fff',
                        'sanitize_callback' => array( 'pawfect_Customizer_Sanitize', 'sanitize_alpha_color' ),
                    ),
                    'control' => array(
                        'type'            => 'color',
                        'priority'        => 35,
                        'label'           => esc_html__( 'Slide Description Color', 'pawfect' ),
                        'description'     => esc_html__( 'Set the color for slide description.', 'pawfect' ),
                        'section'         => 'pawfect_main_theme_slider',
                        'choices'         => array(
                            'alpha' => true,
                        ),
                       'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),

                // =======================================================
                // == SUBTITLE STYLING OPTIONS
                // =======================================================

                'pawfect_main_slider_subtitle_styling_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type' => 'heading',
                        'priority' => 40,
                        'label' => esc_html__('Subtitle Styling (Pro only)', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                         'active_callback' => 'pawfect_main_slider_disabled',

                    ),
                ),

                'pawfect_main_slider_subtitle_font_size' => array(
                    'setting' => array(
                        'default' => 16,
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_range_value'),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 45,
                        'label' => esc_html__('Subtitle Font Size (px)', 'pawfect'),
                        'description' => esc_html__('Desktop font size for subtitle', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'input_attrs' => array(
                            'min' => 14,
                            'max' => 48,
                            'step' => 2,
                            
                        ),
                        'active_callback' => 'pawfect_main_slider_pro_only',
                    ),
                ),

                'pawfect_main_slider_subtitle_font_weight' => array(
                    'setting' => array(
                        'default' => '500',
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_radio'),
                    ),
                    'control' => array(
                        'type' => 'select',
                        'priority' => 50,
                        'is_default_type' => true,
                        'label' => esc_html__('Subtitle Font Weight', 'pawfect'),
                        'description' => esc_html__('Choose the font weight for subtitle', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'choices' => array(
                            '300' => esc_html__('Light', 'pawfect'),
                            '400' => esc_html__('Normal', 'pawfect'),
                            '500' => esc_html__('Medium', 'pawfect'),
                            '600' => esc_html__('Semi Bold', 'pawfect'),
                            '700' => esc_html__('Bold', 'pawfect'),
                        ),

                        'active_callback' => 'pawfect_main_slider_pro_only',
                    ),
                ),

                'pawfect_main_slider_subtitle_text_transform' => array(
                    'setting' => array(
                        'default' => 'uppercase',
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_radio'),
                    ),
                    'control' => array(
                       'type' => 'select',
                        'priority' => 55,
                          'is_default_type' => true,
                        'label' => esc_html__('Subtitle Text Transform', 'pawfect'),
                        'description' => esc_html__('Text transformation for subtitle', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'choices' => array(
                            'none' => esc_html__('None', 'pawfect'),
                            'uppercase' => esc_html__('UPPERCASE', 'pawfect'),
                            'lowercase' => esc_html__('lowercase', 'pawfect'),
                            'capitalize' => esc_html__('Capitalize', 'pawfect'),
                        ),
                        'active_callback' => 'pawfect_main_slider_pro_only',
                    ),
                ),

                'pawfect_main_slider_subtitle_letter_spacing' => array(
                    'setting' => array(
                        'default' => 1,
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_range_value'),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 60,
                        'label' => esc_html__('Subtitle Letter Spacing (px)', 'pawfect'),
                        'description' => esc_html__('Space between letters in subtitle', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'input_attrs' => array(
                            'min' => 0,
                            'max' => 10,
                            'step' => 0.5,
                        ),
                        'active_callback' => 'pawfect_main_slider_pro_only',
                    ),
                ),

                // =======================================================
                // == TITLE STYLING OPTIONS
                // =======================================================

                'pawfect_main_slider_title_styling_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type' => 'heading',
                        'priority' => 65,
                        'label' => esc_html__('Title Styling (Pro only)', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                         'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),

                'pawfect_main_slider_title_font_size' => array(
                    'setting' => array(
                        'default' => json_encode(array(
                            'desktop' => 92,
                            'tablet' => 72,
                            'mobile' => 48,
                        )),
                        'sanitize_callback' => array('Pawfect_Responsive_Range_Control', 'sanitize_responsive_range'),
                        'transport' => 'postMessage',
                    ),
                    'control' => array(
                        'type' => 'pawfect-responsive-range',
                        'priority' => 70,
                        'section' => 'pawfect_main_theme_slider',
                        'label' => esc_html__('Title Font Size', 'pawfect'),
                        'description' => esc_html__('Set the hero title font size across different devices.', 'pawfect'),
                        'media_query' => true,
                        'suffix' => 'px',
                        'input_attrs' => array(
                            'min' => 32,
                            'max' => 120,
                            'step' => 4,
                        ),
                        'active_callback' => 'pawfect_main_slider_pro_only',
                    ),
                ),

                'pawfect_main_slider_title_line_height' => array(
                    'setting' => array(
                        'default' => 1,
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_range_value'),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 75,
                        'label' => esc_html__('Title Line Height', 'pawfect'),
                        'description' => esc_html__('Line height for main title', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'input_attrs' => array(
                            'min' => 0.8,
                            'max' => 2,
                            'step' => 0.1,
                        ),
                        'active_callback' => 'pawfect_main_slider_pro_only',
                    ),
                ),

                // =======================================================
                // == LAYOUT & SPACING OPTIONS
                // =======================================================

                'pawfect_main_slider_layout_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type' => 'heading',
                        'priority' => 80,
                        'label' => esc_html__('Layout & Spacing (Pro only)', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                         'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),

                'pawfect_main_slider_content_spacing' => array(
                    'setting' => array(
                        'default' => 24, // 6 * 4 = 24px (mt-6)
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_range_value'),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 85,
                        'label' => esc_html__('Content Spacing (px)', 'pawfect'),
                        'description' => esc_html__('Space between text elements', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'input_attrs' => array(
                            'min' => 16,
                            'max' => 80,
                            'step' => 8,
                        ),
                        'active_callback' => 'pawfect_main_slider_pro_only',
                    ),
                ),

                // Navigation and Pagination Settings
                'pawfect_main_slider_navigation_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type' => 'heading',
                        'priority' => 90,
                        'label' => esc_html__('Navigation & Pagination (Pro only)', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                         'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),

                'pawfect_main_slider_show_navigation' => array(
                    'setting' => array(
                        'default' => true,
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_checkbox'),
                        'transport' => 'postMessage',
                    ),
                    'control' => array(
                        'type' => 'toggle',
                        'priority' => 91,
                        'label' => esc_html__('Show Navigation Arrows', 'pawfect'),
                        'description' => esc_html__('Display left/right navigation arrows', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'active_callback' => 'pawfect_main_slider_pro_only',
                    ),
                ),

                'pawfect_main_slider_show_pagination' => array(
                    'setting' => array(
                        'default' => true,
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_checkbox'),
                        'transport' => 'postMessage',
                    ),
                    'control' => array(
                        'type' => 'toggle',
                        'priority' => 92,
                        'label' => esc_html__('Show Pagination Dots', 'pawfect'),
                        'description' => esc_html__('Display pagination dots at bottom', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'active_callback' => 'pawfect_main_slider_pro_only',
                    ),
                ),

                'pawfect_main_slider_button_spacing' => array(
                    'setting' => array(
                        'default' => 64, // 16 * 4 = 64px (mt-16)
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_range_value'),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 90,
                        'label' => esc_html__('Button Top Spacing (px)', 'pawfect'),
                        'description' => esc_html__('Space above the button', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'input_attrs' => array(
                            'min' => 24,
                            'max' => 100,
                            'step' => 8,
                        ),
                        'active_callback' => 'pawfect_main_slider_pro_only',
                    ),
                ),

                // =======================================================
                // == SLIDER BEHAVIOR OPTIONS
                // =======================================================

                'pawfect_main_slider_behavior_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type' => 'heading',
                        'priority' => 35,
                        'label' => esc_html__('Slider Behavior', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                         'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),

                'pawfect_main_slider_autoplay' => array(
                    'setting' => array(
                        'default' => true,
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_checkbox'),
                    ),
                    'control' => array(
                        'type' => 'toggle',
                        'priority' => 36,
                        'label' => esc_html__('Enable Autoplay', 'pawfect'),
                        'description' => esc_html__('Automatically advance slides', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),

                'pawfect_main_slider_autoplay_delay' => array(
                    'setting' => array(
                        'default' => 5000,
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_range_value'),
                    ),
                    'control' => array(
                        'type' => 'pawfect-range-slider',
                        'priority' => 37,
                        'label' => esc_html__('Autoplay Delay (ms)', 'pawfect'),
                        'description' => esc_html__('Time between slide transitions', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'input_attrs' => array(
                            'min' => 2000,
                            'max' => 10000,
                            'step' => 500,
                        ),
                        'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),

                'pawfect_main_slider_pause_on_hover' => array(
                    'setting' => array(
                        'default' => true,
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_checkbox'),
                    ),
                    'control' => array(
                        'type' => 'toggle',
                        'priority' => 38,
                        'label' => esc_html__('Pause on Hover', 'pawfect'),
                        'description' => esc_html__('Pause autoplay when hovering over slider', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),

                'pawfect_main_slider_infinite_loop' => array(
                    'setting' => array(
                        'default' => true,
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_checkbox'),
                    ),
                    'control' => array(
                        'type' => 'toggle',
                        'priority' => 39,
                        'label' => esc_html__('Infinite Loop', 'pawfect'),
                        'description' => esc_html__('Loop back to first slide after last slide', 'pawfect'),
                        'section' => 'pawfect_main_theme_slider',
                        'active_callback' => 'pawfect_main_slider_disabled',
                    ),
                ),


            );
        }

      
    }
 
    // Remove automatic instantiation - let main customizer class handle this
     new Pawfect_Options_Slider();

endif;


function pawfect_main_slider_disabled($control)
{
    // Following Formula theme pattern - return true when slider is enabled
    // This makes other slider settings visible when main toggle is ON
    return true === ( $control->manager->get_setting( 'pawfect_main_slider_enabled' )->value() == true );
}

function pawfect_main_slider_pro_only($control)
{
    // Pro-only features - always return false to make them inactive
    return false;
}


