<?php
/**
 * Email Settings Manager.
 *
 * Handles storage and retrieval of email configuration options.
 *
 * @package Ugcify\Email
 */

namespace Ugcify\Email;

use Ugcify\Helpers\FeatureGate;

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

/**
 * Class EmailSettings
 */
class EmailSettings {

	/**
	 * Option key for global email settings.
	 *
	 * @var string
	 */
	const GLOBAL_OPTION = 'ugcify_email_global_settings';

	/**
	 * Option key for email types configuration.
	 *
	 * @var string
	 */
	const TYPES_OPTION = 'ugcify_email_types';

	/**
	 * Option key marking the saved order-complete body upgrade.
	 *
	 * @var string
	 */
	const ORDER_COMPLETE_REVIEW_BODY_UPGRADED_OPTION = 'ugcify_order_complete_review_body_upgraded';

	/**
	 * Get default global settings.
	 *
	 * @return array
	 */
	public static function get_default_global_settings() {
		return array(
			'from_name'     => get_bloginfo( 'name' ),
			'from_email'    => get_option( 'admin_email' ),
			'reply_to'      => get_option( 'admin_email' ),
			'body_color'    => '#f7f7f7',
			'heading_color' => '#1e1e1e',
			'text_color'    => '#555555',
			'button_color'  => '#201CFE',
			'link_color'    => '#201CFE',
			'header_logo'   => '',
			'footer_text'   => sprintf(
				/* translators: %s: site name */
				__( '&copy; %1$s %2$s. All rights reserved.', 'ugcify' ),
				gmdate( 'Y' ),
				get_bloginfo( 'name' )
			),
		);
	}

	/**
	 * Get global settings merged with defaults.
	 *
	 * @return array
	 */
	public static function get_global_settings() {
		$defaults = self::get_default_global_settings();
		$saved    = get_option( self::GLOBAL_OPTION, array() );

		return wp_parse_args( $saved, $defaults );
	}

	/**
	 * Save global settings.
	 *
	 * @param array $settings Settings to save.
	 * @return bool
	 */
	public static function save_global_settings( $settings ) {
		$sanitized = array(
			'from_name'     => sanitize_text_field( $settings['from_name'] ?? '' ),
			'from_email'    => sanitize_email( $settings['from_email'] ?? '' ),
			'reply_to'      => sanitize_email( $settings['reply_to'] ?? '' ),
			'body_color'    => sanitize_hex_color( $settings['body_color'] ?? '#f7f7f7' ),
			'heading_color' => sanitize_hex_color( $settings['heading_color'] ?? '#1e1e1e' ),
			'text_color'    => sanitize_hex_color( $settings['text_color'] ?? '#555555' ),
			'button_color'  => sanitize_hex_color( $settings['button_color'] ?? '#201CFE' ),
			'link_color'    => sanitize_hex_color( $settings['link_color'] ?? '#201CFE' ),
			'header_logo'   => esc_url_raw( $settings['header_logo'] ?? '' ),
			'footer_text'   => wp_kses_post( $settings['footer_text'] ?? '' ),
		);

		// update_option() returns false when the value is unchanged — that is not an error.
		update_option( self::GLOBAL_OPTION, $sanitized );
		return true;
	}

