<?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 class="flex justify-between items-center">
            <h2 class="font-semibold text-xl text-slate-900 leading-tight">
                <?php echo e(__('Trips')); ?>

            </h2>
            <a href="<?php echo e(route('trips.create')); ?>" class="bg-indigo-600 text-white px-4 py-2 rounded shadow hover:bg-indigo-700">Add Trip</a>
        </div>
     <?php $__env->endSlot(); ?>

    <div class="py-6">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
            
            <?php if(session('success')): ?>
                <div class="bg-green-100  text-green-700 p-4 rounded shadow-sm" role="alert">
                    <p><?php echo e(session('success')); ?></p>
                </div>
            <?php endif; ?>

            <!-- Filter Bar -->
            <div class="bg-white border border-slate-200 rounded-xl shadow-sm p-4 px-4 sm:px-6">
                <form action="<?php echo e(route('trips.index')); ?>" method="GET" class="grid grid-cols-1 md:grid-cols-5 gap-4 items-end">
                    <div>
                        <label class="block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1">Vehicle</label>
                        <select name="vehicle_id" class="block w-full rounded-lg border-slate-200 text-sm shadow-sm focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500">
                            <option value="">All Vehicles</option>
                            <?php $__currentLoopData = $vehicles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($v->id); ?>" <?php echo e(request('vehicle_id') == $v->id ? 'selected' : ''); ?>><?php echo e($v->vehicle_number); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div>
                        <label class="block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1">Driver</label>
                        <select name="driver_id" class="block w-full rounded-lg border-slate-200 text-sm shadow-sm focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500">
                            <option value="">All Drivers</option>
                            <?php $__currentLoopData = $drivers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($d->id); ?>" <?php echo e(request('driver_id') == $d->id ? 'selected' : ''); ?>><?php echo e($d->driver_name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div>
                        <label class="block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1">Date</label>
                        <input type="date" name="date" value="<?php echo e(request('date')); ?>" class="block w-full rounded-lg border-slate-200 text-sm shadow-sm focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500">
                    </div>
                    <div>
                        <label class="block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1">Type</label>
                        <select name="trip_type" class="block w-full rounded-lg border-slate-200 text-sm shadow-sm focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500">
                            <option value="">All</option>
                            <option value="rent" <?php echo e(request('trip_type') == 'rent' ? 'selected' : ''); ?>>Rent</option>
                            <option value="own" <?php echo e(request('trip_type') == 'own' ? 'selected' : ''); ?>>Own</option>
                            <option value="empty" <?php echo e(request('trip_type') == 'empty' ? 'selected' : ''); ?>>Empty</option>
                        </select>
                    </div>
                    <div class="flex gap-2">
                        <button type="submit" class="flex-1 bg-indigo-600 text-white font-medium text-sm py-2 rounded-lg shadow-sm hover:bg-indigo-700 transition">Filter</button>
                        <a href="<?php echo e(route('trips.index')); ?>" class="px-4 py-2 bg-white border border-slate-200 text-slate-700 text-sm font-medium rounded-lg shadow-sm hover:bg-slate-50 transition flex items-center justify-center">Clear</a>
                    </div>
                </form>
            </div>

            <!-- Table Layout -->
            <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden">
                <div class="overflow-x-auto">
                    <table class="min-w-full divide-y divide-slate-100">
                        <thead class="bg-slate-50/50">
                            <tr>
                                <th class="px-6 py-3 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">Date</th>
                                <th class="px-6 py-3 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">Vehicle & Driver</th>
                                <th class="px-6 py-3 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">Location & Type</th>
                                <th class="px-6 py-3 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">Financials</th>
                                <th class="px-6 py-3 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">Actions</th>
                            </tr>
                        </thead>
                        <tbody class="bg-white divide-y divide-slate-100">
                            <?php $__empty_1 = true; $__currentLoopData = $trips; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $trip): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr class="hover:bg-slate-50/50 transition">
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-slate-900 font-bold">
                                        <?php echo e($trip->date ? $trip->date->format('d M Y') : 'N/A'); ?>

                                    </td>
                                    <td class="px-6 py-4 text-sm text-slate-900">
                                        <div class="font-bold text-blue-600"><?php echo e($trip->vehicle->vehicle_number ?? 'N/A'); ?></div>
                                        <div class="text-xs text-slate-500"><?php echo e($trip->driver->driver_name ?? 'N/A'); ?></div>
                                    </td>
                                    <td class="px-6 py-4 text-sm text-slate-900">
                                        <div class="font-bold"><?php echo e($trip->location); ?></div>
                                        <div class="flex gap-2 items-center mt-1">
                                            <span class="px-2 py-0.5 bg-slate-50/80 text-[10px] font-bold rounded uppercase"><?php echo e($trip->trip_type); ?></span>
                                            <span class="text-xs text-slate-500"><?php echo e($trip->total_km); ?> km</span>
                                            <span class="text-xs text-indigo-500 font-bold ml-1"><?php echo e($trip->total_hour); ?> hrs</span>
                                        </div>
                                        <?php if($trip->work): ?>
                                            <div class="mt-1 text-xs text-slate-600"><strong>Work:</strong> <?php echo e($trip->work); ?></div>
                                        <?php endif; ?>
                                        <?php if($trip->maintenance_note || $trip->loan_note): ?>
                                            <div class="mt-2 space-y-1">
                                                <?php if($trip->maintenance_note): ?>
                                                    <p class="text-[10px] text-orange-600 bg-orange-50 px-1.5 py-0.5 rounded inline-block">🛠️ <?php echo e($trip->maintenance_note); ?></p>
                                                <?php endif; ?>
                                                <?php if($trip->loan_note): ?>
                                                    <p class="text-[10px] text-purple-600 bg-purple-50 px-1.5 py-0.5 rounded inline-block">💰 <?php echo e($trip->loan_note); ?></p>
                                                <?php endif; ?>
                                            </div>
                                        <?php endif; ?>


                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-slate-900">
                                        <div class="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1 text-xs">
                                            <span class="text-slate-500">Total Amount:</span> <span class="font-bold text-green-600 text-right">₹<?php echo e(number_format($trip->total_amount, 2)); ?></span>

                                            <span class="text-slate-500">Fuel:</span> <span class="font-bold text-red-500 text-right">₹<?php echo e(number_format($trip->fuel_cost, 2)); ?></span>
                                            <span class="text-slate-500 font-bold">Profit:</span> <span class="font-black text-blue-600 text-right">₹<?php echo e(number_format($trip->profit, 2)); ?></span>
                                        </div>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                        <div class="flex space-x-2">
                                            <a href="<?php echo e(route('trips.edit', $trip)); ?>" class="text-slate-600 hover:text-slate-900 bg-slate-50 hover:bg-slate-100 border border-slate-200 px-2 py-1 rounded transition">Edit</a>
                                            <a href="<?php echo e(route('trips.payments', $trip)); ?>" class="text-green-600 hover:text-green-900 bg-green-50 px-2 py-1 rounded transition">Pay</a>
                                            <form action="<?php echo e(route('trips.destroy', $trip)); ?>" method="POST" class="inline" onsubmit="return confirm('Delete this trip?')">
                                                <?php echo csrf_field(); ?>
                                                <?php echo method_field('DELETE'); ?>
                                                <button type="submit" class="text-rose-600 hover:text-rose-900 bg-rose-50 hover:bg-rose-100 border border-rose-100 px-2 py-1 rounded transition">Del</button>
                                            </form>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="5" class="px-6 py-8 text-center text-slate-500 font-bold">
                                        No trips found matching the criteria.
                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
            
            <div class="mt-4 ">
                <?php echo e($trips->links()); ?>

            </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 /Users/roni/Documents/Vicky/vms/resources/views/trips/index.blade.php ENDPATH**/ ?>