<?php
/**
 * Admin panel and settings helpers.
 *
 * @package TIP_Countdown_Generator
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'tipcg_panel' ) ) {

	/**
	 * Builds and handles the TIP Countdown Generator admin panel.
	 */
	class tipcg_panel {

		/**
		 * Panel field definitions.
		 *
		 * @var array
		 */
		public $panel_fields;

		/**
		 * CSS class and ID prefix used by the panel.
		 *
		 * @var string
		 */
		public $plugin_slug;

		/**
		 * Main plugin option name.
		 *
		 * @var string
		 */
		public $plugin_optionname;

		/**
		 * Constructor.
		 *
		 * @param array $fields Panel field definitions.
		 */
		public function __construct( $fields = array() ) {

			$this->panel_fields      = $fields;
			$this->plugin_slug       = 'tipcg_panel_';
			$this->plugin_optionname = TIPCG_OPTION_KEY;

			add_action( 'admin_menu', array( $this, 'admin_menu' ), 11 );
			add_action( 'admin_init', array( $this, 'add_script' ), 11 );
			add_action( 'admin_init', array( $this, 'save_option' ), 11 );

		}

		/**
		 * Create option panel menu
		 */
		public function admin_menu() {

			global $admin_page_hooks;

			if ( ! isset( $admin_page_hooks['tip_plugins_panel'] ) ) {

				add_menu_page(
					esc_html__( 'TIP Plugins', 'tip-countdown-generator' ),
					esc_html__( 'TIP Plugins', 'tip-countdown-generator' ),
					'manage_options',
					'tip_plugins_panel',
					null,
					plugins_url( '/assets/images/tip-icon.svg', dirname( __FILE__ ) ),
					64
				);

			}

			add_submenu_page(
				'tip_plugins_panel',
				esc_html__( 'TIP Countdown Generator', 'tip-countdown-generator' ),
				esc_html__( 'TIP Countdown Generator', 'tip-countdown-generator' ),
				'manage_options',
				'tipcg_panel',
				array( $this, 'tipcg_panel' )
			);

			if ( isset( $admin_page_hooks['tip_plugins_panel'] ) ) {
				remove_submenu_page( 'tip_plugins_panel', 'tip_plugins_panel' );
			}

		}

		/**
		 * Loads the plugin scripts and styles
		 */
		public function add_script() {

			global $pagenow;

			$file_dir = plugins_url( '/assets/', dirname( __FILE__ ) );
			$page     = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification

			if ( $pagenow === 'admin.php' && 'tipcg_panel' === $page ) {
				wp_enqueue_style( 'tipcg_panel', $file_dir . 'css/admin.css', array(), '2.5' );
				wp_enqueue_style( 'tipcg_free_pro_table', $file_dir . 'css/free_pro_table.css', array(), TIPCG_VERSION );
				wp_enqueue_style( 'wp-jquery-ui-dialog' );
				wp_enqueue_style( 'wp-color-picker' );
				wp_enqueue_editor();
				wp_enqueue_script( 'jquery-ui-datepicker' );
				wp_enqueue_script( 'tipcg_panel_admin', $file_dir . 'js/admin.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker' ), '2.3', true );
				wp_localize_script(
					'tipcg_panel_admin',
					'tipcgAdminL10n',
					array(
						'confirmExportSettings' => esc_html__( 'Do you want to export the plugin settings?', 'tip-countdown-generator' ),
						'confirmRestoreSettings' => esc_html__( 'Do you want to restore the plugin settings?', 'tip-countdown-generator' ),
						'templateProUnavailable' => esc_html__( 'The selected template is available in the Pro version.', 'tip-countdown-generator' ),
					)
				);
			}

		}

		/**
		 * Message after saving
		 */
		public function save_message() {

			global $tipcg_message;
			$plugin_slug = $this->plugin_slug;

			if ( ! isset( $tipcg_message ) ) {
				$stored_message = get_transient( 'tipcg_admin_notice_' . get_current_user_id() );
				if ( false !== $stored_message && is_string( $stored_message ) && '' !== $stored_message ) {
					$tipcg_message = $stored_message;
					delete_transient( 'tipcg_admin_notice_' . get_current_user_id() );
				}
			}

			if ( isset( $tipcg_message ) ) {
				echo '<div id="message" class="updated fade message_save ' . esc_attr( $plugin_slug ) . 'message"><p><strong> ' . esc_html( $tipcg_message ) . '</strong></p></div>';
			}

		}

		/**
		 * Request helper.
		 *
		 * @param string $id Request key to read.
		 */
		public function tipcg_request( $id ) {
			// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Generic request helper; write actions verify nonces before use.
			if ( isset( $_REQUEST[ $id ] ) ) {
				return sanitize_text_field( wp_unslash( $_REQUEST[ $id ] ) );
			}
			// phpcs:enable WordPress.Security.NonceVerification.Recommended

			return null;
		}

		/**
		 * Ensure default countdown array exists.
		 *
		 * @param array $settings Existing plugin settings.
		 * @param bool  $create_first Whether to create the first countdown when missing.
		 */
		protected function ensure_default( $settings, $create_first = false ) {

			if ( ! is_array( $settings ) ) {
				$settings = array();
			}

			if ( ! isset( $settings['tipcg_countdowns'] ) || ! is_array( $settings['tipcg_countdowns'] ) ) {
				$settings['tipcg_countdowns'] = array();
			}

			if ( empty( $settings['tipcg_countdowns'] ) && $create_first ) {
				$settings['tipcg_countdowns'] = array(
					'slot1' => $this->default_countdown( 'slot1' ),
				);
			}

			foreach ( $settings['tipcg_countdowns'] as $slot => $data ) {
				$settings['tipcg_countdowns'][ $slot ] = $this->normalize_countdown_data( $data, $slot );
			}

			return $settings;
		}

		/**
		 * Default countdown data.
		 *
		 * @param string $slot Countdown slot key.
		 */
		protected function default_countdown( $slot ) {
			$index = intval( str_replace( 'slot', '', $slot ) );
			$index = ( $index > 0 ) ? $index : 1;

			return array(
				/* translators: %d: countdown number. */
				'name'             => sprintf( esc_html__( 'Countdown %d', 'tip-countdown-generator' ), $index ),
				'type'             => 'evergreen',
				'template'         => 'default',
				'duration'         => '01:00:00:00',
				'evergreen_days'   => 1,
				'evergreen_hours'  => 0,
				'evergreen_minutes'=> 0,
				'evergreen_seconds'=> 0,
				'tracking'         => 'cookie',
				'id'               => 'countdown_' . $index,
				'target_date'      => '',
				'number_font_size' => 40,
				'label_font_size'  => 10,
				'cell_background_color' => '#f0f0f0',
				'cell_text_color' => '#333333',
				'label_text_color' => '#666666',
				'countdown_alignment' => 'center',
				'show_separators' => 1,
				'separator_text_color' => '#333333',
				'cell_border_radius' => 8,
				'margin_top'       => 0,
				'margin_bottom'    => 0,
			);
		}

		/**
		 * Converts a DD:HH:MM:SS duration string into numeric parts.
		 *
		 * @param string $duration Duration string.
		 */
		protected function duration_string_to_parts( $duration ) {
			$parts = array(
				'days'    => 0,
				'hours'   => 0,
				'minutes' => 0,
				'seconds' => 0,
			);

			if ( preg_match( '/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})$/', $duration, $matches ) ) {
				$parts['days']    = intval( $matches[1] );
				$parts['hours']   = intval( $matches[2] );
				$parts['minutes'] = intval( $matches[3] );
				$parts['seconds'] = intval( $matches[4] );
			}

			return $parts;
		}

		/**
		 * Builds a DD:HH:MM:SS duration string from individual values.
		 *
		 * @param int $days Days.
		 * @param int $hours Hours.
		 * @param int $minutes Minutes.
		 * @param int $seconds Seconds.
		 */
		protected function format_duration_parts( $days, $hours, $minutes, $seconds ) {
			$days    = absint( $days );
			$hours   = absint( $hours );
			$minutes = absint( $minutes );
			$seconds = absint( $seconds );

			$day_part = str_pad( (string) $days, 2, '0', STR_PAD_LEFT );
			$hour_part = str_pad( (string) $hours, 2, '0', STR_PAD_LEFT );
			$minute_part = str_pad( (string) $minutes, 2, '0', STR_PAD_LEFT );
			$second_part = str_pad( (string) $seconds, 2, '0', STR_PAD_LEFT );

			return $day_part . ':' . $hour_part . ':' . $minute_part . ':' . $second_part;
		}

		/**
		 * Returns the templates that can be used in Lite.
		 *
		 * @return string[]
		 */
		protected function lite_available_templates() {
			return array( 'default', 'flip_clock' );
		}

		/**
		 * Returns all known templates, including Pro-only choices shown in the UI.
		 *
		 * @return string[]
		 */
		protected function lite_all_templates() {
			return array( 'default', 'animated_flip', 'flip_clock', 'typewriter', 'paper' );
		}

		/**
		 * Checks whether a template can be saved in Lite.
		 *
		 * @param string $template Template key.
		 */
		protected function is_lite_template_available( $template ) {
			return in_array( sanitize_key( $template ), $this->lite_available_templates(), true );
		}

		/**
		 * Returns a Lite limitation error for a raw countdown POST payload.
		 *
		 * @param array $data Countdown data.
		 */
		protected function get_lite_countdown_post_error( $data ) {
			$type = $this->sanitize_countdown_choice_field( $data, 'type', array( 'evergreen', 'fixed', 'recurring' ), 'evergreen' );
			if ( 'recurring' === $type ) {
				return esc_html__( 'Recurring countdowns are available in the Pro version.', 'tip-countdown-generator' );
			}

			$template = sanitize_key( $this->get_sanitizable_countdown_field( $data, 'template', 'default' ) );
			if ( in_array( $template, $this->lite_all_templates(), true ) && ! $this->is_lite_template_available( $template ) ) {
				return esc_html__( 'The selected template is available in the Pro version.', 'tip-countdown-generator' );
			}

			return '';
		}

		/**
		 * Normalizes a saved countdown by adding missing default values.
		 *
		 * @param array  $data Countdown data.
		 * @param string $slot Countdown slot key.
		 */
		protected function normalize_countdown_data( $data, $slot ) {
			$defaults = $this->default_countdown( $slot );
			$merged   = wp_parse_args( $data, $defaults );

			$merged['type'] = isset( $merged['type'] ) ? sanitize_key( $merged['type'] ) : $defaults['type'];
			$merged['type'] = in_array( $merged['type'], array( 'evergreen', 'fixed' ), true ) ? $merged['type'] : $defaults['type'];

			$merged['template'] = isset( $merged['template'] ) ? sanitize_key( $merged['template'] ) : $defaults['template'];
			$merged['template'] = $this->is_lite_template_available( $merged['template'] ) ? $merged['template'] : $defaults['template'];

			// Align evergreen parts.
			if ( ! isset( $merged['evergreen_days'] ) || ! isset( $merged['evergreen_hours'] ) || ! isset( $merged['evergreen_minutes'] ) || ! isset( $merged['evergreen_seconds'] ) ) {
				$parts                     = $this->duration_string_to_parts( $merged['duration'] );
				$merged['evergreen_days']    = $parts['days'];
				$merged['evergreen_hours']   = $parts['hours'];
				$merged['evergreen_minutes'] = $parts['minutes'];
				$merged['evergreen_seconds'] = $parts['seconds'];
			}

			$merged['duration'] = $this->format_duration_parts(
				$merged['evergreen_days'],
				$merged['evergreen_hours'],
				$merged['evergreen_minutes'],
				$merged['evergreen_seconds']
			);

			$merged['number_font_size']      = min( 200, max( 8, absint( $merged['number_font_size'] ) ) );
			$merged['label_font_size']       = min( 80, max( 6, absint( $merged['label_font_size'] ) ) );
			$merged['cell_background_color'] = sanitize_hex_color( $merged['cell_background_color'] );
			$merged['cell_background_color'] = $merged['cell_background_color'] ? $merged['cell_background_color'] : $defaults['cell_background_color'];
			$merged['cell_text_color']       = sanitize_hex_color( $merged['cell_text_color'] );
			$merged['cell_text_color']       = $merged['cell_text_color'] ? $merged['cell_text_color'] : $defaults['cell_text_color'];
			if ( ! isset( $data['label_text_color'] ) || '' === $data['label_text_color'] ) {
				$merged['label_text_color'] = $merged['cell_text_color'];
			}
			$merged['label_text_color']      = sanitize_hex_color( $merged['label_text_color'] );
			$merged['label_text_color']      = $merged['label_text_color'] ? $merged['label_text_color'] : $defaults['label_text_color'];
			$merged['countdown_alignment']   = isset( $merged['countdown_alignment'] ) ? sanitize_key( $merged['countdown_alignment'] ) : $defaults['countdown_alignment'];
			$merged['countdown_alignment']   = in_array( $merged['countdown_alignment'], array( 'left', 'center', 'right' ), true ) ? $merged['countdown_alignment'] : $defaults['countdown_alignment'];
			$merged['show_separators']       = isset( $data['show_separators'] ) ? absint( $merged['show_separators'] ) : $defaults['show_separators'];
			$merged['show_separators']       = $merged['show_separators'] ? 1 : 0;
			if ( ! isset( $data['separator_text_color'] ) || '' === $data['separator_text_color'] ) {
				$merged['separator_text_color'] = $merged['cell_text_color'];
			}
			$merged['separator_text_color']  = sanitize_hex_color( $merged['separator_text_color'] );
			$merged['separator_text_color']  = $merged['separator_text_color'] ? $merged['separator_text_color'] : $defaults['separator_text_color'];
			$merged['cell_border_radius']    = min( 80, max( 0, absint( $merged['cell_border_radius'] ) ) );
			$merged['margin_top']            = min( 400, max( 0, absint( $merged['margin_top'] ) ) );
			$merged['margin_bottom']         = min( 400, max( 0, absint( $merged['margin_bottom'] ) ) );

			return $merged;
		}

		/**
		 * Creates a shortcode string from saved data.
		 *
		 * @param array $data Saved countdown data.
		 */
		protected function build_shortcode_string( $data ) {
			$slot_number = isset( $data['slot_number'] ) ? absint( $data['slot_number'] ) : 0;
			if ( 0 === $slot_number ) {
				return '[tipcg_countdown]';
			}

			return '[tipcg_countdown countdown_id="' . $slot_number . '"]';
		}

		/**
		 * Returns the slot number from its key name.
		 *
		 * @param string $slot_key Countdown slot key.
		 */
		protected function get_slot_number( $slot_key ) {
			return absint( str_replace( 'slot', '', strtolower( $slot_key ) ) );
		}

		/**
		 * Next slot key.
		 *
		 * @param array $countdowns Existing countdowns.
		 */
		protected function next_slot( $countdowns ) {
			if ( empty( $countdowns ) ) {
				return 'slot1';
			}

			$numbers = array();

			foreach ( array_keys( $countdowns ) as $slot ) {
				$numbers[] = intval( str_replace( 'slot', '', $slot ) );
			}

			return 'slot' . ( max( $numbers ) + 1 );
		}

		/**
		 * Gets a scalar field value ready for sanitization.
		 *
		 * @param array  $data Field source data.
		 * @param string $key Field key.
		 * @param mixed  $default Default value.
		 */
		protected function get_sanitizable_countdown_field( $data, $key, $default = '' ) {
			if ( ! is_array( $data ) || ! array_key_exists( $key, $data ) || ! is_scalar( $data[ $key ] ) ) {
				return $default;
			}

			return $data[ $key ];
		}

		/**
		 * Reads an array POST field after nonce verification by the caller.
		 *
		 * @param string $key POST field key.
		 */
		protected function get_post_array_field( $key ) {
			if ( ! isset( $_POST[ $key ] ) || ! is_array( $_POST[ $key ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Callers verify the save nonce before reading the field.
				return array();
			}

			return wp_unslash( $_POST[ $key ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized field-by-field by sanitize_countdown().
		}

		/**
		 * Reads a numeric POST field after nonce verification by the caller.
		 *
		 * @param string $key POST field key.
		 */
		protected function get_post_absint_field( $key ) {
			if ( ! isset( $_POST[ $key ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Callers verify the save nonce before reading the field.
				return 0;
			}

			return absint( wp_unslash( $_POST[ $key ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
		}

		/**
		 * Sanitizes a plain text countdown field.
		 *
		 * @param array  $data Field source data.
		 * @param string $key Field key.
		 * @param string $default Default value.
		 */
		protected function sanitize_countdown_text_field( $data, $key, $default = '' ) {
			return sanitize_text_field( $this->get_sanitizable_countdown_field( $data, $key, $default ) );
		}

		/**
		 * Sanitizes an enum-like countdown field.
		 *
		 * @param array  $data Field source data.
		 * @param string $key Field key.
		 * @param array  $allowed Allowed values.
		 * @param string $default Default value.
		 */
		protected function sanitize_countdown_choice_field( $data, $key, $allowed, $default ) {
			$value = sanitize_key( $this->get_sanitizable_countdown_field( $data, $key, $default ) );

			return in_array( $value, $allowed, true ) ? $value : $default;
		}

		/**
		 * Sanitizes a positive integer countdown field.
		 *
		 * @param array  $data Field source data.
		 * @param string $key Field key.
		 * @param int    $default Default value.
		 */
		protected function sanitize_countdown_absint_field( $data, $key, $default = 0 ) {
			return absint( $this->get_sanitizable_countdown_field( $data, $key, $default ) );
		}

		/**
		 * Sanitizes an integer countdown field constrained to a range.
		 *
		 * @param array  $data Field source data.
		 * @param string $key Field key.
		 * @param int    $default Default value.
		 * @param int    $min Minimum value.
		 * @param int    $max Maximum value.
		 */
		protected function sanitize_countdown_range_field( $data, $key, $default, $min, $max ) {
			$value = $this->sanitize_countdown_absint_field( $data, $key, $default );

			return min( $max, max( $min, $value ) );
		}

		/**
		 * Sanitizes a boolean-like countdown field.
		 *
		 * @param array  $data Field source data.
		 * @param string $key Field key.
		 * @param int    $default Default value.
		 */
		protected function sanitize_countdown_bool_field( $data, $key, $default = 0 ) {
			return $this->sanitize_countdown_absint_field( $data, $key, $default ) ? 1 : 0;
		}

		/**
		 * Sanitizes a hex color countdown field.
		 *
		 * @param array  $data Field source data.
		 * @param string $key Field key.
		 * @param string $default Default value.
		 */
		protected function sanitize_countdown_color_field( $data, $key, $default ) {
			$value = sanitize_hex_color( $this->get_sanitizable_countdown_field( $data, $key, '' ) );

			return $value ? $value : $default;
		}

		/**
		 * Sanitizes a countdown DOM/tracking identifier.
		 *
		 * @param array  $data Field source data.
		 * @param string $key Field key.
		 * @param string $default Default value.
		 */
		protected function sanitize_countdown_id_field( $data, $key, $default ) {
			$value = $this->sanitize_countdown_text_field( $data, $key, '' );
			$value = preg_replace( '/[^A-Za-z0-9_-]/', '', $value );

			return ( '' !== $value ) ? $value : $default;
		}

		/**
		 * Sanitize countdown data.
		 *
		 * @param array  $data Countdown data.
		 * @param string $slot Countdown slot key.
		 */
		protected function sanitize_countdown( $data, $slot ) {
			$index = intval( str_replace( 'slot', '', $slot ) );
			$index = ( $index > 0 ) ? $index : 1;

			$defaults = $this->default_countdown( $slot );

			$name = $this->sanitize_countdown_text_field( $data, 'name', '' );
			/* translators: %d: countdown number. */
			$name = ( '' === $name ) ? sprintf( esc_html__( 'Countdown %d', 'tip-countdown-generator' ), $index ) : $name;

			$type = $this->sanitize_countdown_choice_field( $data, 'type', array( 'evergreen', 'fixed' ), 'evergreen' );

			$template = $this->sanitize_countdown_choice_field( $data, 'template', $this->lite_available_templates(), $defaults['template'] );

			// Evergreen duration.
			$ev_days    = $this->sanitize_countdown_absint_field( $data, 'evergreen_days', $defaults['evergreen_days'] );
			$ev_hours   = $this->sanitize_countdown_absint_field( $data, 'evergreen_hours', $defaults['evergreen_hours'] );
			$ev_minutes = $this->sanitize_countdown_absint_field( $data, 'evergreen_minutes', $defaults['evergreen_minutes'] );
			$ev_seconds = $this->sanitize_countdown_absint_field( $data, 'evergreen_seconds', $defaults['evergreen_seconds'] );

			if ( 0 === ( $ev_days + $ev_hours + $ev_minutes + $ev_seconds ) ) {
				$ev_minutes = 1;
			}

			$duration = $this->format_duration_parts( $ev_days, $ev_hours, $ev_minutes, $ev_seconds );

			$tracking = $this->sanitize_countdown_choice_field( $data, 'tracking', array( 'cookie', 'ip', 'cookie_ip' ), 'cookie' );

			$id = $this->sanitize_countdown_id_field( $data, 'id', 'countdown_' . $index );

			$target_date = $this->sanitize_countdown_text_field( $data, 'target_date', '' );

			$number_font_size = $this->sanitize_countdown_range_field( $data, 'number_font_size', $defaults['number_font_size'], 8, 200 );
			$label_font_size  = $this->sanitize_countdown_range_field( $data, 'label_font_size', $defaults['label_font_size'], 6, 80 );

			$cell_background_color = $this->sanitize_countdown_color_field( $data, 'cell_background_color', $defaults['cell_background_color'] );
			$cell_text_color       = $this->sanitize_countdown_color_field( $data, 'cell_text_color', $defaults['cell_text_color'] );
			$label_text_color      = $this->sanitize_countdown_color_field( $data, 'label_text_color', $defaults['label_text_color'] );
			$countdown_alignment   = $this->sanitize_countdown_choice_field( $data, 'countdown_alignment', array( 'left', 'center', 'right' ), $defaults['countdown_alignment'] );
			$show_separators       = $this->sanitize_countdown_bool_field( $data, 'show_separators', $defaults['show_separators'] );
			$separator_text_color  = $this->sanitize_countdown_color_field( $data, 'separator_text_color', $cell_text_color );

			$cell_border_radius = $this->sanitize_countdown_range_field( $data, 'cell_border_radius', $defaults['cell_border_radius'], 0, 80 );
			$margin_top         = $this->sanitize_countdown_range_field( $data, 'margin_top', $defaults['margin_top'], 0, 400 );
			$margin_bottom      = $this->sanitize_countdown_range_field( $data, 'margin_bottom', $defaults['margin_bottom'], 0, 400 );

			return array(
				'name'              => $name,
				'type'              => $type,
				'template'          => $template,
				'duration'          => $duration,
				'evergreen_days'    => $ev_days,
				'evergreen_hours'   => $ev_hours,
				'evergreen_minutes' => $ev_minutes,
				'evergreen_seconds' => $ev_seconds,
				'tracking'          => $tracking,
				'id'                => $id,
				'target_date'       => $target_date,
				'number_font_size'  => $number_font_size,
				'label_font_size'   => $label_font_size,
				'cell_background_color' => $cell_background_color,
				'cell_text_color'   => $cell_text_color,
				'label_text_color'  => $label_text_color,
				'countdown_alignment' => $countdown_alignment,
				'show_separators'   => $show_separators,
				'separator_text_color' => $separator_text_color,
				'cell_border_radius'=> $cell_border_radius,
				'margin_top'        => $margin_top,
				'margin_bottom'     => $margin_bottom,
			);
		}

		/**
		 * Handle saves / add / delete
		 */
		public function save_option() {

			global $tipcg_message;

			$tipcg_setting = get_option( $this->plugin_optionname );
			$tipcg_setting = ( false !== $tipcg_setting ) ? maybe_unserialize( $tipcg_setting ) : array();
			$tipcg_setting = $this->ensure_default( $tipcg_setting, false );

			// Export plugin settings.
			if (
				current_user_can( 'manage_options' ) &&
				isset( $_GET['action'] ) &&
				'tipcg_export_action' === sanitize_text_field( wp_unslash( $_GET['action'] ) ) &&
				isset( $_GET['tipcg_export_nonce'] ) &&
				wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['tipcg_export_nonce'] ) ), 'tipcg_export_options' )
			) { // phpcs:ignore WordPress.Security.NonceVerification

				header( 'Cache-Control: public, must-revalidate' );
				header( 'Pragma: hack' );
				header( 'Content-Type: text/plain' );
				header( 'Content-Disposition: attachment; filename="tipcg_backup.dat"' );
				echo serialize( $this->get_options() ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize,WordPress.Security.EscapeOutput.OutputNotEscaped -- Backup download payload, not HTML output.
				exit;
			}

			// Reset plugin settings.
			if (
				current_user_can( 'manage_options' ) &&
				isset( $_GET['action'] ) &&
				'tipcg_backup_reset' === sanitize_text_field( wp_unslash( $_GET['action'] ) ) &&
				isset( $_GET['tipcg_reset_nonce'] ) &&
				wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['tipcg_reset_nonce'] ) ), 'tipcg_reset_options' )
			) { // phpcs:ignore WordPress.Security.NonceVerification

				update_option( $this->plugin_optionname, array() );
				set_transient( 'tipcg_admin_notice_' . get_current_user_id(), esc_html__( 'Settings restored.', 'tip-countdown-generator' ), 120 );
				wp_safe_redirect( admin_url( 'admin.php?page=tipcg_panel&tab=Import_Export' ) );
				exit;
			}

			// Import plugin settings.
			if (
				current_user_can( 'manage_options' ) &&
				isset( $_POST['tipcg_upload_backup'] ) &&
				isset( $_POST['tipcg_upload_nonce'] ) &&
				wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['tipcg_upload_nonce'] ) ), 'tipcg_upload_options' )
			) { // phpcs:ignore WordPress.Security.NonceVerification

				$imported_backup = false;
				$upload_error    = isset( $_FILES['tipcg_upload_file']['error'] ) ? absint( $_FILES['tipcg_upload_file']['error'] ) : UPLOAD_ERR_NO_FILE; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- PHP upload error code, cast to integer.
				$uploaded_file   = isset( $_FILES['tipcg_upload_file']['tmp_name'] ) && is_string( $_FILES['tipcg_upload_file']['tmp_name'] ) ? $_FILES['tipcg_upload_file']['tmp_name'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Temporary upload path must not be unslashed on Windows.

				if (
					UPLOAD_ERR_OK === $upload_error &&
					'' !== $uploaded_file &&
					( is_uploaded_file( $uploaded_file ) || is_readable( $uploaded_file ) )
				) {
					$options = $this->parse_backup_file( $uploaded_file );

					if ( is_array( $options ) ) {
						foreach ( $options as $option ) {
							$option_data = $this->normalize_backup_option( $option );

							if ( false === $option_data ) {
								continue;
							}

							update_option( $this->plugin_optionname, $this->ensure_default( $option_data, false ) );
							$imported_backup = true;
						}
					}
				}

				$message = $imported_backup
					? esc_html__( 'Backup imported successfully.', 'tip-countdown-generator' )
					: esc_html__( 'Invalid backup file.', 'tip-countdown-generator' );
				set_transient( 'tipcg_admin_notice_' . get_current_user_id(), $message, 120 );
				wp_safe_redirect( admin_url( 'admin.php?page=tipcg_panel&tab=Import_Export' ) );
				exit;
			}

			// Add new countdown.
			if ( $this->tipcg_request( 'tipcg_new_countdown_action' ) !== null ) {

				if (
					! current_user_can( 'manage_options' ) ||
					! isset( $_POST['tipcg_save_nonces'] ) ||
					! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['tipcg_save_nonces'] ) ), 'tipcg_save_options' ) // phpcs:ignore WordPress.Security.NonceVerification
				) {
					exit;
				}

				$new_slot                               = $this->next_slot( $tipcg_setting['tipcg_countdowns'] );
				$tipcg_setting['tipcg_countdowns'][ $new_slot ] = $this->default_countdown( $new_slot );
				update_option( $this->plugin_optionname, $tipcg_setting );
				wp_safe_redirect( admin_url( 'admin.php?page=tipcg_panel&tab=Countdown_Generator&countdownID=' . str_replace( 'slot', '', $new_slot ) ) );
				exit;
			}

			// Duplicate countdown.
			if ( $this->tipcg_request( 'tipcg_duplicate_countdown_action' ) !== null ) {

				if (
					! current_user_can( 'manage_options' ) ||
					! isset( $_POST['tipcg_save_nonces'] ) ||
					! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['tipcg_save_nonces'] ) ), 'tipcg_save_options' ) // phpcs:ignore WordPress.Security.NonceVerification
				) {
					exit;
				}

				$slot_id = $this->get_post_absint_field( 'tipcg_duplicate_countdown_action' );
				if ( 0 === $slot_id ) {
					$slot_id = $this->get_post_absint_field( 'tipcg_countdown_id' );
				}

				set_transient( 'tipcg_admin_notice_' . get_current_user_id(), esc_html__( 'Duplicate countdown is available in the Pro version.', 'tip-countdown-generator' ), 120 );
				$redirect_url = ( $slot_id > 0 )
					? admin_url( 'admin.php?page=tipcg_panel&tab=Countdown_Generator&countdownID=' . $slot_id )
					: admin_url( 'admin.php?page=tipcg_panel&tab=Countdown_Generator' );
				wp_safe_redirect( $redirect_url );
				exit;
			}

			// Delete countdown.
			if ( $this->tipcg_request( 'tipcg_delete_countdown_action' ) !== null ) {

				if (
					! current_user_can( 'manage_options' ) ||
					! isset( $_POST['tipcg_save_nonces'] ) ||
					! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['tipcg_save_nonces'] ) ), 'tipcg_save_options' ) // phpcs:ignore WordPress.Security.NonceVerification
				) {
					exit;
				}

				$slot_id = $this->get_post_absint_field( 'tipcg_delete_countdown_action' );
				if ( 0 === $slot_id ) {
					$slot_id = $this->get_post_absint_field( 'tipcg_countdown_id' );
				}

				unset( $tipcg_setting['tipcg_countdowns'][ 'slot' . $slot_id ] );
				$tipcg_setting = $this->ensure_default( $tipcg_setting, false );
				update_option( $this->plugin_optionname, $tipcg_setting );
				wp_safe_redirect( admin_url( 'admin.php?page=tipcg_panel&tab=Countdown_Generator' ) );
				exit;
			}

			// Save countdown.
			$save_countdown_requested = ( $this->tipcg_request( 'tipcg_save_countdown_action' ) !== null );
			$save_and_exit_requested  = ( $this->tipcg_request( 'tipcg_save_countdown_exit_action' ) !== null );
			if ( $save_countdown_requested || $save_and_exit_requested ) {

				if (
					! current_user_can( 'manage_options' ) ||
					! isset( $_POST['tipcg_save_nonces'] ) ||
					! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['tipcg_save_nonces'] ) ), 'tipcg_save_options' ) // phpcs:ignore WordPress.Security.NonceVerification
				) {
					exit;
				}

				$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'Countdown_Generator'; // phpcs:ignore WordPress.Security.NonceVerification
				$saved_countdown_id = 0;

				foreach ( $this->panel_fields as $element ) {

					if ( isset( $element['tab'] ) && $element['tab'] === $current_tab ) {

						foreach ( $element as $value ) {

							if ( isset( $value['id'] ) && ( $value['id'] === 'tipcg_countdowns' ) ) {

								$posted_countdown = $this->get_post_array_field( $value['id'] );
								if ( array() !== $posted_countdown ) {

									$countdown_id = $this->get_post_absint_field( 'tipcg_countdown_id' );
									if ( $countdown_id > 0 ) {
										$lite_error = $this->get_lite_countdown_post_error( $posted_countdown );
										if ( '' !== $lite_error ) {
											set_transient( 'tipcg_admin_notice_' . get_current_user_id(), $lite_error, 120 );
											wp_safe_redirect( admin_url( 'admin.php?page=tipcg_panel&tab=Countdown_Generator&countdownID=' . $countdown_id ) );
											exit;
										}

										$tipcg_setting['tipcg_countdowns'][ 'slot' . $countdown_id ] = $this->sanitize_countdown( $posted_countdown, 'slot' . $countdown_id );
										update_option( $this->plugin_optionname, $tipcg_setting );
										$saved_countdown_id = $countdown_id;
									}

								} else {

									unset( $tipcg_setting['tipcg_countdowns'] );
									update_option( $this->plugin_optionname, $tipcg_setting );

								}

							}

							$tipcg_message = esc_html__( 'Options saved successfully.', 'tip-countdown-generator' );

						}

					}

				}

				$tipcg_message = esc_html__( 'Options saved successfully.', 'tip-countdown-generator' );
				set_transient( 'tipcg_admin_notice_' . get_current_user_id(), $tipcg_message, 120 );

				if ( $save_and_exit_requested || 0 === $saved_countdown_id ) {
					wp_safe_redirect( admin_url( 'admin.php?page=tipcg_panel&tab=Countdown_Generator' ) );
					exit;
				}

				wp_safe_redirect( admin_url( 'admin.php?page=tipcg_panel&tab=Countdown_Generator&countdownID=' . $saved_countdown_id ) );
				exit;
			}

		}

		/**
		 * Get plugin options in export format.
		 */
		public function get_options() {
			$option_value = get_option( $this->plugin_optionname, array() );
			if ( ! is_array( $option_value ) ) {
				$option_value = array();
			}

			return array(
				array(
					'option_name'  => $this->plugin_optionname,
					'option_value' => maybe_serialize( $option_value ),
				),
			);
		}

		/**
		 * Parse a serialized backup file without allowing arbitrary PHP classes.
		 *
		 * @param string $file_path Backup file path.
		 */
		private function parse_backup_file( $file_path ) {
			if ( ! is_string( $file_path ) || '' === $file_path || ! is_readable( $file_path ) ) {
				return false;
			}

			$contents = file_get_contents( $file_path );
			$contents = is_string( $contents ) ? trim( $contents ) : '';

			if ( ! is_string( $contents ) || '' === trim( $contents ) || ! is_serialized( $contents ) ) {
				return false;
			}

			$options = @unserialize( $contents, array( 'allowed_classes' => array( 'stdClass' ) ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize,WordPress.PHP.NoSilencedErrors.Discouraged

			return is_array( $options ) ? $options : false;
		}

		/**
		 * Normalize an imported backup row to the plugin option array.
		 *
		 * @param array|stdClass $option Imported backup option row.
		 */
		private function normalize_backup_option( $option ) {
			if ( is_array( $option ) ) {
				$option_name  = isset( $option['option_name'] ) ? (string) $option['option_name'] : '';
				$option_value = isset( $option['option_value'] ) ? $option['option_value'] : null;
			} elseif ( $option instanceof stdClass ) {
				$option_name  = isset( $option->option_name ) ? (string) $option->option_name : '';
				$option_value = isset( $option->option_value ) ? $option->option_value : null;
			} else {
				return false;
			}

			if ( $option_name !== $this->plugin_optionname ) {
				return false;
			}

			if ( is_string( $option_value ) ) {
				$option_value = trim( $option_value );
				if ( is_serialized( $option_value ) ) {
					$option_value = @unserialize( $option_value, array( 'allowed_classes' => false ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize,WordPress.PHP.NoSilencedErrors.Discouraged
				}
			}

			return is_array( $option_value ) ? $option_value : false;
		}

		/**
		 * Panel output
		 */
		public function tipcg_panel() {

			global $tipcg_message;

			$tcgForm     = new tipcg_form();
			$plugin_slug = $this->plugin_slug;

			$current_tab          = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'Countdown_Generator'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only admin screen state.
			$current_countdown_id = isset( $_GET['countdownID'] ) ? absint( wp_unslash( $_GET['countdownID'] ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only admin screen state.

			foreach ( $this->panel_fields as $element ) {

				if ( isset( $element['type'] ) ) {

					switch ( $element['type'] ) {

						case 'navigation':

							echo wp_kses( $tcgForm->elementStart( 'div', $plugin_slug . 'tabs', false ), $tcgForm->get_allowed_html() );

								echo wp_kses( $tcgForm->elementStart( 'div', $plugin_slug . 'header', false ), $tcgForm->get_allowed_html() );

									echo wp_kses( $tcgForm->elementStart( 'div', false, 'left plugin_description' ), $tcgForm->get_allowed_html() );

										echo wp_kses( $tcgForm->element( 'h2', false, 'maintitle', esc_html__( 'TIP Countdown Generator', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, false, esc_html__( 'Version: ', 'tip-countdown-generator' ) . TIPCG_VERSION ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->link( 'https://www.themeinprogress.com', false, false, '_blank', false, esc_html__( 'by ThemeinProgress', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->link('https://demo.themeinprogress.eu/tip-countdown-generator-pro/documentation-free-version/', FALSE, FALSE, '_blank', FALSE, esc_html__( 'Documentation','tip-countdown-generator') ), $tcgForm->get_allowed_html() );

									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

									echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

								$this->save_message();

								echo wp_kses( $tcgForm->htmlList( 'ul', false, $plugin_slug . 'navigation', $element['item'], $current_tab ), $tcgForm->get_allowed_html() );

						break;

						case 'end-tab':

								echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

							echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

						break;

					}

				}

				if ( isset( $element['tab'] ) ) {

					switch ( $element['tab'] ) {

						case $current_tab:

							foreach ( $element as $value ) {

								if ( isset( $value['type'] ) ) {

									switch ( $value['type'] ) {

										case 'start-form':

											echo wp_kses( $tcgForm->elementStart( 'div', str_replace( ' ', '', $value['name'] ), false ), $tcgForm->get_allowed_html() );

												echo wp_kses( $tcgForm->formStart( 'post', '?page=tipcg_panel&tab=' . esc_attr( $current_tab ) ), $tcgForm->get_allowed_html() );
												echo wp_kses( $tcgForm->input( 'tipcg_save_nonces', false, false, 'hidden', esc_attr( wp_create_nonce( 'tipcg_save_options' ) ) ), $tcgForm->get_allowed_html() );

										break;

										case 'end-form':

												echo wp_kses( $tcgForm->formEnd(), $tcgForm->get_allowed_html() );

											echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

										break;

										case 'start-open-container':

											echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'container' ), $tcgForm->get_allowed_html() );

												$hide_open_title = (
													'Countdown_Generator' === $current_tab &&
													$current_countdown_id > 0
												);

												if ( ! $hide_open_title ) {
													echo wp_kses( $tcgForm->element( 'h5', false, 'element-open', $value['name'] ), $tcgForm->get_allowed_html() );
												}

												echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'mainbox tipcg_openbox' ), $tcgForm->get_allowed_html() );

										break;

										case 'end-container':

												echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

											echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

										break;

										case 'countdownGenerator':

											$this->countdown_generator( $value['id'] );

										break;

										case 'import_export':

											$this->import_export();

										break;

										case 'free_vs_pro':

											$this->free_vs_pro();

										break;

									}

								}

							}

					}

				}

			}
		}

		/**
		 * Render Import / Export tools.
		 */
		protected function import_export() {
			$tcgForm     = new tipcg_form();
			$plugin_slug = $this->plugin_slug;

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( false, esc_html__( 'Export settings', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$export_url = add_query_arg(
						array(
							'page'   => 'tipcg_panel',
							'tab'    => 'Import_Export',
							'action' => 'tipcg_export_action',
						),
						admin_url( 'admin.php' )
					);
					$export_nonce = wp_nonce_url( $export_url, 'tipcg_export_options', 'tipcg_export_nonce' );

					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Download a backup copy of the current plugin settings.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->link( $export_nonce, false, 'button-primary tipcg_config_action tipcg_export_settings', '_self', false, esc_html__( 'Export settings', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );
			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( false, esc_html__( 'Reset settings', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$reset_url = add_query_arg(
						array(
							'page'   => 'tipcg_panel',
							'tab'    => 'Import_Export',
							'action' => 'tipcg_backup_reset',
						),
						admin_url( 'admin.php' )
					);
					$reset_nonce = wp_nonce_url( $reset_url, 'tipcg_reset_options', 'tipcg_reset_nonce' );

					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Restore the plugin options to their initial values.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->link( $reset_nonce, false, 'button-primary tipcg_config_action tipcg_restore_settings', '_self', false, esc_html__( 'Reset settings', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );
			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( false, esc_html__( 'Import settings', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Upload a previously exported backup file to restore the configuration.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( 'tipcg_upload_file', false, false, 'file', false ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( 'tipcg_upload_backup', 'tipcg_upload_backup', 'button-primary tipcg_config_action', 'submit', esc_html__( 'Import settings', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( 'tipcg_upload_nonce', false, false, 'hidden', esc_attr( wp_create_nonce( 'tipcg_upload_options' ) ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );
			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
		}
		/**
		 * Render Free vs Pro table.
		 */
		protected function free_vs_pro() {

			$tcgForm     = new tipcg_form();
			$plugin_slug = $this->plugin_slug;
			$upgrade_url = TIPCG_UPGRADE_LINK . '?ref=2&campaign=tipcg-freepro-table';

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->tableStart( false, $plugin_slug . ' card table free-pro', 0, 0 ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->tableElementStart( 'tbody', false, 'table-body' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'table-head' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElement( 'th', false, 'large' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'th', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo esc_html__( 'Free', 'tip-countdown-generator' );
							echo wp_kses( $tcgForm->tableElementEnd( 'th' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'th', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo esc_html__( 'Premium', 'tip-countdown-generator' );
							echo wp_kses( $tcgForm->tableElementEnd( 'th' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Evergreen countdowns', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Fixed-date countdowns', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Cookie tracking', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'IP tracking', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Cookie or IP tracking', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'The countdown keeps the earliest timestamp found between the visitor cookie and IP address.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Countdown shortcode', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'Display saved countdowns with the standard [tipcg_countdown] shortcode.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Backup import and export', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Appearance controls', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'Customize font sizes, colors, separators, border radius, and countdown spacing.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Templates', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->tableElementStart('td', FALSE, 'indicator'), $tcgForm->get_allowed_html() );
									echo esc_html__('2', 'tip-countdown-generator');
								echo wp_kses( $tcgForm->tableElementEnd('td'), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
									echo esc_html__('5', 'tip-countdown-generator');
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Recurring countdowns', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'Create countdowns that repeat on a schedule with duration and restart-delay controls.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-no-alt', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Action on expiry', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'Choose what happens when a countdown expires, including hiding the timer, showing a message, or redirecting visitors.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-no-alt', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Dynamic shortcode generator', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'Generate customized shortcode parameters from a dedicated interface.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-no-alt', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Gutenberg blocks', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'Display saved countdowns or create custom timers directly in the Gutenberg editor.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-no-alt', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Elementor widgets', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'Display saved countdowns or create custom timers directly in Elementor.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-no-alt', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Option to duplicate a countdown', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'Create a copy of an existing countdown and adjust it without rebuilding the settings from scratch.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-no-alt', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Logged-in user tracking', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'Tie evergreen countdown progress to the WordPress user account instead of only cookie or IP data.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-no-alt', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'feature-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'large' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-wrap' ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->element( 'h4', false, false, esc_html__( 'Advanced recurring availability rules', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementStart( 'div', false, 'feature-inline-row' ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'info-icon dashicon dashicons dashicons-info', false ), $tcgForm->get_allowed_html() );
										echo wp_kses( $tcgForm->element( 'span', false, 'feature-description', esc_html__( 'Control what visitors see before the countdown starts and on days that are not selected in a recurring schedule.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
									echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-no-alt', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->element( 'span', false, 'dashicon dashicons dashicons-yes', false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );

						echo wp_kses( $tcgForm->tableElementStart( 'tr', false, 'upsell-row' ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElement( 'td', false, false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElement( 'td', false, false ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementStart( 'td', false, 'indicator' ), $tcgForm->get_allowed_html() );
								echo wp_kses( $tcgForm->link( $upgrade_url, false, 'button button-primary', '_blank', false, esc_html__( 'Upgrade to Premium', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
							echo wp_kses( $tcgForm->tableElementEnd( 'td' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->tableElementEnd( 'tr' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->tableElementEnd( 'tbody' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->tableEnd(), $tcgForm->get_allowed_html() );
			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

		}

		/**
		 * Render a pixel range control.
		 *
		 * @param tipcg_form $tcgForm Form helper instance.
		 * @param string   $name Field name.
		 * @param string   $field_id Field ID.
		 * @param int      $value Current value.
		 * @param int      $min Minimum value.
		 * @param int      $max Maximum value.
		 * @param int      $step Step value.
		 */
		protected function render_px_range_control( $tcgForm, $name, $field_id, $value, $min, $max, $step = 1 ) {
			$value = is_numeric( $value ) ? (int) $value : (int) $min;
			$min   = (int) $min;
			$max   = (int) $max;
			$step  = (int) $step;

			if ( $max < $min ) {
				$max = $min;
			}

			$value = max( $min, min( $max, $value ) );

			echo wp_kses( $tcgForm->elementStart( 'div', false, 'tipcg-range-control' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementStart( 'div', false, 'tipcg-range-row' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'span', false, 'tipcg-range-limit tipcg-range-min', esc_html( $min ) ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( $name, $field_id, 'tipcg-range-input', 'range', $value, '', 'min="' . esc_attr( $min ) . '" max="' . esc_attr( $max ) . '" step="' . esc_attr( $step ) . '" data-suffix="px"' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'span', false, 'tipcg-range-limit tipcg-range-max', esc_html( $max ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
				echo '<span class="tipcg-range-value" data-for="' . esc_attr( $field_id ) . '" data-suffix="px">' . esc_html( $value ) . 'px</span>';
			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
		}

		/**
		 * Render the countdown edit action buttons.
		 *
		 * @param tipcg_form $tcgForm Form helper instance.
		 * @param string   $plugin_slug Panel CSS class prefix.
		 */
		protected function render_countdown_action_buttons( $tcgForm, $plugin_slug ) {
			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box saveBox' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->input( 'tipcg_save_countdown_action', false, 'button tipcg_save_countdown', 'submit', esc_html__( 'Save countdown', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->input( 'tipcg_save_countdown_exit_action', false, 'button button-secondary tipcg_default_button tipcg_save_countdown_exit', 'submit', esc_html__( 'Save and exit', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->input( 'tipcg_delete_countdown_action', false, 'button tipcg_delete_countdown', 'submit', esc_html__( 'Delete', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo '<a class="button button-secondary tipcg_default_button" href="' . esc_url( admin_url( 'admin.php?page=tipcg_panel&tab=Countdown_Generator' ) ) . '">' . esc_html__( 'Exit', 'tip-countdown-generator' ) . '</a>';
				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );
			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
		}

		/**
		 * Render the countdown generator UI.
		 *
		 * @param string $id Countdown settings field ID.
		 */
		protected function countdown_generator( $id ) {

			$tcgForm     = new tipcg_form();
			$plugin_slug = $this->plugin_slug;

			$settings   = $this->ensure_default( get_option( $this->plugin_optionname ), false );
			$countdowns = isset( $settings['tipcg_countdowns'] ) ? $settings['tipcg_countdowns'] : array();

			$requested   = isset( $_GET['countdownID'] ) ? absint( wp_unslash( $_GET['countdownID'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only admin screen state.
			$requested   = ( $requested ) ? 'slot' . $requested : null;
			$edit_mode   = ( $requested && isset( $countdowns[ $requested ] ) );
			$current_key = $edit_mode ? $requested : null;
			$current     = $edit_mode ? $this->normalize_countdown_data( $countdowns[ $current_key ], $current_key ) : null;
			$current_id  = $edit_mode ? intval( str_replace( 'slot', '', $current_key ) ) : null;

			// Countdown list: each item opens its own edit area.
			if ( ! $edit_mode ) {
				echo wp_kses( $tcgForm->elementStart( 'div', false, 'tipcg_countdownGenerator' ), $tcgForm->get_allowed_html() );

					echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'countdown_order' ), $tcgForm->get_allowed_html() );

						if ( ! empty( $countdowns ) ) {
							foreach ( $countdowns as $slot => $data ) {
								$data        = $this->normalize_countdown_data( $data, $slot );
								$slot_number = $this->get_slot_number( $slot );
								/* translators: %d: countdown number. */
								$title       = ( '' !== $data['name'] ) ? $data['name'] : sprintf( esc_html__( 'Countdown %d', 'tip-countdown-generator' ), $slot_number );
								$list_data   = $data;
								$list_data['slot_number'] = $slot_number;
								$shortcode   = $this->build_shortcode_string( $list_data );
								$link        = add_query_arg(
									array(
										'page'        => 'tipcg_panel',
										'tab'         => 'Countdown_Generator',
										'countdownID' => $slot_number,
									),
									admin_url( 'admin.php' )
								);

								echo wp_kses( $tcgForm->elementStart( 'div', 'countdown' . $slot_number, $plugin_slug . 'container tipcg-countdown-item' ), $tcgForm->get_allowed_html() );
									echo '<div class="tipcg-countdown-list-shortcode">';
										echo '<input type="text" class="tipcg-countdown-shortcode-field code" readonly="readonly" value="' . esc_attr( $shortcode ) . '" aria-label="' . esc_attr__( 'Shortcode countdown', 'tip-countdown-generator' ) . '" />';
									echo '</div>';
									echo '<h5 class="element linkable-element"><a href="' . esc_url( $link ) . '">' . esc_html( $title ) . '</a></h5>';
								echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
							}
						}

					echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

					echo wp_kses( $tcgForm->elementStart( 'div', false, 'tipcg-new-countdown-row' ), $tcgForm->get_allowed_html() );
						echo wp_kses( $tcgForm->input( 'tipcg_new_countdown_action', false, 'button button-secondary tipcg_add_countdown', 'submit', esc_html__( 'New countdown', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				return;
			}

			// Countdown edit form.
			echo wp_kses( $tcgForm->input( 'tipcg_countdown_id', false, false, 'hidden', $current_id ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', 'countdown' . $current_id, $plugin_slug . 'container tipcg-countdown-editor' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'mainbox-open tipcg-countdown-section tipcg-countdown-section-general' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'h5', false, 'element-open', esc_html__( 'General', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( false, esc_html__( 'Countdown title', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( $id . '[name]', 'tipcg_countdown_name', 'regular-text', 'text', $current['name'] ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Only used internally in the panel.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			// Countdown ID.
			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( false, esc_html__( 'ID countdown', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( $id . '[id]', 'tipcg_id', 'regular-text', 'text', $current['id'] ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Used to distinguish different countdowns and for evergreen tracking.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				$this->render_countdown_action_buttons( $tcgForm, $plugin_slug );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'mainbox-open tipcg-countdown-section tipcg-countdown-section-appearance' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'h5', false, 'element-open', esc_html__( 'Appearance', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_template', esc_html__( 'Countdown template', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$template_options = array(
						'default' => esc_html__( 'Standard', 'tip-countdown-generator' ),
						'animated_flip'  => esc_html__( 'Animated Flip (PRO)', 'tip-countdown-generator' ),
						'flip_clock' => esc_html__( 'Flip Clock', 'tip-countdown-generator' ),
						'typewriter' => esc_html__( 'Typewriter (PRO)', 'tip-countdown-generator' ),
						'paper'   => esc_html__( 'Paper (PRO)', 'tip-countdown-generator' ),
					);
					echo wp_kses( $tcgForm->select( $id . '[template]', 'tipcg_template', 'selectValue tipcg-template-select', $template_options, $current['template'] ), $tcgForm->get_allowed_html() );
					echo '<div class="ilrcp_template_preview" data-template="' . esc_attr( $current['template'] ) . '" data-preview-base="' . esc_url( plugins_url( '/assets/images/templates/', dirname( __FILE__ ) ) ) . '" aria-hidden="true"></div>';
					echo wp_kses( $tcgForm->element( 'p', false, 'tipcg-template-pro-warning', esc_html__( 'This template is available in the Pro version.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Choose the front-end countdown layout.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_countdown_alignment', esc_html__( 'Alignment', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$alignment_options = array(
						'left'   => esc_html__( 'Left alignment', 'tip-countdown-generator' ),
						'center' => esc_html__( 'Center alignment', 'tip-countdown-generator' ),
						'right'  => esc_html__( 'Right alignment', 'tip-countdown-generator' ),
					);
					echo wp_kses( $tcgForm->select( $id . '[countdown_alignment]', 'tipcg_countdown_alignment', 'selectValue', $alignment_options, $current['countdown_alignment'] ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_show_separators', esc_html__( 'Separators', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$separator_options = array(
						'1' => esc_html__( 'Enabled', 'tip-countdown-generator' ),
						'0' => esc_html__( 'Disabled', 'tip-countdown-generator' ),
					);
					echo wp_kses( $tcgForm->select( $id . '[show_separators]', 'tipcg_show_separators', 'selectValue', $separator_options, (string) $current['show_separators'] ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Shows real colon separators between time cells.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_number_font_size', esc_html__( 'Number font size', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$this->render_px_range_control( $tcgForm, $id . '[number_font_size]', 'tipcg_number_font_size', $current['number_font_size'], 8, 200 );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_label_font_size', esc_html__( 'Label font size', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$this->render_px_range_control( $tcgForm, $id . '[label_font_size]', 'tipcg_label_font_size', $current['label_font_size'], 6, 80 );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_cell_background_color', esc_html__( 'Cell background color', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right tipcg-color-field' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( $id . '[cell_background_color]', 'tipcg_cell_background_color', 'regular-text tipcg-color-picker', 'text', $current['cell_background_color'], '', 'data-default-color="#f0f0f0"' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_cell_text_color', esc_html__( 'Number text color', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right tipcg-color-field' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( $id . '[cell_text_color]', 'tipcg_cell_text_color', 'regular-text tipcg-color-picker', 'text', $current['cell_text_color'], '', 'data-default-color="#333333"' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_label_text_color', esc_html__( 'Label text color', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right tipcg-color-field' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( $id . '[label_text_color]', 'tipcg_label_text_color', 'regular-text tipcg-color-picker', 'text', $current['label_text_color'], '', 'data-default-color="#666666"' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_separator_text_color', esc_html__( 'Separator text color', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right tipcg-color-field' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( $id . '[separator_text_color]', 'tipcg_separator_text_color', 'regular-text tipcg-color-picker', 'text', $current['separator_text_color'], '', 'data-default-color="#333333"' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_cell_border_radius', esc_html__( 'Border radius', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$this->render_px_range_control( $tcgForm, $id . '[cell_border_radius]', 'tipcg_cell_border_radius', $current['cell_border_radius'], 0, 80 );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'These values are applied on the front end through inline CSS generated with wp_add_inline_style.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_margin_top', esc_html__( 'Margin top', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$this->render_px_range_control( $tcgForm, $id . '[margin_top]', 'tipcg_margin_top', $current['margin_top'], 0, 400 );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_margin_bottom', esc_html__( 'Margin bottom', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$this->render_px_range_control( $tcgForm, $id . '[margin_bottom]', 'tipcg_margin_bottom', $current['margin_bottom'], 0, 400 );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				$this->render_countdown_action_buttons( $tcgForm, $plugin_slug );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'mainbox-open tipcg-countdown-section tipcg-countdown-section-timer' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'h5', false, 'element-open', esc_html__( 'Timer', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );

			// Countdown type.
			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_type', esc_html__( 'Countdown type', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$type_options = array(
						'evergreen' => esc_html__( 'Evergreen', 'tip-countdown-generator' ),
						'fixed'     => esc_html__( 'Specific date', 'tip-countdown-generator' ),
					);
					echo wp_kses( $tcgForm->select( $id . '[type]', 'tipcg_type', 'selectValue tipcg-countdown-type', $type_options, $current['type'] ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Choose whether to use a visitor-specific evergreen countdown or a fixed date.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			$evergreen_class = $plugin_slug . 'box tipcg-type-block tipcg-type-evergreen' . ( 'evergreen' === $current['type'] ? ' tipcg-active' : '' );
			$fixed_class     = $plugin_slug . 'box tipcg-type-block tipcg-type-fixed' . ( 'fixed' === $current['type'] ? ' tipcg-active' : '' );

			// Evergreen settings.
			echo wp_kses( $tcgForm->elementStart( 'div', false, $evergreen_class ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( false, esc_html__( 'Evergreen duration (DD / HH / MM / SS)', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					echo '<div class="tipcg-duration-grid">';
						echo '<div class="tipcg-duration-field">';
							echo '<span>' . esc_html__( 'Days', 'tip-countdown-generator' ) . '</span>';
							echo wp_kses( $tcgForm->input( $id . '[evergreen_days]', 'tipcg_evergreen_days', 'small-number', 'number', $current['evergreen_days'], '', 'min="0" step="1"' ), $tcgForm->get_allowed_html() );
						echo '</div>';
						echo '<div class="tipcg-duration-field">';
							echo '<span>' . esc_html__( 'Hours', 'tip-countdown-generator' ) . '</span>';
							echo wp_kses( $tcgForm->input( $id . '[evergreen_hours]', 'tipcg_evergreen_hours', 'small-number', 'number', $current['evergreen_hours'], '', 'min="0" step="1" max="23"' ), $tcgForm->get_allowed_html() );
						echo '</div>';
						echo '<div class="tipcg-duration-field">';
							echo '<span>' . esc_html__( 'Minutes', 'tip-countdown-generator' ) . '</span>';
							echo wp_kses( $tcgForm->input( $id . '[evergreen_minutes]', 'tipcg_evergreen_minutes', 'small-number', 'number', $current['evergreen_minutes'], '', 'min="0" step="1" max="59"' ), $tcgForm->get_allowed_html() );
						echo '</div>';
						echo '<div class="tipcg-duration-field">';
							echo '<span>' . esc_html__( 'Seconds', 'tip-countdown-generator' ) . '</span>';
							echo wp_kses( $tcgForm->input( $id . '[evergreen_seconds]', 'tipcg_evergreen_seconds', 'small-number', 'number', $current['evergreen_seconds'], '', 'min="0" step="1" max="59"' ), $tcgForm->get_allowed_html() );
						echo '</div>';
					echo '</div>';
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Set each field separately. The countdown starts from the visitor\'s first visit according to the selected tracking method.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $evergreen_class ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( false, esc_html__( 'Tracking method', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					$options = array(
						'cookie'    => esc_html__( 'Cookie', 'tip-countdown-generator' ),
						'ip'        => esc_html__( 'IP', 'tip-countdown-generator' ),
						'cookie_ip' => esc_html__( 'Cookie or IP', 'tip-countdown-generator' ),
					);
					echo wp_kses( $tcgForm->select( $id . '[tracking]', 'tipcg_tracking', 'selectValue', $options, $current['tracking'] ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Choose whether the evergreen timer is tracked by browser cookie, IP address, or the earliest value between cookie and IP.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

			// Fixed date countdown.
			$fixed_value = ( '' !== $current['target_date'] ) ? $current['target_date'] : gmdate( 'Y-m-d\\TH:i', current_time( 'timestamp' ) + DAY_IN_SECONDS );
			echo wp_kses( $tcgForm->elementStart( 'div', false, $fixed_class ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( 'tipcg_target_date', esc_html__( 'End date/time', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( $id . '[target_date]', 'tipcg_target_date', 'regular-text tipcg-datetime', 'datetime-local', $fixed_value, '', 'step="60"' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Choose the end date for the absolute countdown. Uses the site timezone.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );

			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				$this->render_countdown_action_buttons( $tcgForm, $plugin_slug );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'mainbox-open tipcg-countdown-section tipcg-countdown-section-shortcode' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'h5', false, 'element-open', esc_html__( 'Shortcode', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );

			// Shortcode preview (slot-only).
			$preview_data = $current;
			$preview_data['slot_number'] = $current_id;
			$shortcode = $this->build_shortcode_string( $preview_data );

			echo wp_kses( $tcgForm->elementStart( 'div', false, $plugin_slug . 'box' ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-left' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->label( false, esc_html__( 'Generated shortcode', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementStart( 'div', false, 'input-right' ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->input( 'tipcg_shortcode_preview', false, 'regular-text code', 'text', $shortcode ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'Copy and paste this shortcode into any page.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
					echo wp_kses( $tcgForm->element( 'p', false, false, esc_html__( 'You can add more shortcode parameters if you want to override the saved values.', 'tip-countdown-generator' ) ), $tcgForm->get_allowed_html() );
				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->element( 'div', false, 'clear', false ), $tcgForm->get_allowed_html() );
			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );

				echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
			echo wp_kses( $tcgForm->elementEnd( 'div' ), $tcgForm->get_allowed_html() );
		}

	}

}

?>
