<x-app-layout>
    <x-slot name="header">{{ __('app.expenses') }}</x-slot>

    <div class="mb-3">
        <a href="{{ route('expenses.create') }}" class="btn btn-primary">{{ __('Add Expense') }}</a>
    </div>

    <div class="card shadow-sm">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-striped mb-0">
                    <thead class="table-light">
                        <tr>
                            <th>{{ __('Category') }}</th>
                            <th>{{ __('Amount') }}</th>
                            <th>{{ __('Frequency') }}</th>
                            <th>{{ __('Date') }}</th>
                            <th>{{ __('Notes') }}</th>
                            <th>{{ __('Actions') }}</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse($expenses as $expense)
                            <tr>
                                <td>{{ ucfirst(str_replace('_', ' ', $expense->category)) }}</td>
                                <td>{{ number_format($expense->amount, 2) }} {{ $expense->currency?->symbol ?? '' }}</td>
                                <td>{{ ucfirst($expense->frequency) }}</td>
                                <td>{{ $expense->expense_date->format('Y-m-d') }}</td>
                                <td>{{ $expense->notes }}</td>
                                <td>
                                    <form action="{{ route('expenses.destroy', $expense) }}" method="POST" class="d-inline-block">
                                        @csrf
                                        @method('DELETE')
                                        <button type="submit" class="btn btn-sm btn-danger">{{ __('Delete') }}</button>
                                    </form>
                                </td>
                            </tr>
                        @empty
                            <tr>
                                <td colspan="6" class="text-center">{{ __('No expenses found.') }}</td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="mt-3">{{ $expenses->links() }}</div>
</x-app-layout>
