<?php require_once __DIR__ . '/layout.php'; ?>

<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem;">
    <div>
        <h3 style="margin: 0 0 0.5rem; color: white;">Pending Registrations</h3>
        <p style="color: var(--text-muted); margin: 0;">Review and approve or reject new pharmacy registration requests.</p>
    </div>
</div>

<div class="card" style="padding: 2rem; background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 16px; backdrop-filter: blur(10px);">
    <div class="responsive-table-container" style="overflow-x: auto; border: none;">
        <table class="data-table" style="width: 100%; border-collapse: collapse;">
            <thead>
                <tr>
                    <th style="color: var(--text-muted);">Date & Time</th>
                    <th style="color: var(--text-muted);">Pharmacy Name</th>
                    <th style="color: var(--text-muted);">Admin Name</th>
                    <th style="color: var(--text-muted);">Email Address</th>
                    <th style="color: var(--text-muted); text-align: right;">Actions</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($registrations as $reg): ?>
                    <tr>
                        <td style="color: var(--text-light);"><?php echo htmlspecialchars($reg['created_at']); ?></td>
                        <td style="color: white; font-weight: 500;"><?php echo htmlspecialchars($reg['name']); ?></td>
                        <td style="color: var(--text-light);"><?php echo htmlspecialchars($reg['admin_name']); ?></td>
                        <td style="color: var(--text-light);"><?php echo htmlspecialchars($reg['admin_email'] ?? $reg['email']); ?></td>
                        <td style="text-align: right;">
                            <form action="/superadmin/approveRegistration/<?php echo $reg['id']; ?>" method="POST" style="display: inline-block; margin-right: 0.5rem;">
                                <button type="submit" class="btn-outline-gold" style="padding: 0.4rem 0.8rem; font-size: 0.85rem; border-color: #10b981; color: #10b981;">
                                    <i class="ph ph-check-circle" style="margin-right: 0.25rem;"></i> Approve
                                </button>
                            </form>
                            <form action="/superadmin/rejectRegistration/<?php echo $reg['id']; ?>" method="POST" style="display: inline-block;" onsubmit="return confirm('Are you sure you want to reject and suspend this registration?');">
                                <button type="submit" class="btn-outline-gold" style="padding: 0.4rem 0.8rem; font-size: 0.85rem; border-color: #ef4444; color: #ef4444;">
                                    <i class="ph ph-x-circle" style="margin-right: 0.25rem;"></i> Reject
                                </button>
                            </form>
                        </td>
                    </tr>
                <?php endforeach; ?>
                <?php if (empty($registrations)): ?>
                    <tr>
                        <td colspan="5" style="text-align: center; color: var(--text-muted); padding: 3rem;">
                            <i class="ph ph-check-circle" style="font-size: 2rem; color: #10b981; margin-bottom: 0.5rem; display: block;"></i>
                            No pending registrations found. You're all caught up!
                        </td>
                    </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>

</div> <!-- main-content -->
</div> <!-- dashboard-layout -->
</body>
</html>
