<!-- HEADER -->
<div class="none-header">
  <div class="left" onclick="window.location.href='?page=home'">
    <i class="fas fa-chevron-left"></i> Promosi
  </div>

  <div class="right">
      <a href="javascript:void(0)" onclick="openLiveChat()" class="button-nav">
      <i class="fas fa-headset m-auto"></i>
    </a>
  </div>
</div>

<main id="main-route" class="casino-promo">
  
  <!-- PROMO TOP BANNER -->
<div class="promo-top">
  <h1>Promosi</h1>
  <p>Nikmati promosi menarik dari berbagai macam kategori game.</p>
  </div>
</div>
<div class="promo-wrapper">
    
  <!-- LIST PROMO -->
<div class="promo-grid">
<?php
$query = mysqli_query($koneksi, "SELECT * FROM tb_promosi");
while ($data = mysqli_fetch_array($query)) {
  $id = $data['id'];
?>
  <div class="promo-card">

    <div class="promo-header" onclick="togglePromo(<?= $id ?>)">
      <img src="../uploads/fotopromosi/<?= $data['gambar']; ?>" alt="<?= htmlspecialchars($data['judul']); ?>">

      <div class="promo-header-content">
        <h3><?= $data['judul']; ?></h3>
        <span class="promo-toggle">
          Detail <i class="fas fa-chevron-down"></i>
        </span>
      </div>
    </div>

    <!-- DETAIL -->
    <div class="promo-detail-accordion" id="promo-<?= $id ?>">
      <div class="promo-detail-body">
        <?= $data['text']; ?>
      </div>
    </div>
  </div>
<?php } ?>
</div>

  </div>
<div style="height:100px"></div>
</main>

<script>
document.addEventListener("DOMContentLoaded", function () {
    filterPromoSelection('all');
});
</script>


<link rel="stylesheet" type="text/css" href="luxury-them/custom/css/promosi.css?v=2.6.0.0">
<script>
function togglePromo(id) {
  const target = document.getElementById('promo-' + id);

  document.querySelectorAll('.promo-detail-accordion').forEach(el => {
    if (el !== target) el.classList.remove('active');
  });

  target.classList.toggle('active');

  if (target.classList.contains('active')) {
    setTimeout(() => {
      target.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
    }, 150);
  }
}
</script>