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

<div class="container py-3">
  <div class="d-flex justify-content-between align-items-center mb-3">
    <h4 class="mb-0"><i class="fa-solid fa-gears"></i> <?= e($t('المهام','Jobs')) ?></h4>
    <span class="badge bg-secondary"><?= e($t('الجدول','Table')) ?>: <?= e($table) ?></span>
  </div>

  <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('النوع/المفتاح','Type/Key')) ?></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['type'] ?? $r['job_key'] ?? $r['name'] ?? $r['action'] ?? '—')) ?></td>
            <td><span class="badge bg-secondary"><?= e((string)($r['status'] ?? $r['state'] ?? $r['run_status'] ?? '—')) ?></span></td>
            <td class="text-muted"><?= e((string)($r['created_at'] ?? $r['queued_at'] ?? $r['created'] ?? '')) ?></td>
          </tr>
        <?php endforeach; ?>
        <?php if(empty($rows)): ?><tr><td colspan="4" class="text-center text-muted py-4">—</td></tr><?php endif; ?>
        </tbody>
      </table>
    </div>
  </div>
</div>

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