<?php include('../header.php'); ?>
<?php include('../menu.php'); ?>
<link rel="stylesheet" href="../css/style.css?v=1">

<main class="main-container">
  <section class="admin-card comment-archive">
    <h2 class="text-warning">💬 All Listener Comments</h2>
    <?php
      $comments_file = __DIR__ . '/../data/comments.json';
      $comments = file_exists($comments_file) ? json_decode(file_get_contents($comments_file), true) : [];
    ?>
    <?php if (!empty($comments)): ?>
      <div class="comments-grid">
        <?php foreach ($comments as $comment): ?>
          <div class="comment-card mb-3">
            <h4><?= htmlspecialchars($comment['name']) ?></h4>
            <p><?= nl2br(htmlspecialchars($comment['message'])) ?></p>
            <em class="text-muted">(<?= htmlspecialchars($comment['timestamp']) ?>)</em>
            <?php if (!empty($comment['reply'])): ?>
              <p class="reply"><strong>Reply:</strong> <?= htmlspecialchars($comment['reply']) ?></p>
            <?php endif; ?>
          </div>
        <?php endforeach; ?>
      </div>
    <?php else: ?>
      <div class="comment-card">
        <p>No listener comments yet. The mountain is quiet…</p>
      </div>
    <?php endif; ?>
  </section>
</main>

<?php include('../footer.php'); ?>
