<!--<table class="table table-bordered">
    <thead>
        <tr>
            <th style="width: 55px;">No.</th>
            <th style="width: 300px;">Branch</th>
            <th style="width: 130px;">Model</th>
            <th style="width: 300px;">Variant</th>
            <th style="width: 115px;">Fuel Type</th>
            <th style="width: 220px;">VIN No.</th>
            <th style="width: 220px;">Exterior Color</th>
            <th style="width: 220px;">Interior Color</th>
            <th style="width: 120px;">Aging Days</th>
            <th style="width: 155px;">Status</th>
            <th style="width: 300px;">Customer Name</th>
        </tr>
    </thead>
    <tbody>
        @if ($data_type === 'inventory' && $cars->isNotEmpty())
            @foreach($cars as $key => $car)
                <tr>
                    <td>{{ $key+1 }}</td>
                    <td>{{ $car->branch_name }}</td>
                    <td>{{ $car->car_name }}</td>
                    <td>{{ $car->varient_name }}</td>
                    <td>{{ $car->fuel_type_name }}</td>
                    <td>{{ $car->vin_number }}</td>
                    <td>{{ $car->exterior_color }}</td>
                    <td>{{ $car->interior_color }}</td>
                    <td>{{ $car->aging_days }}</td>
                    <td>{{ ucwords(str_replace('_',' ',$car->status)) }}</td>
                    <td>{{ $car->customer_name }}</td>
                </tr>
            @endforeach
        @elseif ($data_type === 'transit' && $transit_cars->isNotEmpty())
            @foreach($transit_cars as $key => $car)
                <tr>
                    <td>{{ $key+1 }}</td>
                    <td>{{ $car->branch_name }}</td>
                    <td>{{ $car->car_name }}</td>
                    <td>{{ $car->varient_name }}</td>
                    <td>{{ $car->fuel_type_name }}</td>
                    <td>{{ $car->vin_number }}</td>
                    <td>{{ $car->exterior_color }}</td>
                    <td>{{ $car->interior_color }}</td>
                    <td>{{ $car->aging_days }}</td>
                    <td>{{ ucwords(str_replace('_',' ',$car->status)) }}</td>
                    <td> - </td>
                </tr>
            @endforeach
        @else
            <tr>
                <td colspan="11" class="text-center">No data available.</td>
            </tr>
        @endif
    </tbody>
</table>-->


<table class="table table-bordered">
    <thead>
        <tr>
            <th style="width: 55px;">No.</th>
            <th style="width: 300px;">Branch</th>
            <th style="width: 130px;">Model</th>
            <th style="width: 300px;">Variant</th>
            <th style="width: 115px;">Fuel Type</th>
            <th style="width: 220px;">VIN No.</th>
            <th style="width: 220px;">Exterior Color</th>
            <th style="width: 220px;">Interior Color</th>
            <th style="width: 120px;">Aging Days</th>
            <th style="width: 155px;">Status</th>
            <th style="width: 300px;">Customer Name</th>
        </tr>
    </thead>
    <tbody>
        @if (($data_type === 'inventory' && $cars->isNotEmpty()) || ($data_type === 'both' && ($cars->isNotEmpty() || $transit_cars->isNotEmpty())))
            @php
                $combinedCars = $cars->toBase(); // convert to base collection
                if ($data_type === 'both') {
                    $combinedCars = $combinedCars->merge($transit_cars); // merge transit data
                }
            @endphp

            @foreach($combinedCars as $key => $car)
                <tr>
                    <td>{{ $key+1 }}</td>
                    <td>{{ $car->branch_name }}</td>
                    <td>{{ $car->car_name }}</td>
                    <td>{{ $car->varient_name }}</td>
                    <td>{{ $car->fuel_type_name }}</td>
                    <td>{{ $car->vin_number }}</td>
                    <td>{{ $car->exterior_color }}</td>
                    <td>{{ $car->interior_color }}</td>
                    <td>{{ $car->aging_days }}</td>
                    <td>{{ ucwords(str_replace('_',' ',$car->status ?? 'transit')) }}</td>
                    <td>{{ $car->customer_name ?? '-' }}</td>
                </tr>
            @endforeach

        @elseif ($data_type === 'transit' && $transit_cars->isNotEmpty())
            @foreach($transit_cars as $key => $car)
                <tr>
                    <td>{{ $key+1 }}</td>
                    <td>{{ $car->branch_name }}</td>
                    <td>{{ $car->car_name }}</td>
                    <td>{{ $car->varient_name }}</td>
                    <td>{{ $car->fuel_type_name }}</td>
                    <td>{{ $car->vin_number }}</td>
                    <td>{{ $car->exterior_color }}</td>
                    <td>{{ $car->interior_color }}</td>
                    <td>{{ $car->aging_days }}</td>
                    <td>{{ ucwords(str_replace('_',' ',$car->status ?? 'transit')) }}</td>
                    <td> - </td>
                </tr>
            @endforeach
        @else
            <tr>
                <td colspan="11" class="text-center">No data available.</td>
            </tr>
        @endif
    </tbody>
</table>

