@extends('layouts.app')
@section('title', 'Suppliers')
@section('content')
<div class="d-flex justify-content-between align-items-center mb-3">
    <h4>Suppliers (Flour Mills)</h4>
    <a href="{{ route('suppliers.create') }}" class="btn btn-primary btn-sm"><i class="bi bi-plus"></i> Add Supplier</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>Phone</th><th>Balance Due</th><th>Actions</th></tr></thead>
            <tbody>
            @forelse($suppliers as $supplier)
                <tr>
                    <td>{{ $supplier->id }}</td>
                    <td>{{ $supplier->name }}</td>
                    <td>{{ $supplier->phone ?: '-' }}</td>
                    <td>
                        @if($supplier->balance > 0)
                            <span class="text-danger fw-bold">Rs. {{ number_format($supplier->balance, 2) }}</span>
                        @else
                            <span class="text-success">Clear</span>
                        @endif
                    </td>
                    <td>
                        <a href="{{ route('suppliers.show', $supplier) }}" class="btn btn-sm btn-outline-info">Details</a>
                        <a href="{{ route('suppliers.edit', $supplier) }}" class="btn btn-sm btn-outline-primary">Edit</a>
                        <a href="{{ route('suppliers.pay', $supplier) }}" class="btn btn-sm btn-outline-success">Pay</a>
                    </td>
                </tr>
            @empty
                <tr><td colspan="5" class="text-center text-muted">No suppliers yet</td></tr>
            @endforelse
            </tbody>
        </table>
    </div>
</div>
<div class="mt-3">{{ $suppliers->links() }}</div>
@endsection
