<div class="row">
    <div class="col-lg-8">
        <div class="card glass-card">
            <div class="card-header"><h5 class="card-title">Edit Gift Card</h5></div>
            <div class="card-body">
                <form method="POST" action="<?= url('loyalty/giftcards/update/' . $gc->id) ?>" class="needs-validation" novalidate>
                    <?= csrf_field() ?>
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Code</label>
                            <input type="text" class="form-control" value="<?= e($gc->code) ?>" disabled>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Customer</label>
                            <select name="customer_id" class="form-select select2">
                                <option value="">Walk-in</option>
                                <?php foreach ($customers as $c): ?>
                                    <option value="<?= $c->id ?>" <?= $gc->customer_id == $c->id ? 'selected' : '' ?>><?= e($c->first_name . ' ' . $c->last_name) ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Balance <span class="text-danger">*</span></label>
                            <input type="number" step="0.01" name="balance" class="form-control" required min="0" value="<?= $gc->balance ?>">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Expiration Date</label>
                            <input type="date" name="expires_at" class="form-control" value="<?= $gc->expires_at ?? '' ?>">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Status</label>
                            <select name="status" class="form-select">
                                <option value="active" <?= $gc->status === 'active' ? 'selected' : '' ?>>Active</option>
                                <option value="used" <?= $gc->status === 'used' ? 'selected' : '' ?>>Used</option>
                                <option value="expired" <?= $gc->status === 'expired' ? 'selected' : '' ?>>Expired</option>
                            </select>
                        </div>
                    </div>
                    <button type="submit" class="btn btn-gold"><i class="fas fa-save me-1"></i>Update Gift Card</button>
                    <a href="<?= url('loyalty/giftcards') ?>" class="btn btn-ghost ms-2">Cancel</a>
                </form>
            </div>
        </div>
    </div>
</div>
