<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <h2 class="mb-4">
                <i class="fas fa-clock me-2" style="color: var(--nis-primary);"></i>
                Pending Reviews
            </h2>
        </div>
    </div>
    
    <div class="card">
        <div class="card-header">
            <i class="fas fa-list me-2"></i> Applications Awaiting Review
        </div>
        <div class="card-body">
            <?php if (empty($applications)): ?>
                <div class="text-center py-5">
                    <i class="fas fa-check-circle fa-4x text-success mb-3"></i>
                    <h4>No Pending Applications</h4>
                    <p class="text-muted">All applications have been reviewed.</p>
                </div>
            <?php else: ?>
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>Person ID</th>
                                <th>Name</th>
                                <th>Document No</th>
                                <th>Status</th>
                                <th>Submitted By</th>
                                <th>Date</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($applications as $app): ?>
                            <tr>
                                <td><code><?= htmlspecialchars($app['person_id']) ?></code></td>
                                <td><?= htmlspecialchars($app['surname']) ?>, <?= htmlspecialchars($app['given_name']) ?></td>
                                <td><?= htmlspecialchars($app['document_no']) ?></td>
                                <td>
                                    <span class="badge bg-<?= $app['status'] == 'Submitted' ? 'warning' : 'info' ?>">
                                        <?= $app['status'] ?>
                                    </span>
                                </td>
                                <td><?= htmlspecialchars($app['created_by_name'] ?? 'Unknown') ?></td>
                                <td><?= date('d/m/Y H:i', strtotime($app['created_at'])) ?></td>
                                <td>
                                    <a href="<?= APP_URL ?>/migrants/<?= urlencode($app['person_id']) ?>" 
                                       class="btn btn-sm btn-nis">
                                        <i class="fas fa-check-circle"></i> Review
                                    </a>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>