<?php 
/**
 * Slider Section
 *
 * @package go-mechanic
 */
    
$wp_customize->add_section( 'go_mechanic_slider_section' , array(
    'title'      => esc_html__( 'Slider Section', 'go-mechanic' ),
    'capability' => 'edit_theme_options',
    'panel' => 'go_mechanic_option_section_panel' 
) );

// Number of Slider Items
$wp_customize->add_setting('go_mechanic_number_of_slider_items', array(
        'default'           => 3,
        'type'              => 'theme_mod',
        'sanitize_callback' => 'absint', 
    ));
    
    $wp_customize->add_control('go_mechanic_number_of_slider_items', array(
        'label'    => __('Number Of Slider To Show', 'go-mechanic'),
        'section'  => 'go_mechanic_slider_section', // The section where this control will appear
        'type'     => 'number',
        'input_attrs' => array(
            'min' => 1, // Minimum value
            'max' => 10, // Maximum value
            'step' => 1, // Increment step
        ),
    ));
    
    $go_mechanic_slider_list = array();
    $args = array('post_type' => 'post'); // Fetch posts, not pages
    $go_mechanic_posts = get_posts( $args ); 
    foreach($go_mechanic_posts as $go_mechanic_post) {
        $go_mechanic_slider_list[$go_mechanic_post->ID] = $go_mechanic_post->post_title; // Use post ID as key and title as value
    }
    
    for ( $count = 1; $count <= 4; $count++ ) {
        $wp_customize->add_setting( 'go_mechanic_select_post_slider' . $count, array(
            'default'           => '',
            'type'              => 'theme_mod',
            'sanitize_callback' => 'go_mechanic_sanitize_post_dropdown'
        ));
        $wp_customize->add_control( 'go_mechanic_select_post_slider' . $count, array(
            'label'   => __( 'Select A Post Page', 'go-mechanic' ),
            'section' => 'go_mechanic_slider_section',
            'type'    => 'select', // Use 'select' for custom post list
            'choices' => $go_mechanic_slider_list // Populate choices with posts
        ));
    }

    $wp_customize->add_setting('go_mechanic_heading', 
    array(
    'default'           => __('Smart Rides For A Smarter Planet', 'go-mechanic'),
    'type'              => 'theme_mod',
    'capability'        => 'edit_theme_options',    
    'sanitize_callback' => 'sanitize_text_field'
    )
);

// Slider Badge Text
$wp_customize->add_setting('go_mechanic_slider_badge_text', array(
    'default'           => __('Certified mechanics • Transparent pricing • Fast turnaround', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_badge_text', array(
    'label'    => __('Slider Badge Text', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Slider Highlight Words (comma separated)
$wp_customize->add_setting('go_mechanic_slider_highlight_words', array(
    'default'           => __('Auto Repair', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_highlight_words', array(
    'label'    => __('Highlight Words (comma separated)', 'go-mechanic'),
    'description' => __('Words in the title to highlight in orange color', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Slider Description
$wp_customize->add_setting('go_mechanic_slider_description', array(
    'default'           => '',
    'type'              => 'theme_mod',
    'sanitize_callback' => 'wp_kses_post'
));

$wp_customize->add_control('go_mechanic_slider_description', array(
    'label'    => __('Slider Description (Optional)', 'go-mechanic'),
    'description' => __('Leave empty to use post content. HTML allowed.', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'textarea',
));

// Primary Button Text
$wp_customize->add_setting('go_mechanic_slider_primary_btn_text', array(
    'default'           => __('Get Service', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_primary_btn_text', array(
    'label'    => __('Primary Button Text', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Primary Button URL
$wp_customize->add_setting('go_mechanic_slider_primary_btn_url', array(
    'default'           => '',
    'type'              => 'theme_mod',
    'sanitize_callback' => 'esc_url_raw'
));

$wp_customize->add_control('go_mechanic_slider_primary_btn_url', array(
    'label'    => __('Primary Button URL', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'url',
));

// Secondary Button Text
$wp_customize->add_setting('go_mechanic_slider_secondary_btn_text', array(
    'default'           => __('Contact Us', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_secondary_btn_text', array(
    'label'    => __('Secondary Button Text', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Secondary Button URL
$wp_customize->add_setting('go_mechanic_slider_secondary_btn_url', array(
    'default'           => '#',
    'type'              => 'theme_mod',
    'sanitize_callback' => 'esc_url_raw'
));

$wp_customize->add_control('go_mechanic_slider_secondary_btn_url', array(
    'label'    => __('Secondary Button URL', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'url',
));

// Feature 1 Text
$wp_customize->add_setting('go_mechanic_slider_feature_1', array(
    'default'           => __('Same-day options', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_feature_1', array(
    'label'    => __('Feature 1 Text', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Feature 2 Text
$wp_customize->add_setting('go_mechanic_slider_feature_2', array(
    'default'           => __('Warranty-backed repairs', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_feature_2', array(
    'label'    => __('Feature 2 Text', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Feature 3 Text
$wp_customize->add_setting('go_mechanic_slider_feature_3', array(
    'default'           => __('Local & trusted', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_feature_3', array(
    'label'    => __('Feature 3 Text', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Booking Form Title
$wp_customize->add_setting('go_mechanic_slider_booking_title', array(
    'default'           => __('Quick Booking', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_booking_title', array(
    'label'    => __('Booking Form Title', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Booking Status Text
$wp_customize->add_setting('go_mechanic_slider_booking_status', array(
    'default'           => __('Open Today', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_booking_status', array(
    'label'    => __('Booking Status Text', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Booking Name Placeholder
$wp_customize->add_setting('go_mechanic_slider_booking_name_placeholder', array(
    'default'           => __('Your name', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_booking_name_placeholder', array(
    'label'    => __('Name Input Placeholder', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Booking Services (comma separated)
$wp_customize->add_setting('go_mechanic_slider_booking_services', array(
    'default'           => __('Diagnostics,Engine Repair,Brake Service,Oil Change', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_booking_services', array(
    'label'    => __('Booking Services (comma separated)', 'go-mechanic'),
    'description' => __('List services separated by commas', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));

// Booking Button Text
$wp_customize->add_setting('go_mechanic_slider_booking_btn_text', array(
    'default'           => __('Book Appointment', 'go-mechanic'),
    'type'              => 'theme_mod',
    'sanitize_callback' => 'sanitize_text_field'
));

$wp_customize->add_control('go_mechanic_slider_booking_btn_text', array(
    'label'    => __('Booking Button Text', 'go-mechanic'),
    'section'  => 'go_mechanic_slider_section',
    'type'     => 'text',
));