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

<form action="<?= site_url('ppdb/admin/update/' . $record['id']) ?>" method="post" enctype="multipart/form-data">
    <div class="card shadow-sm">
        <div class="card-body">

            <!-- ================= IDENTITAS SISWA ================= -->
            <h6 class="fw-bold text-primary mb-3">
                <i class="fas fa-user"></i> Identitas Siswa
            </h6>

            <div class="row">
                <div class="col-md-6 mb-3">
                    <label>Nama Lengkap</label>
                    <input type="text" name="name" class="form-control" value="<?= $record['name'] ?? '' ?>" required>
                </div>

                <div class="col-md-3 mb-3">
                    <label>NISN</label>
                    <input type="text" name="nisn" class="form-control" value="<?= $record['nisn'] ?? '' ?>">
                </div>

                <div class="col-md-3 mb-3">
                    <label>NIK</label>
                    <input type="text" name="nik" class="form-control" value="<?= $record['nik'] ?? '' ?>">
                </div>

                <div class="col-md-4 mb-3">
                    <label>Tempat Lahir</label>
                    <input type="text" name="birth_place" class="form-control"
                        value="<?= $record['birth_place'] ?? '' ?>">
                </div>

                <div class="col-md-4 mb-3">
                    <label>Tanggal Lahir</label>
                    <input type="date" name="birth_date" class="form-control"
                        value="<?= $record['birth_date'] ?? '' ?>">
                </div>

                <div class="col-md-4 mb-3">
                    <label>Jenis Kelamin</label>
                    <select name="gender" class="form-control">
                        <option value="M" <?= ($record['gender'] ?? '') == 'M' ? 'selected' : '' ?>>Laki-laki</option>
                        <option value="F" <?= ($record['gender'] ?? '') == 'F' ? 'selected' : '' ?>>Perempuan</option>
                    </select>
                </div>
            </div>

            <hr>

            <!-- ================= ALAMAT ================= -->
            <h6 class="fw-bold text-primary mb-3">
                <i class="fas fa-map-marker-alt"></i> Alamat Domisili
            </h6>

            <div class="row">
                <div class="col-md-6 mb-3">
                    <label>Alamat Lengkap</label>
                    <input type="text" name="address_street" class="form-control"
                        value="<?= $record['address_street'] ?? '' ?>">
                </div>

                <div class="col-md-2 mb-3">
                    <label>RT / RW</label>
                    <input type="text" name="rt_rw" class="form-control" value="<?= $record['rt_rw'] ?? '' ?>">
                </div>

                <div class="col-md-2 mb-3">
                    <label>Kode Pos</label>
                    <input type="text" name="postal_code" class="form-control"
                        value="<?= $record['postal_code'] ?? '' ?>">
                </div>

                <div class="col-md-3 mb-3">
                    <label>Provinsi</label>
                    <input type="text" name="province" class="form-control" value="<?= $record['province'] ?? '' ?>">
                </div>

                <div class="col-md-3 mb-3">
                    <label>Kab / Kota</label>
                    <input type="text" name="city" class="form-control" value="<?= $record['city'] ?? '' ?>">
                </div>

                <div class="col-md-3 mb-3">
                    <label>Kecamatan</label>
                    <input type="text" name="district" class="form-control" value="<?= $record['district'] ?? '' ?>">
                </div>

                <div class="col-md-3 mb-3">
                    <label>Kelurahan</label>
                    <input type="text" name="village" class="form-control" value="<?= $record['village'] ?? '' ?>">
                </div>
            </div>

            <hr>

            <!-- ================= ORANG TUA ================= -->
            <h6 class="fw-bold text-primary mb-3">
                <i class="fas fa-users"></i> Data Orang Tua
            </h6>

            <div class="row">
                <div class="col-md-6 mb-3">
                    <label>Nama Ayah</label>
                    <input type="text" name="father_name" class="form-control"
                        value="<?= $record['father_name'] ?? '' ?>">
                </div>

                <div class="col-md-6 mb-3">
                    <label>Pekerjaan Ayah</label>
                    <input type="text" name="father_job" class="form-control"
                        value="<?= $record['father_job'] ?? '' ?>">
                </div>

                <div class="col-md-6 mb-3">
                    <label>No HP Ayah</label>
                    <input type="text" name="father_phone" class="form-control"
                        value="<?= $record['father_phone'] ?? '' ?>">
                </div>

                <div class="col-md-6 mb-3">
                    <label>Nama Ibu</label>
                    <input type="text" name="mother_name" class="form-control"
                        value="<?= $record['mother_name'] ?? '' ?>">
                </div>

                <div class="col-md-6 mb-3">
                    <label>Pekerjaan Ibu</label>
                    <input type="text" name="mother_job" class="form-control"
                        value="<?= $record['mother_job'] ?? '' ?>">
                </div>

                <div class="col-md-6 mb-3">
                    <label>No HP Ibu</label>
                    <input type="text" name="mother_phone" class="form-control"
                        value="<?= $record['mother_phone'] ?? '' ?>">
                </div>
            </div>

            <hr>

            <!-- ================= SEKOLAH ASAL ================= -->
            <h6 class="fw-bold text-primary mb-3">
                <i class="fas fa-school"></i> Sekolah Asal
            </h6>

            <div class="row">
                <div class="col-md-6 mb-3">
                    <label>Nama Sekolah</label>
                    <input type="text" name="school_origin" class="form-control"
                        value="<?= $record['school_origin'] ?? '' ?>">
                </div>

                <div class="col-md-3 mb-3">
                    <label>NPSN</label>
                    <input type="text" name="school_npsn" class="form-control"
                        value="<?= $record['school_npsn'] ?? '' ?>">
                </div>

                <div class="col-md-3 mb-3">
                    <label>Kota Sekolah</label>
                    <input type="text" name="school_city" class="form-control"
                        value="<?= $record['school_city'] ?? '' ?>">
                </div>
            </div>

            <hr>

            <!-- ================= DOKUMEN ================= -->
            <h6 class="fw-bold text-primary mb-3">
                <i class="fas fa-file"></i> Dokumen Upload
            </h6>

            <div class="row">
                <div class="col-md-6 mb-3">
                    <label>Rapor (Multi File)</label>
                    <input type="file" name="rapor_file[]" class="form-control" multiple>
                    <small class="text-muted">Kosongkan jika tidak diganti</small>
                </div>

                <div class="col-md-6 mb-3">
                    <label>Kartu Keluarga</label>
                    <input type="file" name="kk_file" class="form-control">
                </div>

                <div class="col-md-6 mb-3">
                    <label>Akta Kelahiran</label>
                    <input type="file" name="akta_file" class="form-control">
                </div>

                <div class="col-md-6 mb-3">
                    <label>Foto</label>
                    <input type="file" name="photo_file" class="form-control">
                </div>
            </div>

            <hr>

            <div class="text-end">
                <button class="btn btn-primary">
                    <i class="fas fa-save"></i> Simpan Perubahan
                </button>

                <a href="<?= site_url('ppdb/admin') ?>" class="btn btn-secondary">
                    Kembali
                </a>
            </div>

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

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