<?php $pageTitle = 'Activate your subscription'; require __DIR__ . '/../partials/standalone-head.php'; ?>

<div class="standalone-wrap">
  <div class="d-flex align-items-center gap-2 mb-4">
    <div class="brand-mark">CRM</div>
    <div class="fw-bold fs-5"><?= e($tenant['name']) ?></div>
  </div>

  <div class="standalone-card mb-3">
    <h2 class="mb-1">Almost there</h2>
    <p class="text-muted mb-4">Your account at <strong><?= e($tenant['slug']) ?>.<?= e($appDomain) ?></strong> is ready. Activate it to start using your CRM — either now with a card, or later with a subscription code.</p>

    <?php $errors = \App\Core\Session::getFlash('_errors', []); ?>
    <?php if ($errors): ?>
      <div class="alert alert-danger">
        <ul class="mb-0">
          <?php foreach ($errors as $field => $messages): foreach ((array) $messages as $m): ?>
            <li><?= e($m) ?></li>
          <?php endforeach; endforeach; ?>
        </ul>
      </div>
    <?php endif; ?>

    <?php if ($stripeConfigured): ?>
      <form method="POST" action="<?= base_url('signup/activate/' . $tenant['id'] . '/checkout') ?>" class="mb-4">
        <?= csrf_field() ?>
        <button type="submit" class="btn btn-primary w-100"><i class="bi bi-credit-card me-1"></i> Pay by card — activates instantly</button>
      </form>
    <?php else: ?>
      <div class="alert alert-secondary small">Card payment isn't available yet — use a subscription code below, or contact us.</div>
    <?php endif; ?>

    <hr class="my-4">

    <form method="POST" action="<?= base_url('signup/activate/' . $tenant['id'] . '/redeem-code') ?>">
      <?= csrf_field() ?>
      <label class="form-label">Have a subscription code?</label>
      <div class="input-group">
        <input type="text" name="code" class="form-control" placeholder="SUB-XXXXXXXXXXXXXXXX" required>
        <button type="submit" class="btn btn-outline-secondary">Redeem</button>
      </div>
    </form>
  </div>

  <p class="text-center text-muted small">You can also come back to this page later — it's at <code><?= e(base_url('signup/activate/' . $tenant['id'])) ?></code>.</p>
</div>

</body>
</html>
