<?php
function ms_h($v) {
    return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8');
}
$submissions = $submissions ?? [];
?>

<div class="container ec-author-dashboard-responsive py-4">

    <div class="card border-0 shadow-sm mb-4" style="border-radius:24px;background:linear-gradient(135deg,#0f172a,#1d4ed8);color:#fff;">
        <div class="card-body p-4">
            <h3 class="fw-bold mb-1"><?php echo ec_h(ec_t('author.dashboard.my_submissions','My Submissions')); ?></h3>
            <div class="opacity-75">Track submissions, workflow stage, files, activity, revision, and camera-ready actions.</div>
        </div>
    </div>

    <div class="card border-0 shadow-sm" style="border-radius:22px;">
        <div class="card-body p-4">

            <div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3">
                <h5 class="fw-bold mb-0">Submission List</h5>
                <a class="btn btn-success rounded-pill" href="/easychair/author/submit"><?php echo ec_h(ec_t('submission.new_submission','New Submission')); ?></a>
            </div>

            <div class="table-responsive">
                <table class="table table-bordered align-middle">
                    <thead class="table-dark">
                        <tr>
                            <th>Submission</th>
                            <th><?php echo ec_h(ec_t('submission.status','Status')); ?></th>
                            <th>Production</th>
                            <th>Files</th>
                            <th>Activity</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($submissions as $s): ?>
                        <tr>
                            <td>
                                <strong><?= ms_h($s['submission_no'] ?? ('#'.$s['id'])) ?></strong>
                                <div class="text-muted small"><?= ms_h($s['display_title']) ?></div>
                                <div class="text-muted small"><?= ms_h($s['created_at'] ?? '') ?></div>
                            </td>
                            <td>
                                <span class="badge bg-primary"><?= ms_h($s['status'] ?? '') ?></span>
                                <span class="badge bg-warning text-dark"><?= ms_h($s['stage'] ?? '') ?></span>
                            </td>
                            <td>
                                <span class="badge bg-info text-dark"><?= ms_h($s['production_status'] ?? 'pending') ?></span>
                            </td>
                            <td><?= (int)$s['files_count'] ?></td>
                            <td><?= (int)$s['activity_count'] ?></td>
                            <td>
                                <a class="btn btn-sm btn-primary rounded-pill" href="/easychair/author/workflow?submission_id=<?= (int)$s['id'] ?>">
                                    Workflow
                                </a>
                            </td>
                        </tr>
                    <?php endforeach; ?>

                    <?php if (!$submissions): ?>
                        <tr>
                            <td colspan="6" class="text-center text-muted py-4">No submissions yet.</td>
                        </tr>
                    <?php endif; ?>
                    </tbody>
                </table>
            </div>
</div>
