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

<style>
    .card-premium {
        border-radius: 18px;
        overflow: hidden
    }

    .metric-box {
        padding: 20px;
        border-radius: 15px;
        color: white;
        font-weight: bold
    }

    .metric-title {
        font-size: 14px;
        opacity: .8
    }

    .metric-value {
        font-size: 26px;
        margin-top: -4px
    }
</style>

<div class="card shadow-sm card-premium">

    <div class="card-header bg-primary text-white">
        <b>Dashboard Verifikasi PPDB</b>
    </div>

    <div class="card-body">
        <?php if (session()->getFlashdata('success')): ?>
            <div class="alert alert-success">
                <?= session()->getFlashdata('success') ?>
            </div>
        <?php endif; ?>

        <?php if (session()->getFlashdata('error')): ?>
            <div class="alert alert-danger">
                <?= session()->getFlashdata('error') ?>
            </div>
        <?php endif; ?>

        <div class="row mb-3">
            <div class="col-md-4">
                <div class="metric-box bg-warning text-dark">
                    <div class="metric-title">Menunggu Verifikasi</div>
                    <div class="metric-value"><?= $submit ?></div>
                </div>
            </div>

            <div class="col-md-4">
                <div class="metric-box bg-success">
                    <div class="metric-title">Diterima</div>
                    <div class="metric-value"><?= $approved ?></div>
                </div>
            </div>

            <div class="col-md-4">
                <div class="metric-box bg-danger">
                    <div class="metric-title">Ditolak</div>
                    <div class="metric-value"><?= $rejected ?></div>
                </div>
            </div>
        </div>

        <table class="table table-bordered table-striped">
            <thead class="table-dark">
                <tr>
                    <th>No</th>
                    <th>No Daftar</th>
                    <th>Nama</th>
                    <th>NISN</th>
                    <th>Status</th>
                    <th width="150">Aksi</th>
                </tr>
            </thead>

            <tbody>
                <?php $no = 1;
                foreach ($list as $row): ?>
                    <tr>
                        <td><?= $no++ ?></td>
                        <td><?= $row['reg_no'] ?></td>
                        <td><?= $row['name'] ?></td>
                        <td><?= $row['nisn'] ?></td>
                        <td>
                            <span class="badge 
                    <?= $row['status'] == 'PENDING' ? 'bg-warning text-dark' : '' ?>
                    <?= $row['status'] == 'APPROVED' ? 'bg-success' : '' ?>
                    <?= $row['status'] == 'REJECTED' ? 'bg-danger' : '' ?>">
                                <?= $row['status'] ?>
                            </span>
                        </td>

                        <td>
                            <div class="btn-group">
                                <a href="<?= site_url('ppdb/admin/detail/' . $row['id']) ?>"
                                    class="btn btn-info btn-sm text-white">
                                    Detail 
                                </a>
                            </div>
                        </td>
                    </tr>
                <?php endforeach ?>
            </tbody>
        </table>

    </div>
</div>

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

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
