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

<?= $this->section('content') ?>

<div style="display: flex; align-items: center; margin-bottom: 2rem; gap: 1rem;">
    <a href="<?= base_url('fakultas') ?>" class="btn btn-secondary" style="padding: 0.5rem 1rem;">
        <i class='bx bx-arrow-back'></i> Kembali
    </a>
    <h1 class="page-title" style="margin-bottom: 0;">
        <?= isset($fakultas) ? 'Edit Fakultas' : 'Tambah Fakultas Baru' ?>
    </h1>
</div>

<div class="form-container">
    <form action="<?= isset($fakultas) ? base_url('fakultas/update/'.$fakultas['id']) : base_url('fakultas/store') ?>" method="post">
        <?= csrf_field() ?>
        
        <div class="form-group">
            <label class="form-label" for="kode_fakultas">Kode Fakultas</label>
            <input type="text" class="form-control" id="kode_fakultas" name="kode_fakultas" 
                   value="<?= old('kode_fakultas', $fakultas['kode_fakultas'] ?? '') ?>" 
                   placeholder="Contoh: FT, FEB, FIK" autofocus>
            <?php if(isset($validation) && $validation->hasError('kode_fakultas')) : ?>
                <span class="invalid-feedback"><?= $validation->getError('kode_fakultas') ?></span>
            <?php endif; ?>
        </div>

        <div class="form-group">
            <label class="form-label" for="nama_fakultas">Nama Fakultas</label>
            <input type="text" class="form-control" id="nama_fakultas" name="nama_fakultas" 
                   value="<?= old('nama_fakultas', $fakultas['nama_fakultas'] ?? '') ?>" 
                   placeholder="Contoh: Fakultas Teknik">
            <?php if(isset($validation) && $validation->hasError('nama_fakultas')) : ?>
                <span class="invalid-feedback"><?= $validation->getError('nama_fakultas') ?></span>
            <?php endif; ?>
        </div>

        <!-- Kolom Dekan tidak ditampilkan sesuai request -->

        <div class="form-group" style="margin-top: 2rem; display: flex; justify-content: flex-end; gap: 1rem;">
            <button type="reset" class="btn btn-secondary">Reset</button>
            <button type="submit" class="btn btn-primary">
                <i class='bx bx-save'></i> Simpan Data
            </button>
        </div>
    </form>
</div>

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