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

<?= $this->section('content') ?>
<div class="breadcrumb-area pt-50 pb-50 bg-gray">
    <div class="container text-center">
        <h2>Berita & Kegiatan</h2>
        
        <?php if (session()->get('isLoggedIn')) : ?>
            <div class="mt-4">
                <a href="<?= base_url('admin/berita') ?>" class="btn btn-warning shadow-sm">
                    <i class="fa fa-tasks"></i> Kelola Semua Berita
                </a>
                <a href="<?= base_url('admin/berita/tambah') ?>" class="btn btn-success shadow-sm">
                    <i class="fa fa-plus"></i> Tambah Berita Baru
                </a>
            </div>
        <?php endif; ?>
        
    </div>
</div>

<div class="blog-area pt-100 pb-100">
    <div class="container">
        <div class="row">
            <?php foreach ($berita as $b) : ?>
            <div class="col-lg-4 col-md-6 mb-4">
                <div class="card h-100 shadow-sm border-0">
                    <img src="<?= base_url('assets/img/berita/' . $b['gambar']) ?>" class="card-img-top" style="height: 200px; object-fit: cover;">
                    <div class="card-body">
                        <h5 class="fw-bold"><?= $b['judul'] ?></h5>
                        <p class="text-muted small"><?= strip_tags(character_limiter($b['ringkasan'], 100)) ?></p>
                        <a href="<?= base_url('berita/' . $b['slug']) ?>" class="btn btn-success btn-sm">Baca Selengkapnya</a>
                    </div>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</div>
<?= $this->endSection() ?>