<?php require __DIR__ . '/../../layouts/header.php'; $lang=current_lang(); ?>
<?php
$t=fn($ar,$en)=>($lang==='ar'?$ar:$en);
$sub=$sub??[];
$files=$files??[];
$sid=(int)($sub['id']??0);
?>
<div class="container">

  <div class="d-flex justify-content-between align-items-center mb-3 flex-wrap gap-2">
    <div>
      <h4 class="mb-1"><i class="fa-solid fa-file-lines me-2"></i><?= e($t('تفاصيل التقديم','Submission Details')) ?> #<?= e((string)$sid) ?></h4>
      <div class="text-muted small"><?= e($t('الحالة','Status')) ?>: <span class="badge bg-secondary"><?= e((string)($sub['status']??'')) ?></span></div>
    </div>
    <div class="d-flex gap-2">
      <a class="btn btn-outline-secondary" href="<?= e(base_path('author/submissions')) ?>"><i class="fa-solid fa-arrow-right me-2"></i><?= e($t('رجوع','Back')) ?></a>
      <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>

  <div class="row g-3">
    <div class="col-lg-7">
      <div class="card border-0 shadow-sm mb-3">
        <div class="card-body">
          <div class="fw-bold mb-2"><?= e($t('العنوان','Title')) ?></div>
          <div class="mb-3"><?= e($lang==='ar'?(string)($sub['title_ar']??''):(string)($sub['title_en']??'')) ?></div>

          <div class="fw-bold mb-2"><?= e($t('الملخص','Abstract')) ?></div>
          <div class="text-muted"><?= $lang==='ar' ? (string)($sub['abstract_ar']??'') : (string)($sub['abstract_en']??'') ?></div>

          <hr>
          <div class="fw-bold mb-2"><?= e($t('الكلمات المفتاحية','Keywords')) ?></div>
          <div class="text-muted"><?= e($lang==='ar'?(string)($sub['keywords_ar']??''):(string)($sub['keywords_en']??'')) ?></div>
        </div>
      </div>

      <div class="card border-0 shadow-sm">
        <div class="card-body">
          <div class="d-flex justify-content-between align-items-center mb-2">
            <div class="fw-bold"><i class="fa-solid fa-paperclip me-2"></i><?= e($t('الملفات المرفوعة','Uploaded Files')) ?></div>
          </div>

          <?php if(!empty($files)): ?>
            <div class="list-group">
              <?php foreach($files as $f): ?>
                <a class="list-group-item list-group-item-action d-flex justify-content-between align-items-center"
                   target="_blank"
                   href="<?= e(base_path((string)($f['file_path']??''))) ?>">
                  <div class="d-flex flex-column">
                    <div class="fw-bold">
                      <i class="fa-solid fa-file-arrow-down me-2"></i><?= e((string)($f['original_name'] ?? $f['file_path'])) ?>
                    </div>
                    <div class="text-muted small">
                      <span class="badge bg-secondary"><?= e((string)($f['file_category']??'')) ?></span>
                      <?= !empty($f['created_at']) ? ' — '.e((string)$f['created_at']) : '' ?>
                    </div>
                  </div>
                  <i class="fa-solid fa-arrow-up-right-from-square"></i>
                </a>
              <?php endforeach; ?>
            </div>
          <?php else: ?>
            <div class="text-center text-muted py-4">
              <i class="fa-regular fa-folder-open fa-2x mb-2"></i>
              <div><?= e($t('لا توجد ملفات مرتبطة بهذا التقديم بعد.','No files are attached yet.')) ?></div>
            </div>
          <?php endif; ?>

          <hr>
          <div class="text-muted small">
            <?= e($t('ملاحظة: إذا تعذر ظهور الملف من قاعدة البيانات، سيتم عرضه تلقائيًا من مجلد الرفع.','Note: If DB missing, files are shown from upload folder automatically.')) ?>
          </div>
        </div>
      </div>
    </div>

    <div class="col-lg-5">
      <div class="card border-0 shadow-sm">
        <div class="card-body">
          <div class="fw-bold mb-2"><i class="fa-solid fa-circle-info me-2"></i><?= e($t('معلومات','Info')) ?></div>
          <div class="text-muted small"><?= e($t('رقم التقديم','Submission ID')) ?>: <span class="fw-bold"><?= e((string)$sid) ?></span></div>
          <div class="text-muted small mt-2"><?= e($t('اللغة','Language')) ?>: <?= e($lang) ?></div>
        </div>
      </div>
    </div>
  </div>

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