<?php
    $isLight = Auth('admin')->User()->dashboard_style == 'light';
    $text = $isLight ? 'dark' : 'light';
    $currentStatus = $shipment->status ?: 'Pending';
    $holdStatuses = ['Custom Hold', 'Customs Inspection', 'Seized by custom', 'Awaiting Payment'];
    $statusOptions = [
        'Order Confirmed',
        'Picked by Courier',
        'On The Way',
        'Custom Hold',
        'Delivered',
        'Customs Inspection',
        'Customs Clearance',
        'Processing Shipment',
        'In transit',
        'Out for delivery',
        'Seized by custom',
        'Awaiting Payment',
    ];
    $statusClass = $currentStatus == 'Delivered' ? 'delivered' : (in_array($currentStatus, $holdStatuses, true) ? 'hold' : 'active');
    $statusIcon = $currentStatus == 'Delivered' ? 'fa-check-circle' : (in_array($currentStatus, $holdStatuses, true) ? 'fa-exclamation-triangle' : 'fa-truck');
?>



<?php $__env->startSection('content'); ?>
<style>
    .status-update-page{max-width:1180px;margin:0 auto;color:#102033}.status-hero{background:linear-gradient(135deg,#0f2742,#155c9d);border-radius:22px;padding:18px;box-shadow:0 18px 45px rgba(15,23,42,.14);color:#fff;margin-bottom:14px;display:flex;align-items:center;justify-content:space-between;gap:16px;overflow:hidden;position:relative}.status-hero:before{content:"";position:absolute;right:-80px;top:-95px;width:230px;height:230px;border-radius:999px;background:rgba(255,255,255,.16)}.status-hero>*{position:relative;z-index:1}.status-kicker{display:inline-flex;align-items:center;gap:7px;border:1px solid rgba(255,255,255,.18);background:rgba(255,255,255,.12);border-radius:999px;padding:5px 10px;font-size:11px;font-weight:850;text-transform:uppercase;letter-spacing:.04em;color:#dbeafe}.status-hero h2{margin:8px 0 4px;color:#fff;font-size:24px;font-weight:900;letter-spacing:-.03em}.status-hero p{margin:0;color:rgba(226,232,240,.9);font-size:13px}.status-chip{display:inline-flex;align-items:center;gap:8px;border-radius:999px;padding:8px 12px;font-size:12px;font-weight:900;background:#e0f2fe;color:#075985;white-space:nowrap}.status-chip.delivered{background:#dcfce7;color:#166534}.status-chip.hold{background:#fef3c7;color:#92400e}.status-shell{display:grid;grid-template-columns:350px 1fr;gap:14px;align-items:start}.status-card{background:#fff;border:1px solid #e5edf7;border-radius:18px;box-shadow:0 12px 28px rgba(15,23,42,.06);overflow:hidden}.status-card-head{padding:12px 14px;border-bottom:1px solid #edf2f8;background:linear-gradient(180deg,#fbfdff,#f8fafc);display:flex;align-items:center;justify-content:space-between;gap:10px}.status-card-head h5{margin:0;color:#172b4d;font-size:14px;font-weight:900}.status-card-head i{width:34px;height:34px;border-radius:12px;background:#eaf3ff;color:#155c9d;display:flex;align-items:center;justify-content:center}.status-card-body{padding:14px}.status-barcode{background:#f8fafc;border:1px dashed #cbd5e1;border-radius:14px;padding:11px;text-align:center;margin-bottom:12px}.status-barcode img{max-width:100%;height:auto}.status-tracking{display:block;margin-top:6px;font-size:13px;font-weight:900;color:#172b4d;word-break:break-word}.status-info-list{display:grid;gap:8px}.status-info-row{display:grid;grid-template-columns:94px 1fr;gap:8px;align-items:start;border:1px solid #edf2f8;background:#fbfdff;border-radius:12px;padding:9px}.status-info-row span{font-size:10px;color:#64748b;font-weight:900;text-transform:uppercase;letter-spacing:.04em}.status-info-row strong{font-size:12px;color:#102033;font-weight:850;word-break:break-word}.status-detail-btn{margin-top:12px;border-radius:12px;font-weight:850}.status-main{display:grid;gap:14px}.status-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.status-field.full{grid-column:1/-1}.status-field label{font-size:11px;font-weight:900;color:#475569;text-transform:uppercase;letter-spacing:.04em;margin-bottom:6px}.status-field .form-control,.status-field .form-select{border:1px solid #dbe5ef;border-radius:12px;min-height:42px;font-size:13px;color:#102033;background:#fff}.status-field textarea.form-control{min-height:96px;resize:vertical}.status-notify{display:flex;align-items:center;gap:9px;background:#f8fafc;border:1px solid #e5edf7;border-radius:12px;padding:10px 12px;margin:2px 0 12px}.status-notify label{margin:0;font-weight:800;color:#334155;font-size:13px}.status-submit{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:13px;padding:11px 16px;background:linear-gradient(135deg,#155c9d,#0f766e);color:#fff;font-weight:900;box-shadow:0 12px 24px rgba(21,92,157,.22)}.status-submit:hover{color:#fff;filter:brightness(.98);transform:translateY(-1px)}.status-timeline{position:relative;display:grid;gap:10px}.status-track{display:grid;grid-template-columns:34px 1fr;gap:10px;align-items:start}.status-track-dot{width:28px;height:28px;border-radius:999px;background:#e0f2fe;color:#075985;display:flex;align-items:center;justify-content:center;margin-top:3px;box-shadow:0 0 0 5px #f0f9ff}.status-track-dot.delivered{background:#dcfce7;color:#166534;box-shadow:0 0 0 5px #f0fdf4}.status-track-dot.hold{background:#fef3c7;color:#92400e;box-shadow:0 0 0 5px #fffbeb}.status-track-card{border:1px solid #e5edf7;background:#fbfdff;border-radius:14px;padding:10px 12px}.status-track-card h6{margin:0 0 5px;font-size:13px;color:#172b4d;font-weight:900}.status-track-meta{color:#64748b;font-size:11px;font-weight:750;display:flex;flex-wrap:wrap;gap:8px;margin-bottom:6px}.status-track-card p{margin:0;color:#475569;font-size:12.5px;line-height:1.45}.status-empty{padding:26px;text-align:center;color:#64748b;background:#fbfdff;border:1px dashed #cbd5e1;border-radius:14px}@media(max-width:991px){.status-shell{grid-template-columns:1fr}.status-hero{align-items:flex-start}.status-card-body{padding:12px}.status-info-list{grid-template-columns:repeat(2,minmax(0,1fr))}.status-info-row{grid-template-columns:1fr}}@media(max-width:575px){.status-update-page{max-width:none}.status-hero{display:block;border-radius:16px;padding:14px;margin-bottom:10px}.status-hero h2{font-size:20px}.status-chip{margin-top:12px}.status-shell,.status-main{gap:10px}.status-card{border-radius:14px}.status-card-head{padding:10px 12px}.status-info-list,.status-form-grid{grid-template-columns:1fr}.status-field.full{grid-column:auto}.status-submit{width:100%;min-height:44px}.status-track{grid-template-columns:28px 1fr;gap:8px}.status-track-dot{width:24px;height:24px}.status-track-meta{display:block}.status-track-meta span{display:block;margin-bottom:3px}}
</style>

<div class="status-update-page">
    <div class="status-hero">
        <div>
            <span class="status-kicker"><i class="fa fa-shipping-fast"></i> Shipment Control</span>
            <h2>Update Shipment Status</h2>
            <p>Keep the customer tracking timeline current with the latest courier movement.</p>
        </div>
        <span class="status-chip <?php echo e($statusClass); ?>">
            <i class="fa <?php echo e($statusIcon); ?>"></i>
            <?php echo e($currentStatus); ?>

        </span>
    </div>

    <?php if (isset($component)) { $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4 = $component; } ?>
<?php $component = $__env->getContainer()->make(Illuminate\View\AnonymousComponent::class, ['view' => 'components.danger-alert','data' => []]); ?>
<?php $component->withName('danger-alert'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4)): ?>
<?php $component = $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4; ?>
<?php unset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4); ?>
<?php endif; ?>
    <?php if (isset($component)) { $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4 = $component; } ?>
