<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Daily Income Report — {{ $date }}</title>
    <style>
        body { font-family: DejaVu Sans, sans-serif; font-size: 13px; color: #333; margin: 30px; }
        h1 { font-size: 20px; margin-bottom: 4px; }
        .subtitle { font-size: 12px; color: #666; margin-bottom: 20px; }
        table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
        th { background: #0dcaee; color: #fff; padding: 8px 10px; text-align: left; }
        td { padding: 7px 10px; border-bottom: 1px solid #e0e0e0; }
        .text-right { text-align: right; }
        .total-row td { font-weight: bold; background: #f5f5f5; }
        .profit { color: #198754; }
        .loss { color: #dc3545; }
    </style>
</head>
<body>
    <h1>{{ __('Daily Income Report') }}</h1>
    <div class="subtitle">{{ __('Date') }}: {{ $date }}</div>

    <table>
        <thead>
            <tr>
                <th>{{ __('Description') }}</th>
                <th class="text-right">{{ __('Amount') }}</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>{{ __('Total Sales') }}</td>
                <td class="text-right">{{ number_format($sales, 2) }}</td>
            </tr>
            <tr>
                <td>{{ __('Total Purchases') }}</td>
                <td class="text-right">{{ number_format($purchases, 2) }}</td>
            </tr>
            <tr>
                <td>{{ __('Total Expenses') }}</td>
                <td class="text-right">{{ number_format($expenses, 2) }}</td>
            </tr>
            @php $net = $sales - $purchases - $expenses; @endphp
            <tr class="total-row">
                <td>{{ __('Net Income') }}</td>
                <td class="text-right {{ $net >= 0 ? 'profit' : 'loss' }}">{{ number_format($net, 2) }}</td>
            </tr>
        </tbody>
    </table>

    @if($customers->count())
    <h3>{{ __('Outstanding Customer Dues') }}</h3>
    <table>
        <thead>
            <tr>
                <th>#</th>
                <th>{{ __('Customer') }}</th>
                <th>{{ __('Phone') }}</th>
                <th class="text-right">{{ __('Due Amount') }}</th>
            </tr>
        </thead>
        <tbody>
            @foreach($customers as $i => $customer)
            <tr>
                <td>{{ $i + 1 }}</td>
                <td>{{ $customer->name }}</td>
                <td>{{ $customer->phone }}</td>
                <td class="text-right loss">{{ number_format($customer->current_due, 2) }}</td>
            </tr>
            @endforeach
        </tbody>
    </table>
    @endif

    <div style="margin-top:30px; font-size:11px; color:#999; text-align:right;">
        {{ __('Generated on') }} {{ now()->format('Y-m-d H:i') }}
    </div>
</body>
</html>
