<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-wallet card-icon"></i>
                    <h5 class="card-title">Petty Cash</h5>
                </div>
                <div class="card-header-actions">
                    <?php if (can('expenses_create')): ?>
                        <a href="<?= url('accounting/pettycash/create') ?>" class="btn btn-gold btn-sm"><i class="fas fa-plus me-1"></i>Add Entry</a>
                    <?php endif; ?>
                </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 class="text-end">Amount</th>
                                <th>Fund Source</th>
                                <th>Status</th>
                                <th class="text-end">Actions</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->date)) ?></td>
                                    <td><?= e($entry->description) ?></td>
                                    <td class="text-end"><?= currency($entry->amount) ?></td>
                                    <td><?= e($entry->fund_source ?? 'Main') ?></td>
                                    <td>
                                        <span class="badge bg-<?= $entry->status === 'approved' ? 'success' : ($entry->status === 'pending' ? 'warning' : 'secondary') ?>">
                                            <?= e($entry->status) ?>
                                        </span>
                                    </td>
                                    <td class="text-end">
                                        <?php if (can('expenses_edit')): ?>
                                            <a href="<?= url('accounting/pettycash/edit/' . $entry->id) ?>" class="btn btn-sm btn-ghost"><i class="fas fa-edit"></i></a>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                                <?php endforeach; ?>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
