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

<?= $this->section('content') ?>
<div class="breadcrumb-area pt-50 pb-50 bg-gray">
    <div class="container">
        <div class="breadcrumb-content text-center">
            <ul>
                <li><a href="<?= base_url() ?>">Beranda</a></li>
                <li><a href="<?= base_url('profil/'.$halaman['slug']) ?>">Profil</a></li>
                <li class="active">Admin Edit</li>
            </ul>
            <h2>Edit: <?= $halaman['judul_halaman'] ?></h2>
        </div>
    </div>
</div>

<div class="container pt-100 pb-100">
    <div class="row justify-content-center">
        <div class="col-lg-10">
            <div class="card shadow-sm border-0">
                <div class="card-body p-4">
                    <form action="<?= base_url('admin/profil/update') ?>" method="post">
                        <?= csrf_field() ?>
                        <input type="hidden" name="id_halaman" value="<?= $halaman['id_halaman'] ?>">
                        <input type="hidden" name="slug" value="<?= $halaman['slug'] ?>">

                        <div class="form-group mb-4">
                            <label class="h5 fw-bold">Judul Halaman</label>
                            <input type="text" name="judul_halaman" class="form-control form-control-lg" value="<?= $halaman['judul_halaman'] ?>" required>
                        </div>

                        <?php if ($halaman['slug'] == 'visi-misi') : ?>
                            <div class="alert alert-info mb-4">
                                <i class="fa fa-info-circle"></i> <strong>Tips:</strong> Isi teks di bawah ini tanpa perlu memikirkan desain. Sistem akan otomatis mengaturnya menjadi tampilan yang rapi.
                            </div>

                            <div class="form-group mb-4">
                                <label class="fw-bold text-success">1. Visi Sekolah</label>
                                <textarea name="visi" class="form-control" rows="3" placeholder="Contoh: Terbentuknya lulusan yang berakhlak mulia..."><?= $halaman['visi'] ?? '' ?></textarea>
                            </div>

                            <div class="form-group mb-4">
                                <label class="fw-bold text-success">2. Misi Sekolah</label>
                                <small class="d-block text-muted mb-2">Tulis satu poin misi per baris (Tekan Enter untuk poin baru).</small>
                                <textarea name="misi" class="form-control" rows="8" placeholder="Menciptakan budaya religius...&#10;Mempersiapkan peserta didik..."><?= $halaman['misi'] ?? '' ?></textarea>
                            </div>

                            <div class="form-group mb-4">
                                <label class="fw-bold text-success">3. Tujuan Satuan Pendidikan</label>
                                <textarea name="tujuan" class="form-control" rows="6" placeholder="Tuliskan tujuan sekolah di sini..."><?= $halaman['tujuan'] ?? '' ?></textarea>
                            </div>

                        <?php else : ?>
                            <div class="form-group mb-4">
                                <label class="fw-bold">Isi Konten</label>
                                <textarea name="konten" class="form-control" rows="15"><?= $halaman['konten'] ?></textarea>
                            </div>
                        <?php endif; ?>

                        <div class="d-flex justify-content-between border-top pt-4 mt-4">
                            <a href="<?= base_url('profil/'.$halaman['slug']) ?>" class="btn btn-secondary px-4">
                                <i class="fa fa-arrow-left"></i> Batal
                            </a>
                            <button type="submit" class="btn btn-success btn-lg px-5 shadow">
                                <i class="fa fa-save"></i> SIMPAN PERUBAHAN
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    .card { border-radius: 15px; background: #fff; }
    .form-control:focus {
        border-color: #28a745;
        box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
    }
    label { color: #333; }
    .btn-success { background-color: #28a745; border: none; }
    .btn-success:hover { background-color: #218838; }
</style>

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