<?php $pageTitle = 'Payment Review'; ?>
<div class="mb-3"><a href="<?= base_url('admin/payments') ?>" class="text-secondary"><i class="fas fa-arrow-left me-1"></i> Back to Payments</a></div>
<div class="row g-4">
    <div class="col-lg-8">
        <div class="card-cix mb-4">
            <div class="card-cix-header"><h5 class="mb-0"><i class="fas fa-credit-card text-orange me-2"></i> Payment Details</h5></div>
            <div class="row g-3">
                <div class="col-md-6"><p class="text-secondary mb-1">Student</p><h5><?= e($payment['first_name'] . ' ' . $payment['last_name']) ?></h5><p class="small text-secondary"><?= e($payment['student_number']) ?></p></div>
                <div class="col-md-3"><p class="text-secondary mb-1">Amount</p><h3 style="color:var(--secondary)">R<?= number_format($payment['amount'], 2) ?></h3></div>
                <div class="col-md-3"><p class="text-secondary mb-1">Status</p><span class="badge-cix badge-<?= $payment['status'] ?>"><?= ucfirst($payment['status']) ?></span></div>
                <div class="col-md-6"><p class="text-secondary mb-1">Package</p><h5><?= e($payment['package_name'] ?? '-') ?></h5></div>
                <div class="col-md-6"><p class="text-secondary mb-1">Date</p><p><?= e($payment['created_at']) ?></p></div>
            </div>
        </div>
        <div class="card-cix mb-4">
            <div class="card-cix-header"><h5 class="mb-0"><i class="fas fa-file-alt text-orange me-2"></i> Proof of Payment</h5></div>
            <?php if (empty($proofs)): ?>
                <p class="text-secondary p-3">No proof uploaded yet.</p>
            <?php else: ?>
                <?php foreach ($proofs as $proof): ?>
                <div style="padding:0.75rem;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;">
                    <div><i class="fas fa-file text-secondary me-2"></i><?= e($proof['file_name']) ?> <span class="badge-cix badge-<?= $proof['status'] ?>"><?= ucfirst($proof['status']) ?></span></div>
                    <a href="<?= asset_url('uploads/' . $proof['file_path']) ?>" target="_blank" class="btn-cix btn-cix-sm btn-cix-outline"><i class="fas fa-external-link-alt"></i> View</a>
                </div>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
    </div>
    <div class="col-lg-4">
        <div class="card-cix">
            <div class="card-cix-header"><h5 class="mb-0"><i class="fas fa-gavel text-orange me-2"></i> Action</h5></div>
            <form method="POST" action="<?= base_url('admin/payment/' . $payment['id']) ?>">
                <?= csrf_field() ?>
                <div class="form-group-cix"><label class="form-label-cix">Notes</label><textarea name="notes" class="form-control-cix" rows="3" placeholder="Add notes..."></textarea></div>
                <button type="submit" name="action" value="approve" class="btn-cix btn-cix-accent w-100 mb-2"><i class="fas fa-check"></i> Approve Payment</button>
                <button type="submit" name="action" value="reject" class="btn-cix btn-cix-danger w-100"><i class="fas fa-times"></i> Reject Payment</button>
            </form>
        </div>
    </div>
</div>
