@extends('layouts.vendor')

@section('title', 'Bill Book')
@section('header_title', 'Bill Book Management')

@section('content')
    <div class="card">
        <h3><i class="fa-solid fa-file-invoice" style="color: var(--primary);"></i> Customer Bills & Invoices</h3>
        <table>
            <thead><tr><th>Invoice</th><th>Customer</th><th>Order</th><th>Payment</th><th>Total</th><th>Action</th></tr></thead>
            <tbody>
                @forelse($bills as $bill)
                    <tr>
                        <td><strong>{{ $bill->invoice_number }}</strong><div style="color: var(--text-muted); font-size: 0.8rem;">{{ $bill->ordered_at->format('d M Y') }}</div></td>
                        <td>{{ $bill->customer_name }}<div style="color: var(--text-muted); font-size: 0.8rem;">{{ $bill->customer_phone }}</div></td>
                        <td>{{ $bill->order_number }}<div style="color: var(--text-muted); font-size: 0.8rem;">{{ ucfirst($bill->status) }}</div></td>
                        <td><span class="badge {{ $bill->payment_status === 'paid' ? 'badge-success' : 'badge-danger' }}">{{ ucfirst($bill->payment_status) }}</span></td>
                        <td style="color: var(--success); font-weight: 700;">₹{{ number_format($bill->total, 2) }}</td>
                        <td><a href="{{ route('vendor.bills.show', $bill->id) }}" target="_blank" class="btn btn-primary"><i class="fa-solid fa-print"></i> View / Print</a></td>
                    </tr>
                @empty
                    <tr><td colspan="6" style="text-align: center; color: var(--text-muted); padding: 2rem;">No bills available yet.</td></tr>
                @endforelse
            </tbody>
        </table>
        <div style="margin-top: 1.5rem;">{{ $bills->links() }}</div>
    </div>
@endsection
