<?php
/**
 * Blog Over Kirki Customizer Configuration
 * 
 * Complete customizer with all Kirki controls, selective refresh,
 * and comprehensive icon library
 *
 * @package Blog_Over
 */

// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}

// Check if Kirki exists
if (!class_exists('Kirki')) {
    return;
}

// Force enqueue our tabs assets
add_action( 'customize_controls_enqueue_scripts', function() {
    wp_enqueue_style( 'blog-over-tabs-control-global', get_template_directory_uri() . '/assets/css/customizer-tabs.css', array(), time() );
    wp_enqueue_script( 'blog-over-tabs-control-global', get_template_directory_uri() . '/assets/js/customizer-tabs.js', array('jquery', 'customize-controls'), time(), true );
}, 999 );

/**
 * Helper function to get categories for Kirki select
 */
function blog_over_get_categories_choices()
{
    $choices = array('' => esc_html__('All Categories', 'blog-over'));
    $categories = get_categories(array('hide_empty' => false));
    foreach ($categories as $category) {
        $choices[$category->slug] = esc_html($category->name);
    }
    return $choices;
}

/**
 * Helper function to get categories dropdown (for missed/trending sections)
 */
if (!function_exists('blog_over_get_categories_dropdown')) {
    function blog_over_get_categories_dropdown()
    {
        $categories = get_categories(array(
            'orderby' => 'name',
            'order' => 'ASC',
            'hide_empty' => true,
        ));

        $choices = array('all' => esc_html__('All Categories', 'blog-over'));

        foreach ($categories as $category) {
            $choices[$category->slug] = esc_html($category->name);
        }

        return $choices;
    }
}


/**
 * Helper function to get tags for Kirki select
 */
function blog_over_get_tags_choices()
{
    $choices = array();
    $tags = get_tags(array('hide_empty' => false));
    if (!empty($tags)) {
        foreach ($tags as $tag) {
            $choices[$tag->term_id] = esc_html($tag->name);
        }
    }
    return $choices;
}

/**
 * Get all FontAwesome icons for selector
 */
function blog_over_get_social_icons()
{
    return array(
        // Brands
        'fab fa-facebook-f' => 'Facebook',
        'fab fa-facebook' => 'Facebook (Full)',
        'fab fa-x-twitter' => 'Twitter/X',
        'fab fa-twitter' => 'Twitter',
        'fab fa-instagram' => 'Instagram',
        'fab fa-youtube' => 'YouTube',
        'fab fa-linkedin-in' => 'LinkedIn',
        'fab fa-linkedin' => 'LinkedIn (Full)',
        'fab fa-pinterest-p' => 'Pinterest',
        'fab fa-pinterest' => 'Pinterest (Full)',
        'fab fa-tiktok' => 'TikTok',
        'fab fa-whatsapp' => 'WhatsApp',
        'fab fa-telegram' => 'Telegram',
        'fab fa-github' => 'GitHub',
        'fab fa-dribbble' => 'Dribbble',
        'fab fa-behance' => 'Behance',
        'fab fa-snapchat' => 'Snapchat',
        'fab fa-reddit' => 'Reddit',
        'fab fa-tumblr' => 'Tumblr',
        'fab fa-flickr' => 'Flickr',
        'fab fa-vimeo-v' => 'Vimeo',
        'fab fa-soundcloud' => 'SoundCloud',
        'fab fa-spotify' => 'Spotify',
        'fab fa-discord' => 'Discord',
        'fab fa-slack' => 'Slack',
        'fab fa-skype' => 'Skype',
        'fab fa-medium' => 'Medium',
        'fab fa-quora' => 'Quora',
        'fab fa-stack-overflow' => 'Stack Overflow',
        'fab fa-codepen' => 'CodePen',
        'fab fa-twitch' => 'Twitch',
        'fab fa-paypal' => 'PayPal',
        'fab fa-amazon' => 'Amazon',
        'fab fa-apple' => 'Apple',
        'fab fa-android' => 'Android',
        'fab fa-google' => 'Google',
        'fab fa-windows' => 'Windows',
        'fab fa-wordpress' => 'WordPress',
        'fab fa-blogger' => 'Blogger',
        'fab fa-weixin' => 'WeChat',
        'fab fa-weibo' => 'Weibo',
        'fab fa-line' => 'LINE',
        'fab fa-viber' => 'Viber',
        'fab fa-bandcamp' => 'Bandcamp',
        'fab fa-mixcloud' => 'Mixcloud',
        'fab fa-goodreads' => 'Goodreads',
        'fab fa-etsy' => 'Etsy',
        'fab fa-shopify' => 'Shopify',
        'fab fa-yelp' => 'Yelp',
        'fab fa-tripadvisor' => 'TripAdvisor',
        'fab fa-airbnb' => 'Airbnb',
        'fab fa-imdb' => 'IMDb',
        'fab fa-deviantart' => 'DeviantArt',
        'fab fa-patreon' => 'Patreon',
        'fab fa-kickstarter' => 'Kickstarter',
        'fab fa-product-hunt' => 'Product Hunt',
        // Solid Icons
        'fas fa-rss' => 'RSS',
        'fas fa-envelope' => 'Email',
        'fas fa-phone' => 'Phone',
        'fas fa-map-marker-alt' => 'Location',
        'fas fa-globe' => 'Website',
        'fas fa-link' => 'Link',
        'fas fa-share-alt' => 'Share',
        'fas fa-comment' => 'Comment',
        'fas fa-heart' => 'Heart',
        'fas fa-star' => 'Star',
        'fas fa-bell' => 'Bell',
        'fas fa-camera' => 'Camera',
        'fas fa-music' => 'Music',
        'fas fa-video' => 'Video',
        'fas fa-podcast' => 'Podcast',
    );
}

/**
 * Add Kirki Config with partial refresh support
 */
Kirki::add_config('Blog_Over_config', array(
    'capability' => 'edit_theme_options',
    'option_type' => 'theme_mod',
));

// =============================================
// SITE IDENTITY: Branding Layout
// Uses WordPress native "Display Site Title and Tagline" checkbox.
// Layout option only appears when title is visible AND a logo exists.
// =============================================
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_logo_title_layout',
    'label' => esc_html__('Branding Layout', 'blog-over'),
    'description' => esc_html__('Choose how your logo and title are arranged. Only visible when both a logo and "Display Site Title and Tagline" are enabled.', 'blog-over'),
    'section' => 'title_tagline',
    'default' => 'stacked',
    'priority' => 9,
    'choices' => array(
        'stacked' => esc_html__('Stacked', 'blog-over'),
        'inline' => esc_html__('Inline', 'blog-over'),
    ),
    'active_callback' => 'blog_over_branding_layout_active',
    'partial_refresh' => array(
        'blog_over_logo_title_layout' => array(
            'selector' => '.blog-over-site-branding',
            'render_callback' => 'blog_over_site_branding',
        ),
    ),
));

