<?php $__env->startSection('title', 'Mouvements de stock'); ?>
<?php $__env->startSection('page-title', 'Mouvements de stock'); ?>

<?php $__env->startSection('content'); ?>
<div class="space-y-6">
    
    <div class="p-6 rounded-xl bg-slate-50 border border-slate-200 overflow-x-auto">
        <form method="GET" action="<?php echo e(route('mouvements.index')); ?>" class="flex flex-nowrap items-end gap-6 min-w-max">
            <div class="min-w-[400px]">
                <label for="magasin_id" class="block text-xs font-medium text-slate-500 uppercase tracking-wider mb-2">Magasin</label>
                <select id="magasin_id" name="magasin_id" class="form-input w-full text-sm">
                    <option value="">Tous les magasins</option>
                    <?php $__currentLoopData = $magasins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($m->id); ?>" <?php echo e(request('magasin_id') == $m->id ? 'selected' : ''); ?>><?php echo e($m->nom); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div class="min-w-[360px]">
                <label for="type" class="block text-xs font-medium text-slate-500 uppercase tracking-wider mb-2">Type</label>
                <select id="type" name="type" class="form-input w-full text-sm">
                    <option value="">Tous les types</option>
                    <option value="entree" <?php echo e(request('type') === 'entree' ? 'selected' : ''); ?>>Entrée</option>
                    <option value="sortie" <?php echo e(request('type') === 'sortie' ? 'selected' : ''); ?>>Sortie</option>
                </select>
            </div>
            <div class="flex items-center gap-2 shrink-0">
                <button type="submit" class="inline-flex items-center justify-center gap-2 px-5 py-2.5 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg transition-colors">
                    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" /></svg>
                    Filtrer
                </button>
                <a href="<?php echo e(route('mouvements.index')); ?>" class="inline-flex items-center justify-center gap-2 px-5 py-2.5 border border-slate-300 hover:bg-slate-50 text-slate-700 text-sm font-medium rounded-lg transition-colors">
                    Réinitialiser
                </a>
                <a href="<?php echo e(route('mouvements.export', request()->only(['magasin_id', 'type']))); ?>" class="inline-flex items-center justify-center gap-2 px-5 py-2.5 bg-emerald-600 hover:bg-emerald-700 text-white text-sm font-medium rounded-lg transition-colors">
                    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" /></svg>
                    Exporter
                </a>
            </div>
        </form>
    </div>

    
    <div class="bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden">
        <div class="px-4 sm:px-6 py-4 border-b border-slate-200">
            <h2 class="font-semibold text-slate-800 text-lg">Historique des mouvements</h2>
            <p class="text-sm text-slate-500 mt-1">Entrées, sorties et transferts de stock</p>
        </div>
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-slate-200">
                <thead>
                    <tr>
                        <th class="px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Référence</th>
                        <th class="px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Date</th>
                        <th class="px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Heure</th>
                        <th class="px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Type</th>
                        <th class="px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Magasin</th>
                        <th class="px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Produit</th>
                        <th class="px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Quantité</th>

                    </tr>
                </thead>
                <tbody class="divide-y divide-slate-100">
                    <?php $__empty_1 = true; $__currentLoopData = $mouvements; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mouvement): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="hover:bg-slate-50/50">
                        <td class="px-4 py-3 font-mono text-sm text-slate-500"><?php echo e($mouvement->reference); ?></td>
                        <td class="px-4 py-3 text-slate-600"><?php echo e($mouvement->created_at?->format('d/m/Y') ?? '-'); ?></td>
                        <td class="px-4 py-3 text-slate-600"><?php echo e($mouvement->created_at?->format('H:i') ?? '-'); ?></td>
                        <td>
                            <?php
                            $typeClass = match($mouvement->type ?? '') {
                            'entree' => 'bg-emerald-100 text-emerald-700',
                            'sortie' => 'bg-red-100 text-red-700',
                            default => 'bg-slate-100 text-slate-600',
                            };
                            ?>
                            <span class="inline-flex px-2 py-1 text-xs font-medium rounded-full <?php echo e($typeClass); ?>"><?php echo e($mouvement->type); ?></span>
                        </td>
                        <td class="px-4 py-3 text-slate-800"><?php echo e($mouvement->magasin?->nom ?? '-'); ?></td>
                        <td class="px-4 py-3 text-slate-600"><?php echo e($mouvement->produit?->designation ?? '-'); ?></td>
                        <td class="px-4 py-3 font-semibold <?php echo e(($mouvement->type ?? '') === 'entree' ? 'text-emerald-600' : (($mouvement->type ?? '') === 'sortie' ? 'text-red-600' : 'text-slate-600')); ?>"><?php echo e($mouvement->quantite); ?></td>

                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="6" class="px-4 py-8 text-center text-slate-500">Aucun mouvement trouvé.</td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        <?php if($mouvements->total() > 0): ?>
        <div class="px-4 sm:px-6 py-4 border-t border-slate-200">
            <?php echo e($mouvements->links()); ?>

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

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Softsys\stock_transfert\resources\views\mouvements\index.blade.php ENDPATH**/ ?>