<?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">
  <div class="d-flex justify-content-between align-items-center mb-3">
    <h4 class="mb-0"><i class="fa-solid fa-calendar-days"></i> <?= e($t('المؤتمرات','Conferences')) ?></h4>
    <a class="btn btn-primary" href="<?= e(base_path('admin/conferences/create')) ?>">
      <i class="fa-solid fa-plus"></i> <?= e($t('إضافة','Add')) ?>
    </a>
  </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('العنوان','Title')) ?></th><th><?= e($t('الحالة','Status')) ?></th><th><?= e($t('إجراءات','Actions')) ?></th>
          </tr>
        </thead>
        <tbody>
          <?php foreach($rows as $r): ?>
            <tr>
              <td class="text-muted"><?= e((string)$r['id']) ?></td>
              <td><?= e((string)($lang==='ar'?($r['title_ar']??''):($r['title_en']??''))) ?></td>
              <td><?= ((int)($r['is_active']??1)===1) ? '<span class="badge bg-success">ON</span>' : '<span class="badge bg-danger">OFF</span>' ?></td>
              <td class="d-flex gap-2">
                <a class="btn btn-sm btn-outline-primary" href="<?= e(base_path('admin/conferences/edit?id='.(int)$r['id'])) ?>">
                  <i class="fa-solid fa-pen-to-square"></i> <?= e($t('تعديل','Edit')) ?>
                </a>
                <a class="btn btn-sm btn-outline-warning" href="<?= e(base_path('admin/conferences/toggle?id='.(int)$r['id'])) ?>">
                  <i class="fa-solid fa-toggle-on"></i> <?= e($t('تبديل','Toggle')) ?>
                </a>
              </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'; ?>
