<?php require __DIR__ . '/../../layouts/header.php'; $lang=current_lang(); ?>
<?php $t=fn($ar,$en)=>($lang==='ar'?$ar:$en); $rows=$rows??[]; ?>

<div class="container py-3">
  <h4 class="mb-3"><i class="fa-solid fa-envelope"></i> <?= e($t('طابور البريد','Email Queue')) ?></h4>

  <div class="card border-0 shadow-sm">
    <div class="table-responsive">
      <table class="table table-hover mb-0">
        <thead class="table-light">
          <tr>
            <th>#</th>
            <th><?= e($t('إلى','To')) ?></th>
            <th><?= e($t('العنوان','Subject')) ?></th>
            <th><?= e($t('الحالة','Status')) ?></th>
            <th><?= e($t('تاريخ الإضافة','Created')) ?></th>
          </tr>
        </thead>
        <tbody>
          <?php foreach($rows as $r): ?>
            <tr>
              <td class="text-muted"><?= e((string)$r['id']) ?></td>
              <td><?= e((string)$r['to_email']) ?></td>
              <td><?= e((string)$r['subject_line']) ?></td>
              <td><span class="badge bg-secondary"><?= e((string)$r['status']) ?></span></td>
              <td class="text-muted"><?= e((string)$r['created_at']) ?></td>
            </tr>
          <?php endforeach; ?>
          <?php if(empty($rows)): ?><tr><td colspan="5" class="text-center text-muted py-4">—</td></tr><?php endif; ?>
        </tbody>
      </table>
    </div>
  </div>
</div>

<?php require __DIR__ . '/../../layouts/footer.php'; ?>
