<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Invoice Data Report</title>
    <style>
        body {
            font-family: 'Segoe UI', Arial, sans-serif;
            background-color: #f9fafb;
            color: #333;
            margin: 0;
            padding: 0;
        }
        h2 {
            color: #215c98;
            text-align: center;
            margin-bottom: 20px;
        }
        table {
            border-collapse: collapse;
            width: 100%;
            font-size: 14px;
            white-space: nowrap !important;
        }
        th, td {
            border: 1px solid #020813da;
            padding: 8px 10px;
            text-align: center;
            white-space: nowrap !important;
            text-overflow: ellipsis;
        }
        .td-left {
            text-align: left !important;
        }
        th {
            background-color: #215c98;
            color: #fff;
            white-space: nowrap !important;
        }
        tr:nth-child(even) {
            background-color: #f3f4f6;
        }
        .status-wentout {
            color: #10b981;
            font-weight: bold;
        }
        /* .status-pending {
            color: #ef4444;
            font-weight: bold;
        } */
        .status-pending-yellow {
        color: #eab308;
        font-weight: bold;
        }
        .status-pending-red {
            color: #ef4444;
            font-weight: bold;
        }
        .footer {
            text-align: center;
            font-size: 13px;
            color: #6b7280;
            margin-top: 30px;
        }
    </style>
</head>
<body>
    <div style="text-align: center; font-weight: bold;">
        {{ $company }}
    </div>
    <br>
    <p>{!! $greeting !!}</p>
    <div class="container">
        @if(empty($tableData))
            <p style="text-align:center;">No invoice data available for this schedule.</p>
        @else
            <table>
                <thead>
                    <tr>
                        <th>No</th>
                        <th>Plant</th>
                        {{-- <th>Distribution Type</th> --}}
                        <th>Customer Code</th>
                        <th>Document Number</th>
                        <th>Document Date</th>
                        <th>Customer TradeName</th>
                        <th>Customer Location</th>
                        <th>Location</th>
                        <th>Pending Days</th>
                        <th>Status</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($tableData as $row)
                        <tr>
                            <td>{{ $row['no'] }}</td>
                            <td>{{ $row['plant'] }}</td>
                            {{-- <td>{{ $row['distribution_type'] }}</td> --}}
                            <td>{{ $row['customer_code'] }}</td>
                            <td>{{ $row['document_number'] }}</td>
                            <td>
                                @if(!empty($row['document_date']) && $row['document_date'] != '-')
                                    {{ \Carbon\Carbon::parse($row['document_date'])->format('d-M-Y') }}
                                @else
                                    -
                                @endif
                            </td>

                            {{-- <td>{{ $row['customer_trade_name'] }}</td> --}}
                            <td class="td-left">{{ $row['customer_trade_name'] }}</td>
                            <td>{{ $row['customer_location'] }}</td>
                            <td>{{ $row['location'] }}</td>
                            {{-- <td class="{{ $row['status'] == 'Went Out' ? 'status-wentout' : ($row['status'] == 'Pending' ? 'status-pending' : '') }}">
                                {{ $row['status'] }}
                            </td> --}}
                            <td>{{ $row['no_of_days_pending'] }}</td>
                            <td class="{{ $row['status_class'] ?? '' }}">
                                {{ $row['status'] }}
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        @endif
        {{-- <p>* <span class="status-pending-red">Pending</span> - Long Days Pending, <span class="status-pending-yellow">Pending</span> - One Day Pending</p> --}}
        <p style="margin-top: 20px;">
            <strong>* Pending</strong><br>
            <span style="display:inline-block; width:11px; height:11px; background-color:#ff4d4d; border:1px solid #ccc; vertical-align:middle; margin-right:6px;"></span>
            - Long Days Pending<br>
            <span style="display:inline-block; width:9px; height:9px; background-color:#ffd633; border:1px solid #ccc; vertical-align:middle; margin-right:6px;"></span>
            - One Day Pending
        </p>

        <p>{!! $wishes !!}</p>
    </div>
</body>
</html>
