<?php
/**
 * WITHDRAWAL APPROVED EMAIL TEMPLATE
 * File: templates/email/withdrawal-approved.php
 *
 * Available variables:
 * $user_name, $amount, $reference, $bank_name, $account_number, 
 * $account_name, $processed_date, $app_name, $app_url
 */

ob_start();
?>

<p>Hello <strong><?= htmlspecialchars($user_name ?? '') ?></strong>,</p>
<p>Great news! Your withdrawal request has been approved and processed successfully.</p>

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

<div class="order-summary">
    <h3>Bank Account Details</h3>
    <p><strong>Bank Name:</strong> <?= htmlspecialchars($bank_name ?? '') ?></p>
    <p><strong>Account Number:</strong> <?= htmlspecialchars($account_number ?? '') ?></p>
    <p><strong>Account Name:</strong> <?= htmlspecialchars($account_name ?? '') ?></p>
</div>

<div class="alert alert-info">
    <strong>What Happens Next?</strong>
    <ul style="margin:10px 0 0 20px; line-height:1.9;">
        <li>The funds have been deducted from your wallet balance</li>
        <li>Payment will be processed to your bank account within 1-3 business days</li>
        <li>You will receive a credit alert from your bank once the transfer is completed</li>
        <li>Keep this email for your records</li>
    </ul>
</div>

<div class="alert alert-warning">
    <strong>Important:</strong> If you do not receive the funds within 3 business days, please contact our support team with your withdrawal reference number.
</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 Approved',
    'greeting'    => "Withdrawal Approved! &#127881;",
    '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 approved on your " . $app_name . " account.",
    'signature'   => "Best regards,<br>The " . $app_name . " Team"
];

include 'layout.php';
?>