<?php $pageTitle='Carrier Load '.$load['load_number']; ?>
<div class="page-heading"><div><p class="eyebrow">Carrier Load</p><h1><?= e($load['load_number']) ?></h1><p><?= e($load['pickup_location']) ?> → <?= e($load['delivery_location']) ?></p></div><div class="page-actions"><a class="btn btn-light" href="<?= url('/carrier') ?>">Back to Portal</a></div></div>
<div class="stats-grid compact-stats"><div class="stat-card"><span>Carrier Gross</span><strong><?= money($load['carrier_rate']) ?></strong><small>Before dispatch fee</small></div><div class="stat-card"><span>Dispatch Fee</span><strong><?= money($load['dispatch_fee_amount']) ?></strong><small><?= e(readable_status($load['dispatch_fee_type'])) ?></small></div><div class="stat-card highlight"><span>Carrier Net</span><strong><?= money($load['carrier_net_amount']) ?></strong><small><?= e(readable_status($load['payment_responsibility'])) ?></small></div><div class="stat-card"><span>Status</span><strong class="stat-status"><?= e(readable_status($load['status'])) ?></strong><small><?= e(readable_status($load['carrier_confirmation_status'])) ?></small></div></div>
<div class="content-grid two-col"><section class="panel"><div class="panel-header"><div><p class="eyebrow">Route</p><h2>Stops & Schedule</h2></div></div><div class="driver-stops-list"><?php foreach($load['stops'] as $stop): ?><div class="driver-stop-card <?= $stop['completed_at']?'completed':'' ?>"><div class="stop-main"><span class="stop-number"><?= e((string)$stop['sequence']) ?></span><div><strong><?= e(readable_status($stop['stop_type']).' · '.$stop['location']) ?></strong><p><?= e(datetime_display($stop['scheduled_at'])) ?><?= $stop['contact_name']?' · '.e($stop['contact_name']):'' ?></p><?php if($stop['temperature_reading']!==null): ?><small>Temperature <?= e((string)$stop['temperature_reading'].($stop['temperature_unit']?:$load['temperature_unit'])) ?></small><?php endif; ?></div></div></div><?php endforeach; ?></div></section><section class="panel"><div class="panel-header"><div><p class="eyebrow">Assignment</p><h2>Driver & Equipment</h2></div></div><div class="info-list"><div><span>Driver</span><strong><?= e($load['driver_name']?:'Unassigned') ?></strong></div><div><span>Truck / Trailer</span><strong><?= e(($load['truck_number']?:'-').' / '.($load['trailer_number']?:'-')) ?></strong></div><div><span>Pickup / Delivery</span><strong><?= e(datetime_display($load['pickup_datetime'])) ?></strong><small><?= e(datetime_display($load['delivery_datetime'])) ?></small></div><?php if($load['temperature_controlled']): ?><div><span>Temperature Requirement</span><strong><?= e((string)$load['temperature_setpoint'].$load['temperature_unit']) ?> setpoint</strong><small>Allowed <?= e((string)$load['temperature_min'].'–'.$load['temperature_max'].$load['temperature_unit']) ?> · <?= e(readable_status($load['reefer_mode'])) ?></small></div><?php endif; ?></div></section></div>
<div class="content-grid two-col"><section class="panel"><div class="panel-header"><div><p class="eyebrow">Temperature</p><h2>Reefer Log</h2></div></div><div class="temperature-log-list"><?php foreach($temperatureLogs as $reading): ?><div class="temperature-log-item"><div><strong><?= e((string)$reading['temperature'].$reading['temperature_unit']) ?></strong><span><?= e(datetime_display($reading['recorded_at'])) ?><?= $reading['stop_location']?' · '.e($reading['stop_location']):'' ?></span></div><span><?= e($reading['driver_name']?:'Team') ?></span></div><?php endforeach; ?><?php if(!$temperatureLogs): ?><p class="empty">No temperature readings recorded.</p><?php endif; ?></div></section><section class="panel"><div class="panel-header"><div><p class="eyebrow">Files</p><h2>Load Documents</h2></div></div><div class="mini-list"><?php foreach($documents as $doc): ?><a class="mini-card" href="<?= url('/documents/download?id='.$doc['id']) ?>"><strong><?= e($doc['document_type']) ?></strong><span><?= e($doc['file_name']) ?></span></a><?php endforeach; ?><?php if(!$documents): ?><p class="empty">No documents available.</p><?php endif; ?></div></section></div>
