<?php
/**
 * About Section Customizer Settings
 *
 * @package Paws_And_Care
 * @since 1.0.0
 */

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

/**
 * Register About section customizer settings
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function paws_and_care_customizer_about( $wp_customize ) {

    // About Section
    $wp_customize->add_section( 'paws_and_care_about', array(
        'title'    => __( 'About Settings', 'paws-and-care' ),
        'panel'    => 'paws_and_care_front_page',
        'priority' => 20,
    ) );

    // Enable About Section
    $wp_customize->add_setting( 'paws_and_care_about_enable', array(
        'default'           => true,
        'sanitize_callback' => 'paws_and_care_sanitize_checkbox',
    ) );

    $wp_customize->add_control( new Paws_And_Care_Customize_Toggle_Control( $wp_customize, 'paws_and_care_about_enable', array(
        'label'       => __( 'Enable About Section', 'paws-and-care' ),
        'description' => __( 'Show or hide the about section on homepage', 'paws-and-care' ),
        'section'     => 'paws_and_care_about',
    ) ) );

    // Content Heading
    $wp_customize->add_setting( 'paws_and_care_about_content_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
    ) );

    $wp_customize->add_control( new Paws_And_Care_Customize_Heading_Control( $wp_customize, 'paws_and_care_about_content_heading', array(
        'label'           => __( 'Content Settings', 'paws-and-care' ),
        'section'         => 'paws_and_care_about',
        'active_callback' => 'paws_and_care_is_about_enabled',
    ) ) );

    // Section Title
    $wp_customize->add_setting( 'paws_and_care_about_title', array(
        'default'           => __( 'Welcome to Paws & Care', 'paws-and-care' ),
        'sanitize_callback' => 'sanitize_text_field',
    ) );

    $wp_customize->add_control( 'paws_and_care_about_title', array(
        'label'           => __( 'Section Title', 'paws-and-care' ),
        'section'         => 'paws_and_care_about',
        'type'            => 'text',
        'active_callback' => 'paws_and_care_is_about_enabled',
    ) );

    // Lead Text
    $wp_customize->add_setting( 'paws_and_care_about_lead', array(
        'default'           => __( 'Where every pet is treated like family.', 'paws-and-care' ),
        'sanitize_callback' => 'sanitize_text_field',
    ) );

    $wp_customize->add_control( 'paws_and_care_about_lead', array(
        'label'           => __( 'Lead Text', 'paws-and-care' ),
        'description'     => __( 'Short subtitle below the title', 'paws-and-care' ),
        'section'         => 'paws_and_care_about',
        'type'            => 'text',
        'active_callback' => 'paws_and_care_is_about_enabled',
    ) );

    // Description
    $wp_customize->add_setting( 'paws_and_care_about_description', array(
        'default'           => __( 'At Paws & Care, we believe every pet deserves the best. Our caring team provides grooming, boarding, training, and wellness services in a safe and loving environment. Your furry friends are in good hands with us.', 'paws-and-care' ),
        'sanitize_callback' => 'sanitize_textarea_field',
    ) );

    $wp_customize->add_control( 'paws_and_care_about_description', array(
        'label'           => __( 'Description', 'paws-and-care' ),
        'section'         => 'paws_and_care_about',
        'type'            => 'textarea',
        'active_callback' => 'paws_and_care_is_about_enabled',
    ) );

    // About Image
    $wp_customize->add_setting( 'paws_and_care_about_image', array(
        'default'           => get_template_directory_uri() . '/assets/img/about.webp',
        'sanitize_callback' => 'esc_url_raw',
    ) );

    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'paws_and_care_about_image', array(
        'label'           => __( 'About Image', 'paws-and-care' ),
        'section'         => 'paws_and_care_about',
        'active_callback' => 'paws_and_care_is_about_enabled',
    ) ) );

    // Features Heading
    $wp_customize->add_setting( 'paws_and_care_about_features_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
    ) );

    $wp_customize->add_control( new Paws_And_Care_Customize_Heading_Control( $wp_customize, 'paws_and_care_about_features_heading', array(
        'label'           => __( 'Feature Boxes', 'paws-and-care' ),
        'section'         => 'paws_and_care_about',
        'active_callback' => 'paws_and_care_is_about_enabled',
    ) ) );

    // Features Repeater
    $wp_customize->add_setting( 'paws_and_care_about_features', array(
        'default'           => paws_and_care_get_about_features_default(),
        'sanitize_callback' => 'paws_and_care_repeater_sanitize',
    ) );

    $wp_customize->add_control( new Paws_And_Care_Repeater( $wp_customize, 'paws_and_care_about_features', array(
        'label'                             => __( 'Features', 'paws-and-care' ),
        'section'                           => 'paws_and_care_about',
        'add_field_label'                   => __( 'Add New Feature', 'paws-and-care' ),
        'item_name'                         => __( 'Feature', 'paws-and-care' ),
        'customizer_repeater_title_control' => true,
        'customizer_repeater_text_control'  => true,
        'customizer_repeater_icon_control'  => true,
        'active_callback'                   => 'paws_and_care_is_about_enabled',
    ) ) );
}

/**
 * Active callback for about section
 */
function paws_and_care_is_about_enabled() {
    return get_theme_mod( 'paws_and_care_about_enable', true );
}

// Default function moved to inc/customizer/defaults.php

