<div class="main-content">
  <div class="container-fluid" style="margin-top: 50px;">
    <h2><i class="bi bi-pencil-square"></i> Edit Profil Pegawai</h2>

    <?= form_open("pegawai/edit/{$pegawai->id_peg}", ['class' => 'card p-4']) ?>
      <div class="mb-3">
        <label>Nama Lengkap</label>
        <input type="text" name="nama" class="form-control" value="<?= htmlspecialchars($pegawai->nama) ?>" required>
      </div>

      <div class="mb-3">
        <label>NIP</label>
        <input type="text" name="nip" class="form-control" value="<?= htmlspecialchars($pegawai->nip) ?>" required>
      </div>

      <div class="mb-3">
        <label>Jabatan</label>
        <input type="text" name="jabatan" class="form-control" value="<?= htmlspecialchars($pegawai->jabatan) ?>" required>
      </div>

      <div class="mb-3">
        <label>Golongan Ruang</label>
        <input type="text" name="golru" class="form-control" value="<?= htmlspecialchars($pegawai->golru ?? '') ?>">
      </div>

      <div class="mb-3">
        <label>UNOR</label>
        <select name="unor_id" class="form-control" required>
          <option value="">-- Pilih UNOR --</option>
          <?php foreach ($unor_list as $u): ?>
            <option value="<?= $u->unor_id ?>" <?= $pegawai->unor_id == $u->unor_id ? 'selected' : '' ?>>
              <?= htmlspecialchars($u->nama) ?>
            </option>
          <?php endforeach; ?>
        </select>
      </div>

      <div class="d-flex gap-2">
        <button type="submit" class="btn btn-primary">Simpan Perubahan</button>
        <a href="<?= base_url('pegawai') ?>" class="btn btn-secondary">Batal</a>
      </div>
    <?= form_close() ?>
  </div>
</div>