<?php
/**
 * WooCommerce Product Archive Customizer Controls
 *
 * @package pawwell
 */

defined( 'ABSPATH' ) || exit;

if ( ! function_exists( 'pawwell_is_active_woocommerce' ) || ! pawwell_is_active_woocommerce() ) {
	return;
}

if ( ! function_exists( 'pawwell_customizer_woo_product_archive_register' ) ) :
function pawwell_customizer_woo_product_archive_register( $wp_customize ) {

	/**
	 * Section: Product Archive (under the WooCommerce panel)
	 */
	$wp_customize->add_section(
		'pawwell_woo_product_archive',
		array(
			'title'    => esc_html__( 'Shop', 'pawwell' ),
			'panel'    => 'woocommerce',
			'priority' => 28,
		)
	);

	// Title separator
	$wp_customize->add_setting(
		'pawwell_woo_archive_header_label',
		array(
			'sanitize_callback' => 'pawwell_sanitize_title',
		)
	);

	$wp_customize->add_control(
		new Pawwell_Title_Info_Control( $wp_customize, 'pawwell_woo_archive_header_label',
		array(
			'label'    => esc_html__( 'Shop Page Header', 'pawwell' ),
			'section'  => 'pawwell_woo_product_archive',
			'type'     => 'pawwell-title',
			'settings' => 'pawwell_woo_archive_header_label',
		)
	));

	// Eyebrow text
	$wp_customize->add_setting(
		'pawwell_woo_archive_eyebrow',
		array(
			'default'           => __( 'The Collection', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		'pawwell_woo_archive_eyebrow',
		array(
			'settings'    => 'pawwell_woo_archive_eyebrow',
			'section'     => 'pawwell_woo_product_archive',
			'type'        => 'text',
			'label'       => esc_html__( 'Eyebrow', 'pawwell' ),
			'description' => esc_html__( 'Small label displayed above the title on the shop page.', 'pawwell' ),
		)
	);

	// Heading text
	$wp_customize->add_setting(
		'pawwell_woo_archive_heading',
		array(
			'default'           => __( 'Shop', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		'pawwell_woo_archive_heading',
		array(
			'settings'    => 'pawwell_woo_archive_heading',
			'section'     => 'pawwell_woo_product_archive',
			'type'        => 'text',
			'label'       => esc_html__( 'Heading', 'pawwell' ),
			'description' => esc_html__( 'Main title displayed on the shop page (before the accent word).', 'pawwell' ),
		)
	);

	// Accent word
	$wp_customize->add_setting(
		'pawwell_woo_archive_accent',
		array(
			'default'           => __( 'Products', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		'pawwell_woo_archive_accent',
		array(
			'settings'    => 'pawwell_woo_archive_accent',
			'section'     => 'pawwell_woo_product_archive',
			'type'        => 'text',
			'label'       => esc_html__( 'Accent Word', 'pawwell' ),
			'description' => esc_html__( 'Accent word appended after the heading on the shop page.', 'pawwell' ),
		)
	);

	// Subheading text
	$wp_customize->add_setting(
		'pawwell_woo_archive_subheading',
		array(
			'default'           => __( 'Premium nutrition, vet-approved health supplements, grooming essentials, toys & accessories — curated for every wag, whisker and wing.', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_textarea_field',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		'pawwell_woo_archive_subheading',
		array(
			'settings'    => 'pawwell_woo_archive_subheading',
			'section'     => 'pawwell_woo_product_archive',
			'type'        => 'textarea',
			'label'       => esc_html__( 'Subheading', 'pawwell' ),
			'description' => esc_html__( 'Subheading text displayed below the title on the shop page.', 'pawwell' ),
		)
	);

	// Title separator - Stat Card
	$wp_customize->add_setting(
		'pawwell_woo_archive_stat_label',
		array(
			'sanitize_callback' => 'pawwell_sanitize_title',
		)
	);

	$wp_customize->add_control(
		new Pawwell_Title_Info_Control( $wp_customize, 'pawwell_woo_archive_stat_label',
		array(
			'label'    => esc_html__( 'Product Stat Card', 'pawwell' ),
			'section'  => 'pawwell_woo_product_archive',
			'type'     => 'pawwell-title',
			'settings' => 'pawwell_woo_archive_stat_label',
		)
	));

	// Stat card enable/disable
	$wp_customize->add_setting(
		'pawwell_woo_archive_stat_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		new pawwell_Toggle_Control( $wp_customize, 'pawwell_woo_archive_stat_enable',
		array(
			'label'       => esc_html__( 'Show Product Count Stat', 'pawwell' ),
			'section'     => 'pawwell_woo_product_archive',
			'type'        => 'pawwell-toggle',
			'settings'    => 'pawwell_woo_archive_stat_enable',
		)
	));

	// Stat card label text
	$wp_customize->add_setting(
		'pawwell_woo_archive_stat_text',
		array(
			'default'           => __( 'products in stock', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		'pawwell_woo_archive_stat_text',
		array(
			'settings'    => 'pawwell_woo_archive_stat_text',
			'section'     => 'pawwell_woo_product_archive',
			'type'        => 'text',
			'label'       => esc_html__( 'Stat Label', 'pawwell' ),
			'description' => esc_html__( 'Text displayed below the product count (e.g. products in stock).', 'pawwell' ),
		)
	);

	// Title separator - Shop by Category
	$wp_customize->add_setting(
		'pawwell_woo_archive_category_label',
		array(
			'sanitize_callback' => 'pawwell_sanitize_title',
		)
	);

	$wp_customize->add_control(
		new Pawwell_Title_Info_Control( $wp_customize, 'pawwell_woo_archive_category_label',
		array(
			'label'    => esc_html__( 'Shop by Category', 'pawwell' ),
			'section'  => 'pawwell_woo_product_archive',
			'type'     => 'pawwell-title',
			'settings' => 'pawwell_woo_archive_category_label',
		)
	));

	// Shop by Category enable/disable
	$wp_customize->add_setting(
		'pawwell_woo_archive_category_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		new pawwell_Toggle_Control( $wp_customize, 'pawwell_woo_archive_category_enable',
		array(
			'label'       => esc_html__( 'Show Shop by Category', 'pawwell' ),
			'section'     => 'pawwell_woo_product_archive',
			'type'        => 'pawwell-toggle',
			'settings'    => 'pawwell_woo_archive_category_enable',
		)
	));
}
endif;

add_action( 'customize_register', 'pawwell_customizer_woo_product_archive_register' );