	/**
	 * Get default email types configuration.
	 *
	 * @return array
	 */
	public static function get_default_email_types() {
		return array(
			'order_complete'  => array(
				'title'     => __( 'Email On Order Complete', 'ugcify' ),
				'recipient' => 'user',
				'enabled'   => true,
				'subject'   => __( 'Your order #{order_id} is complete!', 'ugcify' ),
				'body'      => self::get_default_order_complete_body(),
			),
			'review_submit'   => array(
				'title'     => __( 'Email On Review Submit', 'ugcify' ),
				'recipient' => 'admin',
				'enabled'   => true,
				'subject'   => __( 'New review submitted on {site_name}', 'ugcify' ),
				'body'      => self::get_default_review_submit_body(),
			),
			'review_approve'  => array(
				'title'     => __( 'Email On Review Approve', 'ugcify' ),
				'recipient' => 'user',
				'enabled'   => true,
				'subject'   => __( 'Your review has been approved!', 'ugcify' ),
				'body'      => self::get_default_review_approve_body(),
			),
			'review_featured' => array(
				'title'     => __( 'Email On Review Featured Bonus', 'ugcify' ),
				'recipient' => 'user',
				'enabled'   => true,
				'subject'   => __( 'Your featured review earned a bonus!', 'ugcify' ),
				'body'      => self::get_default_review_featured_body(),
			),
			'review_reject'   => array(
				'title'     => __( 'Email On Review Reject', 'ugcify' ),
				'recipient' => 'user',
				'enabled'   => true,
				'subject'   => __( 'Update on your review submission', 'ugcify' ),
				'body'      => self::get_default_review_reject_body(),
			),
			'review_reply'    => array(
				'title'     => __( 'Email On Review Reply', 'ugcify' ),
				'recipient' => 'user',
				'enabled'   => true,
				'subject'   => __( 'Reply to your review on {site_name}', 'ugcify' ),
				'body'      => self::get_default_review_reply_body(),
			),
			'lightbox_purchase' => array(
				'title'     => __( 'Email On Lightbox Purchase Bonus', 'ugcify' ),
				'recipient' => 'user',
				'enabled'   => true,
				'subject'   => __( 'You earned a lightbox purchase bonus!', 'ugcify' ),
				'body'      => self::get_default_lightbox_purchase_body(),
			),
			'points_redeemed' => array(
				'title'     => __( 'Email On Points Redeemed', 'ugcify' ),
				'recipient' => 'user',
				'enabled'   => true,
				'subject'   => __( 'Your reward points were redeemed', 'ugcify' ),
				'body'      => self::get_default_points_redeemed_body(),
			),
			'badge_update' => array(
				'title'     => __( 'Email On Badge Gain or Upgrade', 'ugcify' ),
				'recipient' => 'user',
				'enabled'   => true,
				'subject'   => __( 'You unlocked the {current_badge} badge!', 'ugcify' ),
				'body'      => self::get_default_badge_update_body(),
			),
			'review_request' => array(
				'title'     => __( 'Review Request Email', 'ugcify' ),
				'recipient' => 'user',
				'enabled'   => false,
				'subject'   => __( "We'd love your feedback on your recent purchase!", 'ugcify' ),
				'body'      => self::get_default_review_request_body(),
			),
			'influencer_invitation' => array(
				'title'     => __( 'Influencer Invitation Email', 'ugcify' ),
				'recipient' => 'user',
				'enabled'   => false,
				'subject'   => __( 'You are invited to join the {site_name} creator portal', 'ugcify' ),
				'body'      => self::get_default_influencer_invitation_body(),
			),
		);
	}

	/**
	 * Get all email types with saved overrides.
	 *
	 * @return array
	 */
	public static function get_email_types() {
		$defaults = self::get_default_email_types();
		$saved    = get_option( self::TYPES_OPTION, array() );

		self::maybe_upgrade_order_complete_saved_body( $saved, $defaults );

		// Merge saved settings into defaults per email type.
		foreach ( $defaults as $key => $default ) {
			$overrides = self::get_saved_type_overrides( $key, $saved );

			if ( ! empty( $overrides ) ) {
				$defaults[ $key ] = wp_parse_args( $overrides, $default );
			}
		}

		// Influencer invitation email follows the influencer_portal feature gate.
		// Force disabled when the feature is not active so downgraded accounts
		// never send invitation emails they can no longer manage.
		if ( ! FeatureGate::is_enabled( 'influencer_portal' ) ) {
			$defaults['influencer_invitation']['enabled'] = false;
		}

		return $defaults;
	}

