<?php require __DIR__ . '/../../layouts/header.php'; $lang=current_lang(); ?>
<?php $t=fn($ar,$en)=>($lang==='ar'?$ar:$en); $rows=$rows??[]; ?>
<div class="container">
  <div class="d-flex justify-content-between align-items-center mb-3">
    <h4 class="mb-0"><i class="fa-solid fa-file-lines me-2"></i><?= e($t('تقديماتي','My Submissions')) ?></h4>
    <a class="btn btn-primary" href="<?= e(base_path('submit')) ?>"><i class="fa-solid fa-plus me-2"></i><?= e($t('تقديم جديد','New Submission')) ?></a>
  </div>

  <div class="card border-0 shadow-sm">
    <div class="card-body">
      <div class="table-responsive">
        <table class="table align-middle">
          <thead><tr><th>#</th><th><?= e($t('العنوان','Title')) ?></th><th><?= e($t('الحالة','Status')) ?></th><th><?= e($t('تاريخ','Date')) ?></th><th></th></tr></thead>
          <tbody>
            <?php foreach($rows as $r): ?>
              <tr>
                <td><?= e((string)$r['id']) ?></td>
                <td class="fw-bold"><?= e($lang==='ar'?(string)($r['title_ar']??''):(string)($r['title_en']??'')) ?></td>
                <td><span class="badge bg-secondary"><?= e((string)($r['status']??'')) ?></span></td>
                <td class="text-muted"><?= e((string)($r['created_at']??'')) ?></td>
                <td><a class="btn btn-sm btn-outline-primary" href="<?= e(base_path('author/submissions/view?id='.(int)$r['id'])) ?>"><?= e($t('فتح','Open')) ?></a></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>
</div>
<?php require __DIR__ . '/../../layouts/footer.php'; ?>
