<?php
if (!defined('ABSPATH'))
    exit;

/**
 * Frontpage Feature Highlight.
 *
 * @package pawfect
 */

if (!class_exists('pawfect_Customize_Homepage_Feature_Highlight_Option')):

    class pawfect_Customize_Homepage_Feature_Highlight_Option extends pawfect_Customize_Base_Option
    {

        public function elements()
        {

            return array(

                // Section heading
                'pawfect_feature_highlight_heading' => array(
                    'setting' => array(),
                    'control' => array(
                        'type' => 'heading',
                        'priority' => 1,
                        'label' => esc_html__('Feature Highlight Options', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                    ),
                ),

                // Enable/Disable toggle
                'pawfect_feature_highlight_enabled' => array(
                    'setting' => array(
                        'default' => true,
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_checkbox'),
                       
                    ),
                    'control' => array(
                        'type' => 'toggle',
                        'label' => esc_html__('Enable Feature Highlight Section', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'priority' => 2,
                    ),
                ),

                // Title
                'pawfect_feature_highlight_title' => array(
                    'setting' => array(
                        'default' => esc_html__('Luxury Pet Essentials, Tailored for Style', 'pawfect'),
                        'sanitize_callback' => 'sanitize_text_field',
                       
                    ),
                    'control' => array(
                        'type' => 'text',
                        'label' => esc_html__('Section Title', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'priority' => 5,
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),

                // Description
                'pawfect_feature_highlight_desc' => array(
                    'setting' => array(
                        'default' => esc_html__('Discover finely crafted collars, chic apparel, and elegant essentials designed to celebrate your petâ€™s personality with premium comfort and timeless style.', 'pawfect'),
                        'sanitize_callback' => 'wp_kses_post',
                       
                    ),
                    'control' => array(
                        'type' => 'textarea',
                        'label' => esc_html__('Section Description', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'priority' => 6,
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),

                // Image Collage Repeater
                'pawfect_feature_highlight_collage' => array(
                    'setting' => array(
                        'default' => json_encode(array(
                            array(
                                'image_url' => get_template_directory_uri() . '/assets/images/featured-heighlight/collage1.webp',
                                'title' => esc_html__('Premium Pet Collar', 'pawfect'),
                                'text' => esc_html__('Elegant leather collar with gold accents', 'pawfect'),
                                'text_two' => '20px', // Top offset
                                'text_three' => '10px', // Left offset
                                'shortcode' => '300px', // Width
                                'id' => 'customizer_repeater_feature_001',
                            ),
                            array(
                                'image_url' => get_template_directory_uri() . '/assets/images/featured-heighlight/collage2.webp',
                                'title' => esc_html__('Luxury Pet Bed', 'pawfect'),
                                'text' => esc_html__('Comfortable orthopedic bed with premium fabric', 'pawfect'),
                                'text_two' => '150px', // Top offset
                                'text_three' => '200px', // Left offset
                                'shortcode' => '280px', // Width
                                'id' => 'customizer_repeater_feature_002',
                            ),
                        )),
                        'sanitize_callback' => 'wp_kses_post',

                    ),
                    'control' => array(
                        'type' => 'repeater',
                        'label' => esc_html__('Image Collage Stack', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'priority' => 7,
                        'add_field_label' => esc_html__('Add new collage image', 'pawfect'),
                        'item_name' => esc_html__('Collage Item', 'pawfect'),
                        'customizer_repeater_image_control' => true,
                        'customizer_repeater_title_control' => true,
                        'customizer_repeater_text_two_control' => true,  // Top offset
                        'customizer_repeater_text_three_control' => true,  // Left offset
                        'customizer_repeater_shortcode_control' => true,  // Width
                        'customizer_repeater_position_draggable_control' => true,
                        'customizer_repeater_text_control' => true,
                        'customizer_repeater_link_control' => false,
                        'customizer_repeater_icon_control' => false,
                        'customizer_repeater_checkbox_control' => false,
                        'customizer_repeater_button_text_control' => false,
                        'description' => esc_html__('Upload high-resolution images for best quality. Use px, %, or rem units for positioning. Images will automatically use full-size versions.', 'pawfect'),
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),

                // Upgrade control for feature highlight limitation
                'pawfect_feature_highlight_collage_upsale' => array(
                    'setting' => array(
                        'sanitize_callback' => 'sanitize_text_field',
                    ),
                    'control' => array(
                        'type' => 'pawfect-upgrade',
                        'priority' => 7.5,
                        'label' => esc_html__('Feature Highlight Features', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),

                // Button Text
                'pawfect_feature_highlight_button_text' => array(
                    'setting' => array(
                        'default' => esc_html__('Shop Now', 'pawfect'),
                        'sanitize_callback' => 'sanitize_text_field',
                    ),
                    'control' => array(
                        'type' => 'text',
                        'label' => esc_html__('Button Text', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'priority' => 8,
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),

                // Button Link
                'pawfect_feature_highlight_button_link' => array(
                    'setting' => array(
                        'default' => '#',
                        'sanitize_callback' => 'esc_url_raw',
                    ),
                    'control' => array(
                        'type' => 'url',
                        'label' => esc_html__('Button Link', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'priority' => 9,
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),

                // Button Link Target
                'pawfect_feature_highlight_button_target' => array(
                    'setting' => array(
                        'default' => '_self',
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_radio'),
                    ),
                    'control' => array(
                        'type' => 'radio-switch',
                        'priority' => 10,
                        'label' => esc_html__('Button Link Target', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'choices' => array(
                            '_self' => esc_html__('Same Tab', 'pawfect'),
                            '_blank' => esc_html__('New Tab', 'pawfect'),
                        ),
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),

                // Extra Button Text
                'pawfect_feature_highlight_extra_button_text' => array(
                    'setting' => array(
                        'default' => esc_html__('Watch Story', 'pawfect'),
                        'sanitize_callback' => 'sanitize_text_field',
                    ),
                    'control' => array(
                        'type' => 'text',
                        'label' => esc_html__('Extra Button Text', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'priority' => 10,
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),

                // Extra Button Link
                'pawfect_feature_highlight_extra_button_link' => array(
                    'setting' => array(
                        'default' => '#',
                        'sanitize_callback' => 'esc_url_raw',
                    ),
                    'control' => array(
                        'type' => 'url',
                        'label' => esc_html__('Extra Button Link', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'priority' => 12,
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),

                // Extra Button Link Target
                'pawfect_feature_highlight_extra_button_target' => array(
                    'setting' => array(
                        'default' => '_self',
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_radio'),
                    ),
                    'control' => array(
                        'type' => 'radio-switch',
                        'priority' => 13,
                        'label' => esc_html__('Extra Button Link Target', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'choices' => array(
                            '_self' => esc_html__('Same Tab', 'pawfect'),
                            '_blank' => esc_html__('New Tab', 'pawfect'),
                        ),
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),

                // Background color
                'pawfect_feature_highlight_bg_color' => array(
                    'setting' => array(
                        'default' => '#ffffff',
                        'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_alpha_color'),
                    ),
                    'control' => array(
                        'type' => 'color',
                        'label' => esc_html__('Background Color', 'pawfect'),
                        'section' => 'pawfect_theme_feature_highlight',
                        'priority' => 14,
                        'choices' => array('alpha' => true),
                        'active_callback' => 'pawfect_is_feature_highlight_enabled',
                    ),
                ),



            );
        }
    }

    new pawfect_Customize_Homepage_Feature_Highlight_Option();

endif;

/**
 * Check if feature highlight is enabled
 */
function pawfect_is_feature_highlight_enabled()
{
    return get_theme_mod('pawfect_feature_highlight_enabled', true) === true;
}


