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

<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <h1 class="fw-bold mb-0"><?= e(trans('submission_review_overview')) ?></h1>
        <div class="text-muted"><?= e((string) $submission['submission_no']) ?> — <?= e((string) $submission['title']) ?></div>
    </div>
    <a href="<?= e(base_path('submissions')) ?>" class="btn btn-outline-secondary rounded-3"><?= e(trans('back')) ?></a>
</div>

<div class="card border-0 shadow-sm rounded-4 mb-4">
    <div class="card-body">
        <div class="mb-2"><strong><?= e(trans('conference')) ?>:</strong> <?= e(current_lang() === 'ar' ? (string) $submission['title_ar'] : (string) $submission['title_en']) ?></div>
        <div class="mb-2"><strong><?= e(trans('tracks')) ?>:</strong> <?= e(current_lang() === 'ar' ? (string) $submission['name_ar'] : (string) $submission['name_en']) ?></div>
        <div class="mb-0"><strong><?= e(trans('status')) ?>:</strong> <?= e((string) $submission['status']) ?></div>
    </div>
</div>

<div class="card border-0 shadow-sm rounded-4 mb-4">
    <div class="card-body">
        <h3 class="h5 fw-bold mb-3"><?= e(trans('authors')) ?></h3>
        <?php if (!empty($authors)): ?>
            <ul class="mb-0">
                <?php foreach ($authors as $a): ?>
                    <li><?= e((string) $a['full_name']) ?><?= !empty($a['email']) ? ' - ' . e((string) $a['email']) : '' ?></li>
                <?php endforeach; ?>
            </ul>
        <?php else: ?>
            <div class="alert alert-info rounded-4 mb-0"><?= e(trans('no_data')) ?></div>
        <?php endif; ?>
    </div>
</div>

<div class="card border-0 shadow-sm rounded-4">
    <div class="table-responsive">
        <table class="table align-middle mb-0">
            <thead class="table-light">
                <tr>
                    <th>#</th>
                    <th><?= e(trans('reviewer_user')) ?></th>
                    <th><?= e(trans('assignment_status')) ?></th>
                    <th><?= e(trans('due_date')) ?></th>
                    <th><?= e(trans('overall_score')) ?></th>
                    <th><?= e(trans('recommendation')) ?></th>
                    <th><?= e(trans('comments_to_author')) ?></th>
                    <th><?= e(trans('comments_to_editor')) ?></th>
                </tr>
            </thead>
            <tbody>
                <?php if (!empty($assignments)): ?>
                    <?php foreach ($assignments as $row): ?>
                        <tr>
                            <td><?= e((string) $row['id']) ?></td>
                            <td><?= e(trim((string) $row['first_name'] . ' ' . (string) $row['last_name'])) ?></td>
                            <td><span class="badge bg-primary"><?= e((string) $row['status']) ?></span></td>
                            <td><?= e((string) ($row['due_date'] ?? '')) ?></td>
                            <td><?= e((string) ($row['overall_score'] ?? '')) ?></td>
                            <td><?= e((string) ($row['recommendation'] ?? '')) ?></td>
                            <td><?= e((string) ($row['comments_to_author'] ?? '')) ?></td>
                            <td><?= e((string) ($row['comments_to_editor'] ?? '')) ?></td>
                        </tr>
                    <?php endforeach; ?>
                <?php else: ?>
                    <tr><td colspan="8" class="text-center py-4"><?= e(trans('no_data')) ?></td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>

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