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

<section class="page-hero">
  <div class="container">
    <span class="eyebrow">Agenda</span>
    <h1>Agenda &amp; Kegiatan Fakultas</h1>
  </div>
</section>

<section class="agenda-page">
  <div class="container">
    <?php if (empty($daftarAgenda)): ?>
      <p style="color:var(--text-muted); text-align:center; padding:40px 0;">Belum ada agenda yang dijadwalkan.</p>
    <?php else: ?>
      <div class="agenda-list-page">
        <?php
          $namaBulanSingkat = [1=>'Jan',2=>'Feb',3=>'Mar',4=>'Apr',5=>'Mei',6=>'Jun',7=>'Jul',8=>'Agu',9=>'Sep',10=>'Okt',11=>'Nov',12=>'Des'];
        ?>
        <?php foreach ($daftarAgenda as $item): ?>
          <?php
            $sudahLewat = strtotime($item['tanggal_mulai']) < time();
            $bulanIdx = (int) date('n', strtotime($item['tanggal_mulai']));
          ?>
          <div class="agenda-card <?= $sudahLewat ? 'lewat' : '' ?>">
            <div class="date-block">
              <div class="day"><?= date('d', strtotime($item['tanggal_mulai'])) ?></div>
              <div class="month"><?= $namaBulanSingkat[$bulanIdx] ?> <?= date('Y', strtotime($item['tanggal_mulai'])) ?></div>
            </div>

            <div class="info">
              <h3><?= htmlspecialchars($item['judul']) ?></h3>
              <div class="meta">
                <span>🕐 <?= date('H:i', strtotime($item['tanggal_mulai'])) ?> WIB<?= $item['tanggal_selesai'] ? ' &ndash; ' . date('H:i', strtotime($item['tanggal_selesai'])) . ' WIB' : '' ?></span>
                <?php if (!empty($item['lokasi'])): ?><span>📍 <?= htmlspecialchars($item['lokasi']) ?></span><?php endif; ?>
                <?php if ($sudahLewat): ?><span>Selesai</span><?php else: ?><span style="color:var(--blue-light);">Akan Datang</span><?php endif; ?>
              </div>
              <?php if (!empty($item['deskripsi'])): ?>
                <p><?= htmlspecialchars($item['deskripsi']) ?></p>
              <?php endif; ?>
            </div>

            <?php if (!empty($item['gambar'])): ?>
              <div class="thumb">
                <img src="<?= APP_URL . '/uploads/agenda/' . htmlspecialchars($item['gambar']) ?>" alt="<?= htmlspecialchars($item['judul']) ?>">
              </div>
            <?php endif; ?>
          </div>
        <?php endforeach; ?>
      </div>
    <?php endif; ?>
  </div>
</section>

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