<!-- TAB 1: INCOME & EXPENSES -->
    <div class="tab-pane fade <?= $activeTab=='income'?'show active':'' ?>" id="income" role="tabpanel">
        <div class="row animate-slide-up delay-1">
            <div class="col-md-6 mb-4">
                <div class="card card-saas h-100 border-top border-4 border-success">
                    <div class="card-body">
                        <h5 class="fw-bold mb-4"><i class="fa-solid fa-arrow-down text-success"></i> إضافة مورد مالي (دخل)</h5>
                        <form action="<?= BASE_URL ?>/finance/storeIncome" method="POST" class="needs-validation loader-form">
                            <?= csrf_field() ?>
                            <div class="mb-3">
                                <label class="form-label text-muted">التصنيف / المصدر</label>
                                <select name="source" class="form-select" required>
                                    <option value="" disabled selected>اختر المصدر...</option>
                                    <?php foreach($incomeCategories as $cat): ?>
                                    <option value="<?= htmlspecialchars($cat->name) ?>"><?= htmlspecialchars($cat->name) ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                            <div class="row">
                                <div class="col-6 mb-3">
                                    <label class="form-label text-muted">المبلغ</label>
                                    <div class="input-group">
                                        <input type="number" step="0.01" name="amount" class="form-control" required>
                                        <span class="input-group-text bg-light">ج.م</span>
                                    </div>
                                </div>
                                <div class="col-6 mb-3">
                                    <label class="form-label text-muted">التاريخ</label>
                                    <input type="date" name="date_received" value="<?= date('Y-m-d') ?>" class="form-control" required>
                                </div>
                            </div>
                            <button type="submit" class="btn btn-success btn-premium w-100 fw-bold submit-btn">حفظ وتوزيع أوتوماتيكي</button>
                        </form>

                        <div id="incomeTableContainer">
                            <?php include __DIR__ . '/_income_table.php'; ?>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-md-6 mb-4">
                <div class="card card-saas h-100 border-top border-4 border-danger">
                    <div class="card-body">
                        <h5 class="fw-bold mb-4"><i class="fa-solid fa-arrow-up text-danger"></i> تسجيل مصروف</h5>
                        <form action="<?= BASE_URL ?>/finance/storeExpense" method="POST" class="needs-validation" onsubmit="return checkImpulsiveExpense(event, this)">
                            <?= csrf_field() ?>
                            <div class="row">
                                <div class="col-6 mb-3">
                                    <label class="form-label text-muted">البند (تفاصيل المصروف)</label>
                                    <input type="text" name="item_name" class="form-control" required placeholder="مثال: فاتورة كهرباء، كوفي...">
                                </div>
                                <div class="col-6 mb-3">
                                    <label class="form-label text-muted">المبلغ</label>
                                    <div class="input-group">
                                        <input type="number" step="0.01" name="amount" class="form-control" required min="0.01">
                                        <span class="input-group-text bg-light">ج.م</span>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-6 mb-3">
                                    <label class="form-label text-muted">تصنيف المصروف</label>
                                    <select name="category" class="form-select" required>
                                        <option value="" disabled selected>اختر التصنيف...</option>
                                        <?php foreach($expenseCategories as $cat): ?>
                                        <option value="<?= htmlspecialchars($cat->name) ?>"><?= htmlspecialchars($cat->name) ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </div>
                                <div class="col-6 mb-3">
                                    <label class="form-label text-muted">التاريخ</label>
                                    <input type="date" name="expense_date" value="<?= date('Y-m-d') ?>" class="form-control" required>
                                </div>
                            </div>
                            <button type="submit" class="btn btn-danger btn-premium w-100 fw-bold submit-btn">استقطاع</button>
                        </form>
                        
                        <div id="expenseTableContainer">
                            <?php include __DIR__ . '/_expense_table.php'; ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
