<?php
/**
 * Voucher Email
 * Sent to customer when a gift card voucher is generated from their purchase
 *
 * @package GGM_Commerce
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Voucher Email Class
 */
class GGM_Commerce_Email_Voucher extends GGM_Commerce_Email_Template {

    /**
     * Constructor
     */
    public function __construct() {
        $this->id             = 'voucher';
        $this->title          = __( 'Gift Card Voucher', 'ggm-commerce' );
        $this->description    = __( 'Sent to customer when they purchase a gift card and receive their voucher code.', 'ggm-commerce' );
        $this->recipient_type = 'customer';
    }

    /**
     * Get default subject
     *
     * @return string
     */
    public function get_default_subject() {
        return __( 'Your Gift Card Voucher Code - {voucher_code}', 'ggm-commerce' );
    }

    /**
     * Get default heading
     *
     * @return string
     */
    public function get_default_heading() {
        return __( 'Your Gift Card is Ready!', 'ggm-commerce' );
    }

    /**
     * Get default content
     *
     * @return string
     */
    public function get_default_content() {
        return '
<p>Hi {customer_first_name},</p>

<p>Thank you for your purchase! Your gift card voucher is ready to use.</p>

<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; text-align: center; border-radius: 12px; margin: 24px 0;">
    <h2 style="color: white; margin: 0 0 10px 0; font-size: 16px; text-transform: uppercase; letter-spacing: 2px;">Your Voucher Code</h2>
    <div style="background: rgba(255,255,255,0.2); padding: 15px 30px; border-radius: 8px; display: inline-block; margin: 10px 0;">
        <span style="font-family: monospace; font-size: 28px; font-weight: bold; letter-spacing: 3px;">{voucher_code}</span>
    </div>
    <p style="margin: 15px 0 0 0; font-size: 20px; font-weight: bold;">Value: {voucher_value}</p>
    {voucher_expiry_notice}
</div>

<h3 style="margin: 24px 0 16px 0; font-size: 18px; color: #1f2937;">How to Use Your Voucher</h3>

<ol style="padding-left: 20px; line-height: 1.8;">
    <li>Add items to your cart at our store</li>
    <li>Proceed to checkout</li>
    <li>Enter the voucher code <strong>{voucher_code}</strong> in the discount code field</li>
    <li>The value will be applied to your order</li>
</ol>

<p style="margin-top: 24px;"><strong>Order Reference:</strong> #{order_number}<br>
<strong>Product:</strong> {product_name}</p>

<p style="margin-top: 32px; padding: 16px; background: #f3f4f6; border-radius: 8px; font-size: 14px;">
    <strong>Important:</strong> Please save this email. You will need your voucher code to redeem your gift card value.
</p>

<p style="margin-top: 24px;">If you have any questions, please contact us at {business_email}.</p>

<p>Thank you for shopping with us!</p>
';
    }

    /**
     * Get available placeholders for this email.
     *
     * @return array
     */
    public function get_placeholders() {
        $placeholders = parent::get_placeholders();

        return array_merge(
            $placeholders,
            array(
                '{voucher_code}'         => __( 'The generated voucher code', 'ggm-commerce' ),
                '{voucher_value}'        => __( 'The voucher value (formatted)', 'ggm-commerce' ),
                '{voucher_expiry_notice}' => __( 'Expiry notice if voucher expires', 'ggm-commerce' ),
                '{product_name}'         => __( 'The gift card product name', 'ggm-commerce' ),
            )
        );
    }
}
