<?php
/**
 * WooCommerce Checkout Customizer Controls
 *
 * @package pawwell
 */

defined( 'ABSPATH' ) || exit;

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

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

	/**
	 * Section: Checkout
	 */
	$wp_customize->add_section(
		'pawwell_woocommerce_checkout',
		array(
			'title'    => esc_html__( 'Checkout', 'pawwell' ),
			'panel'    => 'woocommerce',
			'priority' => 30,
		)
	);

	/* ── Block Checkout ── */

	$wp_customize->add_setting(
		'pawwell_woocommerce_checkout_label',
		array(
			'sanitize_callback' => 'pawwell_sanitize_title',
		)
	);

	$wp_customize->add_control(
		new Pawwell_Title_Info_Control( $wp_customize, 'pawwell_woocommerce_checkout_label',
		array(
			'label'    => esc_html__( 'Block Checkout', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-title',
			'settings' => 'pawwell_woocommerce_checkout_label',
		)
	));

	$wp_customize->add_setting(
		'pawwell_enable_block_checkout',
		array(
			'default'           => false,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		new Pawwell_Toggle_Control( $wp_customize, 'pawwell_enable_block_checkout',
		array(
			'label'       => esc_html__( 'Enable Block Checkout', 'pawwell' ),
			'description' => esc_html__( 'Use the default WooCommerce Block checkout. When enabled, the theme classic checkout template overrides are disabled.', 'pawwell' ),
			'section'     => 'pawwell_woocommerce_checkout',
			'type'        => 'pawwell-toggle',
			'settings'    => 'pawwell_enable_block_checkout',
		)
	));

	/* ── Payment Section ── */

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

	$wp_customize->add_control(
		new Pawwell_Title_Info_Control( $wp_customize, 'pawwell_default_payment_label',
		array(
			'label'    => esc_html__( 'Payment Section', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-title',
			'settings' => 'pawwell_default_payment_label',
		)
	));

	// Default Payment Section toggle
	$wp_customize->add_setting(
		'pawwell_default_checkout_payment',
		array(
			'default'           => false,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
		)
	);

	$wp_customize->add_control(
		new Pawwell_Toggle_Control( $wp_customize, 'pawwell_default_checkout_payment',
		array(
			'label'       => esc_html__( 'Default Payment Section', 'pawwell' ),
			'description' => esc_html__( 'Use WooCommerce default payment section (native radio list with inline gateway fields). Disable to keep the theme card-style payment selector.', 'pawwell' ),
			'section'     => 'pawwell_woocommerce_checkout',
			'type'        => 'pawwell-toggle',
			'settings'    => 'pawwell_default_checkout_payment',
		)
	));

	/* ── Hero Section ── */

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

	$wp_customize->add_control(
		new Pawwell_Title_Info_Control( $wp_customize, 'pawwell_co_hero_label',
		array(
			'label'    => esc_html__( 'Checkout Hero / Title', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-title',
			'settings' => 'pawwell_co_hero_label',
		)
	));

	// Master enable toggle
	$wp_customize->add_setting(
		'pawwell_co_hero_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
		)
	);

	$wp_customize->add_control(
		new Pawwell_Toggle_Control( $wp_customize, 'pawwell_co_hero_enable',
		array(
			'label'       => esc_html__( 'Show Hero Section', 'pawwell' ),
			'description' => esc_html__( 'Display the hero title block at the top of the checkout page.', 'pawwell' ),
			'section'     => 'pawwell_woocommerce_checkout',
			'type'        => 'pawwell-toggle',
			'settings'    => 'pawwell_co_hero_enable',
		)
	));

	// Eyebrow text
	$wp_customize->add_setting(
		'pawwell_co_hero_eyebrow',
		array(
			'default'           => __( 'Final Step', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_hero_eyebrow',
		array(
			'settings'  => 'pawwell_co_hero_eyebrow',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'Eyebrow Text', 'pawwell' ),
		)
	);

	// Title (main)
	$wp_customize->add_setting(
		'pawwell_co_hero_title',
		array(
			'default'           => __( 'Secure', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_hero_title',
		array(
			'settings'  => 'pawwell_co_hero_title',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'Title', 'pawwell' ),
		)
	);

	// Title (accent)
	$wp_customize->add_setting(
		'pawwell_co_hero_title_accent',
		array(
			'default'           => __( 'Checkout', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_hero_title_accent',
		array(
			'settings'  => 'pawwell_co_hero_title_accent',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'Title Accent (highlighted)', 'pawwell' ),
		)
	);

	// Subtitle
	$wp_customize->add_setting(
		'pawwell_co_hero_subtitle',
		array(
			'default'           => __( 'Review your details, pick a delivery method and complete your purchase. Your payment is encrypted end-to-end.', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_textarea_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_hero_subtitle',
		array(
			'settings'  => 'pawwell_co_hero_subtitle',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'textarea',
			'label'     => esc_html__( 'Subtitle', 'pawwell' ),
		)
	);

	/* ── Hero Stat Box ── */

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

	$wp_customize->add_control(
		new Pawwell_Title_Info_Control( $wp_customize, 'pawwell_co_hero_stat_label',
		array(
			'label'    => esc_html__( 'Hero Stat Box', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-title',
			'settings' => 'pawwell_co_hero_stat_label',
		)
	));

	// Show stat box toggle
	$wp_customize->add_setting(
		'pawwell_co_hero_stat_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
		)
	);

	$wp_customize->add_control(
		new Pawwell_Toggle_Control( $wp_customize, 'pawwell_co_hero_stat_enable',
		array(
			'label'    => esc_html__( 'Show Security Stat', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-toggle',
			'settings' => 'pawwell_co_hero_stat_enable',
		)
	));

	// Stat badge text
	$wp_customize->add_setting(
		'pawwell_co_hero_stat_badge',
		array(
			'default'           => __( '256-bit', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_hero_stat_badge',
		array(
			'settings'  => 'pawwell_co_hero_stat_badge',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'Stat Badge', 'pawwell' ),
			'description' => esc_html__( 'The bold text in the stat box, e.g. "256-bit".', 'pawwell' ),
		)
	);

	// Stat caption
	$wp_customize->add_setting(
		'pawwell_co_hero_stat_text',
		array(
			'default'           => __( 'encrypted & secure', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_hero_stat_text',
		array(
			'settings'  => 'pawwell_co_hero_stat_text',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'Stat Caption', 'pawwell' ),
			'description' => esc_html__( 'Text shown under the badge, e.g. "encrypted & secure".', 'pawwell' ),
		)
	);

	/* ── Security Note (SSL) ── */

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

	$wp_customize->add_control(
		new Pawwell_Title_Info_Control( $wp_customize, 'pawwell_co_ssl_label',
		array(
			'label'    => esc_html__( 'Security Note', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-title',
			'settings' => 'pawwell_co_ssl_label',
		)
	));

	// SSL note enable/disable
	$wp_customize->add_setting(
		'pawwell_co_ssl_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
		)
	);

	$wp_customize->add_control(
		new pawwell_Toggle_Control( $wp_customize, 'pawwell_co_ssl_enable',
		array(
			'label'       => esc_html__( 'Show Security Note', 'pawwell' ),
			'description' => esc_html__( 'Display the SSL encryption note near the place order button.', 'pawwell' ),
			'section'     => 'pawwell_woocommerce_checkout',
			'type'        => 'pawwell-toggle',
			'settings'    => 'pawwell_co_ssl_enable',
		)
	));

	// SSL note text
	$wp_customize->add_setting(
		'pawwell_co_ssl_text',
		array(
			'default'           => __( 'Secured by 256-bit SSL encryption', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_ssl_text',
		array(
			'settings'  => 'pawwell_co_ssl_text',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'Security Note Text', 'pawwell' ),
		)
	);

	/* ── Trust Badges ── */

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

	$wp_customize->add_control(
		new Pawwell_Title_Info_Control( $wp_customize, 'pawwell_co_trust_label',
		array(
			'label'    => esc_html__( 'Trust Badges', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-title',
			'settings' => 'pawwell_co_trust_label',
		)
	));

	// Secure Payment
	$wp_customize->add_setting(
		'pawwell_co_trust_secure_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
		)
	);

	$wp_customize->add_control(
		new pawwell_Toggle_Control( $wp_customize, 'pawwell_co_trust_secure_enable',
		array(
			'label'    => esc_html__( 'Show Secure Payment', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-toggle',
			'settings' => 'pawwell_co_trust_secure_enable',
		)
	));

	$wp_customize->add_setting(
		'pawwell_co_trust_secure_text',
		array(
			'default'           => __( 'Secure Payment', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_trust_secure_text',
		array(
			'settings'  => 'pawwell_co_trust_secure_text',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'Secure Payment Text', 'pawwell' ),
		)
	);

	// Easy Returns
	$wp_customize->add_setting(
		'pawwell_co_trust_returns_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
		)
	);

	$wp_customize->add_control(
		new pawwell_Toggle_Control( $wp_customize, 'pawwell_co_trust_returns_enable',
		array(
			'label'    => esc_html__( 'Show Easy Returns', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-toggle',
			'settings' => 'pawwell_co_trust_returns_enable',
		)
	));

	$wp_customize->add_setting(
		'pawwell_co_trust_returns_text',
		array(
			'default'           => __( 'Easy Returns', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_trust_returns_text',
		array(
			'settings'  => 'pawwell_co_trust_returns_text',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'Easy Returns Text', 'pawwell' ),
		)
	);

	// Fast Delivery
	$wp_customize->add_setting(
		'pawwell_co_trust_delivery_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
		)
	);

	$wp_customize->add_control(
		new pawwell_Toggle_Control( $wp_customize, 'pawwell_co_trust_delivery_enable',
		array(
			'label'    => esc_html__( 'Show Fast Delivery', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-toggle',
			'settings' => 'pawwell_co_trust_delivery_enable',
		)
	));

	$wp_customize->add_setting(
		'pawwell_co_trust_delivery_text',
		array(
			'default'           => __( 'Fast Delivery', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_trust_delivery_text',
		array(
			'settings'  => 'pawwell_co_trust_delivery_text',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'Fast Delivery Text', 'pawwell' ),
		)
	);

	/* ── Payment Methods (Chips) ── */

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

	$wp_customize->add_control(
		new Pawwell_Title_Info_Control( $wp_customize, 'pawwell_co_pay_label',
		array(
			'label'    => esc_html__( 'Payment Methods', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-title',
			'settings' => 'pawwell_co_pay_label',
		)
	));

	// VISA
	$wp_customize->add_setting(
		'pawwell_co_pay_visa_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
		)
	);

	$wp_customize->add_control(
		new pawwell_Toggle_Control( $wp_customize, 'pawwell_co_pay_visa_enable',
		array(
			'label'    => esc_html__( 'Show VISA', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-toggle',
			'settings' => 'pawwell_co_pay_visa_enable',
		)
	));

	$wp_customize->add_setting(
		'pawwell_co_pay_visa_text',
		array(
			'default'           => __( 'VISA', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_pay_visa_text',
		array(
			'settings'  => 'pawwell_co_pay_visa_text',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'VISA Text', 'pawwell' ),
		)
	);

	// Mastercard
	$wp_customize->add_setting(
		'pawwell_co_pay_mc_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
		)
	);

	$wp_customize->add_control(
		new pawwell_Toggle_Control( $wp_customize, 'pawwell_co_pay_mc_enable',
		array(
			'label'    => esc_html__( 'Show Mastercard', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-toggle',
			'settings' => 'pawwell_co_pay_mc_enable',
		)
	));

	$wp_customize->add_setting(
		'pawwell_co_pay_mc_text',
		array(
			'default'           => __( 'MC', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_pay_mc_text',
		array(
			'settings'  => 'pawwell_co_pay_mc_text',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'Mastercard Text', 'pawwell' ),
		)
	);

	// PayPal
	$wp_customize->add_setting(
		'pawwell_co_pay_paypal_enable',
		array(
			'default'           => true,
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_checkbox',
		)
	);

	$wp_customize->add_control(
		new pawwell_Toggle_Control( $wp_customize, 'pawwell_co_pay_paypal_enable',
		array(
			'label'    => esc_html__( 'Show PayPal', 'pawwell' ),
			'section'  => 'pawwell_woocommerce_checkout',
			'type'     => 'pawwell-toggle',
			'settings' => 'pawwell_co_pay_paypal_enable',
		)
	));

	$wp_customize->add_setting(
		'pawwell_co_pay_paypal_text',
		array(
			'default'           => __( 'PayPal', 'pawwell' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'pawwell_sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'pawwell_co_pay_paypal_text',
		array(
			'settings'  => 'pawwell_co_pay_paypal_text',
			'section'   => 'pawwell_woocommerce_checkout',
			'type'      => 'text',
			'label'     => esc_html__( 'PayPal Text', 'pawwell' ),
		)
	);
}
endif;

add_action( 'customize_register', 'pawwell_customizer_woocommerce_checkout_register' );