/**
 * ===========================================
 * PANEL: Header Options
 * ===========================================
 */
Kirki::add_panel('blog_over_header_panel', array(
    'priority' => 10,
    'title' => esc_html__('Header Options', 'blog-over'),
));

/**
 * ===========================================
 * PANEL: Front Page Sections
 * ===========================================
 */
Kirki::add_panel('blog_over_frontpage_panel', array(
    'priority' => 20,
    'title' => esc_html__('Front Page Sections', 'blog-over'),
));

/**
 * ===========================================
 * PANEL: Blog
 * ===========================================
 */
Kirki::add_panel('Blog_Over_panel', array(
    'priority' => 30,
    'title' => esc_html__('Blog', 'blog-over'),
));

/**
 * ===========================================
 * PANEL: Layout & Sidebars
 * ===========================================
 */
Kirki::add_panel('blog_over_layout_panel', array(
    'priority' => 40,
    'title' => esc_html__('Layout & Sidebars', 'blog-over'),
));

// ---------------------------------------------
// Section: Top Bar Settings
// ---------------------------------------------
Kirki::add_section('blog_over_topbar_section', array(
    'title' => esc_html__('Top Bar Settings', 'blog-over'),
    'panel' => 'blog_over_header_panel',
    'priority' => 10,
));

// === GENERAL ===
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_topbar_show',
    'label' => esc_html__('Show Top Bar', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 1,
    'default' => true,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-all',
    ),
    'partial_refresh' => array(
        'blog_over_topbar_show' => array(
            'selector' => '.blog-over-topbar',
            'render_callback' => '__return_false',
        ),
    ),
));

// Tabs Control
Kirki::add_field('Blog_Over_config', array(
    'type' => 'blog-over-tabs',
    'settings' => 'blog_over_topbar_tabs',
    'section' => 'blog_over_topbar_section',
    'priority' => 1.5,
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
    ),
));

// Dark/Light Mode Switcher Toggle
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_dark_mode_toggle',
    'label' => esc_html__('Dark/Light Mode Switch', 'blog-over'),
    'description' => esc_html__('Show a toggle button in the header for users to switch between dark and light themes.', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 2,
    'default' => true,
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
    ),
    'partial_refresh' => array(
        'blog_over_dark_mode_toggle' => array(
            'selector' => '.blog-over-theme-toggle-wrapper',
            'render_callback' => '__return_false',
        ),
    ),
));

