<?php $pageTitle = 'My Loads'; ?>
<div class="panel">
    <div class="panel-header">
        <div><p class="eyebrow">Driver Portal</p><h2>My Assigned Loads</h2><p class="muted">View dispatch details, update trip status, and upload delivery documents.</p></div>
    </div>
    <?php if ($missingDriver): ?>
        <div class="alert alert-info">Your login is not linked to a driver profile yet. Ask an admin to link your user account to your driver record.</div>
    <?php endif; ?>
    <div class="driver-load-grid">
        <?php foreach ($loads as $load): ?>
            <a class="driver-load-card" href="<?= url('/driver/loads/show?id=' . $load['id']) ?>">
                <div class="load-card-top"><strong><?= e($load['load_number']) ?></strong><span class="badge badge-<?= status_class($load['status']) ?>"><?= e(readable_status($load['status'])) ?></span></div>
                <p><?= e($load['pickup_location']) ?> → <?= e($load['delivery_location']) ?></p>
                <small>Pickup: <?= e(datetime_display($load['pickup_datetime'] ?? null)) ?></small><br>
                <small>Delivery: <?= e(datetime_display($load['delivery_datetime'] ?? null)) ?></small><br>
                <small>Truck: <?= e($load['truck_number'] ?? '-') ?> · Trailer: <?= e($load['trailer_number'] ?? '-') ?></small>
            </a>
        <?php endforeach; ?>
        <?php if (!$loads && !$missingDriver): ?><div class="empty-card">No assigned loads right now.</div><?php endif; ?>
    </div>
</div>
