<div class="row">
    <div class="col-12">
        <div class="card glass-card">
            <div class="card-header">
                <div class="card-header-left">
                    <i class="fas fa-book card-icon"></i>
                    <h5 class="card-title">Cash Book</h5>
                </div>
                <div class="card-header-actions">
                    <a href="<?= url('accounting/cashbook/export') ?>" class="btn btn-sm btn-ghost"><i class="fas fa-download me-1"></i>Export</a>
                </div>
            </div>
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-hover align-middle mb-0">
                        <thead>
                            <tr>
                                <th>Date</th>
                                <th>Description</th>
                                <th>Type</th>
                                <th class="text-end">Debit</th>
                                <th class="text-end">Credit</th>
                                <th class="text-end">Balance</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if (empty($entries)): ?>
                            <tr><td colspan="6" class="text-center py-4 text-muted">No entries found.</td></tr>
                            <?php else: ?>
                                <?php foreach ($entries as $entry): ?>
                                <tr>
                                    <td><?= date('d M Y', strtotime($entry->created_at)) ?></td>
                                    <td><?= e($entry->description) ?></td>
                                    <td><span class="badge bg-<?= $entry->type === 'debit' ? 'success' : 'danger' ?>"><?= e($entry->type) ?></span></td>
                                    <td class="text-end"><?= $entry->type === 'debit' ? currency($entry->amount) : '-' ?></td>
                                    <td class="text-end"><?= $entry->type === 'credit' ? currency($entry->amount) : '-' ?></td>
                                    <td class="text-end fw-bold"><?= currency($entry->balance) ?></td>
                                </tr>
                                <?php endforeach; ?>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