// Toggle Button Style
Kirki::add_field('Blog_Over_config', array(
    'type' => 'select',
    'settings' => 'blog_over_toggle_style',
    'label' => esc_html__('Toggle Switch Style', 'blog-over'),
    'description' => esc_html__('Choose the visual style for the dark/light mode switch button.', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 3,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => 'pill',
    'choices' => array(
        'icon' => esc_html__('Icon (Classic)', 'blog-over'),
        'pill' => esc_html__('Pill Toggle (Modern)', 'blog-over'),
        'labeled' => esc_html__('Labeled Toggle', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
        array('setting' => 'blog_over_dark_mode_toggle', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'text',
    'settings' => 'blog_over_topbar_date_text',
    'label' => esc_html__('Custom Top Bar Text', 'blog-over'),
    'description' => esc_html__('Leave empty to show current date', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 10,
    'default' => '',
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
    ),
    'partial_refresh' => array(
        'blog_over_topbar_date_text' => array(
            'selector' => '.blog-over-topbar-inner',
            'render_callback' => '__return_false',
        ),
    ),
));

// === REGULAR SETTINGS ===
Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_topbar_height',
    'label' => esc_html__('Top Bar Height (px)', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 20,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => 40,
    'choices' => array('min' => 30, 'max' => 80, 'step' => 1),
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.blog-over-topbar',
            'property' => 'min-height',
            'units' => 'px',
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_topbar_width',
    'label' => esc_html__('Top Bar Width', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 25,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => 'boxed',
    'choices' => array(
        'full-width' => esc_html__('Full Width', 'blog-over'),
        'boxed' => esc_html__('Boxed', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_topbar_bg_type',
    'label' => esc_html__('Background Type', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 30,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => 'solid',
    'choices' => array(
        'solid' => esc_html__('Solid Color', 'blog-over'),
        'gradient' => esc_html__('Gradient', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_topbar_bg',
    'label' => esc_html__('Background Color', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 31,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => '#1e293b',
    'choices' => array('alpha' => true),
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.blog-over-topbar',
            'property' => 'background-color',
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
        array('setting' => 'blog_over_topbar_bg_type', 'operator' => '==', 'value' => 'solid'),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_topbar_gradient_start',
    'label' => esc_html__('Gradient Start Color', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 32,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => '#1e293b',
    'choices' => array('alpha' => true),
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
        array('setting' => 'blog_over_topbar_bg_type', 'operator' => '==', 'value' => 'gradient'),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_topbar_gradient_end',
    'label' => esc_html__('Gradient End Color', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 33,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => '#334155',
    'choices' => array('alpha' => true),
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
        array('setting' => 'blog_over_topbar_bg_type', 'operator' => '==', 'value' => 'gradient'),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_topbar_text_color',
    'label' => esc_html__('Text Color', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 35,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => '#94a3b8',
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => ':root',
            'property' => '--blog-over-topbar-text',
        ),
        array(
            'element' => '.blog-over-topbar-date, .blog-over-topbar-text, .blog-over-topbar-custom-text, .blog-over-topbar-centered-message, .blog-over-topbar-mobile-text',
            'property' => 'color',
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_topbar_border_show',
    'label' => esc_html__('Show Border Bottom', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 40,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => false,
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_topbar_border_color',
    'label' => esc_html__('Border Color', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 41,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => '#334155',
    'choices' => array('alpha' => true),
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.blog-over-topbar.blog-over-topbar-border',
            'property' => 'border-bottom-color',
            'suffix' => ' !important',
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
        array('setting' => 'blog_over_topbar_border_show', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_topbar_border_width',
    'label' => esc_html__('Border Width (px)', 'blog-over'),
    'section' => 'blog_over_topbar_section',
    'priority' => 42,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'default' => 1,
    'choices' => array('min' => 0, 'max' => 5, 'step' => 1),
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.blog-over-topbar.blog-over-topbar-border',
            'property' => 'border-bottom-width',
            'units' => 'px',
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_topbar_show', 'operator' => '==', 'value' => true),
        array('setting' => 'blog_over_topbar_border_show', 'operator' => '==', 'value' => true),
    ),
));

// ---------------------------------------------
// Section: Button Settings (CTA)
// ---------------------------------------------
Kirki::add_section('blog_over_button_section', array(
    'title' => esc_html__('Button Settings', 'blog-over'),
    'panel' => 'blog_over_header_panel',
    'priority' => 30,
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_show_subscribe_btn',
    'label' => esc_html__('Show Subscribe Button', 'blog-over'),
    'section' => 'blog_over_button_section',
    'priority' => 10,
    'default' => true,
    'partial_refresh' => array(
        'blog_over_show_subscribe_btn' => array(
            'selector' => '.blog-over-subscribe-btn',
            'render_callback' => '__return_false',
        ),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'text',
    'settings' => 'blog_over_subscribe_text',
    'label' => esc_html__('Button Text', 'blog-over'),
    'section' => 'blog_over_button_section',
    'default' => esc_html__('Subscribe', 'blog-over'),
    'active_callback' => array(
        array('setting' => 'blog_over_show_subscribe_btn', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'url',
    'settings' => 'blog_over_subscribe_url',
    'label' => esc_html__('Button URL', 'blog-over'),
    'section' => 'blog_over_button_section',
    'default' => '#',
    'active_callback' => array(
        array('setting' => 'blog_over_show_subscribe_btn', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_subscribe_new_tab',
    'label' => esc_html__('Open in New Tab', 'blog-over'),
    'section' => 'blog_over_button_section',
    'default' => true,
    'active_callback' => array(
        array('setting' => 'blog_over_show_subscribe_btn', 'operator' => '==', 'value' => true),
    ),
));

// ---------------------------------------------
// Section: Social Icons
// ---------------------------------------------
Kirki::add_section('blog_over_social_section', array(
    'title' => esc_html__('Social Icons', 'blog-over'),
    'panel' => 'blog_over_header_panel',
    'priority' => 50,
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_header_social_show',
    'label' => esc_html__('Show Social Icons in Header', 'blog-over'),
    'section' => 'blog_over_social_section',
    'priority' => 10,
    'default' => true,
    'partial_refresh' => array(
        'blog_over_header_social_show' => array(
            'selector' => '.blog-over-topbar-social',
            'render_callback' => '__return_false',
        ),
    ),
));

// === REGULAR SETTINGS (Always visible when Social Icons are enabled) ===
Kirki::add_field('Blog_Over_config', array(
    'type' => 'repeater',
    'settings' => 'blog_over_social_links',
    'label' => esc_html__('Social Links', 'blog-over'),
    'description' => esc_html__('Add your social media links with icons', 'blog-over'),
    'section' => 'blog_over_social_section',
    'row_label' => array(
        'type' => 'field',
        'value' => esc_html__('Social Link', 'blog-over'),
        'field' => 'label',
    ),
    'button_label' => esc_html__('Add Social Link', 'blog-over'),
    'default' => array(
        array('icon' => 'fab fa-facebook-f', 'url' => '#', 'label' => 'Facebook'),
        array('icon' => 'fab fa-x-twitter', 'url' => '#', 'label' => 'Twitter/X'),
        array('icon' => 'fab fa-instagram', 'url' => '#', 'label' => 'Instagram'),
    ),
    'fields' => array(
        'icon' => array(
            'type' => 'iconpicker',
            'label' => esc_html__('Select Icon', 'blog-over'),
        ),
        'url' => array(
            'type' => 'url',
            'label' => esc_html__('URL', 'blog-over'),
        ),
        'label' => array(
            'type' => 'text',
            'label' => esc_html__('Label', 'blog-over'),
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_header_social_show', 'operator' => '==', 'value' => true),
    ),
    'partial_refresh' => array(
        'blog_over_social_links_panel' => array(
            'selector'        => '.blog-over-mobile-panel-social',
            'render_callback' => '__return_false',
        ),
        'blog_over_social_links_topbar' => array(
            'selector'        => '.blog-over-topbar-social',
            'render_callback' => '__return_false',
        ),
    ),
));

// === DESIGN SETTINGS (Inside Design dropdown - registered in customizer-headings.php) ===

Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_social_icon_size',
    'label' => esc_html__('Icon Size (px)', 'blog-over'),
    'section' => 'blog_over_social_section',
    'priority' => 30,
    'default' => 14,
    'choices' => array('min' => 10, 'max' => 30, 'step' => 1),
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.blog-over-topbar-social-link i',
            'property' => 'font-size',
            'units' => 'px',
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_header_social_show', 'operator' => '==', 'value' => true),
    ),
));

// Icon Size Slider
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_social_icon_style',
    'label' => esc_html__('Icon Style', 'blog-over'),
    'section' => 'blog_over_social_section',
    'priority' => 40,
    'default' => 'default',
    'choices' => array(
        'default' => esc_html__('Default', 'blog-over'),
        'rounded' => esc_html__('Rounded', 'blog-over'),
        'outline' => esc_html__('Outline', 'blog-over'),
        'filled' => esc_html__('Filled', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_header_social_show', 'operator' => '==', 'value' => true),
    ),
));

// ---------------------------------------------
// Section: Menu Settings
// ---------------------------------------------
Kirki::add_section('blog_over_menu_section', array(
    'title' => esc_html__('Menu Settings', 'blog-over'),
    'panel' => 'blog_over_header_panel',
    'priority' => 20,
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'select',
    'settings' => 'blog_over_menu_layout',
    'label' => esc_html__('Menu Layout', 'blog-over'),
    'description' => esc_html__('Choose your preferred menu design layout.', 'blog-over'),
    'section' => 'blog_over_menu_section',
    'default' => 'layout-1',
    'choices' => blog_over_get_menu_layout_choices(),
    'sanitize_callback' => 'blog_over_sanitize_select',
    'partial_refresh' => array(
        'blog_over_menu_layout' => array(
            'selector' => '.blog-over-primary-menu-container, .blog-over-menu-left',
            'render_callback' => '__return_false',
        ),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_menu_width',
    'label' => esc_html__('Container Size', 'blog-over'),
    'description' => esc_html__('Choose whether the menu should be constrained to a box or stretch full width.', 'blog-over'),
    'section' => 'blog_over_menu_section',
    'default' => 'boxed',
    'priority' => 10,
    'choices' => array(
        'boxed' => esc_html__('Boxed', 'blog-over'),
        'full-width' => esc_html__('Full Width', 'blog-over'),
    ),
));

// ---------------------------------------------
// Section: Search Settings
// ---------------------------------------------
Kirki::add_section('blog_over_search_section', array(
    'title' => esc_html__('Search Settings', 'blog-over'),
    'panel' => 'blog_over_header_panel',
    'priority' => 40,
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_show_search',
    'label' => esc_html__('Show Search Icon', 'blog-over'),
    'section' => 'blog_over_search_section',
    'default' => true,
    'partial_refresh' => array(
        'blog_over_show_search' => array(
            'selector' => '.blog-over-search-wrapper',
            'render_callback' => '__return_false',
        ),
    ),
));

// === REGULAR SETTINGS (Always visible when Search is enabled) ===
Kirki::add_field('Blog_Over_config', array(
    'type' => 'select',
    'settings' => 'blog_over_search_style',
    'label' => esc_html__('Search Icon Style', 'blog-over'),
    'description' => esc_html__('Choose how the search opens when clicking the icon.', 'blog-over'),
    'section' => 'blog_over_search_section',
    'default' => 'popup',
    'choices' => blog_over_get_search_style_choices(),
    'sanitize_callback' => 'blog_over_sanitize_select',
    'active_callback' => array(
        array('setting' => 'blog_over_show_search', 'operator' => '==', 'value' => true),
    ),
));

// === DESIGN SETTINGS (Inside Design dropdown - registered in customizer-headings.php) ===


Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_search_icon_size',
    'label' => esc_html__('Search Icon Size (px)', 'blog-over'),
    'section' => 'blog_over_search_section',
    'priority' => 51,
    'default' => 16,
    'choices' => array('min' => 12, 'max' => 30, 'step' => 1),
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.blog-over-search-toggle i',
            'property' => 'font-size',
            'units' => 'px',
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_show_search', 'operator' => '==', 'value' => true),
    ),
));

/**
 * ===========================================
 * PANEL: Theme Design
 * ===========================================
 */
Kirki::add_panel('blog_over_theme_panel', array(
    'priority' => 50,
    'title' => esc_html__('Theme Design', 'blog-over'),
));

// ---------------------------------------------
// Section: Typography
// ---------------------------------------------
Kirki::add_section('blog_over_typography_section', array(
    'title' => esc_html__('Typography', 'blog-over'),
    'panel' => 'blog_over_theme_panel',
    'priority' => 30,
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'typography',
    'settings' => 'blog_over_body_font',
    'label' => esc_html__('Body Typography', 'blog-over'),
    'section' => 'blog_over_typography_section',
    'default' => array(
        'font-family' => 'Inter',
        'font-size' => '16px',
        'font-weight' => '400',
        'line-height' => '1.6',
    ),
    'transport' => 'auto',
    'output' => array(array('element' => 'body')),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'typography',
    'settings' => 'blog_over_heading_font',
    'label' => esc_html__('Headings Typography', 'blog-over'),
    'section' => 'blog_over_typography_section',
    'default' => array(
        'font-family' => 'Inter',
        'font-weight' => '700',
    ),
    'transport' => 'auto',
    'output' => array(array('element' => 'h1,h2,h3,h4,h5,h6')),
));

// ---------------------------------------------
// Section: Colors
// ---------------------------------------------
Kirki::add_section('blog_over_colors_section', array(
    'title' => esc_html__('Color Settings', 'blog-over'),
    'panel' => 'blog_over_theme_panel',
    'priority' => 20,
));

// Theme Skin - Default theme color on page load
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_theme_skin',
    'label' => esc_html__('Theme Skin', 'blog-over'),
    'description' => esc_html__('Select the default skin color. This will be loaded when the page refreshes.', 'blog-over'),
    'section' => 'blog_over_colors_section',
    'priority' => 3,
    'default' => 'light',
    'choices' => array(
        'light' => esc_html__('Light', 'blog-over'),
        'dark' => esc_html__('Dark', 'blog-over'),
    ),
));



Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_primary_color',
    'label' => esc_html__('Primary Color', 'blog-over'),
    'section' => 'blog_over_colors_section',
    'default' => '#3b82f6',
    'transport' => 'refresh',
    'output' => array(
        array('element' => ':root', 'property' => '--blog-over-primary'),
        array('element' => 'a:hover,.blog-over-post-title a:hover', 'property' => 'color'),
        array('element' => '.blog-over-category-badge,.blog-over-scroll-top', 'property' => 'background-color'),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_secondary_color',
    'label' => esc_html__('Secondary Color', 'blog-over'),
    'section' => 'blog_over_colors_section',
    'default' => '#1e40af',
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_text_color',
    'label' => esc_html__('Text Color', 'blog-over'),
    'section' => 'blog_over_colors_section',
    'default' => '#334155',
    'transport' => 'auto',
    'output' => array(array('element' => 'body', 'property' => 'color')),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_heading_color',
    'label' => esc_html__('Heading Color', 'blog-over'),
    'section' => 'blog_over_colors_section',
    'default' => '#1e293b',
    'transport' => 'auto',
    'output' => array(array('element' => 'h1,h2,h3,h4,h5,h6', 'property' => 'color')),
));

// ---------------------------------------------
// Section: Blog Settings
// ---------------------------------------------
Kirki::add_section('Blog_Over_section', array(
    'title' => esc_html__('Blog Settings', 'blog-over'),
    'panel' => 'Blog_Over_panel',
    'priority' => 10,
));

// TABS CONTROL
Kirki::add_field('Blog_Over_config', array(
    'type' => 'blog-over-tabs',
    'settings' => 'blog_over_blog_tabs',
    'section' => 'Blog_Over_section',
    'priority' => 0.5,
));

// Blog Style Selector
Kirki::add_field('Blog_Over_config', array(
    'type' => 'select',
    'settings' => 'Blog_Over_style',
    'label' => esc_html__('Blog Style', 'blog-over'),
    'description' => esc_html__('Choose the visual style for blog/archive pages.', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => 'default',
    'priority' => 5,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-general',
    ),
    'choices' => blog_over_get_blog_style_choices(),
    'sanitize_callback' => 'blog_over_sanitize_select',
));

// Grid Layout Mode (only for Modern Grid style)
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_grid_layout_mode',
    'label' => esc_html__('Grid Layout Mode', 'blog-over'),
    'description' => esc_html__('Choose between a structured grid or a Pinterest-style masonry layout.', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => 'default',
    'priority' => 6,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-general',
    ),
    'choices' => array(
        'default' => esc_html__('Default Grid', 'blog-over'),
        'masonry' => esc_html__('Masonry Grid', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'Blog_Over_style', 'operator' => '==', 'value' => 'modern-cards'),
    ),
    'sanitize_callback' => 'blog_over_sanitize_select',
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-image',
    'settings' => 'Blog_Over_layout',
    'label' => esc_html__('Blog Layout', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => 'right-sidebar',
    'priority' => 8,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-general',
    ),
    'choices' => array(
        'right-sidebar' => get_template_directory_uri() . '/assets/images/layout-right-sidebar.svg',
        'left-sidebar' => get_template_directory_uri() . '/assets/images/layout-left-sidebar.svg',
        'full-width' => get_template_directory_uri() . '/assets/images/layout-fullwidth.svg',
    ),
));

// Section Width (Blog only)
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'Blog_Over_section_width',
    'label' => esc_html__('Section Width', 'blog-over'),
    'description' => esc_html__('Controls the overall blog section container width.', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => 'boxed',
    'priority' => 10,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'choices' => array(
        'boxed' => esc_html__('Boxed', 'blog-over'),
        'full-width' => esc_html__('Full Width', 'blog-over'),
    ),
));

// Content Alignment
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_content_alignment',
    'label' => esc_html__('Content Alignment', 'blog-over'),
    'description' => esc_html__('Align post card text (left, center, right). Applies to all blog styles.', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => 'left',
    'priority' => 12,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'choices' => array(
        'left' => esc_html__('Left', 'blog-over'),
        'center' => esc_html__('Center', 'blog-over'),
        'right' => esc_html__('Right', 'blog-over'),
    ),
    'sanitize_callback' => 'blog_over_sanitize_select',
));

// Image Auto Height (Default Blog Style only)
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_default_image_auto_height',
    'label' => esc_html__('Image Auto Height', 'blog-over'),
    'description' => esc_html__('When enabled, the featured image stretches to match the full height of the content area, eliminating blank space below the image.', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => 'off',
    'priority' => 13,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'choices' => array(
        'on' => esc_html__('On', 'blog-over'),
        'off' => esc_html__('Off', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'Blog_Over_style', 'operator' => '==', 'value' => 'default'),
        array('setting' => 'Blog_Over_show_thumbnail', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'custom',
    'settings' => 'Blog_Over_elements_heading',
    'section' => 'Blog_Over_section',
    'default' => '<div style="padding: 12px 0; border-top: 1px solid #ddd; margin-top: 20px;"><strong>' . esc_html__('Post Elements', 'blog-over') . '</strong></div>',
    'priority' => 14,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-general',
    ),
));

// Featured Image Toggle - styled like sortable item but fixed at top
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'Blog_Over_show_thumbnail',
    'label' => esc_html__('Featured Image (Fixed)', 'blog-over'),
    'description' => esc_html__('Always shown when enabled. Category Badge requires this.', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => true,
    'priority' => 15,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-general',
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'sortable',
    'settings' => 'Blog_Over_entry_elements',
    'label' => esc_html__('Post Card Elements', 'blog-over'),
    'description' => esc_html__('Drag to reorder. Uncheck to hide.', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => array(
        'category',
        'header',
        'meta',
        'summary',
        'footer',
    ),
    'choices' => array(
        'category' => esc_html__('Category Badge', 'blog-over'),
        'header' => esc_html__('Post Title', 'blog-over'),
        'meta' => esc_html__('Post Meta', 'blog-over'),
        'summary' => esc_html__('Excerpt', 'blog-over'),
        'footer' => esc_html__('Read More Button', 'blog-over'),
    ),
    'priority' => 16,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-general',
    ),
    'partial_refresh' => array(
        'Blog_Over_entry_elements' => array(
            'selector' => '.blog-over-post-content, .blog-over-modern-content, .blog-over-grid-content, .blog-over-editorial-featured-content, .blog-over-editorial-item-content',
            'render_callback' => '__return_false',
        ),
    ),
));

// Read More Button Text
Kirki::add_field('Blog_Over_config', array(
    'type' => 'text',
    'settings' => 'blog_over_read_more_text',
    'label' => esc_html__('Read More Button Text', 'blog-over'),
    'description' => esc_html__('Customize the label for the Read More button.', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => esc_html__('Read More', 'blog-over'),
    'priority' => 17,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-general',
    ),
    // Only relevant when Read More Button (footer) is visible
    'active_callback' => array(
        array('setting' => 'Blog_Over_entry_elements', 'operator' => 'contains', 'value' => 'footer'),
    ),
    'partial_refresh' => array(
        'blog_over_read_more_text' => array(
            'selector' => '.blog-over-read-more, .blog-over-modern-readmore, .blog-over-grid-readmore, .blog-over-editorial-readmore',
            'render_callback' => function () {
                // Return text only; icon could be appended if needed, but keeping as original.
                // We could wrap it, but sticking to existing logic.
                return esc_html(get_theme_mod('blog_over_read_more_text', __('Read More', 'blog-over')));
            },
        ),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'custom',
    'settings' => 'Blog_Over_meta_heading',
    'section' => 'Blog_Over_section',
    'default' => '<div style="padding: 12px 0; border-top: 1px solid #ddd; margin-top: 20px;"><strong>' . esc_html__('Post Meta', 'blog-over') . '</strong></div>',
    'priority' => 18,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-general',
    ),
    'active_callback' => array(
        array('setting' => 'Blog_Over_entry_elements', 'operator' => 'contains', 'value' => 'meta'),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'sortable',
    'settings' => 'Blog_Over_entry_meta',
    'label' => esc_html__('Meta Elements', 'blog-over'),
    'description' => esc_html__('Set order and visibility for post meta items.', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => array(
        'author',
        'date',
        'comments',
    ),
    'choices' => array(
        'author' => esc_html__('Author', 'blog-over'),
        'date' => esc_html__('Publish Date', 'blog-over'),
        'category' => esc_html__('Category', 'blog-over'),
        'comments' => esc_html__('Comments', 'blog-over'),
    ),
    'priority' => 19,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-general',
    ),
    'active_callback' => array(
        array('setting' => 'Blog_Over_entry_elements', 'operator' => 'contains', 'value' => 'meta'),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_excerpt_length',
    'label' => esc_html__('Excerpt Length (words)', 'blog-over'),
    'section' => 'Blog_Over_section',
    'default' => 25,
    'choices' => array('min' => 10, 'max' => 100, 'step' => 5),
    'priority' => 20,
    // Hide this slider when Excerpt (summary) is removed from Post Card Elements
    'active_callback' => array(
        array('setting' => 'Blog_Over_entry_elements', 'operator' => 'contains', 'value' => 'summary'),
    ),
));

// Show Pagination Toggle
Kirki::add_field('Blog_Over_config', array(
    'type'     => 'toggle',
    'settings' => 'blog_over_show_pagination',
    'label'    => esc_html__('Show Pagination', 'blog-over'),
    'description' => esc_html__('Display page navigation links below the blog posts list.', 'blog-over'),
    'section'  => 'Blog_Over_section',
    'default'  => true,
    'priority' => 21,
));

// Pagination Style Selector
Kirki::add_field('Blog_Over_config', array(
    'type'     => 'radio-buttonset',
    'settings' => 'blog_over_pagination_style',
    'label'    => esc_html__('Pagination Style', 'blog-over'),
    'section'  => 'Blog_Over_section',
    'default'  => 'modern',
    'priority' => 22,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'choices'  => array(
        'modern'   => esc_html__('Modern', 'blog-over'),
        'minimal'  => esc_html__('Minimal', 'blog-over'),
        'rounded'  => esc_html__('Rounded', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_show_pagination', 'operator' => '==', 'value' => true),
    ),
    'sanitize_callback' => 'blog_over_sanitize_select',
));

// ---------------------------------------------
// Section: Tabbed Magazine (Front Page)
// ---------------------------------------------
Kirki::add_section('blog_over_tabbed_magazine_section', array(
    'title' => esc_html__('Tabbed Magazine', 'blog-over'),
    'panel' => 'blog_over_frontpage_panel',
    'priority' => 38,
));

// Enable Toggle
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_tabbed_magazine_enable',
    'label' => esc_html__('Enable Tab Magazine Section', 'blog-over'),
    'description' => esc_html__('Display a tabbed category magazine on the front page.', 'blog-over'),
    'section' => 'blog_over_tabbed_magazine_section',
    'default' => false,
    'priority' => 10,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-general',
    ),
));

// Tabs Control
Kirki::add_field('Blog_Over_config', array(
    'type' => 'blog-over-tabs',
    'settings' => 'blog_over_tabbed_magazine_tabs_control',
    'section' => 'blog_over_tabbed_magazine_section',
    'priority' => 0.5,
));

// Section Title
Kirki::add_field('Blog_Over_config', array(
    'type' => 'text',
    'settings' => 'blog_over_tabbed_magazine_title',
    'label' => esc_html__('Section Title', 'blog-over'),
    'section' => 'blog_over_tabbed_magazine_section',
    'default' => esc_html__('Around The Web', 'blog-over'),
    'priority' => 20,
    'active_callback' => array(
        array('setting' => 'blog_over_tabbed_magazine_enable', 'operator' => '==', 'value' => true),
    ),
    'partial_refresh' => array(
        'blog_over_tabbed_magazine_title' => array(
            'selector' => '.blog-over-tabbed-magazine-title',
            'render_callback' => function () {
                return esc_html(get_theme_mod('blog_over_tabbed_magazine_title', __('Around The Web', 'blog-over')));
            },
        ),
    ),
));

// Section Width
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_tabbed_magazine_section_width',
    'label' => esc_html__('Section Width', 'blog-over'),
    'section' => 'blog_over_tabbed_magazine_section',
    'default' => 'boxed',
    'priority' => 25,
    'wrapper_attrs' => array(
        'class' => '{default_class} blog-over-tab-design',
    ),
    'choices' => array(
        'boxed' => esc_html__('Boxed', 'blog-over'),
        'full-width' => esc_html__('Full Width', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_tabbed_magazine_enable', 'operator' => '==', 'value' => true),
    ),
));

// Posts per Tab
Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_tabbed_magazine_posts',
    'label' => esc_html__('Posts Per Tab', 'blog-over'),
    'description' => esc_html__('Number of posts shown per tab. Free: max 6.', 'blog-over'),
    'section' => 'blog_over_tabbed_magazine_section',
    'default' => 4,
    'choices' => array('min' => 2, 'max' => 6, 'step' => 1),
    'priority' => 30,
    'active_callback' => array(
        array('setting' => 'blog_over_tabbed_magazine_enable', 'operator' => '==', 'value' => true),
    ),
));

// Tabs Repeater
Kirki::add_field('Blog_Over_config', array(
    'type' => 'repeater',
    'settings' => 'blog_over_tabbed_magazine_tabs',
    'label' => esc_html__('Magazine Tabs', 'blog-over'),
    'description' => esc_html__('Add up to 3 tabs in the free version. Pro version unlocks unlimited tabs.', 'blog-over'),
    'section' => 'blog_over_tabbed_magazine_section',
    'priority' => 40,
    'choices' => array('limit' => apply_filters('blog_over_tabbed_magazine_tabs_limit', 3)),
    'row_label' => array(
        'type' => 'field',
        'value' => esc_html__('Tab', 'blog-over'),
        'field' => 'tab_label',
    ),
    'button_label' => esc_html__('Add Tab', 'blog-over'),
    'default' => array(
        array('tab_label' => esc_html__('Technology', 'blog-over'), 'tab_category' => ''),
        array('tab_label' => esc_html__('Travel', 'blog-over'), 'tab_category' => ''),
        array('tab_label' => esc_html__('Lifestyle', 'blog-over'), 'tab_category' => ''),
    ),
    'fields' => array(
        'tab_label' => array(
            'type' => 'text',
            'label' => esc_html__('Tab Label', 'blog-over'),
        ),
        'tab_category' => array(
            'type' => 'select',
            'label' => esc_html__('Filter by Category', 'blog-over'),
            'choices' => blog_over_get_categories_choices(),
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_tabbed_magazine_enable', 'operator' => '==', 'value' => true),
    ),
));


// ---------------------------------------------
// Section: Trending Posts (Front Page / Sidebar)
// ---------------------------------------------
require_once get_template_directory() . '/inc/customizer/sections/trending.php';

// ---------------------------------------------
// Section: Newsletter / CTA Banner
// ---------------------------------------------
require_once get_template_directory() . '/inc/customizer/sections/newsletter.php';

// ---------------------------------------------
// Section: Category Showcase
// ---------------------------------------------
require_once get_template_directory() . '/inc/customizer/sections/category-showcase.php';

// ---------------------------------------------
// Section: Announcement Bar
// ---------------------------------------------
require_once get_template_directory() . '/inc/customizer/sections/announcement.php';

// ---------------------------------------------
// Section: Single Post Settings (moved to separate file)
// ---------------------------------------------
require_once get_template_directory() . '/inc/customizer/sections/single.php';

/**
 * ===========================================
 * PANEL: Footer Options
 * ===========================================
 */
Kirki::add_panel('blog_over_footer_panel', array(
    'priority' => 60,
    'title' => esc_html__('Footer Options', 'blog-over'),
));

// ---------------------------------------------
// Section: Footer Widgets
// ---------------------------------------------
Kirki::add_section('blog_over_footer_section', array(
    'title' => esc_html__('Footer Widgets', 'blog-over'),
    'panel' => 'blog_over_footer_panel',
    'priority' => 10,
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_footer_columns',
    'label' => esc_html__('Footer Columns', 'blog-over'),
    'section' => 'blog_over_footer_section',
    'default' => '3',
    'priority' => 10,
    'choices' => array(
        '1' => '1',
        '2' => '2',
        '3' => '3',
        '4' => '4',
    ),
    'partial_refresh' => array(
        'blog_over_footer_columns_refresh' => array(
            'selector' => '.footer-widgets',
            'render_callback' => 'blog_over_render_footer_partial',
            'container_inclusive' => true,
            'fallback_refresh' => true,
        ),
    ),
    'active_callback' => array(
        array(
            'setting' => 'blog_over_footer_widgets_enable',
            'operator' => '==',
            'value' => true,
        ),
    ),
));

// Section Width
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_footer_section_width',
    'label' => esc_html__('Section Width', 'blog-over'),
    'section' => 'blog_over_footer_section',
    'default' => 'boxed',
    'priority' => 15,
    'choices' => array(
        'boxed' => esc_html__('Boxed', 'blog-over'),
        'full-width' => esc_html__('Full Width', 'blog-over'),
    ),
    'active_callback' => array(
        array(
            'setting' => 'blog_over_footer_widgets_enable',
            'operator' => '==',
            'value' => true,
        ),
    ),
));

// Enable / Disable Footer Widgets.
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_footer_widgets_enable',
    'label' => esc_html__('Enable Footer Widgets', 'blog-over'),
    'description' => esc_html__('Show or hide the footer widget area.', 'blog-over'),
    'section' => 'blog_over_footer_section',
    'default' => true,
    'priority' => 5,
    'partial_refresh' => array(
        'blog_over_footer_widgets_enable_refresh' => array(
            'selector' => '.footer-widgets',
            'render_callback' => 'blog_over_render_footer_partial',
            'container_inclusive' => true,
            'fallback_refresh' => true,
        ),
    ),
));

// Footer Column Gap.
Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_footer_column_gap',
    'label' => esc_html__('Column Gap (px)', 'blog-over'),
    'section' => 'blog_over_footer_section',
    'default' => 30,
    'priority' => 16,
    'choices' => array(
        'min' => 0,
        'max' => 80,
        'step' => 2,
    ),
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.footer-widgets-grid',
            'property' => 'gap',
            'units' => 'px',
        ),
    ),
    'active_callback' => array(
        array(
            'setting' => 'blog_over_footer_widgets_enable',
            'operator' => '==',
            'value' => true,
        ),
    ),
));

