<?php
/**
 * Customizer: Header Settings Section
 *
 * @package Paws_And_Care
 * @since 3.0.2
 */

if (!defined('ABSPATH')) {
    exit;
}

/**
 * Register Header Settings Section
 *
 * @param WP_Customize_Manager $wp_customize Customizer object.
 */
function paws_and_care_customizer_header($wp_customize)
{
    // ========================================
    // Header Settings Section (inside Theme Settings panel)
    // ========================================
    $wp_customize->add_section('paws_and_care_header', array(
        'title' => __('Header Settings', 'paws-and-care'),
        'description' => __('Configure header/navigation appearance and behavior.', 'paws-and-care'),
        'panel' => 'paws_and_care_theme_settings',
        'priority' => 15, // After Layout (10)
    ));

    // ========================================
    // STICKY HEADER SETTINGS
    // ========================================

    // Sticky Header Heading
    $wp_customize->add_setting('paws_and_care_sticky_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
    ));
    $wp_customize->add_control(new Paws_And_Care_Customize_Heading_Control($wp_customize, 'paws_and_care_sticky_heading', array(
        'label' => __('Sticky Header', 'paws-and-care'),
        'section' => 'paws_and_care_header',
    )));

    // Enable Sticky Header
    $wp_customize->add_setting('paws_and_care_sticky_header', array(
        'default' => true,
        'sanitize_callback' => 'paws_and_care_sanitize_checkbox',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control(new Paws_And_Care_Customize_Toggle_Control($wp_customize, 'paws_and_care_sticky_header', array(
        'label' => __('Enable Sticky Header', 'paws-and-care'),
        'description' => __('Header stays fixed at top when scrolling.', 'paws-and-care'),
        'section' => 'paws_and_care_header',
    )));

    // ========================================
    // TRANSPARENT/OVERLAP HEADER SETTINGS
    // ========================================

    // Transparent Header Heading
    $wp_customize->add_setting('paws_and_care_transparent_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
    ));
    $wp_customize->add_control(new Paws_And_Care_Customize_Heading_Control($wp_customize, 'paws_and_care_transparent_heading', array(
        'label' => __('Transparent Header', 'paws-and-care'),
        'section' => 'paws_and_care_header',
    )));

    // Enable Transparent/Overlap Header
    $wp_customize->add_setting('paws_and_care_header_overlap', array(
        'default' => false,
        'sanitize_callback' => 'paws_and_care_sanitize_checkbox',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control(new Paws_And_Care_Customize_Toggle_Control($wp_customize, 'paws_and_care_header_overlap', array(
        'label' => __('Enable Transparent Header', 'paws-and-care'),
        'description' => __('Header overlays content with transparent background. Topbar is automatically hidden in this mode.', 'paws-and-care'),
        'section' => 'paws_and_care_header',
    )));

    // Apply On Setting
    $wp_customize->add_setting('paws_and_care_overlap_apply_on', array(
        'default' => 'front-page',
        'sanitize_callback' => 'paws_and_care_sanitize_select',
        'transport' => 'refresh',
    ));
    $wp_customize->add_control('paws_and_care_overlap_apply_on', array(
        'label' => __('Apply Transparent Header On', 'paws-and-care'),
        'description' => __('Choose where the transparent header should appear.', 'paws-and-care'),
        'section' => 'paws_and_care_header',
        'type' => 'select',
        'choices' => array(
            'front-page' => __('Front Page Only', 'paws-and-care'),
            'all-pages' => __('All Pages', 'paws-and-care'),
        ),
        'active_callback' => 'paws_and_care_is_header_overlap_enabled',
    ));
}

/**
 * Active callback: Check if header overlap is enabled
 */
function paws_and_care_is_header_overlap_enabled()
{
    return get_theme_mod('paws_and_care_header_overlap', false);
}
