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

<?= $this->section('content') ?>
<div class="container pt-100 pb-100">
    <div class="row justify-content-center">
        <div class="col-lg-10">
            <div class="card shadow border-0">
                <div class="card-header bg-success text-white">
                    <h4 class="mb-0"><i class="fa fa-plus-circle"></i> Tambah Berita Baru</h4>
                </div>
                <div class="card-body p-4">
                    <form action="<?= base_url('admin/berita/simpan') ?>" method="post" enctype="multipart/form-data">
                        <?= csrf_field() ?>

                        <div class="form-group mb-3">
                            <label class="fw-bold">Judul Berita</label>
                            <input type="text" name="judul" class="form-control" placeholder="Masukkan judul berita..." required>
                        </div>

                        <div class="row">
                    
                            <div class="col-md-6 mb-3">
        <label class="fw-bold text-success">Keterangan Foto (Caption)</label>
        <input type="text" name="caption_foto" class="form-control" placeholder="Contoh: Siswa sedang praktik di Lab DKV">
    </div>
                        
                            <div class="col-md-6 mb-3">
                                <label class="fw-bold">Status Penerbitan</label>
                                <select name="status" class="form-control">
                                    <option value="publish">Langsung Terbitkan</option>
                                    <option value="draft">Simpan sebagai Draft</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group mb-3">
                            <label class="fw-bold">Ringkasan (Muncul di Halaman Depan)</label>
                            <textarea name="ringkasan" class="form-control" rows="3" placeholder="Tuliskan 1-2 kalimat pengantar berita..." required></textarea>
                        </div>

                        <div class="form-group mb-3">
                            <label class="fw-bold">Isi Berita Lengkap</label>
                            <textarea id="summernote" name="isi_berita" class="form-control" required></textarea>
                        </div>
                        <div class="col-md-6 mb-3">
    <label class="fw-bold text-success">Upload Foto Kegiatan (Bisa pilih banyak)</label>
    <input type="file" name="gambar[]" class="form-control" accept="image/*" multiple required>
    <small class="text-danger fw-bold">* Pilih 3-4 foto sekaligus, sistem akan otomatis membuat kolase.</small>
</div>

                        <div class="mt-4 border-top pt-3">
                            <button type="submit" class="btn btn-success btn-lg px-5 shadow-sm">
                                <i class="fa fa-paper-plane"></i> TERBITKAN BERITA
                            </button>
                            <a href="<?= base_url('admin/berita') ?>" class="btn btn-secondary btn-lg px-4">BATAL</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.js"></script>

<script>
    $(document).ready(function() {
        $('#summernote').summernote({
            placeholder: 'Tuliskan detail berita di sini...',
            tabsize: 2,
            height: 300,
            toolbar: [
                ['style', ['style']],
                ['font', ['bold', 'underline', 'clear']],
                ['color', ['color']],
                ['para', ['ul', 'ol', 'paragraph']],
                ['table', ['table']],
                ['insert', ['link', 'picture', 'video']],
                ['view', ['fullscreen', 'codeview', 'help']]
            ]
        });
    });
</script>
<?= $this->endSection() ?>