// Widget Vertical Spacing.
Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_footer_widget_spacing',
    'label' => esc_html__('Widget Vertical Spacing (px)', 'blog-over'),
    'section' => 'blog_over_footer_section',
    'default' => 20,
    'priority' => 17,
    'choices' => array(
        'min' => 0,
        'max' => 60,
        'step' => 2,
    ),
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.footer-widget .widget',
            'property' => 'margin-bottom',
            'units' => 'px',
        ),
    ),
    'active_callback' => array(
        array(
            'setting' => 'blog_over_footer_widgets_enable',
            'operator' => '==',
            'value' => true,
        ),
    ),
));

// Widget Title Color.
Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_footer_widget_title_color',
    'label' => esc_html__('Widget Title Color', 'blog-over'),
    'section' => 'blog_over_footer_section',
    'default' => '#ffffff',
    'priority' => 18,
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.footer-widget .widget-title, .footer-widget h2.wp-block-heading, .footer-widget .wp-block-group h2',
            'property' => 'color',
        ),
    ),
    'active_callback' => array(
        array(
            'setting' => 'blog_over_footer_widgets_enable',
            'operator' => '==',
            'value' => true,
        ),
    ),
));

// Widget Title Margin Bottom.
Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_footer_widget_title_margin',
    'label' => esc_html__('Widget Title Margin Bottom (px)', 'blog-over'),
    'section' => 'blog_over_footer_section',
    'default' => 15,
    'priority' => 19,
    'choices' => array(
        'min' => 0,
        'max' => 50,
        'step' => 1,
    ),
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.footer-widget .widget-title, .footer-widget h2.wp-block-heading, .footer-widget .wp-block-group h2',
            'property' => 'margin-bottom',
            'units' => 'px',
        ),
    ),
    'active_callback' => array(
        array(
            'setting' => 'blog_over_footer_widgets_enable',
            'operator' => '==',
            'value' => true,
        ),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_footer_bg_color',
    'label' => esc_html__('Footer Background Color', 'blog-over'),
    'section' => 'blog_over_footer_section',
    'default' => '#1e293b',
    'choices' => array('alpha' => true),
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-footer', 'property' => 'background-color')),
    'active_callback' => array(
        array(
            'setting' => 'blog_over_footer_widgets_enable',
            'operator' => '==',
            'value' => true,
        ),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_footer_text_color',
    'label' => esc_html__('Footer Text Color', 'blog-over'),
    'section' => 'blog_over_footer_section',
    'default' => '#94a3b8',
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-footer,.blog-over-footer a', 'property' => 'color')),
    'active_callback' => array(
        array(
            'setting' => 'blog_over_footer_widgets_enable',
            'operator' => '==',
            'value' => true,
        ),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'image',
    'settings' => 'blog_over_footer_bg_image',
    'label' => esc_html__('Footer Background Image', 'blog-over'),
    'section' => 'blog_over_footer_section',
    'active_callback' => array(
        array(
            'setting' => 'blog_over_footer_widgets_enable',
            'operator' => '==',
            'value' => true,
        ),
    ),
));

// ---------------------------------------------
// Section: Copyright
// ---------------------------------------------
Kirki::add_section('blog_over_copyright_section', array(
    'title' => esc_html__('Copyright Settings', 'blog-over'),
    'panel' => 'blog_over_footer_panel',
    'priority' => 20,
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_copyright_show',
    'label' => esc_html__('Show Copyright Section', 'blog-over'),
    'section' => 'blog_over_copyright_section',
    'default' => true,
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'textarea',
    'settings' => 'blog_over_copyright_text',
    'label' => esc_html__('Copyright Text', 'blog-over'),
    'description' => esc_html__('Use {year} for current year, {site} for site name', 'blog-over'),
    'section' => 'blog_over_copyright_section',
    'default' => '© {year} {site}. All rights reserved.',
    'partial_refresh' => array(
        'blog_over_copyright_text' => array(
            'selector' => '.blog-over-copyright-text',
            'render_callback' => '__return_false',
        ),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_copyright_bg',
    'label' => esc_html__('Copyright Background', 'blog-over'),
    'section' => 'blog_over_copyright_section',
    'default' => '#000000',
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-copyright', 'property' => 'background-color')),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_copyright_text_color',
    'label' => esc_html__('Copyright Text Color', 'blog-over'),
    'section' => 'blog_over_copyright_section',
    'default' => '#888888',
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-footer-bottom, .blog-over-site-info', 'property' => 'color')),
));

// ---------------------------------------------
// Section: Scroll to Top (Go to Top)
// ---------------------------------------------
Kirki::add_section('blog_over_scrolltop_section', array(
    'title' => esc_html__('Go to Top', 'blog-over'),
    'panel' => 'blog_over_theme_panel',
    'priority' => 60,
    'preview_selector' => '.blog-over-scroll-top',
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_scroll_top',
    'label' => esc_html__('Show Scroll to Top Button', 'blog-over'),
    'section' => 'blog_over_scrolltop_section',
    'default' => true,
    'partial_refresh' => array(
        'blog_over_scroll_top_partial' => array(
            'selector' => '.blog-over-scroll-top',
            'container_inclusive' => true,
            'render_callback' => 'blog_over_render_scroll_top_partial',
        ),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_scroll_top_icon',
    'label' => esc_html__('Select Icon', 'blog-over'),
    'section' => 'blog_over_scrolltop_section',
    'default' => 'fas fa-chevron-up',
    'choices' => array(
        'fas fa-chevron-up' => '<i class="fas fa-chevron-up" style="font-size: 1.2rem;"></i>',
        'fas fa-arrow-up' => '<i class="fas fa-arrow-up" style="font-size: 1.2rem;"></i>',
        'fas fa-angle-up' => '<i class="fas fa-angle-up" style="font-size: 1.2rem;"></i>',
        'fas fa-caret-up' => '<i class="fas fa-caret-up" style="font-size: 1.2rem;"></i>',
        'fas fa-long-arrow-alt-up' => '<i class="fas fa-long-arrow-alt-up" style="font-size: 1.2rem;"></i>',
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_scroll_top_position',
    'label' => esc_html__('Position', 'blog-over'),
    'section' => 'blog_over_scrolltop_section',
    'default' => 'right',
    'choices' => array(
        'left' => esc_html__('Left', 'blog-over'),
        'right' => esc_html__('Right', 'blog-over'),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_scroll_top_offset_x',
    'label' => esc_html__('Horizontal Offset (px)', 'blog-over'),
    'section' => 'blog_over_scrolltop_section',
    'default' => 30,
    'choices' => array('min' => 0, 'max' => 100, 'step' => 1),
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-scroll-top', 'property' => '--blog-over-scroll-offset-x', 'units' => 'px')),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_scroll_top_offset_y',
    'label' => esc_html__('Vertical Offset (px)', 'blog-over'),
    'section' => 'blog_over_scrolltop_section',
    'default' => 30,
    'choices' => array('min' => 0, 'max' => 100, 'step' => 1),
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-scroll-top', 'property' => '--blog-over-scroll-offset-y', 'units' => 'px')),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_scroll_top_size',
    'label' => esc_html__('Button Size (px)', 'blog-over'),
    'section' => 'blog_over_scrolltop_section',
    'default' => 45,
    'choices' => array('min' => 30, 'max' => 80, 'step' => 1),
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-scroll-top', 'property' => '--blog-over-scroll-size', 'units' => 'px')),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_scroll_top_radius',
    'label' => esc_html__('Border Radius', 'blog-over'),
    'section' => 'blog_over_scrolltop_section',
    'default' => 50,
    'choices' => array('min' => 0, 'max' => 50, 'step' => 1, 'suffix' => '%'),
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-scroll-top', 'property' => '--blog-over-scroll-radius', 'units' => '%')),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_scroll_top_icon_size',
    'label' => esc_html__('Icon Size (rem)', 'blog-over'),
    'section' => 'blog_over_scrolltop_section',
    'default' => 1.1,
    'choices' => array('min' => 0.5, 'max' => 3, 'step' => 0.1),
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-scroll-top', 'property' => '--blog-over-scroll-icon-size', 'units' => 'rem')),
));



Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_scroll_top_border_width',
    'label' => esc_html__('Border Width (px)', 'blog-over'),
    'section' => 'blog_over_scrolltop_section',
    'default' => 0,
    'choices' => array('min' => 0, 'max' => 5, 'step' => 1),
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-scroll-top', 'property' => '--blog-over-scroll-border-width', 'units' => 'px')),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'color',
    'settings' => 'blog_over_scroll_top_border_color',
    'label' => esc_html__('Border Color', 'blog-over'),
    'section' => 'blog_over_scrolltop_section',
    'default' => 'transparent',
    'choices' => array('alpha' => true),
    'transport' => 'auto',
    'output' => array(array('element' => '.blog-over-scroll-top', 'property' => '--blog-over-scroll-border-color')),
    'active_callback' => array(
        array('setting' => 'blog_over_scroll_top_border_width', 'operator' => '>', 'value' => 0),
    ),
));

/**
 * ===========================================
 * Section: Breadcrumb Settings
 * Breadcrumb settings are now loaded from:
 * inc/customizer/sections/breadcrumb.php
 * ===========================================
 */

/**
 * ===========================================
 * Section: Sidebar Settings (loaded from sidebar.php)
 * ===========================================
 */
// Sidebar settings are now loaded from inc/customizer/sections/sidebar.php

/**
 * Modular Sections
 */
require_once BLOG_OVER_DIR . '/inc/customizer/sections/ticker.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/hero.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/featured.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/feature-story.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/missed.php';

/**
 * Additional Settings
 */
require_once BLOG_OVER_DIR . '/inc/customizer/sections/sidebar.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/page.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/archive.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/related-posts.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/author-box.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/post-navigation.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/page-header.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/breadcrumb.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/loading-screen.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/advertisement.php';
require_once BLOG_OVER_DIR . '/inc/customizer/sections/custom-header.php';