<?php $component = $__env->getContainer()->make(Illuminate\View\AnonymousComponent::class, ['view' => 'components.success-alert','data' => []]); ?>
<?php $component->withName('success-alert'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4)): ?>
<?php $component = $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4; ?>
<?php unset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4); ?>
<?php endif; ?>

    <div class="status-shell">
        <aside class="status-card">
            <div class="status-card-head">
                <h5>Shipment Summary</h5>
                <i class="fa fa-barcode"></i>
            </div>
            <div class="status-card-body">
                <div class="status-barcode">
                    <img src="https://barcode.tec-it.com/barcode.ashx?data=<?php echo e($shipment->trackingnumber); ?>&code=Code128" alt="Shipment barcode">
                    <span class="status-tracking"><?php echo e($shipment->trackingnumber); ?></span>
                </div>

                <div class="status-info-list">
                    <div class="status-info-row"><span>Sender</span><strong><?php echo e($shipment->sname); ?></strong></div>
                    <div class="status-info-row"><span>Sender Email</span><strong><?php echo e($shipment->semail ?: 'Not provided'); ?></strong></div>
                    <div class="status-info-row"><span>Receiver</span><strong><?php echo e($shipment->name); ?></strong></div>
                    <div class="status-info-row"><span>Origin</span><strong><?php echo e($shipment->take_off_point); ?></strong></div>
                    <div class="status-info-row"><span>Destination</span><strong><?php echo e($shipment->final_destination); ?></strong></div>
                    <div class="status-info-row"><span>Created</span><strong><?php echo e(\Carbon\Carbon::parse($shipment->created_at)->toDayDateTimeString()); ?></strong></div>
                    <div class="status-info-row"><span>Status</span><strong><?php echo e($currentStatus); ?></strong></div>
                </div>

                <a href="<?php echo e(route('admin.shipments.view', $shipment->id)); ?>" class="btn btn-primary status-detail-btn w-100">
                    <i class="fa fa-eye"></i> View Shipment Details
                </a>
            </div>
        </aside>

        <main class="status-main">
            <section class="status-card">
                <div class="status-card-head">
                    <h5>New Tracking Update</h5>
                    <i class="fa fa-pen"></i>
                </div>
                <div class="status-card-body">
                    <form method="POST" action="<?php echo e(route('admin.shipments.update-status')); ?>">
                        <?php echo csrf_field(); ?>
                        <input type="hidden" name="shipment_id" value="<?php echo e($shipment->id); ?>">

                        <div class="status-form-grid">
                            <div class="status-field">
                                <label class="form-label">New Status</label>
                                <select class="form-select" name="status" required>
                                    <?php $__currentLoopData = $statusOptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($status); ?>" <?php echo e(old('status', $currentStatus) == $status ? 'selected' : ''); ?>><?php echo e($status); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>

                            <div class="status-field">
                                <label class="form-label">Current Location</label>
                                <input type="text" class="form-control" name="location" placeholder="City, country or facility" required>
                            </div>

                            <div class="status-field full">
                                <label class="form-label">Comment</label>
                                <textarea class="form-control" rows="4" name="comment" placeholder="Add a concise customer-facing update" required></textarea>
                            </div>

                            <div class="status-field full">
                                <label class="form-label">Email Alert</label>
                                <select class="form-select" name="send_email_alert" required>
                                    <option value="1" <?php echo e(old('send_email_alert', '1') == '1' ? 'selected' : ''); ?>>Send email alert to receiver and sender</option>
                                    <option value="0" <?php echo e(old('send_email_alert') == '0' ? 'selected' : ''); ?>>Do not send email alert</option>
                                </select>
                            </div>
                        </div>

                        <button class="status-submit" type="submit">
                            <i class="fa fa-paper-plane"></i> Update Status
                        </button>
                    </form>
                </div>
            </section>

            <section class="status-card">
                <div class="status-card-head">
                    <h5>Status History</h5>
                    <i class="fa fa-route"></i>
                </div>
                <div class="status-card-body">
                    <div class="status-timeline">
                        <?php $__empty_1 = true; $__currentLoopData = $tracks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $track): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <?php
                                $trackClass = $track->status == 'Delivered' ? 'delivered' : (in_array($track->status, $holdStatuses, true) ? 'hold' : 'active');
                                $trackIcon = $track->status == 'Delivered' ? 'fa-check' : (in_array($track->status, $holdStatuses, true) ? 'fa-exclamation' : 'fa-map-marker-alt');
                            ?>
                            <div class="status-track">
                                <div class="status-track-dot <?php echo e($trackClass); ?>">
                                    <i class="fa <?php echo e($trackIcon); ?>"></i>
                                </div>
                                <div class="status-track-card">
                                    <div class="d-flex justify-content-between align-items-start">
                                        <h6><?php echo e($track->status); ?></h6>
                                        <form action="<?php echo e(route('admin.shipments.delete-tracking', $track->id)); ?>" method="POST" onsubmit="return confirm('Delete this tracking record?');" class="m-0">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="submit" class="btn btn-sm btn-danger" title="Delete this record">
                                                <i class="fa fa-trash-alt"></i>
                                            </button>
                                        </form>
                                    </div>
                                    <div class="status-track-meta">
                                        <span><i class="fa fa-map-marker-alt"></i> <?php echo e($track->address); ?></span>
                                        <span><i class="fa fa-clock"></i> <?php echo e(\Carbon\Carbon::parse($track->created_at)->format('M d, Y - h:i A')); ?></span>
                                    </div>
                                    <p><?php echo e($track->comment); ?></p>
                                </div>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <div class="status-empty">No tracking updates have been added yet.</div>
                        <?php endif; ?>
                    </div>
                </div>
            </section>
        </main>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/purecarg/public_html/resources/views/admin/update-shipment-status.blade.php ENDPATH**/ ?>