<?= $this->extend('layout/publik') ?>

<?= $this->section('content') ?>
<div class="row justify-content-center">
    <div class="col-lg-8">
        
        <div class="header-title">
            <h6 class="fw-bold mb-1">HASIL PELACAKAN PENGADUAN</h6>
            <h3 class="fw-bold mb-0 text-uppercase"><?= $kode_akses ?></h3>
        </div>

        <div class="card form-card p-4">
            <div class="card-body">
                
                <?php if(!$pengaduan): ?>
                    <!-- Jika ID tidak ditemukan -->
                    <div class="text-center py-5">
                        <h4 class="text-danger fw-bold mb-3">DATA TIDAK DITEMUKAN</h4>
                        <p class="text-muted">Kode akses <strong><?= $kode_akses ?></strong> tidak terdaftar dalam sistem kami. Pastikan Anda memasukkan kode dengan benar.</p>
                        <a href="<?= base_url('/') ?>" class="btn btn-dark mt-3 rounded-pill px-4">Kembali</a>
                    </div>
                <?php else: ?>
                    <!-- Jika ID ditemukan, tampilkan detail dan timeline -->
                    <div class="mb-4 pb-3 border-bottom">
                        <h5 class="fw-bold text-dark"><?= $pengaduan['judul'] ?></h5>
                        <p class="text-muted mb-1"><small>Dilaporkan pada: <?= date('d M Y', strtotime($pengaduan['created_at'])) ?></small></p>
                        <p class="mb-0"><?= $pengaduan['detail_laporan'] ?></p>
                    </div>

                    <h6 class="fw-bold mb-4">Riwayat Progres (Timeline)</h6>
                    
                    <div class="timeline" style="border-left: 2px solid #dee2e6; margin-left: 10px; padding-left: 20px;">
                        <?php foreach($history as $hist): ?>
                        <div class="mb-4 position-relative">
                            <span class="position-absolute" style="left: -27px; top: 0; background: #333; width: 12px; height: 12px; border-radius: 50%;"></span>
                            <div class="mb-1">
                                <span class="badge bg-primary me-2"><?= $hist['nama_status'] ?></span>
                                <small class="text-muted fw-bold"><?= date('d M Y - H:i', strtotime($hist['created_at'])) ?></small>
                            </div>
                            <div class="p-3 bg-light rounded mt-2 border">
                                <?= $hist['tanggapan'] ?>
                            </div>
                        </div>
                        <?php endforeach; ?>
                    </div>

                    <div class="text-center mt-5">
                        <a href="<?= base_url('/') ?>" class="btn btn-outline-dark px-5 py-2 rounded-pill fw-bold">KEMBALI KE BERANDA</a>
                    </div>
                <?php endif; ?>

            </div>
        </div>

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