<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Payment Receipt</title>
    <style>
        body { font-family: Arial, sans-serif; background: #f4f4f4; margin: 0; padding: 0; }
        .container { max-width: 600px; margin: 30px auto; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.1); }
        .header { background: #1a56db; color: #fff; padding: 30px 40px; }
        .header h1 { margin: 0; font-size: 22px; }
        .body { padding: 30px 40px; color: #333; }
        .receipt-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
        .receipt-table td { padding: 10px 0; border-bottom: 1px solid #eee; }
        .receipt-table td:first-child { color: #666; width: 45%; }
        .receipt-table td:last-child { font-weight: bold; }
        .btn { display: inline-block; margin-top: 24px; padding: 12px 28px; background: #1a56db; color: #fff; text-decoration: none; border-radius: 6px; font-size: 15px; }
        .footer { background: #f9f9f9; padding: 20px 40px; font-size: 12px; color: #999; text-align: center; }
    </style>
</head>
<body>
<div class="container">
    <div class="header">
        <h1>Payment Receipt</h1>
        <p style="margin:6px 0 0;opacity:.85;">{{ config('app.name') }}</p>
    </div>
    <div class="body">
        <p>Dear {{ $user->name }},</p>
        <p>Your payment for the course <strong>{{ $course->title }}</strong> has been successfully processed. You can now access your course through the learner portal.</p>

        <table class="receipt-table">
            <tr>
                <td>Course</td>
                <td>{{ $course->title }}</td>
            </tr>
            <tr>
                <td>Amount Paid</td>
                <td>{{ number_format((float) $enrollment->amount_paid, 2) }} {{ $course->currency ?? config('services.mtn_momo.currency', 'SSP') }}</td>
            </tr>
            <tr>
                <td>Payment Reference</td>
                <td>{{ $enrollment->payment_reference }}</td>
            </tr>
            <tr>
                <td>Payment Date</td>
                <td>{{ $enrollment->payment_date?->format('F j, Y \a\t H:i') ?? now()->format('F j, Y \a\t H:i') }}</td>
            </tr>
            <tr>
                <td>Status</td>
                <td style="color:#16a34a;">Successful</td>
            </tr>
        </table>

        <a href="{{ $portalUrl }}" class="btn">Go to Learner Portal</a>
    </div>
    <div class="footer">
        <p>This is an automated message from {{ config('app.name') }}. Please do not reply to this email.</p>
    </div>
</div>
</body>
</html>
