</div><!-- /admin-content -->
  </div><!-- /admin-main -->
</div><!-- /admin-wrapper -->

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="<?= BASE_URL ?>/assets/js/admin.js"></script>
<script>
function toggleSidebar() {
  document.getElementById('adminSidebar').classList.toggle('open');
}
</script>

<script>
// Auto-update badge chat unread setiap 30 detik
(function pollChatBadge() {
  fetch('<?= BASE_URL ?>/chat_api.php?action=unread')
    .then(r => r.json())
    .then(res => {
      if (!res.ok) return;
      const badge = document.getElementById('chatBadge');
      const menu  = document.getElementById('menuChat');
      if (!menu) return;
      if (res.total > 0) {
        if (badge) { badge.textContent = res.total; }
        else {
          const s = document.createElement('span');
          s.id = 'chatBadge'; s.className = 'sidebar-badge';
          s.textContent = res.total;
          menu.appendChild(s);
        }
      } else {
        if (badge) badge.remove();
      }
    })
    .catch(() => {});
  setTimeout(pollChatBadge, 30000);
})();
</script>

</body>
</html>