<?php require BASE_PATH . '/app/Views/layouts/header.php'; ?>

<section class="berita-detail-page">
  <div class="container">
    <div class="berita-detail-layout">
      <article class="berita-detail">
        <h1><?= htmlspecialchars($halaman['judul']) ?></h1>

        <?php if (!empty($halaman['gambar'])): ?>
          <div class="berita-thumbnail">
            <img src="<?= APP_URL . '/uploads/halaman/' . htmlspecialchars($halaman['gambar']) ?>" alt="<?= htmlspecialchars($halaman['judul']) ?>">
          </div>
        <?php endif; ?>

        <div class="berita-content">
          <?= $halaman['konten'] ?? '' /* konten HTML dari TinyMCE, hanya diisi admin terpercaya */ ?>
        </div>
      </article>

      <aside class="sidebar">
        <?php foreach ($widgetSidebar as $widget): ?>
          <div class="widget-box">
            <?php if (!empty($widget['judul'])): ?><h4><?= htmlspecialchars($widget['judul']) ?></h4><?php endif; ?>
            <?php if ($widget['tipe'] === 'gambar' && !empty($widget['gambar'])): ?>
              <img src="<?= APP_URL . '/uploads/widget/' . htmlspecialchars($widget['gambar']) ?>" alt="<?= htmlspecialchars($widget['judul'] ?? '') ?>" style="border-radius:8px;margin-bottom:10px;">
            <?php elseif ($widget['tipe'] === 'html'): ?>
              <?= $widget['konten'] ?? '' ?>
            <?php else: ?>
              <p><?= htmlspecialchars($widget['konten'] ?? '') ?></p>
            <?php endif; ?>
            <?php if (!empty($widget['url'])): ?>
              <a href="<?= htmlspecialchars($widget['url']) ?>" class="btn" style="margin-top:12px;">Selengkapnya</a>
            <?php endif; ?>
          </div>
        <?php endforeach; ?>
      </aside>
    </div>
  </div>
</section>

<?php require BASE_PATH . '/app/Views/layouts/footer.php'; ?>
