@extends('layouts.app')
@section('title', 'Customers')
@section('content')
<div class="d-flex justify-content-between align-items-center mb-3">
    <h4>Customers (B2B Shopkeepers)</h4>
    <a href="{{ route('customers.create') }}" class="btn btn-primary btn-sm"><i class="bi bi-plus"></i> Add Customer</a>
</div>
<div class="card">
    <div class="card-body p-0">
        <table class="table table-hover mb-0">
            <thead><tr><th>#</th><th>Name</th><th>Shop</th><th>Phone</th><th>Balance Due</th><th>Actions</th></tr></thead>
            <tbody>
            @forelse($customers as $c)
                <tr>
                    <td>{{ $c->id }}</td>
                    <td>{{ $c->name }}</td>
                    <td>{{ $c->shop_name ?: '-' }}</td>
                    <td>{{ $c->phone ?: '-' }}</td>
                    <td>
                        @if($c->balance > 0)
                            <span class="text-danger fw-bold">Rs. {{ number_format($c->balance, 2) }}</span>
                        @else
                            <span class="text-success">Clear</span>
                        @endif
                    </td>
                    <td>
                        <a href="{{ route('customers.show', $c) }}" class="btn btn-sm btn-outline-info">Details</a>
                        <a href="{{ route('customers.edit', $c) }}" class="btn btn-sm btn-outline-primary">Edit</a>
                        <a href="{{ route('customers.pay', $c) }}" class="btn btn-sm btn-outline-success">Receive Payment</a>
                    </td>
                </tr>
            @empty
                <tr><td colspan="6" class="text-center text-muted">No customers yet</td></tr>
            @endforelse
            </tbody>
        </table>
    </div>
</div>
<div class="mt-3">{{ $customers->links() }}</div>
@endsection
