<?php $__env->startSection('title', 'Ready Stock Inventory – Admin CRM'); ?>
<?php $__env->startSection('page_title', 'Showroom Ready Stock Management'); ?>

<?php $__env->startSection('content'); ?>
<div class="space-y-6">
    
    <!-- Top Action & Filter Header -->
    <div class="bg-slate-900 border border-white/10 rounded-2xl p-4 flex flex-col sm:flex-row items-center justify-between gap-4 shadow-xl">
        <div class="flex items-center gap-2 w-full sm:w-auto">
            <form method="GET" action="<?php echo e(route('admin.inventory.index')); ?>" class="flex items-center gap-2 flex-1 sm:flex-initial">
                <div class="relative">
                    <i class="fa-solid fa-magnifying-glass absolute left-3 top-2.5 text-slate-400 text-xs"></i>
                    <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search stock #, model, chassis..." class="bg-slate-950 border border-white/10 rounded-xl pl-8 pr-3 py-1.5 text-white text-xs focus:border-red-500 focus:outline-none">
                </div>
                <select name="status" class="bg-slate-950 border border-white/10 rounded-xl px-3 py-1.5 text-white text-xs">
                    <option value="">All Statuses</option>
                    <option value="available" <?php echo e(request('status') === 'available' ? 'selected' : ''); ?>>Available</option>
                    <option value="reserved" <?php echo e(request('status') === 'reserved' ? 'selected' : ''); ?>>Reserved</option>
                    <option value="sold" <?php echo e(request('status') === 'sold' ? 'selected' : ''); ?>>Sold</option>
                </select>
                <button type="submit" class="px-3 py-1.5 rounded-xl bg-white/10 hover:bg-white/20 text-white font-bold text-xs transition">
                    Filter
                </button>
            </form>
        </div>

        <a href="<?php echo e(route('admin.inventory.create')); ?>" class="w-full sm:w-auto px-4 py-2 rounded-xl bg-red-600 hover:bg-red-700 text-white font-bold text-xs shadow-lg transition flex items-center justify-center gap-2">
            <i class="fa-solid fa-plus"></i>
            <span>Add Ready Stock Vehicle</span>
        </a>
    </div>

    <!-- Vehicles Table -->
    <div class="bg-slate-900 border border-white/10 rounded-2xl overflow-hidden shadow-xl">
        <div class="overflow-x-auto">
            <table class="w-full text-left text-xs">
                <thead class="bg-slate-950 text-slate-400 uppercase tracking-wider text-[10px] border-b border-white/10">
                    <tr>
                        <th class="p-4">Vehicle Details</th>
                        <th class="p-4">Stock & Chassis #</th>
                        <th class="p-4">Specs</th>
                        <th class="p-4">Price (BDT)</th>
                        <th class="p-4">Grade</th>
                        <th class="p-4">Status</th>
                        <th class="p-4 text-right">Actions</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-white/5 text-slate-300">
                    <?php $__empty_1 = true; $__currentLoopData = $vehicles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $vehicle): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr class="hover:bg-white/5 transition">
                            <td class="p-4">
                                <div class="flex items-center gap-3">
                                    <div class="w-14 h-11 rounded-lg overflow-hidden bg-slate-800 shrink-0">
                                        <img src="<?php echo e($vehicle->main_image); ?>" alt="Car" class="w-full h-full object-cover">
                                    </div>
                                    <div>
                                        <a href="<?php echo e(route('inventory.show', $vehicle->slug ?? $vehicle->id)); ?>" target="_blank" class="font-bold text-white hover:text-red-400">
                                            <?php echo e($vehicle->full_name); ?>

                                        </a>
                                        <span class="text-[10px] text-slate-400 block"><?php echo e($vehicle->variant ?? $vehicle->body_type); ?> · <?php echo e($vehicle->color); ?></span>
                                    </div>
                                </div>
                            </td>
                            <td class="p-4 font-mono text-[11px]">
                                <span class="text-red-400 font-bold block"><?php echo e($vehicle->stock_number); ?></span>
                                <span class="text-slate-400"><?php echo e($vehicle->chassis_number); ?></span>
                            </td>
                            <td class="p-4 text-slate-300">
                                <?php echo e(number_format($vehicle->mileage)); ?> km<br>
                                <span class="text-[10px] text-slate-500"><?php echo e($vehicle->engine_cc); ?>cc · <?php echo e($vehicle->fuel_type); ?></span>
                            </td>
                            <td class="p-4">
                                <span class="font-extrabold text-white text-sm">৳<?php echo e(number_format($vehicle->final_price_bdt)); ?></span>
                                <?php if($vehicle->discount_bdt > 0): ?>
                                    <span class="text-[10px] text-rose-400 block line-through">৳<?php echo e(number_format($vehicle->selling_price_bdt)); ?></span>
                                <?php endif; ?>
                            </td>
                            <td class="p-4 font-bold text-amber-400">
                                <?php echo e($vehicle->auction_grade); ?>

                            </td>
                            <td class="p-4">
                                <?php
                                    $badge = match($vehicle->status) {
                                        'available' => 'bg-emerald-500/20 text-emerald-400',
                                        'reserved' => 'bg-amber-500/20 text-amber-400',
                                        'sold' => 'bg-slate-700 text-slate-400',
                                        default => 'bg-blue-500/20 text-blue-400'
                                    };
                                ?>
                                <span class="px-2.5 py-0.5 rounded-full text-[10px] font-bold uppercase <?php echo e($badge); ?>">
                                    <?php echo e($vehicle->status); ?>

                                </span>
                            </td>
                            <td class="p-4 text-right">
                                <div class="flex items-center justify-end gap-2">
                                    <a href="<?php echo e(route('admin.inventory.edit', $vehicle->id)); ?>" class="px-2.5 py-1.5 rounded-lg bg-white/10 hover:bg-white/20 text-white font-bold transition">
                                        <i class="fa-solid fa-pen-to-square"></i>
                                    </a>
                                    <form method="POST" action="<?php echo e(route('admin.inventory.destroy', $vehicle->id)); ?>" onsubmit="return confirm('Delete this vehicle from showroom inventory?')">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="px-2.5 py-1.5 rounded-lg bg-rose-500/20 hover:bg-rose-500/40 text-rose-300 transition">
                                            <i class="fa-solid fa-trash"></i>
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="7" class="p-8 text-center text-slate-400">
                                No ready stock vehicles found. Click "Add Ready Stock Vehicle" to create one.
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        <div class="p-4 border-t border-white/10">
            <?php echo e($vehicles->links()); ?>

        </div>
    </div>

</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Users/redwoneferdous/Desktop/MotoSolution/resources/views/admin/inventory/index.blade.php ENDPATH**/ ?>