<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <div>
            <h2 class="font-semibold text-xl text-gray-800 leading-tight"><?php echo e(__('Loads & Document History')); ?></h2>
            <p class="mt-1 text-sm text-gray-500">Track extracted load data, stored rate snapshots, and profit/loss history for every upload.</p>
        </div>
     <?php $__env->endSlot(); ?>

    <div class="py-12">
        <div class="max-w-7xl mx-auto space-y-6 sm:px-6 lg:px-8">
            <div class="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
                <div class="rounded-xl border border-cyan-200 bg-cyan-50 p-4 shadow-sm">
                    <p class="text-xs font-semibold uppercase tracking-wide text-cyan-700">Total Loads</p>
                    <p class="mt-2 text-2xl font-bold text-slate-900"><?php echo e($summary['load_count']); ?></p>
                </div>
                <div class="rounded-xl border border-violet-200 bg-violet-50 p-4 shadow-sm">
                    <p class="text-xs font-semibold uppercase tracking-wide text-violet-700">Total Mileage</p>
                    <p class="mt-2 text-2xl font-bold text-slate-900"><?php echo e(number_format((float) $summary['total_miles'], 2)); ?></p>
                </div>
                <div class="rounded-xl border border-emerald-200 bg-emerald-50 p-4 shadow-sm">
                    <p class="text-xs font-semibold uppercase tracking-wide text-emerald-700">Revenue</p>
                    <p class="mt-2 text-2xl font-bold text-slate-900">$<?php echo e(number_format((float) $summary['total_revenue'], 2)); ?></p>
                </div>
                <div class="rounded-xl border border-amber-200 bg-amber-50 p-4 shadow-sm">
                    <p class="text-xs font-semibold uppercase tracking-wide text-amber-700">Profit / Loss</p>
                    <p class="mt-2 text-2xl font-bold text-slate-900">$<?php echo e(number_format((float) $summary['total_profit'], 2)); ?></p>
                </div>
            </div>

            <div class="overflow-hidden rounded-xl border border-emerald-200 bg-gradient-to-br from-white to-emerald-50 shadow">
                <div class="border-b border-emerald-200 bg-gradient-to-r from-emerald-50 to-white px-6 py-4">
                    <h3 class="text-lg font-medium text-gray-900">Company Loads</h3>
                </div>
                <div class="overflow-x-auto">
                    <table class="min-w-full divide-y divide-gray-200">
                        <thead class="bg-emerald-50/40">
                            <tr>
                                <th class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Load</th>
                                <th class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Company / Commodity</th>
                                <th class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Driver</th>
                                <th class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Distance</th>
                                <th class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Rate Snapshot</th>
                                <th class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Revenue</th>
                                <th class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Profit / Loss</th>
                                <th class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Document</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-200 bg-white">
                            <?php $__empty_1 = true; $__currentLoopData = $loads; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $load): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td class="px-6 py-4 text-sm text-gray-900">
                                        <p class="font-semibold"><?php echo e($load->load_number); ?></p>
                                        <p class="text-xs text-gray-500"><?php echo e($load->registration_number ?: 'No registration #'); ?></p>
                                        <p class="text-xs text-gray-500"><?php echo e(optional($load->pickup_date)->format('M d, Y') ?? 'No pickup date'); ?></p>
                                    </td>
                                    <td class="px-6 py-4 text-sm text-gray-600">
                                        <p class="font-medium text-gray-900"><?php echo e($load->broker_company); ?></p>
                                        <p><?php echo e($load->commodity ?: 'General Freight'); ?></p>
                                    </td>
                                    <td class="px-6 py-4 text-sm text-gray-600">
                                        <p><?php echo e($load->driver->name ?? 'Unassigned'); ?></p>
                                        <p class="text-xs text-gray-500"><?php echo e($load->truck->number ?? 'No truck'); ?></p>
                                    </td>
                                    <td class="px-6 py-4 text-sm text-gray-600">
                                        <p><?php echo e(number_format((float) $load->miles, 2)); ?> mi</p>
                                        <p class="text-xs text-gray-500"><?php echo e(number_format((float) $load->weight, 0)); ?> lbs</p>
                                    </td>
                                    <td class="px-6 py-4 text-sm text-gray-600">
                                        <p class="font-medium text-gray-900"><?php echo e(ucfirst(str_replace('_', ' ', $load->rate_type ?? 'per_mile'))); ?></p>
                                        <p class="text-xs text-gray-500">$ <?php echo e(number_format((float) $load->rate_snapshot_per_mile, 2)); ?>/mi</p>
                                        <p class="text-xs text-gray-500">$ <?php echo e(number_format((float) $load->rate_snapshot_additional_charge, 2)); ?> add-ons</p>
                                    </td>
                                    <td class="px-6 py-4 text-sm font-semibold text-emerald-700">$<?php echo e(number_format((float) $load->gross_rate, 2)); ?></td>
                                    <td class="px-6 py-4 text-sm font-semibold <?php echo e((float) $load->net_profit >= 0 ? 'text-teal-700' : 'text-red-600'); ?>">$<?php echo e(number_format((float) $load->net_profit, 2)); ?></td>
                                    <td class="px-6 py-4 text-sm">
                                        <?php if($load->rate_confirmation_path): ?>
                                            <a href="<?php echo e(Storage::url($load->rate_confirmation_path)); ?>" target="_blank" class="font-semibold text-blue-600 hover:text-blue-900">View</a>
                                        <?php else: ?>
                                            -
                                        <?php endif; ?>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="8" class="px-6 py-12 text-center text-sm text-gray-500">No loads yet. Upload a document to start OCR extraction and profit tracking.</td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
                <div class="border-t border-emerald-200 bg-emerald-50/50 px-6 py-4">
                    <?php echo e($loads->links()); ?>

                </div>
            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>

<?php /**PATH D:\true-trucker\web\resources\views/loads/index.blade.php ENDPATH**/ ?>