

<?php $__env->startSection('title', 'Manage Shipments'); ?>

<?php $__env->startSection('content'); ?>
<div class="space-y-6">
    <!-- Header Section -->
    <div class="flex flex-col md:flex-row md:items-center md:justify-between bg-white rounded-xl shadow-sm p-6">
        <div>
            <h1 class="text-2xl font-bold text-gray-900">Manage Shipments</h1>
            <p class="mt-1 text-gray-500">View, filter and manage all your shipments</p>
        </div>
        <div class="mt-4 md:mt-0">
            <a href="<?php echo e(route('admin.shipments.create')); ?>" 
               class="inline-flex items-center justify-center px-4 py-2 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors shadow-sm">
                <i class="fas fa-plus mr-2"></i>
                <span>Add New Shipment</span>
            </a>
        </div>
    </div>

    <!-- Flash Messages -->
    <?php if(session('success')): ?>
        <div class="bg-green-50 border-l-4 border-green-400 p-4 rounded-lg shadow-sm">
            <div class="flex">
                <div class="flex-shrink-0">
                    <i class="fas fa-check-circle text-green-400"></i>
                </div>
                <div class="ml-3">
                    <p class="text-sm text-green-700"><?php echo e(session('success')); ?></p>
                </div>
            </div>
        </div>
    <?php endif; ?>

    <!-- Search and Filter Section -->
    <div class="bg-white rounded-xl shadow-sm overflow-hidden">
        <div class="px-6 py-4 border-b border-gray-100">
            <h2 class="text-lg font-semibold text-gray-900">Search & Filters</h2>
        </div>
        <div class="p-6">
            <form action="<?php echo e(route('admin.shipments.index')); ?>" method="GET" class="grid grid-cols-1 md:grid-cols-4 gap-6">
                <div>
                    <label for="search" class="block text-sm font-medium text-gray-700 mb-1">Search</label>
                    <div class="relative rounded-md shadow-sm">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fas fa-search text-gray-400"></i>
                        </div>
                        <input type="text" name="search" id="search" 
                              value="<?php echo e(request('search')); ?>"
                              placeholder="Tracking number, name, email..."
                              class="pl-10 block w-full rounded-lg border-gray-300 focus:ring-blue-500 focus:border-blue-500">
                    </div>
                </div>
                
                <div>
                    <label for="status" class="block text-sm font-medium text-gray-700 mb-1">Status</label>
                    <div class="relative rounded-md shadow-sm">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fas fa-tag text-gray-400"></i>
                        </div>
                        <select name="status" id="status" 
                                class="pl-10 block w-full rounded-lg border-gray-300 focus:ring-blue-500 focus:border-blue-500">
                            <option value="">All Status</option>
                            <option value="pending" <?php echo e(request('status') == 'pending' ? 'selected' : ''); ?>>Pending</option>
                            <option value="in_transit" <?php echo e(request('status') == 'in_transit' ? 'selected' : ''); ?>>In Transit</option>
                            <option value="delivered" <?php echo e(request('status') == 'delivered' ? 'selected' : ''); ?>>Delivered</option>
                        </select>
                    </div>
                </div>

                <div>
                    <label for="date_range" class="block text-sm font-medium text-gray-700 mb-1">Date Range</label>
                    <div class="relative rounded-md shadow-sm">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fas fa-calendar-alt text-gray-400"></i>
                        </div>
                        <input type="date" name="date_range" id="date_range" 
                              value="<?php echo e(request('date_range')); ?>"
                              class="pl-10 block w-full rounded-lg border-gray-300 focus:ring-blue-500 focus:border-blue-500">
                    </div>
                </div>

                <div class="flex items-end">
                    <button type="submit" 
                            class="w-full flex items-center justify-center px-4 py-2.5 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors shadow-sm">
                        <i class="fas fa-filter mr-2"></i>
                        <span>Apply Filters</span>
                    </button>
                </div>
            </form>
        </div>
    </div>

    <!-- Shipments Table -->
    <div class="bg-white rounded-xl shadow-sm overflow-hidden">
        <div class="px-6 py-4 border-b border-gray-100 flex items-center justify-between">
            <h2 class="text-lg font-semibold text-gray-900">Shipments</h2>
            <div class="text-sm text-gray-600">
                Total: <span class="font-semibold"><?php echo e($shipments->total()); ?></span>
            </div>
        </div>
        
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-200">
                <thead class="bg-gray-50">
                    <tr>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            Tracking Number
                        </th>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            From / To
                        </th>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            Status
                        </th>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            Dates
                        </th>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            Amount
                        </th>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            Actions
                        </th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200">
                    <?php $__empty_1 = true; $__currentLoopData = $shipments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $shipment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4">
                                <div class="text-sm font-medium text-blue-600">
                                    <?php echo e($shipment->tracking_number); ?>

                                </div>
                                <div class="text-xs text-gray-500 mt-1">
                                    <?php echo e($shipment->carrier); ?>

                                </div>
                            </td>
                            <td class="px-6 py-4">
                                <div class="flex flex-col space-y-1">
                                    <div class="text-sm text-gray-900">
                                        <span class="text-xs bg-gray-100 text-gray-800 px-2 py-0.5 rounded mr-1">From</span>
                                        <?php echo e($shipment->sender_name); ?>

                                    </div>
                                    <div class="text-sm text-gray-700">
                                        <span class="text-xs bg-gray-100 text-gray-800 px-2 py-0.5 rounded mr-1">To</span>
                                        <?php echo e($shipment->receiver_name); ?>

                                    </div>
                                </div>
                            </td>
                            <td class="px-6 py-4">
                                <span class="px-2 py-1 inline-flex text-xs leading-5 font-semibold rounded-full 
                                    <?php echo e($shipment->status === 'delivered' ? 'bg-green-100 text-green-800' : 
                                       ($shipment->status === 'in_transit' ? 'bg-yellow-100 text-yellow-800' : 
                                       'bg-gray-100 text-gray-800')); ?>">
                                    <?php echo e(ucfirst($shipment->status)); ?>

                                </span>
                                <?php if($shipment->current_location): ?>
                                    <div class="flex items-center text-xs text-gray-500 mt-2">
                                        <i class="fas fa-map-marker-alt text-gray-400 mr-1"></i>
                                        <?php echo e($shipment->current_location); ?>

                                    </div>
                                <?php endif; ?>
                            </td>
                            <td class="px-6 py-4">
                                <div class="text-xs text-gray-500 flex items-center">
                                    <i class="fas fa-calendar-check text-gray-400 mr-1.5 w-4"></i>
                                    Dispatch: <?php echo e($shipment->dispatch_date); ?>

                                </div>
                                <div class="text-xs text-gray-500 flex items-center mt-1.5">
                                    <i class="fas fa-truck text-gray-400 mr-1.5 w-4"></i>
                                    Delivery: <?php echo e($shipment->delivery_date); ?>

                                </div>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
                                $<?php echo e($shipment->total_f); ?>

                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                <div class="flex flex-col space-y-2">
                                    <div class="flex space-x-2">
                                        <a href="<?php echo e(route('admin.shipments.show', $shipment)); ?>" 
                                           class="text-blue-600 hover:text-blue-900 inline-flex items-center">
                                            <i class="fas fa-eye mr-1"></i> View
                                        </a>
                                        <a href="<?php echo e(route('admin.shipments.edit', $shipment)); ?>" 
                                           class="text-yellow-600 hover:text-yellow-900 inline-flex items-center">
                                            <i class="fas fa-edit mr-1"></i> Edit
                                        </a>
                                    </div>
                                    <div class="flex space-x-2">
                                        <a href="<?php echo e(route('admin.tracking-updates.create', $shipment)); ?>" 
                                           class="text-green-600 hover:text-green-700 inline-flex items-center">
                                            <i class="fas fa-plus-circle mr-1"></i> Add Update
                                        </a>
                                        <a href="<?php echo e(route('admin.shipments.updates.index', $shipment)); ?>" 
                                           class="text-purple-600 hover:text-purple-700 inline-flex items-center">
                                            <i class="fas fa-history mr-1"></i> Updates
                                        </a>
                                    </div>
                                    <form action="<?php echo e(route('admin.shipments.destroy', $shipment)); ?>" 
                                          method="POST" 
                                          onsubmit="return confirm('Are you sure you want to delete this shipment?');"
                                          class="inline">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="text-red-600 hover:text-red-900 inline-flex items-center">
                                            <i class="fas fa-trash-alt mr-1"></i> Delete
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="6" class="px-6 py-10 whitespace-nowrap text-sm text-gray-500 text-center">
                                <div class="flex flex-col items-center">
                                    <i class="fas fa-box-open text-gray-300 text-5xl mb-3"></i>
                                    <span class="font-medium">No shipments found</span>
                                    <p class="text-gray-400 mt-1">Try adjusting your search or filter criteria</p>
                                </div>
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <!-- Pagination -->
        <?php if($shipments->hasPages()): ?>
            <div class="px-6 py-4 border-t border-gray-100">
                <?php echo e($shipments->links()); ?>

            </div>
        <?php endif; ?>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home2/gczzqaya/goldenmuskfreight.com/resources/views/admin/shipments/index.blade.php ENDPATH**/ ?>