<?php
if (!defined('ABSPATH'))
	exit;

/**
 * Frontpage Promo Banner Section.
 *
 * @package pawfect
 */

if (!class_exists('pawfect_Customize_Homepage_Promo_Banner_Option')):

	class pawfect_Customize_Homepage_Promo_Timer_Option extends pawfect_Customize_Base_Option
	{

		public function elements()
		{
			return array(

				'pawfect_promo_timer_heading' => array(
					'setting' => array(),
					'control' => array(
						'type' => 'heading',
						'priority' => 1,
						'label' => esc_html__('Promo Timer Options', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
					),
				),

				'pawfect_promo_timer_enabled' => array(
					'setting' => array(
						'default' => false,
						'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_checkbox'),
					),
					'control' => array(
						'type' => 'toggle',
						'priority' => 2,
						'label' => esc_html__('Enable Promo Timer Section', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
						'active_callback' => 'pawfect_promo_timer_pro_only',
					),
				),

				'pawfect_promo_timer_title' => array(
					'setting' => array(
						'default' => esc_html__("Don't Sleep On This Sale!", 'pawfect'),
						'sanitize_callback' => 'sanitize_text_field',
					),
					'control' => array(
						'type' => 'text',
						'priority' => 3,
						'label' => esc_html__('Timer Title', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
						'active_callback' => 'pawfect_promo_timer_pro_only',
					),
				),

				'pawfect_promo_timer_desc' => array(
					'setting' => array(
						'default' => esc_html__('Our semi-annual sale ends soon â€” grab your favorite picks before time runs out.', 'pawfect'),
						'sanitize_callback' => 'sanitize_textarea_field',
					),
					'control' => array(
						'type' => 'textarea',
						'priority' => 4,
						'label' => esc_html__('Timer Description', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
						'active_callback' => 'pawfect_promo_timer_pro_only',
					),
				),

				'pawfect_promo_timer_desc_color' => array(
					'setting' => array(
						'default' => '#ffffff',
						'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_alpha_color'),
					),
					'control' => array(
						'type' => 'color',
						'priority' => 5,
						'label' => esc_html__('Description Color', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
						'active_callback' => 'pawfect_promo_timer_pro_only',
					),
				),

				'pawfect_promo_timer_button_text' => array(
					'setting' => array(
						'default' => esc_html__('SHOP NOW', 'pawfect'),
						'sanitize_callback' => 'sanitize_text_field',
					),
					'control' => array(
						'type' => 'text',
						'priority' => 6,
						'label' => esc_html__('Button Text', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
						'active_callback' => 'pawfect_promo_timer_pro_only',
					),
				),

				'pawfect_promo_timer_button_link' => array(
					'setting' => array(
						'default' => '#',
						'sanitize_callback' => 'esc_url_raw',
					),
					'control' => array(
						'type' => 'url',
						'priority' => 7,
						'label' => esc_html__('Button Link', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
						'active_callback' => 'pawfect_promo_timer_pro_only',
					),
				),

				'pawfect_promo_timer_button_target' => array(
					'setting' => array(
						'default' => '_self',
						'sanitize_callback' => array('pawfect_Customizer_Sanitize', 'sanitize_radio'),
					),
					'control' => array(
						'type' => 'radio-switch',
						'priority' => 8,
						'label' => esc_html__('Button Link Target', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
						'choices' => array(
							'_self' => esc_html__('Same Tab', 'pawfect'),
							'_blank' => esc_html__('New Tab', 'pawfect'),
						),
						'active_callback' => 'pawfect_promo_timer_pro_only',
					),
				),

				'pawfect_promo_timer_bg_image' => array(
					'setting' => array(
						'default' => PAWFECT_THEME_URL . '/assets/images/count-sale.webp',
						'sanitize_callback' => 'esc_url_raw',
					),
					'control' => array(
						'type' => 'image',
						'priority' => 9,
						'label' => esc_html__('Background Image', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
						'active_callback' => 'pawfect_promo_timer_pro_only',
					),
				),

				'pawfect_promo_timer_date' => array(
					'setting' => array(
						'default' => '',
						'sanitize_callback' => 'sanitize_text_field',
					),
					'control' => array(
						'type' => 'datetime-local',
						'priority' => 10,
						'label' => esc_html__('Countdown Target Date & Time', 'pawfect'),
						'description' => esc_html__('Set the target date and time for countdown timer (format: YYYY-MM-DD HH:MM)', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
						'active_callback' => 'pawfect_promo_timer_pro_only',
						'input_attrs' => array(
							'placeholder' => '2024-12-31 23:59',
							'style' => 'width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;'
						),
					),
				),

				// Upgrade control for Promo Timer
				'pawfect_promo_timer_upsale' => array(
					'setting' => array(
						'sanitize_callback' => 'sanitize_text_field',
					),
					'control' => array(
						'type' => 'pawfect-upgrade',
						'priority' => 1,
						'label' => esc_html__('Promo Timer Features', 'pawfect'),
						'section' => 'pawfect_promo_timer_section',
						'upgrade_message' => esc_html__('for Promo Timer functionality and premium features!', 'pawfect'),
					),
				),

			);
		}
	}

	new pawfect_Customize_Homepage_Promo_Timer_Option();

endif;



function pawfect_promo_timer_enabled($control)
{
    return get_theme_mod('pawfect_promo_timer_enabled', true) === true;
}

function pawfect_promo_timer_pro_only($control)
{
    // Pro-only features - always return false to make them inactive
    return false;
}


