<div class="row">
    <div class="col-lg-8">
        <div class="card glass-card">
            <div class="card-header">
                <h5 class="card-title">Edit Income Record</h5>
            </div>
            <div class="card-body">
                <form method="POST" action="<?= url('income/update/' . $income->id) ?>" class="needs-validation" novalidate>
                    <?= csrf_field() ?>
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Category <span class="text-danger">*</span></label>
                            <select name="category_id" class="form-select" required>
                                <option value="">Select Category</option>
                                <?php foreach ($categories as $cat): ?>
                                    <option value="<?= $cat->id ?>" <?= $income->category_id == $cat->id ? 'selected' : '' ?>><?= e($cat->name) ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Amount <span class="text-danger">*</span></label>
                            <input type="number" step="0.01" name="amount" class="form-control" required value="<?= $income->amount ?>">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Payment Method</label>
                            <select name="payment_method" class="form-select">
                                <option value="cash" <?= $income->payment_method === 'cash' ? 'selected' : '' ?>>Cash</option>
                                <option value="card" <?= $income->payment_method === 'card' ? 'selected' : '' ?>>Card</option>
                                <option value="bank_transfer" <?= $income->payment_method === 'bank_transfer' ? 'selected' : '' ?>>Bank Transfer</option>
                                <option value="cheque" <?= $income->payment_method === 'cheque' ? 'selected' : '' ?>>Cheque</option>
                            </select>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Date <span class="text-danger">*</span></label>
                            <input type="date" name="date" class="form-control" required value="<?= $income->date ?>">
                        </div>
                        <div class="col-12 mb-3">
                            <label class="form-label">Description</label>
                            <textarea name="description" class="form-control" rows="2"><?= e($income->description ?? '') ?></textarea>
                        </div>
                    </div>
                    <button type="submit" class="btn btn-gold"><i class="fas fa-save me-1"></i>Update Income</button>
                    <a href="<?= url('income') ?>" class="btn btn-ghost ms-2">Cancel</a>
                </form>
            </div>
        </div>
    </div>
</div>
