<?= $this->extend('layout/admin') ?>
<?= $this->section('content') ?>

<style>
    .detail-table th {
        width: 35%;
        background: #f8f9fa;
    }

    .badge-lg {
        font-size: 0.85rem;
        padding: 6px 10px;
    }
</style>

<div class="row justify-content-center">
    <div class="col-lg-8">

        <div class="card shadow-lg border-0 rounded-4">
            <div class="card-header bg-gradient bg-info text-white rounded-top-4 d-flex align-items-center">
                <i class="fas fa-receipt me-2 fs-5"></i>
                <b>Detail Pembayaran PPDB</b>
            </div>

            <div class="card-body p-4">

                <table class="table table-bordered detail-table align-middle mb-4">
                    <tr>
                        <th>Student ID</th>
                        <td><?= esc($payment['student_id']) ?></td>
                    </tr>

                    <tr>
                        <th>Jumlah Bayar</th>
                        <td class="fw-bold text-success fs-5">
                            Rp <?= number_format($payment['amount'], 0, ',', '.') ?>
                        </td>
                    </tr>

                    <tr>
                        <th>Metode Pembayaran</th>
                        <td>
                            <span class="badge bg-secondary badge-lg">
                                <?= esc($payment['method']) ?>
                            </span>
                        </td>
                    </tr>

                    <tr>
                        <th>Status</th>
                        <td>
                            <?php
                            $badge = 'secondary';
                            if ($payment['status'] === 'PAID')
                                $badge = 'success';
                            if ($payment['status'] === 'PENDING')
                                $badge = 'warning';
                            if ($payment['status'] === 'FAILED')
                                $badge = 'danger';
                            ?>
                            <span class="badge bg-<?= $badge ?> badge-lg">
                                <?= esc($payment['status']) ?>
                            </span>
                        </td>
                    </tr>

                    <tr>
                        <th>Tanggal Pembayaran</th>
                        <td>
                            <i class="far fa-calendar-alt me-1 text-muted"></i>
                            <?= date('d M Y H:i', strtotime($payment['payment_date'])) ?>
                        </td>
                    </tr>

                    <tr>
                        <th>Bukti Pembayaran</th>
                        <td>
                            <?php if ($payment['proof_file']): ?>
                                <a href="<?= base_url('uploads/ppdb/payment/' . $payment['proof_file']) ?>" target="_blank"
                                    class="btn btn-sm btn-outline-primary">
                                    <i class="fas fa-eye"></i> Lihat Bukti
                                </a>
                            <?php else: ?>
                                <span class="text-muted fst-italic">Tidak ada</span>
                            <?php endif; ?>
                        </td>
                    </tr>
                </table>

                <div class="d-flex justify-content-between">
                    <a href="<?= site_url('ppdb/payment') ?>" class="btn btn-secondary">
                        <i class="fas fa-arrow-left me-1"></i> Kembali
                    </a>

                    <?php if ($payment['proof_file']): ?>
<a href="<?= base_url('uploads/ppdb/payment/' . $payment['proof_file']) ?>"
   target="_blank"
   class="btn btn-sm btn-primary">
   Lihat Bukti
</a>
                    <?php endif; ?>
                </div>

            </div>
        </div>

    </div>
</div>

<?= $this->endSection() ?>