<?php
/**
 * AI Services Theme Customizer
 *
 * @link: https://developer.wordpress.org/themes/customize-api/customizer-objects/
 *
 * @package AI Services
 */

if ( ! function_exists( 'ai_services_file_setup' ) ) :

    function ai_services_file_setup() {

        if ( ! defined( 'AI_SERVICES_URL' ) ) {
            define( 'AI_SERVICES_URL', esc_url( 'https://www.themagnifico.net/products/agentic-ai-wordpress-theme', 'ai-services') );
        }
        if ( ! defined( 'AI_SERVICES_TEXT' ) ) {
            define( 'AI_SERVICES_TEXT', __( 'AI Services Pro','ai-services' ));
        }

    }
endif;
add_action( 'after_setup_theme', 'ai_services_file_setup' );

use WPTRT\Customize\Section\AI_Services_Button;

add_action( 'customize_register', function( $manager ) {

    $manager->register_section_type( AI_Services_Button::class );

    $manager->add_section(
        new AI_Services_Button( $manager, 'ai_services_pro', [
            'title'       => esc_html( AI_SERVICES_TEXT,'ai-services' ),
            'priority'    => 0,
            'button_text' => __( 'GET PREMIUM', 'ai-services' ),
            'button_url'  => esc_url( AI_SERVICES_URL )
        ] )
    );

} );

