<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Invoice Pembayaran</title>
    <!--[if mso]>
    <style type="text/css">
        body, table, td {font-family: Arial, sans-serif !important;}
    </style>
    <![endif]-->
</head>
<body style="margin: 0; padding: 0; background-color: #f3f4f6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;">
    <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background-color: #f3f4f6;">
        <tr>
            <td align="center" style="padding: 40px 20px;">
                <!-- Main Container -->
                <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="600" style="max-width: 600px; background-color: #ffffff; border-radius: 16px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); overflow: hidden;">
                    <!-- Header with Gradient -->
                    <tr>
                        <td style="background: linear-gradient(135deg, #d4af37 0%, #b8941f 100%); padding: 40px 30px; text-align: center;">
                            <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
                                <tr>
                                    <td align="center">
                                        <div style="width: 64px; height: 64px; background-color: rgba(255, 255, 255, 0.2); border-radius: 50%; display: inline-block; margin-bottom: 20px;">
                                            <svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" style="margin-top: 16px;">
                                                <path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
                                            </svg>
                                        </div>
                                        <h1 style="margin: 0; color: #ffffff; font-size: 28px; font-weight: 700; letter-spacing: -0.5px;">
                                            Invoice Pembayaran
                                        </h1>
                                        <p style="margin: 12px 0 0 0; color: rgba(255, 255, 255, 0.9); font-size: 16px;">
                                            Topup {{ \App\Models\User::getCoinAbbreviation() }}
                                        </p>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    
                    <!-- Content -->
                    <tr>
                        <td style="padding: 40px 30px;">
                            <p style="margin: 0 0 24px 0; color: #374151; font-size: 16px; line-height: 1.6;">
                                Terima kasih! Invoice pembayaran Anda telah dibuat. Silakan selesaikan pembayaran sebelum waktu kedaluwarsa.
                            </p>
                            
                            <!-- Invoice Details Box -->
                            <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
                                <tr>
                                    <td style="background-color: #f9fafb; border-radius: 12px; padding: 24px; border: 1px solid #e5e7eb;">
                                        <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
                                            <tr>
                                                <td style="padding-bottom: 16px; border-bottom: 2px solid #d4af37;">
                                                    <p style="margin: 0; color: #92400e; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;">
                                                        Detail Invoice
                                                    </p>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="padding-top: 16px;">
                                                    <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
                                                        <tr>
                                                            <td style="padding: 8px 0;">
                                                                <p style="margin: 0; color: #6b7280; font-size: 14px;">Kode Referensi</p>
                                                                <p style="margin: 4px 0 0 0; color: #111827; font-size: 16px; font-weight: 600;">{{ $transaction->reference_code }}</p>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td style="padding: 8px 0;">
                                                                <p style="margin: 0; color: #6b7280; font-size: 14px;">Metode Pembayaran</p>
                                                                <p style="margin: 4px 0 0 0; color: #111827; font-size: 16px; font-weight: 600;">{{ $transaction->payment_channel }}</p>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td style="padding: 8px 0;">
                                                                <p style="margin: 0; color: #6b7280; font-size: 14px;">Jumlah Coin</p>
                                                                <p style="margin: 4px 0 0 0; color: #d4af37; font-size: 20px; font-weight: 700;">{{ number_format($transaction->coins, 0, ',', '.') }} {{ \App\Models\User::getCoinAbbreviation() }}</p>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td style="padding: 8px 0;">
                                                                <p style="margin: 0; color: #6b7280; font-size: 14px;">Jumlah Pembayaran</p>
                                                                <p style="margin: 4px 0 0 0; color: #111827; font-size: 18px; font-weight: 600;">Rp {{ number_format($transaction->amount, 0, ',', '.') }}</p>
                                                            </td>
                                                        </tr>
                                                        @if($transaction->fee > 0)
                                                        <tr>
                                                            <td style="padding: 8px 0;">
                                                                <p style="margin: 0; color: #6b7280; font-size: 14px;">Biaya Admin</p>
                                                                <p style="margin: 4px 0 0 0; color: #111827; font-size: 16px; font-weight: 600;">Rp {{ number_format($transaction->fee, 0, ',', '.') }}</p>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td style="padding: 8px 0; border-top: 1px solid #e5e7eb; margin-top: 8px;">
                                                                <p style="margin: 8px 0 0 0; color: #6b7280; font-size: 14px;">Total Pembayaran</p>
                                                                <p style="margin: 4px 0 0 0; color: #d4af37; font-size: 22px; font-weight: 700;">Rp {{ number_format($transaction->amount + $transaction->fee, 0, ',', '.') }}</p>
                                                            </td>
                                                        </tr>
                                                        @endif
                                                        <tr>
                                                            <td style="padding: 8px 0;">
                                                                <p style="margin: 0; color: #6b7280; font-size: 14px;">Status</p>
                                                                <p style="margin: 4px 0 0 0;">
                                                                    <span style="display: inline-block; padding: 4px 12px; background-color: #fef3c7; color: #92400e; border-radius: 6px; font-size: 14px; font-weight: 600;">
                                                                        {{ strtoupper($transaction->status) }}
                                                                    </span>
                                                                </p>
                                                            </td>
                                                        </tr>
                                                        @if($transaction->expires_at)
                                                        <tr>
                                                            <td style="padding: 8px 0;">
                                                                <p style="margin: 0; color: #6b7280; font-size: 14px;">Batas Waktu Pembayaran</p>
                                                                <p style="margin: 4px 0 0 0; color: #dc2626; font-size: 16px; font-weight: 600;">{{ $transaction->expires_at->format('d F Y, H:i') }} WIB</p>
                                                            </td>
                                                        </tr>
                                                        @endif
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                            
                            <!-- Payment Instructions -->
                            @if($transaction->payment_channel === 'QRIS' && $transaction->qr_code_url)
                            <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-top: 24px;">
                                <tr>
                                    <td style="background-color: #fef3c7; border-left: 4px solid #d4af37; border-radius: 8px; padding: 20px;">
                                        <p style="margin: 0 0 12px 0; color: #111827; font-size: 14px; font-weight: 600;">
                                            💳 Cara Pembayaran:
                                        </p>
                                        <ol style="margin: 0; padding-left: 20px; color: #6b7280; font-size: 14px; line-height: 1.8;">
                                            <li style="margin-bottom: 8px;">Buka aplikasi e-wallet atau mobile banking Anda</li>
                                            <li style="margin-bottom: 8px;">Scan QR code yang tersedia di halaman status pembayaran</li>
                                            <li style="margin-bottom: 8px;">Pastikan jumlah pembayaran sesuai dengan invoice</li>
                                            <li>Konfirmasi pembayaran dan tunggu konfirmasi otomatis</li>
                                        </ol>
                                        <div style="margin-top: 16px; text-align: center;">
                                            <a href="{{ route('topup-coin.status', ['reference' => $transaction->reference_code]) }}" style="display: inline-block; padding: 12px 24px; background-color: #d4af37; color: #ffffff; text-decoration: none; border-radius: 8px; font-weight: 600; font-size: 14px;">
                                                Lihat QR Code Pembayaran
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                            @elseif($transaction->payment_url)
                            <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-top: 24px;">
                                <tr>
                                    <td style="text-align: center;">
                                        <a href="{{ $transaction->payment_url }}" style="display: inline-block; padding: 14px 32px; background-color: #d4af37; color: #ffffff; text-decoration: none; border-radius: 8px; font-weight: 600; font-size: 16px;">
                                            Lanjutkan ke Halaman Pembayaran
                                        </a>
                                    </td>
                                </tr>
                            </table>
                            @endif
                            
                            <!-- Important Notice -->
                            <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-top: 24px;">
                                <tr>
                                    <td style="padding: 16px; background-color: #fef3c7; border-radius: 8px; border: 1px solid #fde68a;">
                                        <p style="margin: 0; color: #92400e; font-size: 13px; line-height: 1.6;">
                                            <strong>⏰ Penting:</strong> Invoice ini akan kedaluwarsa dalam waktu yang telah ditentukan. Pastikan Anda menyelesaikan pembayaran sebelum waktu kedaluwarsa.
                                        </p>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    
                    <!-- Footer -->
                    <tr>
                        <td style="background-color: #f9fafb; padding: 30px; border-top: 1px solid #e5e7eb;">
                            <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
                                <tr>
                                    <td style="text-align: center;">
                                        <p style="margin: 0 0 8px 0; color: #6b7280; font-size: 12px;">
                                            Jika Anda memiliki pertanyaan tentang invoice ini, silakan hubungi tim support kami.
                                        </p>
                                        <p style="margin: 20px 0 0 0; color: #9ca3af; font-size: 11px;">
                                            © {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
                                        </p>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>