	/**
	 * Replace saved generic order-complete body with the review request body once.
	 *
	 * @param array $saved    Saved email type settings.
	 * @param array $defaults Default email type settings.
	 * @return void
	 */
	private static function maybe_upgrade_order_complete_saved_body( array &$saved, array $defaults ) {
		if ( ! function_exists( 'update_option' ) ) {
			return;
		}

		if ( get_option( self::ORDER_COMPLETE_REVIEW_BODY_UPGRADED_OPTION, false ) ) {
			return;
		}

		if ( empty( $defaults['order_complete']['body'] ) ) {
			return;
		}

		if ( ! isset( $saved['order_complete'] ) || ! is_array( $saved['order_complete'] ) ) {
			update_option( self::ORDER_COMPLETE_REVIEW_BODY_UPGRADED_OPTION, true, false );
			return;
		}

		$saved['order_complete']['body'] = $defaults['order_complete']['body'];
		update_option( self::TYPES_OPTION, $saved );
		update_option( self::ORDER_COMPLETE_REVIEW_BODY_UPGRADED_OPTION, true, false );
	}

	private static function get_saved_type_overrides( string $key, array $saved ): array {
		if ( isset( $saved[ $key ] ) && is_array( $saved[ $key ] ) ) {
			return $saved[ $key ];
		}

		if ( 'badge_update' === $key && isset( $saved['tier_upgrade'] ) && is_array( $saved['tier_upgrade'] ) ) {
			return array(
				'enabled' => ! empty( $saved['tier_upgrade']['enabled'] ),
			);
		}

		return array();
	}

	/**
	 * Get a single email type configuration.
	 *
	 * @param string $type Email type key.
	 * @return array|null
	 */
	public static function get_email_type( $type ) {
		$types = self::get_email_types();
		return isset( $types[ $type ] ) ? $types[ $type ] : null;
	}

	/**
	 * Save a single email type configuration.
	 *
	 * @param string $type     Email type key.
	 * @param array  $settings Settings to save.
	 * @return bool
	 */
	public static function save_email_type( $type, $settings ) {
		$types = self::get_email_types();

		if ( ! isset( $types[ $type ] ) ) {
			return false;
		}

		$sanitized = array(
			'title'     => $types[ $type ]['title'], // Title is not editable.
			'recipient' => $types[ $type ]['recipient'], // Recipient is not editable.
			'enabled'   => isset( $settings['enabled'] ) ? (bool) $settings['enabled'] : $types[ $type ]['enabled'],
			'subject'   => sanitize_text_field( $settings['subject'] ?? $types[ $type ]['subject'] ),
			'body'      => wp_kses_post( $settings['body'] ?? $types[ $type ]['body'] ),
		);

		// Get all saved types and update this one.
		$saved          = get_option( self::TYPES_OPTION, array() );
		$saved[ $type ] = $sanitized;

		// update_option() returns false when the value is unchanged — that is not an error.
		update_option( self::TYPES_OPTION, $saved );
		return true;
	}

	/**
	 * Toggle email type enabled/disabled.
	 *
	 * @param string $type    Email type key.
	 * @param bool   $enabled Whether to enable or disable.
	 * @return bool
	 */
	public static function toggle_email_type( $type, $enabled ) {
		$email_type = self::get_email_type( $type );
		if ( ! $email_type ) {
			return false;
		}

		$email_type['enabled'] = (bool) $enabled;

		$saved          = get_option( self::TYPES_OPTION, array() );
		$saved[ $type ] = $email_type;

		// update_option() returns false when the value is unchanged — that is not an error.
		update_option( self::TYPES_OPTION, $saved );
		return true;
	}

	/**
	 * Check if an email type is enabled.
	 *
	 * @param string $type Email type key.
	 * @return bool
	 */
	public static function is_enabled( $type ) {
		$email_type = self::get_email_type( $type );
		return $email_type ? (bool) $email_type['enabled'] : false;
	}

