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

<div class="container-fluid py-4">

    <!-- A. IDENTITAS SISWA -->
    <div class="card mb-4 shadow-sm border-0">
        <div class="card-body">
            <h5 class="mb-1 fw-bold"><?= session('ppdb_nama') ?></h5>
            <div class="text-muted small">
                No. Pendaftaran: <b>PPDB-2026-0145</b> |
                Jenjang: <b>SMP</b> |
                Jalur: <b>Reguler</b> |
                Tahun Ajaran: <b>2026 / 2027</b>
            </div>
        </div>
    </div>

    <!-- IDENTITAS SISWA -->
    <div class="card mb-3 shadow-sm border-0">
        <div class="card-body">
            <h5 class="fw-bold mb-1">
                <?= esc(session('ppdb_nama')) ?>
            </h5>
            <div class="text-muted small">
                No. Pendaftaran: <b>
                    <?= esc($siswa['no_pendaftaran']) ?>
                </b>
            </div>
        </div>
    </div>

    <!-- ALERT KEAMANAN AKUN -->
    <div class="alert alert-warning small shadow-sm">
        Demi keamanan akun, silakan ganti password Anda secara berkala.
        <a href="<?= site_url('ppdb/account/password') ?>" class="fw-bold">
            Ganti Password
        </a>
    </div>

    <div class="row">

        <!-- KIRI -->
        <div class="col-md-8">

            <!-- B. TO DO / AKSI -->            
            <div class="card mb-4 shadow-sm border-0">
                <div class="card-header bg-warning fw-bold">
                    🔔 Tahapan Pendaftaran yang Harus Di tempuh
                </div>
                <div class="card-body">

                    <?php if ($siswa['current_step'] == 'account_created'): ?>
                        <div class="d-flex justify-content-between align-items-center">
                            <div>⚠️ Lengkapi Data Siswa & Orang Tua</div>
                            <a href="<?= site_url('ppdb/profil') ?>" class="btn btn-sm btn-primary">
                                Lengkapi
                            </a>
                        </div>

                    <?php elseif ($siswa['current_step'] == 'form_completed'): ?>
                        <div class="d-flex justify-content-between align-items-center">
                            <div>⚠️ Upload Dokumen (Akta, KK, dll)</div>
                            <a href="<?= site_url('ppdb/dokumen') ?>" class="btn btn-sm btn-primary">
                                Upload
                            </a>
                        </div>

                    <?php elseif ($siswa['current_step'] == 'doc_verified'): ?>
                        <div class="text-muted">
                            ⏳ Data sedang diverifikasi. Menunggu jadwal tes seleksi.
                        </div>

                    <?php elseif ($siswa['current_step'] == 'test'): ?>
                        <div class="d-flex justify-content-between align-items-center">
                            <div>📝 Ikuti Tes Seleksi</div>
                            <a href="<?= site_url('ppdb/tes') ?>" class="btn btn-sm btn-primary">
                                Lihat Jadwal
                            </a>
                        </div>

                    <?php else: ?>
                        <div class="text-muted text-center">
                            ✅ Tidak ada tindakan yang perlu dilakukan saat ini
                        </div>
                    <?php endif ?>

                </div>
            </div>


            <!-- C. PROGRESS PENDAFTARAN -->
            <div class="card mb-4 shadow-sm border-0">
                <div class="card-header fw-bold">
                    📊 Status Pendaftaran
                </div>
                <div class="card-body">

                    <ul class="list-group list-group-flush">
                        <?php
                        $currentReached = true;
                        ?>

                        <?php foreach ($steps as $step): ?>

                            <?php
                            if ($currentReached) {
                                if ($step['step_code'] == $siswa['current_step']) {
                                    $icon = '⏳';
                                    $class = 'text-warning';
                                    $currentReached = false;
                                } else {
                                    $icon = '✅';
                                    $class = 'text-success';
                                }
                            } else {
                                $icon = '⬜';
                                $class = 'text-muted';
                            }
                            ?>

                            <li class="list-group-item <?= $class ?>">
                                <?= $icon ?>
                                <?= $step['step_label'] ?>
                            </li>

                        <?php endforeach ?>
                    </ul>

                </div>
            </div>
        </div>

        <!-- KANAN -->
        <div class="col-md-4">

            <!-- E. JADWAL SELEKSI -->
            <div class="card mb-4 shadow-sm border-0">
                <div class="card-header fw-bold">
                    📅 Jadwal Seleksi
                </div>
                <div class="card-body small">
                    <p class="mb-1"><b>Tes Akademik</b></p>
                    <p class="mb-2 text-muted">12 Maret 2026</p>

                    <p class="mb-1"><b>Wawancara Orang Tua</b></p>
                    <p class="mb-2 text-muted">14 Maret 2026</p>

                    <p class="mb-1"><b>Lokasi</b></p>
                    <p class="text-muted">Sekolah</p>

                    <div class="alert alert-info p-2 mt-3 mb-0 text-center">
                        ⏰ Tes Akademik: <b>3 hari lagi</b>
                    </div>
                </div>
            </div>

            <!-- F. PENGUMUMAN -->
            <div class="card shadow-sm border-0">
                <div class="card-header fw-bold">
                    📢 Pengumuman
                </div>
                <div class="card-body small">
                    <ul class="mb-0 ps-3">
                        <li>Verifikasi berkas dibuka s/d 10 Maret</li>
                        <li>Jadwal tes dapat berubah sewaktu-waktu</li>
                    </ul>
                </div>
            </div>

        </div>

    </div>

</div>

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