<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Subscriptions - Flex Market</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-4">
    <h3>My Subscriptions</h3>

    <?php if (empty($subscriptions)): ?>
        <div class="alert alert-info">You have no active subscriptions.</div>
    <?php else: ?>
        <div class="row">
            <?php foreach ($subscriptions as $sub): ?>
                <div class="col-md-6 mb-3">
                    <div class="card">
                        <div class="card-body">
                            <h5 class="card-title"><?= esc($sub['package_name'] ?? 'Package') ?></h5>
                            <p class="mb-1">Contacts allowed: <strong><?= intval($sub['contact_limit'] ?? 0) ?></strong></p>
                            <p class="mb-1">Contacts used: <strong><?= intval($sub['contacts_used'] ?? 0) ?></strong></p>
                            <p class="mb-1">Remaining contacts: <strong><?= max(0, intval($sub['contact_limit'] ?? 0) - intval($sub['contacts_used'] ?? 0)) ?></strong></p>
                            <p class="mb-1">Valid until: <strong><?= esc($sub['expires_at'] ?? 'N/A') ?></strong></p>
                        </div>
                    </div>
                </div>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>

    <a href="<?= base_url('buyer') ?>" class="btn btn-secondary mt-3">Back to Browse</a>
</div>
</body>
</html>