	/**
	 * Get available placeholders for each email type.
	 *
	 * @param string $type Email type key.
	 * @return array
	 */
	public static function get_available_placeholders( $type ) {
		$common = array(
			'{site_name}'  => __( 'Your website name', 'ugcify' ),
			'{user_name}'  => __( 'Recipient name', 'ugcify' ),
			'{user_email}' => __( 'Recipient email', 'ugcify' ),
		);

		$type_specific = array(
			'order_complete' => array(
				'{order_id}'     => __( 'WooCommerce order ID', 'ugcify' ),
				'{product_name}' => __( 'Product name', 'ugcify' ),
				'{product_link}' => __( 'Product name with link', 'ugcify' ),
				'{review_url}'   => __( 'Direct URL to submit a review for single-product orders', 'ugcify' ),
				'{order_review_cta}' => __( 'Adaptive review CTA: button for one product, table for multiple products', 'ugcify' ),
				'{order_products_review_table}' => __( 'Review request table for multi-product orders', 'ugcify' ),
			),
			'review_submit'  => array(
				'{review_content}' => __( 'Review text content', 'ugcify' ),
				'{review_rating}'  => __( 'Review star rating', 'ugcify' ),
				'{product_name}'   => __( 'Product name', 'ugcify' ),
				'{product_link}'   => __( 'Product name with link', 'ugcify' ),
				'{review_link}'    => __( 'Link to review in admin', 'ugcify' ),
			),
			'review_approve' => array(
				'{review_content}'  => __( 'Review text content', 'ugcify' ),
				'{review_rating}'   => __( 'Review star rating', 'ugcify' ),
				'{product_name}'    => __( 'Product name', 'ugcify' ),
				'{product_link}'    => __( 'Product name with link', 'ugcify' ),
				'{points_earned}'   => __( 'Exact reward points earned from the approval', 'ugcify' ),
				'{current_tier}'    => __( 'Current reward tier name', 'ugcify' ),
				'{current_badge}'   => __( 'Current reward badge name', 'ugcify' ),
				'{available_balance}' => __( 'Current available reward points balance', 'ugcify' ),
				'{reward_message}'  => __( 'Reward summary message (shown when reward points are earned)', 'ugcify' ),
			),
			'review_featured' => array(
				'{review_content}'  => __( 'Review text content', 'ugcify' ),
				'{review_rating}'   => __( 'Review star rating', 'ugcify' ),
				'{product_name}'    => __( 'Product name', 'ugcify' ),
				'{product_link}'    => __( 'Product name with link', 'ugcify' ),
				'{points_earned}'   => __( 'Featured bonus points earned', 'ugcify' ),
				'{current_tier}'    => __( 'Current reward tier name', 'ugcify' ),
				'{current_badge}'   => __( 'Current reward badge name', 'ugcify' ),
				'{available_balance}' => __( 'Current available reward points balance', 'ugcify' ),
			),
			'review_reject'  => array(
				'{review_content}' => __( 'Review text content', 'ugcify' ),
				'{review_rating}'  => __( 'Review star rating', 'ugcify' ),
				'{product_name}'   => __( 'Product name', 'ugcify' ),
				'{product_link}'   => __( 'Product name with link', 'ugcify' ),
			),
			'lightbox_purchase' => array(
				'{product_name}'    => __( 'Product name', 'ugcify' ),
				'{product_link}'    => __( 'Product name with link', 'ugcify' ),
				'{order_id}'        => __( 'WooCommerce order ID when available', 'ugcify' ),
				'{points_earned}'   => __( 'Referral bonus points earned', 'ugcify' ),
				'{current_tier}'    => __( 'Current reward tier name', 'ugcify' ),
				'{current_badge}'   => __( 'Current reward badge name', 'ugcify' ),
				'{available_balance}' => __( 'Current available reward points balance', 'ugcify' ),
			),
			'points_redeemed' => array(
				'{points_redeemed}'      => __( 'Number of reward points deducted', 'ugcify' ),
				'{available_balance}'    => __( 'Remaining available reward points balance', 'ugcify' ),
				'{redemption_description}' => __( 'Human-readable redemption description', 'ugcify' ),
				'{order_id}'             => __( 'WooCommerce order ID when available', 'ugcify' ),
				'{discount_amount}'      => __( 'Discount amount when available', 'ugcify' ),
			),
			'badge_update' => array(
				'{previous_badge}'      => __( 'Previous badge name before the latest update', 'ugcify' ),
				'{current_badge}'       => __( 'Current badge name after the latest update', 'ugcify' ),
				'{approved_review_count}' => __( 'Number of approved reviews for this user', 'ugcify' ),
				'{badge_change_type}'   => __( 'Whether the badge was gained for the first time or upgraded', 'ugcify' ),
				'{badge_update_message}' => __( 'Human-readable badge gain or upgrade summary', 'ugcify' ),
				'{available_balance}'   => __( 'Current available reward points balance', 'ugcify' ),
			),
			'review_request' => array(
				'{order_id}'     => __( 'WooCommerce order ID', 'ugcify' ),
				'{product_name}' => __( 'Product name(s) from the order', 'ugcify' ),
				'{product_link}' => __( 'Product name(s) with links', 'ugcify' ),
				'{review_url}'   => __( 'Direct URL to leave a review', 'ugcify' ),
			),
			'influencer_invitation' => array(
				'{influencer_name}'       => __( 'Invited creator display name', 'ugcify' ),
				'{influencer_email}'      => __( 'Invited creator email address', 'ugcify' ),
				'{portal_url}'            => __( 'Creator portal invitation link', 'ugcify' ),
				'{invitation_expires_at}' => __( 'Invitation expiry date and time', 'ugcify' ),
				'{product_name}'          => __( 'Requested WooCommerce product names for this invitation', 'ugcify' ),
				'{product_link}'          => __( 'Requested WooCommerce product links for this invitation', 'ugcify' ),
				'{custom_message}'        => __( 'Plain custom invitation message', 'ugcify' ),
				'{custom_message_block}'  => __( 'Formatted custom invitation message block', 'ugcify' ),
			),
		);

		$specific = isset( $type_specific[ $type ] ) ? $type_specific[ $type ] : array();

		return array_merge( $common, $specific );
	}

