<?php
/**
 * WITHDRAWAL REJECTED EMAIL TEMPLATE
 * File: templates/email/withdrawal-rejected.php
 *
 * Available variables:
 * $user_name, $amount, $reference, $reason, $processed_date, 
 * $app_name, $app_url, $user_type
 */

ob_start();
?>

<p>Hello <strong><?= htmlspecialchars($user_name ?? '') ?></strong>,</p>
<p>We regret to inform you that your withdrawal request has been rejected.</p>

<div class="order-summary">
    <h3>Withdrawal Details</h3>
    <p><strong>Reference:</strong> <?= htmlspecialchars($reference ?? '') ?></p>
    <p><strong>Amount:</strong> <span style="font-size:18px; font-weight:bold;">&#8358;<?= number_format($amount ?? 0, 2) ?></span></p>
    <p><strong>Status:</strong> <span style="color:#e74c3c; font-weight:bold;">✗ Rejected</span></p>
    <p><strong>Processed Date:</strong> <?= date('F j, Y g:i A', strtotime($processed_date ?? 'now')) ?></p>
</div>

<div class="alert alert-warning">
    <strong>Reason for Rejection:</strong><br>
    <p style="margin-top:10px;"><?= nl2br(htmlspecialchars($reason ?? 'Not specified')) ?></p>
</div>

<div class="alert alert-info">
    <strong>Note:</strong><br>
    Your wallet balance remains unchanged. The withdrawal request has simply been declined and you may submit a new request after addressing the issues mentioned above.
</div>

<div class="alert alert-success">
    <strong>What You Can Do:</strong>
    <ul style="margin:10px 0 0 20px; line-height:1.9;">
        <li>Review the rejection reason above</li>
        <li>Verify your bank account details are correct</li>
        <li>Ensure you meet all withdrawal requirements</li>
        <li>Submit a new withdrawal request after addressing the issues</li>
        <li>Contact support if you need assistance</li>
    </ul>
</div>

<p>
    <a href="<?= $app_url ?>/<?= $user_type === 'vendor' ? 'vendor' : 'customer' ?>/wallet.php" class="btn btn-success">View Wallet</a>
</p>

<?php
$content = ob_get_clean();

$email_data = [
    'title'       => 'Withdrawal Rejected',
    'greeting'    => "Withdrawal Request Update",
    'content'     => $content,
    'action_url'  => $app_url . '/' . ($user_type === 'vendor' ? 'vendor' : 'customer') . '/wallet.php',
    'action_text' => 'View Wallet',
    'footer_note' => "You're receiving this email because a withdrawal request was processed on your " . $app_name . " account.",
    'signature'   => "Best regards,<br>The " . $app_name . " Team"
];

include 'layout.php';
?>