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

<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <h1 class="page-title"><?= e((string) ($submission['title'] ?? '')) ?></h1>
        <div class="text-muted"><?= e((string) ($submission['submission_no'] ?? '')) ?></div>
    </div>
    <div class="d-flex gap-2">
        <a href="<?= e(base_path('submissions')) ?>" class="btn btn-outline-secondary rounded-3"><?= e(trans('back')) ?></a>
        <?php if (!empty($submission['id'])): ?>
            <a href="<?= e(base_path('submissions/edit?id=' . (int) $submission['id'])) ?>" class="btn btn-outline-primary rounded-3"><?= e(trans('edit')) ?></a>
        <?php endif; ?>
    </div>
</div>

<div class="row g-4">
    <div class="col-lg-8">
        <div class="card border-0 shadow-sm rounded-4">
            <div class="card-body p-4">
                <div class="section-title">
                    <span class="dot"></span>
                    <h2 class="h5 mb-0"><?= e(trans('submission_summary')) ?></h2>
                </div>

                <div class="mb-3"><strong><?= e(trans('title_en')) ?>:</strong> <?= e((string) ($submission['title'] ?? '')) ?></div>
                <div class="mb-3"><strong><?= e(trans('title_ar')) ?>:</strong> <?= e((string) ($submission['title_ar'] ?? '')) ?></div>
                <div class="mb-3"><strong><?= e(trans('status')) ?>:</strong> <span class="badge bg-primary"><?= e((string) ($submission['status'] ?? '')) ?></span></div>
                <div class="mb-3"><strong><?= e(trans('keywords_en')) ?>:</strong> <?= e((string) ($submission['keywords'] ?? '')) ?></div>
                <div class="mb-3"><strong><?= e(trans('keywords_ar')) ?>:</strong> <?= e((string) ($submission['keywords_ar'] ?? '')) ?></div>

                <hr>

                <div class="mb-3">
                    <strong><?= e(trans('abstract_en')) ?>:</strong>
                    <div class="mt-2"><?= (string) ($submission['abstract'] ?? '') ?></div>
                </div>

                <div class="mb-3">
                    <strong><?= e(trans('abstract_ar')) ?>:</strong>
                    <div class="mt-2"><?= (string) ($submission['abstract_ar'] ?? '') ?></div>
                </div>
            </div>
        </div>

        <?php if (!empty($files ?? [])): ?>
        <div class="card border-0 shadow-sm rounded-4 mt-4">
            <div class="card-body p-4">
                <div class="section-title">
                    <span class="dot"></span>
                    <h2 class="h5 mb-0"><?= e(trans('uploaded_files')) ?></h2>
                </div>

                <div class="table-responsive">
                    <table class="table align-middle mb-0">
                        <thead>
                            <tr>
                                <th><?= e(trans('file_category')) ?></th>
                                <th><?= e(trans('submission_files')) ?></th>
                                <th>Date</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($files as $f): ?>
                                <tr>
                                    <td><span class="badge bg-primary"><?= e((string) ($f['file_category'] ?? '')) ?></span></td>
                                    <td><?= e((string) ($f['original_filename'] ?? '')) ?></td>
                                    <td><?= e((string) ($f['created_at'] ?? '')) ?></td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>

            </div>
        </div>
        <?php endif; ?>
    </div>

    <div class="col-lg-4">
        <div class="card border-0 shadow-sm rounded-4">
            <div class="card-body p-4">
                <div class="section-title">
                    <span class="dot"></span>
                    <h2 class="h5 mb-0"><?= e(trans('authors')) ?></h2>
                </div>

                <?php if (!empty($authors ?? [])): ?>
                    <?php foreach ($authors as $a): ?>
                        <div class="soft-panel mb-3">
                            <div class="fw-bold"><?= e((string) ($a['full_name'] ?? '')) ?></div>
                            <div class="small text-muted"><?= e((string) ($a['email'] ?? '')) ?></div>
                            <div class="small text-muted"><?= e((string) ($a['affiliation'] ?? '')) ?></div>
                        </div>
                    <?php endforeach; ?>
                <?php else: ?>
                    <div class="empty-state">
                        <i class="fa-solid fa-users"></i>
                        <div><?= e(trans('no_data')) ?></div>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>

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