	// -------------------------------------------------------------------------
	// Default email body templates.
	// -------------------------------------------------------------------------

	/**
	 * Default body for order complete email.
	 *
	 * @return string
	 */
	private static function get_default_order_complete_body() {
		return '<h2>' . __( 'How was your purchase?', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'Hi {user_name},', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Your order <strong>#{order_id}</strong> is complete. We hope you are enjoying your purchase.', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Here are the product details from your completed order. Your feedback helps other shoppers make confident decisions, so please share your experience when you have a moment.', 'ugcify' ) . '</p>'
			. '{order_review_cta}'
			. '<p>' . __( 'Thank you for shopping with us!', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Best regards,', 'ugcify' ) . '<br>{site_name} ' . __( 'Team', 'ugcify' ) . '</p>';
	}

	/**
	 * Default body for review submission email.
	 *
	 * @return string
	 */
	private static function get_default_review_submit_body() {
		return '<h2>' . __( 'New Review Submitted', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'A new review has been submitted on your site.', 'ugcify' ) . '</p>'
			. '<p><strong>' . __( 'Product:', 'ugcify' ) . '</strong> {product_link}</p>'
			. '<p><strong>' . __( 'Rating:', 'ugcify' ) . '</strong> {review_rating}/5</p>'
			. '<p><strong>' . __( 'Reviewer:', 'ugcify' ) . '</strong> {user_name} ({user_email})</p>'
			. '<p><strong>' . __( 'Review:', 'ugcify' ) . '</strong></p>'
			. '<blockquote>{review_content}</blockquote>'
			. '<p>{review_link}</p>'
			. '<p>' . __( 'Log in to your admin panel to approve or reject this review.', 'ugcify' ) . '</p>';
	}

	/**
	 * Default body for review approval email.
	 *
	 * @return string
	 */
	private static function get_default_review_approve_body() {
		return '<h2>' . __( 'Your Review Has Been Approved!', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'Hi {user_name},', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Great news! Your review for {product_link} has been approved and is now visible on our website.', 'ugcify' ) . '</p>'
			. '<p><strong>' . __( 'Your review:', 'ugcify' ) . '</strong></p>'
			. '<blockquote>{review_content}</blockquote>'
			. '<p><strong>' . __( 'Reward points earned:', 'ugcify' ) . '</strong> {points_earned} pts</p>'
			. '<p><strong>' . __( 'Your current tier:', 'ugcify' ) . '</strong> {current_tier}</p>'
			. '<p><strong>' . __( 'Your current badge:', 'ugcify' ) . '</strong> {current_badge}</p>'
			. '{reward_message}'
			. '<p>' . __( 'Thank you for sharing your experience!', 'ugcify' ) . '</p>';
	}

	/**
	 * Default body for review featured bonus email.
	 *
	 * @return string
	 */
	private static function get_default_review_featured_body() {
		return '<h2>' . __( 'Your Review Has Been Featured!', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'Hi {user_name},', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Your review for {product_link} has been marked as featured.', 'ugcify' ) . '</p>'
			. '<p><strong>' . __( 'Featured bonus earned:', 'ugcify' ) . '</strong> {points_earned} pts</p>'
			. '<p><strong>' . __( 'Your current tier:', 'ugcify' ) . '</strong> {current_tier}</p>'
			. '<p><strong>' . __( 'Your current badge:', 'ugcify' ) . '</strong> {current_badge}</p>'
			. '<p><strong>' . __( 'Available balance:', 'ugcify' ) . '</strong> {available_balance} pts</p>'
			. '<p>' . __( 'Thank you for contributing standout content to the community.', 'ugcify' ) . '</p>';
	}

	/**
	 * Default body for review rejection email.
	 *
	 * @return string
	 */
	private static function get_default_review_reject_body() {
		return '<h2>' . __( 'Update on Your Review', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'Hi {user_name},', 'ugcify' ) . '</p>'
			. '<p>' . __( 'We appreciate you taking the time to review <strong>{product_name}</strong>. Unfortunately, your review could not be published at this time.', 'ugcify' ) . '</p>'
			. '<p>' . __( 'If you believe this was a mistake, please feel free to contact us.', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Thank you for your understanding.', 'ugcify' ) . '</p>';
	}

	/**
	 * Default body for review reply email.
	 *
	 * @return string
	 */
	private static function get_default_review_reply_body() {
		return '<h2>' . __( 'Reply to Your Review', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'Hi {user_name},', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Thank you for your review on {product_link}. We wanted to respond to your feedback:', 'ugcify' ) . '</p>'
			. '<blockquote>{reply_message}</blockquote>'
			. '<p>' . __( 'We appreciate your feedback and hope you continue to enjoy our products!', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Best regards,', 'ugcify' ) . '<br>{site_name} ' . __( 'Team', 'ugcify' ) . '</p>';
	}

	/**
	 * Default body for lightbox purchase reward email.
	 *
	 * @return string
	 */
	private static function get_default_lightbox_purchase_body() {
		return '<h2>' . __( 'You Earned a Lightbox Purchase Bonus!', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'Hi {user_name},', 'ugcify' ) . '</p>'
			. '<p>' . __( 'A customer completed a purchase after engaging with your review for {product_link}.', 'ugcify' ) . '</p>'
			. '<p><strong>' . __( 'Bonus earned:', 'ugcify' ) . '</strong> {points_earned} pts</p>'
			. '<p><strong>' . __( 'Your current tier:', 'ugcify' ) . '</strong> {current_tier}</p>'
			. '<p><strong>' . __( 'Your current badge:', 'ugcify' ) . '</strong> {current_badge}</p>'
			. '<p><strong>' . __( 'Available balance:', 'ugcify' ) . '</strong> {available_balance} pts</p>'
			. '<p>' . __( 'Thanks for creating content that helps other shoppers buy with confidence.', 'ugcify' ) . '</p>';
	}

	/**
	 * Default body for points redeemed email.
	 *
	 * @return string
	 */
	private static function get_default_points_redeemed_body() {
		return '<h2>' . __( 'Your Reward Points Were Redeemed', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'Hi {user_name},', 'ugcify' ) . '</p>'
			. '<p>' . __( 'A redemption has been processed against your UGC Reward balance.', 'ugcify' ) . '</p>'
			. '<p><strong>' . __( 'Points spent:', 'ugcify' ) . '</strong> {points_redeemed} pts</p>'
			. '<p><strong>' . __( 'Remaining balance:', 'ugcify' ) . '</strong> {available_balance} pts</p>'
			. '<p><strong>' . __( 'Details:', 'ugcify' ) . '</strong> {redemption_description}</p>'
			. '<p>' . __( 'If you did not expect this redemption, please contact support.', 'ugcify' ) . '</p>';
	}

	/**
	 * Default body for badge gain or upgrade email.
	 *
	 * @return string
	 */
	private static function get_default_badge_update_body() {
		return '<h2>' . __( 'Your Badge Has Been Updated!', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'Hi {user_name},', 'ugcify' ) . '</p>'
			. '<p>{badge_update_message}</p>'
			. '<p><strong>' . __( 'Previous badge:', 'ugcify' ) . '</strong> {previous_badge}</p>'
			. '<p><strong>' . __( 'Current badge:', 'ugcify' ) . '</strong> {current_badge}</p>'
			. '<p><strong>' . __( 'Approved reviews:', 'ugcify' ) . '</strong> {approved_review_count}</p>'
			. '<p><strong>' . __( 'Badge change type:', 'ugcify' ) . '</strong> {badge_change_type}</p>'
			. '<p><strong>' . __( 'Available balance:', 'ugcify' ) . '</strong> {available_balance} pts</p>'
			. '<p>' . __( 'Keep contributing to unlock even more recognition.', 'ugcify' ) . '</p>';
	}

	/**
	 * Default body for review request email.
	 *
	 * @return string
	 */
	private static function get_default_review_request_body() {
		return '<h2>' . __( 'How was your recent purchase?', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'Hi {user_name},', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Thank you for your recent order #{order_id}. We hope you\'re enjoying {product_name}!', 'ugcify' ) . '</p>'
			. '<p>' . __( 'We\'d love to hear what you think. Your feedback helps other shoppers and helps us improve.', 'ugcify' ) . '</p>'
			. '<p style="text-align:center; margin:24px 0;">'
			. '<a href="{review_url}" style="background:#201CFE;color:#fff;text-decoration:none;padding:12px 28px;border-radius:6px;font-weight:600;display:inline-block;">'
			. __( 'Leave a Review', 'ugcify' )
			. '</a></p>'
			. '<p>' . __( 'Thank you for shopping with us!', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Best regards,', 'ugcify' ) . '<br>{site_name} ' . __( 'Team', 'ugcify' ) . '</p>';
	}

	/**
	 * Default body for creator invitation email.
	 *
	 * @return string
	 */
	private static function get_default_influencer_invitation_body() {
		return '<h2>' . __( 'You are invited to join our creator portal', 'ugcify' ) . '</h2>'
			. '<p>' . __( 'Hi {influencer_name},', 'ugcify' ) . '</p>'
			. '<p>' . __( 'We would love to work with you as an approved creator for {site_name}.', 'ugcify' ) . '</p>'
			. '<p>' . __( 'This invitation is requesting creator content for {product_link}.', 'ugcify' ) . '</p>'
			. '{custom_message_block}'
			. '<p>' . __( 'Use the secure link below to activate your creator access, review the requested products, and complete onboarding.', 'ugcify' ) . '</p>'
			. '<p style="text-align:center; margin:24px 0;">'
			. '<a href="{portal_url}" style="background:#201CFE;color:#fff;text-decoration:none;padding:12px 28px;border-radius:6px;font-weight:600;display:inline-block;">'
			. __( 'Open Creator Portal', 'ugcify' )
			. '</a></p>'
			. '<p><strong>' . __( 'Invitation expires:', 'ugcify' ) . '</strong> {invitation_expires_at}</p>'
			. '<p>' . __( 'If you were not expecting this invitation, you can safely ignore this email.', 'ugcify' ) . '</p>'
			. '<p>' . __( 'Best regards,', 'ugcify' ) . '<br>{site_name} ' . __( 'Team', 'ugcify' ) . '</p>';
	}
}