// Load the JS and CSS.
add_action( 'customize_controls_enqueue_scripts', function() {

    $version = wp_get_theme()->get( 'Version' );

    wp_enqueue_script(
        'ai-services-customize-section-button',
        get_theme_file_uri( 'vendor/wptrt/customize-section-button/public/js/customize-controls.js' ),
        [ 'customize-controls' ],
        $version,
        true
    );

    wp_enqueue_style(
        'ai-services-customize-section-button',
        get_theme_file_uri( 'vendor/wptrt/customize-section-button/public/css/customize-controls.css' ),
        [ 'customize-controls' ],
        $version
    );

} );

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function ai_services_customize_register($wp_customize){

    $wp_customize->get_setting('blogname')->transport = 'postMessage';
    $wp_customize->get_setting('blogdescription')->transport = 'postMessage';

    $wp_customize->add_setting('ai_services_logo_title_text', array(
        'default' => true,
        'sanitize_callback' => 'ai_services_sanitize_checkbox'
    ));
    $wp_customize->add_control( new WP_Customize_Control($wp_customize,'ai_services_logo_title_text',array(
        'label'          => __( 'Enable Disable Title', 'ai-services' ),
        'section'        => 'title_tagline',
        'settings'       => 'ai_services_logo_title_text',
        'type'           => 'checkbox',
    )));

    $wp_customize->add_setting('ai_services_logo_title_font_size',array(
        'default'   => '',
        'sanitize_callback' => 'ai_services_sanitize_number_absint'
    ));
    $wp_customize->add_control('ai_services_logo_title_font_size',array(
        'label' => esc_html__('Title Font Size','ai-services'),
        'section' => 'title_tagline',
        'type'    => 'number'
    ));

    $wp_customize->add_setting('ai_services_theme_description', array(
        'default' => false,
        'sanitize_callback' => 'ai_services_sanitize_checkbox'
    ));
    $wp_customize->add_control( new WP_Customize_Control($wp_customize,'ai_services_theme_description',array(
        'label'          => __( 'Enable Disable Tagline', 'ai-services' ),
        'section'        => 'title_tagline',
        'settings'       => 'ai_services_theme_description',
        'type'           => 'checkbox',
    )));

    $wp_customize->add_setting('ai_services_logo_tagline_font_size',array(
        'default'   => '',
        'sanitize_callback' => 'ai_services_sanitize_number_absint'
    ));
    $wp_customize->add_control('ai_services_logo_tagline_font_size',array(
        'label' => esc_html__('Tagline Font Size','ai-services'),
        'section'   => 'title_tagline',
        'type'      => 'number'
    ));

    //Logo
    $wp_customize->add_setting('ai_services_logo_max_height',array(
        'default'   => '200',
        'sanitize_callback' => 'ai_services_sanitize_number_absint'
    ));
    $wp_customize->add_control('ai_services_logo_max_height',array(
        'label' => esc_html__('Logo Width','ai-services'),
        'section'   => 'title_tagline',
        'type'      => 'number'
    ));

    // Global Color Settings
     $wp_customize->add_section('ai_services_global_color_settings',array(
        'title' => esc_html__('Global Settings','ai-services'),
        'priority'   => 28,
    ));

    $wp_customize->add_setting( 'ai_services_first_color', array(
        'default' => '#7D59FB',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ai_services_first_color', array(
        'label' => __('Select Your First Color', 'ai-services'),
        'description' => __('Change the global color of the theme in one click.', 'ai-services'),
        'section' => 'ai_services_global_color_settings',
        'settings' => 'ai_services_first_color',
    )));

    $wp_customize->add_setting( 'ai_services_second_color', array(
        'default' => '#040019',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ai_services_second_color', array(
        'label' => __('Select Your Second Color', 'ai-services'),
        'description' => __('Change the global color of the theme in one click.', 'ai-services'),
        'section' => 'ai_services_global_color_settings',
        'settings' => 'ai_services_second_color',
    )));

    //Typography option
    $ai_services_font_array = array(
        ''                       => 'No Fonts',
        'Abril Fatface'          => 'Abril Fatface',
        'Acme'                   => 'Acme',
        'Anton'                  => 'Anton',
        'Architects Daughter'    => 'Architects Daughter',
        'Sail'                   => 'Sail',
        'Arimo'                  => 'Arimo',
        'Arsenal'                => 'Arsenal',
        'Arvo'                   => 'Arvo',
        'Alegreya'               => 'Alegreya',
        'Alfa Slab One'          => 'Alfa Slab One',
        'Averia Serif Libre'     => 'Averia Serif Libre',
        'Bangers'                => 'Bangers',
        'Boogaloo'               => 'Boogaloo',
        'Bad Script'             => 'Bad Script',
        'Bitter'                 => 'Bitter',
        'Bree Serif'             => 'Bree Serif',
        'BenchNine'              => 'BenchNine',
        'Cabin'                  => 'Cabin',
        'Cardo'                  => 'Cardo',
        'Courgette'              => 'Courgette',
        'Cherry Swash'           => 'Cherry Swash',
        'Cormorant Garamond'     => 'Cormorant Garamond',
        'Crimson Text'           => 'Crimson Text',
        'Cuprum'                 => 'Cuprum',
        'Cookie'                 => 'Cookie',
        'Chewy'                  => 'Chewy',
        'Days One'               => 'Days One',
        'Dosis'                  => 'Dosis',
        'Droid Sans'             => 'Droid Sans',
        'Economica'              => 'Economica',
        'Fredoka One'            => 'Fredoka One',
        'Fjalla One'             => 'Fjalla One',
        'Francois One'           => 'Francois One',
        'Frank Ruhl Libre'       => 'Frank Ruhl Libre',
        'Gloria Hallelujah'      => 'Gloria Hallelujah',
        'Great Vibes'            => 'Great Vibes',
        'Handlee'                => 'Handlee',
        'Hammersmith One'        => 'Hammersmith One',
        'Inconsolata'            => 'Inconsolata',
        'Indie Flower'           => 'Indie Flower',
        'IM Fell English SC'     => 'IM Fell English SC',
        'Julius Sans One'        => 'Julius Sans One',
        'Josefin Slab'           => 'Josefin Slab',
        'Josefin Sans'           => 'Josefin Sans',
        'Kanit'                  => 'Kanit',
        'Lobster'                => 'Lobster',
        'Lato'                   => 'Lato',
        'Lora'                   => 'Lora',
        'Libre Baskerville'      => 'Libre Baskerville',
        'Lobster Two'            => 'Lobster Two',
        'Merriweather'           => 'Merriweather',
        'Monda'                  => 'Monda',
        'Montserrat'             => 'Montserrat',
        'Muli'                   => 'Muli',
        'Marck Script'           => 'Marck Script',
        'Noto Serif'             => 'Noto Serif',
        'Open Sans'              => 'Open Sans',
        'Overpass'               => 'Overpass',
        'Overpass Mono'          => 'Overpass Mono',
        'Oxygen'                 => 'Oxygen',
        'Orbitron'               => 'Orbitron',
        'Patua One'              => 'Patua One',
        'Pacifico'               => 'Pacifico',
        'Padauk'                 => 'Padauk',
        'Playball'               => 'Playball',
        'Playfair Display'       => 'Playfair Display',
        'PT Sans'                => 'PT Sans',
        'Philosopher'            => 'Philosopher',
        'Permanent Marker'       => 'Permanent Marker',
        'Poiret One'             => 'Poiret One',
        'Quicksand'              => 'Quicksand',
        'Quattrocento Sans'      => 'Quattrocento Sans',
        'Raleway'                => 'Raleway',
        'Rubik'                  => 'Rubik',
        'Roboto'                 => 'Roboto',
        'Rokkitt'                => 'Rokkitt',
        'Russo One'              => 'Russo One',
        'Righteous'              => 'Righteous',
        'Slabo'                  => 'Slabo',
        'Source Sans Pro'        => 'Source Sans Pro',
        'Shadows Into Light Two' => 'Shadows Into Light Two',
        'Shadows Into Light'     => 'Shadows Into Light',
        'Sacramento'             => 'Sacramento',
        'Shrikhand'              => 'Shrikhand',
        'Tangerine'              => 'Tangerine',
        'Ubuntu'                 => 'Ubuntu',
        'VT323'                  => 'VT323',
        'Varela Round'           => 'Varela Round',
        'Vampiro One'            => 'Vampiro One',
        'Vollkorn'               => 'Vollkorn',
        'Volkhov'                => 'Volkhov',
        'Yanone Kaffeesatz'      => 'Yanone Kaffeesatz'
    );

    // Heading Typography
    $wp_customize->add_setting( 'ai_services_heading_color', array(
        'default' => '',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ai_services_heading_color', array(
        'label' => __('Heading Color', 'ai-services'),
        'section' => 'ai_services_global_color_settings',
        'settings' => 'ai_services_heading_color',
    )));

    $wp_customize->add_setting('ai_services_heading_font_family', array(
        'default'           => '',
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'ai_services_sanitize_choices',
    ));
    $wp_customize->add_control( 'ai_services_heading_font_family', array(
        'section' => 'ai_services_global_color_settings',
        'label'   => __('Heading Fonts', 'ai-services'),
        'type'    => 'select',
        'choices' => $ai_services_font_array,
    ));

    $wp_customize->add_setting('ai_services_heading_font_size',array(
        'default' => '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('ai_services_heading_font_size',array(
        'label' => esc_html__('Heading Font Size','ai-services'),
        'section' => 'ai_services_global_color_settings',
        'setting' => 'ai_services_heading_font_size',
        'type'  => 'text'
    ));

    // Paragraph Typography
    $wp_customize->add_setting( 'ai_services_paragraph_color', array(
        'default' => '',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ai_services_paragraph_color', array(
        'label' => __('Paragraph Color', 'ai-services'),
        'section' => 'ai_services_global_color_settings',
        'settings' => 'ai_services_paragraph_color',
    )));

    $wp_customize->add_setting('ai_services_paragraph_font_family', array(
        'default'           => '',
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'ai_services_sanitize_choices',
    ));
    $wp_customize->add_control( 'ai_services_paragraph_font_family', array(
        'section' => 'ai_services_global_color_settings',
        'label'   => __('Paragraph Fonts', 'ai-services'),
        'type'    => 'select',
        'choices' => $ai_services_font_array,
    ));

    $wp_customize->add_setting('ai_services_paragraph_font_size',array(
        'default' => '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('ai_services_paragraph_font_size',array(
        'label' => esc_html__('Paragraph Font Size','ai-services'),
        'section' => 'ai_services_global_color_settings',
        'setting' => 'ai_services_paragraph_font_size',
        'type'  => 'text'
    ));

    // Post Layouts Settings
     $wp_customize->add_section('ai_services_post_layouts_settings',array(
        'title' => esc_html__('Post Layouts Settings','ai-services'),
        'priority'   => 30,
    ));

    $wp_customize->add_setting('ai_services_post_layout',array(
        'default' => 'pattern_two_column_right',
        'sanitize_callback' => 'ai_services_sanitize_choices'
    ));
    $wp_customize->add_control(new AI_Services_Image_Radio_Control($wp_customize, 'ai_services_post_layout', array(
        'type' => 'select',
        'label' => __('Blog Post Layouts','ai-services'),
        'section' => 'ai_services_post_layouts_settings',
        'choices' => array(
            'pattern_one_column' => esc_url(get_template_directory_uri()).'/assets/img/1column.png',
            'pattern_two_column_right' => esc_url(get_template_directory_uri()).'/assets/img/right-sidebar.png',
            'pattern_two_column_left' => esc_url(get_template_directory_uri()).'/assets/img/left-sidebar.png',
            'pattern_three_column' => esc_url(get_template_directory_uri()).'/assets/img/3column.png',
            'pattern_four_column' => esc_url(get_template_directory_uri()).'/assets/img/4column.png',
            'pattern_grid_post' => esc_url(get_template_directory_uri()).'/assets/img/grid.png',
    ))
    ));

    // General Settings
     $wp_customize->add_section('ai_services_general_settings',array(
        'title' => esc_html__('General Settings','ai-services'),
        'priority'   => 30,
    ));

     $wp_customize->add_setting('ai_services_width_option',array(
        'default' => 'Full Width',
        'transport' => 'refresh',
        'sanitize_callback' => 'ai_services_sanitize_choices'
    ));
    $wp_customize->add_control('ai_services_width_option',array(
        'type' => 'select',
        'section' => 'ai_services_general_settings',
        'choices' => array(
            'Full Width' => __('Full Width','ai-services'),
            'Wide Width' => __('Wide Width','ai-services'),
            'Boxed Width' => __('Boxed Width','ai-services')
        ),
    ) );

    $wp_customize->add_setting('ai_services_nav_menu_text_transform',array(
        'default'=> 'Capitalize',
        'sanitize_callback' => 'ai_services_sanitize_choices'
    ));
    $wp_customize->add_control('ai_services_nav_menu_text_transform',array(
        'type' => 'radio',
        'choices' => array(
            'Uppercase' => __('Uppercase','ai-services'),
            'Capitalize' => __('Capitalize','ai-services'),
            'Lowercase' => __('Lowercase','ai-services'),
        ),
        'section'=> 'ai_services_general_settings',
    ));

    $wp_customize->add_setting('ai_services_preloader_hide', array(
        'default' => 0,
        'sanitize_callback' => 'ai_services_sanitize_checkbox'
    ));
    $wp_customize->add_control( new WP_Customize_Control($wp_customize,'ai_services_preloader_hide',array(
        'label'          => __( 'Show Theme Preloader', 'ai-services' ),
        'section'        => 'ai_services_general_settings',
        'settings'       => 'ai_services_preloader_hide',
        'type'           => 'checkbox',
    )));

    $wp_customize->add_setting( 'ai_services_preloader_bg_color', array(
        'default' => '#7D59FB',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ai_services_preloader_bg_color', array(
        'label' => esc_html__('Preloader Background Color','ai-services'),
        'section' => 'ai_services_general_settings',
        'settings' => 'ai_services_preloader_bg_color'
    )));

    $wp_customize->add_setting( 'ai_services_preloader_dot_1_color', array(
        'default' => '#ffffff',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ai_services_preloader_dot_1_color', array(
        'label' => esc_html__('Preloader First Dot Color','ai-services'),
        'section' => 'ai_services_general_settings',
        'settings' => 'ai_services_preloader_dot_1_color'
    )));

    $wp_customize->add_setting( 'ai_services_preloader_dot_2_color', array(
        'default' => '#222222',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ai_services_preloader_dot_2_color', array(
        'label' => esc_html__('Preloader Second Dot Color','ai-services'),
        'section' => 'ai_services_general_settings',
        'settings' => 'ai_services_preloader_dot_2_color'
    )));

    $wp_customize->add_setting('ai_services_scroll_hide', array(
        'default' => true,
        'sanitize_callback' => 'ai_services_sanitize_checkbox'
    ));
    $wp_customize->add_control( new WP_Customize_Control($wp_customize,'ai_services_scroll_hide',array(
        'label'          => __( 'Show Theme Scroll To Top', 'ai-services' ),
        'section'        => 'ai_services_general_settings',
        'settings'       => 'ai_services_scroll_hide',
        'type'           => 'checkbox',
    )));

    $wp_customize->add_setting('ai_services_scroll_top_position',array(
        'default' => 'Right',
        'sanitize_callback' => 'ai_services_sanitize_choices'
    ));
    $wp_customize->add_control('ai_services_scroll_top_position',array(
        'type' => 'radio',
        'section' => 'ai_services_general_settings',
        'choices' => array(
            'Right' => __('Right','ai-services'),
            'Left' => __('Left','ai-services'),
            'Center' => __('Center','ai-services')
        ),
    ) );

    $wp_customize->add_setting( 'ai_services_scroll_bg_color', array(
        'default' => '',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ai_services_scroll_bg_color', array(
        'label' => esc_html__('Scroll Top Background Color','ai-services'),
        'section' => 'ai_services_general_settings',
        'settings' => 'ai_services_scroll_bg_color'
    )));

    $wp_customize->add_setting( 'ai_services_scroll_color', array(
        'default' => '',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ai_services_scroll_color', array(
        'label' => esc_html__('Scroll Top Color','ai-services'),
        'section' => 'ai_services_general_settings',
        'settings' => 'ai_services_scroll_color'
    )));

    $wp_customize->add_setting('ai_services_scroll_font_size',array(
        'default'   => 16,
        'sanitize_callback' => 'ai_services_sanitize_number_absint'
    ));
    $wp_customize->add_control('ai_services_scroll_font_size',array(
        'label' => __('Scroll Top Font Size','ai-services'),
        'description' => __('Put in px','ai-services'),
        'section'   => 'ai_services_general_settings',
        'type'      => 'number'
    ));

    $wp_customize->add_setting('ai_services_scroll_border_radius',array(
        'default'   => 0,
        'sanitize_callback' => 'absint'
    ));
    $wp_customize->add_control('ai_services_scroll_border_radius',array(
        'label' => __('Scroll Top Border Radius','ai-services'),
        'description' => __('Put in %','ai-services'),
        'section'   => 'ai_services_general_settings',
        'type'      => 'number'
    ));

    // Product Columns
    $wp_customize->add_setting( 'ai_services_products_per_row' , array(
       'default'           => '3',
       'transport'         => 'refresh',
       'sanitize_callback' => 'ai_services_sanitize_select',
    ) );

    $wp_customize->add_control('ai_services_products_per_row', array(
       'label' => __( 'Product per row', 'ai-services' ),
       'section'  => 'ai_services_general_settings',
       'type'     => 'select',
       'choices'  => array(
           '2' => '2',
           '3' => '3',
           '4' => '4',
       ),
    ) );

    $wp_customize->add_setting('ai_services_product_per_page',array(
        'default'   => 9,
        'sanitize_callback' => 'ai_services_sanitize_number_absint'
    ));
    $wp_customize->add_control('ai_services_product_per_page',array(
        'label' => __('Product per page','ai-services'),
        'section'   => 'ai_services_general_settings',
        'type'      => 'number'
    ));

    // Product Columns
    $wp_customize->add_setting('custom_related_products_number_per_row',array(
        'default'           => 3,
        'transport'         => 'refresh',
        'sanitize_callback' => 'ai_services_sanitize_number_range',
    ));

    $wp_customize->add_control('custom_related_products_number_per_row',array(
        'label'       => esc_html__('Related Products Column Count', 'ai-services'),
        'section'     => 'ai_services_general_settings',
        'type'        => 'number',
        'input_attrs' => array(
            'step' => 1,
            'min'  => 1,
            'max'  => 4,
        ),
    ));

    // Product Columns
    $wp_customize->add_setting('custom_related_products_number',array(
        'default'           => 3,
        'transport'         => 'refresh',
        'sanitize_callback' => 'ai_services_sanitize_number_range',
    ));

    $wp_customize->add_control('custom_related_products_number',array(
        'label'       => esc_html__('Number of Related Products Per Page', 'ai-services'),
        'section'     => 'ai_services_general_settings',
        'type'        => 'number',
        'input_attrs' => array(
            'step' => 1,
            'min'  => 1,
            'max'  => 10,
        ),
    ));

    $wp_customize->add_setting('ai_services_related_product_display_setting', array(
        'default' => true,
        'sanitize_callback' => 'ai_services_sanitize_checkbox'
    ));
    $wp_customize->add_control( new WP_Customize_Control($wp_customize,'ai_services_related_product_display_setting',array(
        'label'          => __( 'Show Related Products', 'ai-services' ),
        'section'        => 'ai_services_general_settings',
        'settings'       => 'ai_services_related_product_display_setting',
        'type'           => 'checkbox',
    )));

    //Woocommerce shop page Sidebar
    $wp_customize->add_setting('ai_services_woocommerce_shop_page_sidebar', array(
        'default' => true,
        'sanitize_callback' => 'ai_services_sanitize_checkbox'
    ));
    $wp_customize->add_control( new WP_Customize_Control($wp_customize,'ai_services_woocommerce_shop_page_sidebar',array(
        'label'          => __( 'Hide Shop Page Sidebar', 'ai-services' ),
        'section'        => 'ai_services_general_settings',
        'settings'       => 'ai_services_woocommerce_shop_page_sidebar',
        'type'           => 'checkbox',
    )));

    $wp_customize->add_setting('ai_services_shop_page_sidebar_layout',array(
        'default' => 'Right Sidebar',
        'sanitize_callback' => 'ai_services_sanitize_choices'
    ));
    $wp_customize->add_control('ai_services_shop_page_sidebar_layout',array(
        'type' => 'select',
        'label' => __('Woocommerce Shop Page Sidebar','ai-services'),
        'section' => 'ai_services_general_settings',
        'choices' => array(
            'Left Sidebar' => __('Left Sidebar','ai-services'),
            'Right Sidebar' => __('Right Sidebar','ai-services'),
        ),
    ) );

    //Woocommerce Single Product page Sidebar
    $wp_customize->add_setting('ai_services_woocommerce_single_product_page_sidebar', array(
        'default' => true,
        'sanitize_callback' => 'ai_services_sanitize_checkbox'
    ));
    $wp_customize->add_control( new WP_Customize_Control($wp_customize,'ai_services_woocommerce_single_product_page_sidebar',array(
        'label'          => __( 'Hide Single Product Page Sidebar', 'ai-services' ),
        'section'        => 'ai_services_general_settings',
        'settings'       => 'ai_services_woocommerce_single_product_page_sidebar',
        'type'           => 'checkbox',
    )));

    $wp_customize->add_setting('ai_services_single_product_sidebar_layout',array(
        'default' => 'Right Sidebar',
        'sanitize_callback' => 'ai_services_sanitize_choices'
    ));
    $wp_customize->add_control('ai_services_single_product_sidebar_layout',array(
        'type' => 'select',
        'label' => __('Woocommerce Single Product Page Sidebar','ai-services'),
        'section' => 'ai_services_general_settings',
        'choices' => array(
            'Left Sidebar' => __('Left Sidebar','ai-services'),
            'Right Sidebar' => __('Right Sidebar','ai-services'),
        ),
    ) );

    //Header
    $wp_customize->add_section('ai_services_header',array(
        'title' => esc_html__('Header Option','ai-services')
    ));

    $wp_customize->add_setting('ai_services_header_btn_text',array(
        'default' => '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('ai_services_header_btn_text',array(
        'label' => esc_html__('Header Button Text','ai-services'),
        'section' => 'ai_services_header',
        'setting' => 'ai_services_header_btn_text',
        'type'  => 'text'
    ));

    $wp_customize->add_setting('ai_services_header_btn_url',array(
        'default' => '',
        'sanitize_callback' => 'esc_url_raw'
    ));
    $wp_customize->add_control('ai_services_header_btn_url',array(
        'label' => esc_html__('Header Button URL','ai-services'),
        'section' => 'ai_services_header',
        'setting' => 'ai_services_header_btn_url',
        'type'  => 'url'
    ));

    // Hero / Slider Section
    $wp_customize->add_section( 'ai_services_top_slider', array(
        'title'       => esc_html__( 'Banner Settings', 'ai-services' ),
        'description' => esc_html__( 'Controls the hero section with left content and the right appointment form. Select a page to pull the heading, description, and featured image. You can also upload a custom hero image below.', 'ai-services' ),
    ) );

    $wp_customize->add_setting('ai_services_top_slider_setting', array(
        'default' => false,
        'sanitize_callback' => 'ai_services_sanitize_checkbox'
    ));
    $wp_customize->add_control( new WP_Customize_Control($wp_customize,'ai_services_top_slider_setting',array(
        'label'          => __( 'Enable Disable Banner', 'ai-services' ),
        'section'        => 'ai_services_top_slider',
        'settings'       => 'ai_services_top_slider_setting',
        'type'           => 'checkbox',
    )));


    $wp_customize->add_setting( 'ai_services_banner_heading', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'ai_services_banner_heading', array(
        'label'       => __( 'Main Heading', 'ai-services' ),
        'section'     => 'ai_services_top_slider',
        'type'        => 'text',
    ) );

    // Slider Short Heading / Badge
    $wp_customize->add_setting( 'ai_services_banner_circle_heading', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'ai_services_banner_circle_heading', array(
        'label'       => __( 'Circle Small Heading', 'ai-services' ),
        'section'     => 'ai_services_top_slider',
        'type'        => 'text',
    ) );


    $wp_customize->add_setting( 'ai_services_banner_content', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'ai_services_banner_content', array(
        'label'       => __( 'Banner Content', 'ai-services' ),
        'section'     => 'ai_services_top_slider',
        'type'        => 'text',
    ) );

    // Slider Button 2 text
    $wp_customize->add_setting( 'ai_services_slider_button_text_2', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'ai_services_slider_button_text_2', array(
        'label'   => __( 'Button 1 Text', 'ai-services' ),
        'section' => 'ai_services_top_slider',
        'type'    => 'text',
    ) );

    $wp_customize->add_setting( 'ai_services_slider_button_text_2_url', array(
        'default'           => '',
        'sanitize_callback' => 'esc_url_raw',
    ) );
    $wp_customize->add_control( 'ai_services_slider_button_text_2_url', array(
        'label'   => esc_html__( 'Button 1 URL', 'ai-services' ),
        'section' => 'ai_services_top_slider',
        'type'    => 'url',
    ) );

    // Features Section
    $wp_customize->add_section( 'ai_services_features_section', array(
        'title' => esc_html__( 'Features Section', 'ai-services' ),
    ) );

    $wp_customize->add_setting( 'ai_services_features_section_setting', array(
        'default'           => false,
        'sanitize_callback' => 'ai_services_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'ai_services_features_section_setting', array(
        'label'    => __( 'Show Features Section', 'ai-services' ),
        'section'  => 'ai_services_features_section',
        'settings' => 'ai_services_features_section_setting',
        'type'     => 'checkbox',
    ) ) );

    $wp_customize->add_setting( 'ai_services_features_sub_heading', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'ai_services_features_sub_heading', array(
        'label'   => esc_html__( 'Sub Heading', 'ai-services' ),
        'section' => 'ai_services_features_section',
        'type'    => 'text',
    ) );

    $wp_customize->add_setting( 'ai_services_features_main_heading', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'ai_services_features_main_heading', array(
        'label'   => esc_html__( 'Main Heading', 'ai-services' ),
        'section' => 'ai_services_features_section',
        'type'    => 'text',
    ) );

    $wp_customize->add_setting( 'ai_services_features_post_count', array(
        'default'           => '3',
        'sanitize_callback' => 'ai_services_sanitize_number_absint',
    ) );
    $wp_customize->add_control( 'ai_services_features_post_count', array(
        'label'   => esc_html__( 'Post Count', 'ai-services' ),
        'section' => 'ai_services_features_section',
        'type'    => 'number',
    ) );

    $categories = get_categories();
    $cat_post = array();
    $cat_post[]= 'select';
    $i = 0;
    foreach($categories as $category){
        if($i==0){
            $default = $category->slug;
            $i++;
        }
        $cat_post[$category->slug] = $category->name;
    }

    $wp_customize->add_setting('ai_services_features_category',array(
        'default'   => '',
        'sanitize_callback' => 'ai_services_sanitize_choices',
    ));
    $wp_customize->add_control('ai_services_features_category',array(
        'type'    => 'select',
        'choices' => $cat_post,
        'label' => __('Select Category to display Features','ai-services'),
        'section' => 'ai_services_features_section',
    ));

    for ($ai_services_count=1; $ai_services_count <= get_theme_mod('ai_services_features_post_count',3); $ai_services_count++) { 
        $wp_customize->add_setting( 'ai_services_feature_icon'.$ai_services_count, array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        ) );
        $wp_customize->add_control( 'ai_services_feature_icon'.$ai_services_count, array(
            'label'   => esc_html__( 'Feature Icon ', 'ai-services' ).$ai_services_count,
            'description' => esc_html__( 'Add Font Awesome icon class here. For Ex.. "fa-solid fa-robot"', 'ai-services' ),
            'section' => 'ai_services_features_section',
            'type'    => 'text',
        ) );
    }

    $wp_customize->add_setting( 'ai_services_features_btn_text', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'ai_services_features_btn_text', array(
        'label'   => esc_html__( 'Features Button Text', 'ai-services' ),
        'section' => 'ai_services_features_section',
        'type'    => 'text',
    ) );

    // Task Section
    $wp_customize->add_section( 'ai_services_task_section', array(
        'title' => esc_html__( 'Task Section', 'ai-services' ),
    ) );

    $wp_customize->add_setting( 'ai_services_task_section_setting', array(
        'default'           => false,
        'sanitize_callback' => 'ai_services_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'ai_services_task_section_setting', array(
        'label'    => __( 'Show Task Section', 'ai-services' ),
        'section'  => 'ai_services_task_section',
        'settings' => 'ai_services_task_section_setting',
        'type'     => 'checkbox',
    ) ) );

    $wp_customize->add_setting( 'ai_services_task_heading', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'ai_services_task_heading', array(
        'label'   => esc_html__( 'Main Heading', 'ai-services' ),
        'section' => 'ai_services_task_section',
        'type'    => 'text',
    ) );

    $wp_customize->add_setting( 'ai_services_task_content', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'ai_services_task_content', array(
        'label'       => esc_html__( 'Task Description', 'ai-services' ),
        'section'     => 'ai_services_task_section',
        'type'        => 'text',
    ) );

    for ($i=1; $i <= 4; $i++) { 
        $wp_customize->add_setting( 'ai_services_task_list_text'.$i, array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        ) );
        $wp_customize->add_control( 'ai_services_task_list_text'.$i, array(
            'label'   => esc_html__( 'Task List Text ', 'ai-services' ).$i,
            'section' => 'ai_services_task_section',
            'type'    => 'text',
        ) );
    }

    $wp_customize->add_setting( 'ai_services_task_right_image', array(
        'default'           => '',
        'sanitize_callback' => 'esc_url_raw',
    ) );
    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'ai_services_task_right_image', array(
        'label'   => esc_html__( 'Right Side Image', 'ai-services' ),
        'section' => 'ai_services_task_section',
    ) ) );

    // Post Settings
     $wp_customize->add_section('ai_services_post_settings',array(
        'title' => esc_html__('Post Settings','ai-services'),
        'priority'   =>40,
    ));

    $wp_customize->add_setting('ai_services_post_page_title',array(
        'sanitize_callback' => 'ai_services_sanitize_checkbox',
        'default'           => 1,
    ));
    $wp_customize->add_control('ai_services_post_page_title',array(
        'type'        => 'checkbox',
        'label'       => esc_html__('Enable Post Page Title', 'ai-services'),
        'section'     => 'ai_services_post_settings',
        'description' => esc_html__('Check this box to enable title on post page.', 'ai-services'),
    ));

    $wp_customize->add_setting('ai_services_post_page_meta',array(
        'sanitize_callback' => 'ai_services_sanitize_checkbox',
        'default'           => 1,
    ));
    $wp_customize->add_control('ai_services_post_page_meta',array(
        'type'        => 'checkbox',
        'label'       => esc_html__('Enable Post Page Meta', 'ai-services'),
        'section'     => 'ai_services_post_settings',
        'description' => esc_html__('Check this box to enable meta on post page.', 'ai-services'),
    ));

    $wp_customize->add_setting('ai_services_post_page_thumb',array(
        'sanitize_callback' => 'ai_services_sanitize_checkbox',
        'default'           => 1,
    ));
    $wp_customize->add_control('ai_services_post_page_thumb',array(
        'type'        => 'checkbox',
        'label'       => esc_html__('Enable Post Page Thumbnail', 'ai-services'),
        'section'     => 'ai_services_post_settings',
        'description' => esc_html__('Check this box to enable thumbnail on post page.', 'ai-services'),
    ));

    $wp_customize->add_setting('ai_services_post_page_content',array(
        'sanitize_callback' => 'ai_services_sanitize_checkbox',
        'default'           => 1,
    ));
    $wp_customize->add_control('ai_services_post_page_content',array(
        'type'        => 'checkbox',
        'label'       => esc_html__('Enable Post Page Content', 'ai-services'),
        'section'     => 'ai_services_post_settings',
        'description' => esc_html__('Check this box to enable content on post page.', 'ai-services'),
    ));

    $wp_customize->add_setting('ai_services_post_page_excerpt_length',array(
        'sanitize_callback' => 'ai_services_sanitize_number_range',
        'default'           => 30,
    ));
    $wp_customize->add_control('ai_services_post_page_excerpt_length',array(
        'label'       => esc_html__('Post Page Excerpt Length', 'ai-services'),
        'section'     => 'ai_services_post_settings',
        'type'        => 'range',
        'input_attrs' => array(
            'step'             => 1,
            'min'              => 1,
            'max'              => 50,
        ),
    ));

    $wp_customize->add_setting('ai_services_post_page_excerpt_suffix',array(
        'sanitize_callback' => 'sanitize_text_field',
        'default'           => '[...]',
    ));
    $wp_customize->add_control('ai_services_post_page_excerpt_suffix',array(
        'type'        => 'text',
        'label'       => esc_html__('Post Page Excerpt Suffix', 'ai-services'),
        'section'     => 'ai_services_post_settings',
        'description' => esc_html__('For Ex. [...], etc', 'ai-services'),
    ));

    $wp_customize->add_setting('ai_services_post_page_pagination',array(
        'sanitize_callback' => 'ai_services_sanitize_checkbox',
        'default'           => 1,
    ));
    $wp_customize->add_control('ai_services_post_page_pagination',array(
        'type'        => 'checkbox',
        'label'       => esc_html__('Enable Post Page Pagination', 'ai-services'),
        'section'     => 'ai_services_post_settings',
        'description' => esc_html__('Check this box to enable pagination on post page.', 'ai-services'),
    ));

    $wp_customize->add_setting('ai_services_single_post_page_content',array(
        'sanitize_callback' => 'ai_services_sanitize_checkbox',
        'default'           => 1,
    ));
    $wp_customize->add_control('ai_services_single_post_page_content',array(
        'type'        => 'checkbox',
        'label'       => esc_html__('Enable Single Post Page Content', 'ai-services'),
        'section'     => 'ai_services_post_settings',
        'description' => esc_html__('Check this box to enable content on single post page.', 'ai-services'),
    ));
    
    // Footer
    $wp_customize->add_section('ai_services_site_footer_section', array(
        'title' => esc_html__('Footer', 'ai-services'),
    ));

    $wp_customize->add_setting('ai_services_footer_widget_content_alignment',array(
        'default' => 'Left',
        'transport' => 'refresh',
        'sanitize_callback' => 'ai_services_sanitize_choices'
    ));
    $wp_customize->add_control('ai_services_footer_widget_content_alignment',array(
        'type' => 'select',
        'label' => __('Footer Widget Content Alignment','ai-services'),
        'section' => 'ai_services_site_footer_section',
        'choices' => array(
            'Left' => __('Left','ai-services'),
            'Center' => __('Center','ai-services'),
            'Right' => __('Right','ai-services')
        ),
    ) );

    $wp_customize->add_setting('ai_services_show_hide_copyright',array(
        'default' => true,
        'sanitize_callback' => 'ai_services_sanitize_checkbox'
    ));
    $wp_customize->add_control('ai_services_show_hide_copyright',array(
        'type' => 'checkbox',
        'label' => __('Show / Hide Copyright','ai-services'),
        'section' => 'ai_services_site_footer_section',
    ));

    $wp_customize->add_setting('ai_services_footer_text_setting', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ));
    $wp_customize->add_control('ai_services_footer_text_setting', array(
        'label' => __('Replace the footer text', 'ai-services'),
        'section' => 'ai_services_site_footer_section',
        'type' => 'text',
    ));

    $wp_customize->add_setting('ai_services_copyright_content_alignment',array(
        'default' => 'Center',
        'transport' => 'refresh',
        'sanitize_callback' => 'ai_services_sanitize_choices'
    ));
    $wp_customize->add_control('ai_services_copyright_content_alignment',array(
        'type' => 'select',
        'label' => __('Copyright Content Alignment','ai-services'),
        'section' => 'ai_services_site_footer_section',
        'choices' => array(
            'Left' => __('Left','ai-services'),
            'Center' => __('Center','ai-services'),
            'Right' => __('Right','ai-services')
        ),
    ) );
}
add_action('customize_register', 'ai_services_customize_register');

/**
 * Render the site title for the selective refresh partial.
 *
 * @return void
 */
function ai_services_customize_partial_blogname(){
    echo esc_html( get_bloginfo( 'name' ) );
}

/**
 * Render the site tagline for the selective refresh partial.
 *
 * @return void
 */
function ai_services_customize_partial_blogdescription(){
    echo esc_html( get_bloginfo( 'description' ) );
}

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function ai_services_customize_preview_js(){
    wp_enqueue_script('ai-services-customizer', esc_url( get_template_directory_uri() . '/assets/js/customizer.js' ), array('customize-preview'), '20151215', true);
}
add_action('customize_preview_init', 'ai_services_customize_preview_js');

/*
** Load dynamic logic for the customizer controls area.
*/
function ai_services_panels_js() {
    wp_enqueue_style( 'ai-services-customizer-layout-css', esc_url( get_theme_file_uri( '/assets/css/customizer-layout.css' ) ) );
    wp_enqueue_script( 'ai-services-customize-layout', esc_url( get_theme_file_uri( '/assets/js/customize-layout.js' ) ), array(), '1.2', true );
}
add_action( 'customize_controls_enqueue_scripts', 'ai_services_panels_js' );