<?php $__env->startSection('title', 'Ajouter un produit'); ?>
<?php $__env->startSection('page-title', 'Ajouter un produit'); ?>

<?php $__env->startSection('content'); ?>

<div class="max-w-3xl mx-auto">

    <div class="mb-6">
        <a href="<?php echo e(route('admin.products.index')); ?>"
           class="inline-flex items-center gap-2 text-sm text-gray-500 hover:text-primary transition-colors">
            <i class="fas fa-arrow-left"></i> Retour aux produits
        </a>
    </div>

    
    <?php if($errors->any()): ?>
    <div class="bg-red-50 border border-red-200 rounded-xl p-4 mb-6">
        <div class="flex items-center gap-2 mb-2">
            <i class="fas fa-exclamation-circle text-red-500"></i>
            <p class="font-semibold text-red-700 text-sm">Veuillez corriger les erreurs suivantes :</p>
        </div>
        <ul class="list-disc list-inside space-y-1">
            <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <li class="text-red-600 text-sm"><?php echo e($error); ?></li>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </ul>
    </div>
    <?php endif; ?>

    <div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
        <div class="px-6 py-4 border-b border-gray-100 bg-gray-50">
            <h2 class="font-semibold text-gray-800 flex items-center gap-2">
                <i class="fas fa-box-open text-primary"></i> Informations du produit
            </h2>
        </div>

        <form action="<?php echo e(route('admin.products.store')); ?>" method="POST"
              enctype="multipart/form-data" class="p-6 space-y-6">
            <?php echo csrf_field(); ?>

            
            <div class="grid grid-cols-1 sm:grid-cols-2 gap-5">
                <div class="sm:col-span-2">
                    <label class="block text-sm font-semibold text-gray-700 mb-1.5">
                        Nom du produit <span class="text-red-500">*</span>
                    </label>
                    <input type="text" name="name" value="<?php echo e(old('name')); ?>" required
                           class="w-full border rounded-xl px-4 py-2.5 text-sm outline-none transition
                                  focus:ring-2 focus:ring-primary focus:border-transparent
                                  <?php echo e($errors->has('name') ? 'border-red-400 bg-red-50' : 'border-gray-200'); ?>"
                           placeholder="Ex : Vase en poterie traditionnelle">
                    <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <p class="text-red-500 text-xs mt-1 flex items-center gap-1">
                        <i class="fas fa-circle-exclamation"></i> <?php echo e($message); ?>

                    </p>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>

                <div>
                    <label class="block text-sm font-semibold text-gray-700 mb-1.5">
                        Catégorie <span class="text-red-500">*</span>
                    </label>
                    <select name="category_id" required
                            class="w-full border rounded-xl px-4 py-2.5 text-sm bg-white outline-none transition
                                   focus:ring-2 focus:ring-primary focus:border-transparent
                                   <?php echo e($errors->has('category_id') ? 'border-red-400 bg-red-50' : 'border-gray-200'); ?>">
                        <option value="">— Sélectionner une catégorie —</option>
                        <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($cat->id); ?>" <?php echo e(old('category_id') == $cat->id ? 'selected' : ''); ?>>
                            <?php echo e($cat->name); ?>

                        </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                    <?php $__errorArgs = ['category_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <p class="text-red-500 text-xs mt-1 flex items-center gap-1">
                        <i class="fas fa-circle-exclamation"></i> <?php echo e($message); ?>

                    </p>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>

                <div>
                    <label class="block text-sm font-semibold text-gray-700 mb-1.5">
                        Prix (FCFA) <span class="text-red-500">*</span>
                    </label>
                    <div class="relative">
                        <input type="number" name="price" value="<?php echo e(old('price')); ?>"
                               required min="0" step="0.01"
                               class="w-full border rounded-xl pl-4 pr-12 py-2.5 text-sm outline-none transition
                                      focus:ring-2 focus:ring-primary focus:border-transparent
                                      <?php echo e($errors->has('price') ? 'border-red-400 bg-red-50' : 'border-gray-200'); ?>"
                               placeholder="0.00">
                        <span class="absolute right-4 top-1/2 -translate-y-1/2 text-gray-400 text-sm font-medium">FCFA</span>
                    </div>
                    <?php $__errorArgs = ['price'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <p class="text-red-500 text-xs mt-1 flex items-center gap-1">
                        <i class="fas fa-circle-exclamation"></i> <?php echo e($message); ?>

                    </p>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>

                <div>
                    <label class="block text-sm font-semibold text-gray-700 mb-1.5">
                        Image du produit
                        <span class="text-gray-400 font-normal">(jpg, png, webp — max 2 Mo)</span>
                    </label>
                    <input type="file" name="image" accept="image/jpeg,image/png,image/webp,image/jpg"
                           class="w-full border rounded-xl px-4 py-2.5 text-sm outline-none transition
                                  focus:ring-2 focus:ring-primary focus:border-transparent
                                  <?php echo e($errors->has('image') ? 'border-red-400 bg-red-50' : 'border-gray-200'); ?>

                                  file:mr-3 file:py-1 file:px-3 file:rounded-lg file:border-0
                                  file:text-xs file:font-medium file:bg-primary file:text-white hover:file:bg-primary-dark">
                    <?php $__errorArgs = ['image'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <p class="text-red-500 text-xs mt-1 flex items-center gap-1">
                        <i class="fas fa-circle-exclamation"></i> <?php echo e($message); ?>

                    </p>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>

                <div class="sm:col-span-2">
                    <label class="block text-sm font-semibold text-gray-700 mb-1.5">
                        Description courte
                        <span class="text-gray-400 font-normal">(affichée sur la carte produit)</span>
                    </label>
                    <input type="text" name="short_description"
                           value="<?php echo e(old('short_description')); ?>" maxlength="500"
                           class="w-full border border-gray-200 rounded-xl px-4 py-2.5 text-sm outline-none transition
                                  focus:ring-2 focus:ring-primary focus:border-transparent"
                           placeholder="Résumé en une phrase...">
                </div>

                <div class="sm:col-span-2">
                    <label class="block text-sm font-semibold text-gray-700 mb-1.5">
                        Description complète <span class="text-red-500">*</span>
                    </label>
                    <textarea name="description" required rows="5"
                              class="w-full border rounded-xl px-4 py-2.5 text-sm outline-none transition resize-none
                                     focus:ring-2 focus:ring-primary focus:border-transparent
                                     <?php echo e($errors->has('description') ? 'border-red-400 bg-red-50' : 'border-gray-200'); ?>"
                              placeholder="Description détaillée du produit, matériaux utilisés, dimensions..."><?php echo e(old('description')); ?></textarea>
                    <?php $__errorArgs = ['description'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <p class="text-red-500 text-xs mt-1 flex items-center gap-1">
                        <i class="fas fa-circle-exclamation"></i> <?php echo e($message); ?>

                    </p>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>

            
            <div class="bg-gray-50 rounded-xl p-4 border border-gray-100">
                <p class="text-sm font-semibold text-gray-700 mb-3">Options de visibilité</p>
                <div class="flex flex-col sm:flex-row gap-4">
                    <label class="flex items-center gap-3 cursor-pointer select-none group">
                        <div class="relative">
                            <input type="checkbox" name="is_active" value="1"
                                   <?php echo e(old('is_active', true) ? 'checked' : ''); ?>

                                   class="sr-only peer">
                            <div class="w-10 h-6 bg-gray-200 rounded-full peer-checked:bg-primary transition-colors"></div>
                            <div class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full shadow transition-transform peer-checked:translate-x-4"></div>
                        </div>
                        <div>
                            <span class="text-sm font-medium text-gray-700">Produit actif</span>
                            <p class="text-xs text-gray-400">Visible sur le site public</p>
                        </div>
                    </label>

                    <label class="flex items-center gap-3 cursor-pointer select-none group">
                        <div class="relative">
                            <input type="checkbox" name="is_featured" value="1"
                                   <?php echo e(old('is_featured') ? 'checked' : ''); ?>

                                   class="sr-only peer">
                            <div class="w-10 h-6 bg-gray-200 rounded-full peer-checked:bg-yellow-400 transition-colors"></div>
                            <div class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full shadow transition-transform peer-checked:translate-x-4"></div>
                        </div>
                        <div>
                            <span class="text-sm font-medium text-gray-700">Produit vedette</span>
                            <p class="text-xs text-gray-400">Affiché sur la page d'accueil</p>
                        </div>
                    </label>
                </div>
            </div>

            
            <div class="flex gap-3 pt-2 border-t border-gray-100">
                <a href="<?php echo e(route('admin.products.index')); ?>"
                   class="flex-1 sm:flex-none px-6 py-3 border border-gray-200 rounded-xl text-sm font-medium
                          text-gray-600 hover:bg-gray-50 transition-colors text-center">
                    Annuler
                </a>
                <button type="submit"
                        class="flex-1 sm:flex-none px-8 py-3 bg-primary text-white rounded-xl text-sm font-bold
                               hover:bg-primary-dark transition-all shadow-sm hover:shadow-md
                               flex items-center justify-center gap-2">
                    <i class="fas fa-save"></i> Enregistrer le produit
                </button>
            </div>
        </form>
    </div>
</div>

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

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/astechc1/public_html/artisanal/resources/views/admin/products/create.blade.php ENDPATH**/ ?>