<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Subscription - 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>Subscription Plans</h3>
    
    <div class="alert alert-info">
        <strong>Current Plan:</strong> <?= ucfirst($user['subscription_tier'] ?? 'free') ?>
    </div>

    <?php helper('price_calculator');
          $tiers = ['free','basic','pro','enterprise']; ?>

    <div class="row">
        <?php foreach ($tiers as $t):
            $info = getSubscriptionLimits($t);
            $isCurrent = ($user['subscription_tier'] ?? 'free') === $t;
            // choose header color
            $headerClass = 'bg-secondary text-white';
            if ($t === 'basic') $headerClass = 'bg-primary text-white';
            if ($t === 'pro') $headerClass = 'bg-warning text-dark';
            if ($t === 'enterprise') $headerClass = 'bg-dark text-white';
        ?>
        <div class="col-md-3">
            <div class="card <?= $isCurrent ? 'border-success' : '' ?>">
                <div class="card-header <?= $headerClass ?>"><?= ucfirst($t) ?></div>
                <div class="card-body">
                    <h4>₹<?= number_format($info['monthly_price'], 0) ?>/month</h4>
                    <p class="small mb-1">Upload up to <?= intval($info['max_products']) ?> products</p>
                    <?php if (!empty($info['features'])): ?>
                        <ul>
                            <?php foreach ($info['features'] as $feat): ?>
                                <li><?= esc($feat) ?></li>
                            <?php endforeach; ?>
                        </ul>
                    <?php endif; ?>

                    <?php if (!$isCurrent): ?>
                        <button class="btn btn-sm btn-outline-primary">Upgrade</button>
                    <?php else: ?>
                        <span class="badge bg-success">Current</span>
                    <?php endif; ?>
                </div>
            </div>
        </div>
        <?php endforeach; ?>
    </div>
    
    <a href="<?= base_url('seller/dashboard') ?>" class="btn btn-secondary mt-3">Back</a>
</div>
</body>
</html>
