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

    <div class="mb-3">
        <a href="{{ route('customers.create') }}" class="btn btn-primary">{{ __('Add Customer') }}</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>{{ __('Name') }}</th>
                            <th>{{ __('Phone') }}</th>
                            <th>{{ __('Address') }}</th>
                            <th>{{ __('Credit Limit') }}</th>
                            <th>{{ __('Actions') }}</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse($customers as $customer)
                            <tr>
                                <td>{{ $customer->name }}</td>
                                <td>{{ $customer->phone }}</td>
                                <td>{{ $customer->address }}</td>
                                <td>{{ number_format($customer->credit_limit, 2) }} {{ $customer->currency?->symbol ?? '' }}</td>
                                <td>
                                    <a href="{{ route('customer-ledgers.index', ['customer_id' => $customer->id]) }}" class="btn btn-sm btn-secondary">{{ __('Ledger') }}</a>
                                </td>
                            </tr>
                        @empty
                            <tr>
                                <td colspan="5" class="text-center">{{ __('No customers found.') }}</td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>

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