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

<div class="container py-3">

  <div class="card border-0 shadow-sm mb-3">
    <div class="card-body p-4">
      <div class="d-flex justify-content-between align-items-center flex-wrap gap-2">
        <div>
          <h3 class="mb-1"><i class="fa-solid fa-graduation-cap"></i> <?= e($t('بوابة المؤتمرات','Conference Portal')) ?></h3>
          <div class="text-muted"><?= e($t('نظام إدارة مؤتمرات متعدد اللغات (عربي/إنجليزي).','A bilingual (AR/EN) multi-conference management portal.')) ?></div>
        </div>
        <div class="d-flex gap-2">
          <a class="btn btn-outline-secondary" href="<?= e(base_path('login')) ?>"><i class="fa-solid fa-right-to-bracket"></i> <?= e($t('تسجيل الدخول','Login')) ?></a>
          <a class="btn btn-primary" href="<?= e(base_path('register')) ?>"><i class="fa-solid fa-user-plus"></i> <?= e($t('إنشاء حساب','Register')) ?></a>
        </div>
      </div>
    </div>
  </div>

  <div class="d-flex justify-content-between align-items-center mb-2">
    <h5 class="mb-0"><i class="fa-solid fa-calendar-days"></i> <?= e($t('المؤتمرات المتاحة','Available Conferences')) ?></h5>
  </div>

  <div class="row g-3">
    <?php foreach($confs as $c): ?>
      <div class="col-md-6 col-lg-4">
        <div class="card border-0 shadow-sm h-100">
          <div class="card-body">
            <div class="fw-bold mb-1"><?= e((string)($c['title_ar'] ?? $c['name_ar'] ?? $c['name'] ?? $c['title'] ?? 'Conference')) ?></div>
            <div class="text-muted small mb-2"><?= e((string)($c['title_en'] ?? $c['name_en'] ?? '')) ?></div>

            <?php if(!empty($c['start_date']) || !empty($c['end_date'])): ?>
              <div class="text-muted small mb-2">
                <i class="fa-regular fa-clock"></i>
                <?= e((string)($c['start_date'] ?? '')) ?> <?= e($t('إلى','to')) ?> <?= e((string)($c['end_date'] ?? '')) ?>
              </div>
            <?php endif; ?>

            <div class="d-flex gap-2">
              <a class="btn btn-sm btn-outline-primary" href="<?= e(base_path('conference?id='.(int)$c['id'])) ?>">
                <i class="fa-solid fa-eye"></i> <?= e($t('عرض','View')) ?>
              </a>
              <a class="btn btn-sm btn-primary" href="<?= e(base_path('submit')) ?>">
                <i class="fa-solid fa-paper-plane"></i> <?= e($t('تقديم بحث','Submit')) ?>
              </a>
            </div>
          </div>
        </div>
      </div>
    <?php endforeach; ?>

    <?php if(empty($confs)): ?>
      <div class="col-12">
        <div class="card border-0 shadow-sm">
          <div class="card-body text-center text-muted py-5">
            <i class="fa-regular fa-folder-open fa-2x mb-2"></i>
            <div><?= e($t('لا توجد مؤتمرات مفعّلة حاليًا.','No active conferences yet.')) ?></div>
          </div>
        </div>
      </div>
    <?php endif; ?>
  </div>

</div>

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