<?php require __DIR__ . '/../../layouts/header.php'; $lang = current_lang(); ?>

<div class="row g-3 mb-3">
  <?php
    $cards = [
      ['k'=>'submissions','i'=>'fa-solid fa-file-lines','ar'=>'إجمالي التقديمات','en'=>'Submissions'],
      ['k'=>'reviewers','i'=>'fa-solid fa-user-check','ar'=>'المحكمون','en'=>'Reviewers'],
      ['k'=>'accepted','i'=>'fa-solid fa-circle-check','ar'=>'المقبول','en'=>'Accepted'],
    ];
  ?>
  <?php foreach ($cards as $c): ?>
    <div class="col-md-4">
      <div class="card shadow-sm border-0">
        <div class="card-body">
          <div class="fw-bold"><i class="<?= e($c['i']) ?> me-2"></i><?= e($lang==='ar'?$c['ar']:$c['en']) ?></div>
          <div style="font-size:32px;font-weight:900;color:#0b2a6f"><?= e((string)($stats[$c['k']]??0)) ?></div>
        </div>
      </div>
    </div>
  <?php endforeach; ?>
</div>

<?php if (!empty($featured)): ?>
  <?php
    $title = ($lang==='ar') ? (string)($featured['title_ar'] ?? '') : (string)($featured['title_en'] ?? '');
    $logo = !empty($featured['logo_path']) ? base_path('storage/'.$featured['logo_path']) : '';
  ?>
  <div class="card shadow-sm border-0 mb-3" style="background:linear-gradient(135deg,#0b2a6f,#1146b3);color:#fff">
    <div class="card-body">
      <div class="d-flex gap-3 align-items-center flex-wrap">
        <?php if ($logo): ?><img src="<?= e($logo) ?>" style="max-height:70px;max-width:160px;object-fit:contain;background:#fff;border-radius:12px;padding:6px"><?php endif; ?>
        <div class="flex-grow-1">
          <div style="font-size:22px;font-weight:900"><?= e($title) ?></div>
          <div class="small" style="opacity:.9"><?= e((string)($featured['start_date']??'')) ?> → <?= e((string)($featured['end_date']??'')) ?></div>
        </div>
        <div class="d-flex gap-2 flex-wrap">
          <a class="btn btn-light btn-rounded" href="<?= e(base_path('conference/home?id='.(int)$featured['id'])) ?>"><i class="fa-solid fa-house me-2"></i><?= e($lang==='ar'?'صفحة المؤتمر':'Conference Home') ?></a>
          <a class="btn btn-outline-light btn-rounded" href="<?= e(base_path('schedule?conference_id='.(int)$featured['id'])) ?>"><i class="fa-solid fa-calendar-days me-2"></i><?= e($lang==='ar'?'الجدول':'Schedule') ?></a>
        </div>
      </div>
    </div>
  </div>
<?php endif; ?>

<div class="card shadow-sm border-0">
  <div class="card-body">
    <div class="fw-bold mb-2"><i class="fa-solid fa-list me-2"></i><?= e($lang==='ar'?'المؤتمرات':'Conferences') ?></div>
    <div class="table-responsive">
      <table class="table table-hover align-middle mb-0">
        <thead><tr><th>#</th><th><?= e($lang==='ar'?'الاسم':'Title') ?></th><th><?= e($lang==='ar'?'المدة':'Dates') ?></th><th><?= e($lang==='ar'?'الموقع':'Location') ?></th><th></th></tr></thead>
        <tbody>
          <?php foreach (($conferences ?? []) as $c): ?>
            <?php $t = ($lang==='ar') ? (string)($c['title_ar']??'') : (string)($c['title_en']??''); ?>
            <tr>
              <td><?= e((string)$c['id']) ?></td>
              <td class="fw-bold"><?= e($t) ?></td>
              <td class="text-muted small"><?= e((string)($c['start_date']??'')) ?> → <?= e((string)($c['end_date']??'')) ?></td>
              <td class="text-muted small"><?= e((string)($c['location']??'')) ?></td>
              <td class="text-end">
                <a class="btn btn-sm btn-outline-primary btn-rounded" href="<?= e(base_path('conference/home?id='.(int)$c['id'])) ?>"><i class="fa-solid fa-eye me-2"></i><?= e($lang==='ar'?'عرض':'View') ?></a>
              </td>
            </tr>
          <?php endforeach; ?>
          <?php if (empty($conferences ?? [])): ?><tr><td colspan="5" class="text-center text-muted py-4"><?= e(trans('no_data')) ?></td></tr><?php endif; ?>
        </tbody>
      </table>
    </div>
  </div>
</div>

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