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

<?php $__env->startSection('content'); ?>
<div x-data="{ add: false, edit: null }">
    <div class="mb-5 flex items-center justify-between">
        <div>
            <h1 class="text-xl font-extrabold text-slate-900 lg:text-2xl">Chef profiles</h1>
            <p class="text-sm text-slate-500">The culinary talent behind Epelcon.</p>
        </div>
        <button @click="add = true" class="rounded-xl bg-indigo-600 px-4 py-2.5 text-sm font-bold text-white shadow-lg shadow-indigo-600/25 hover:bg-indigo-700">+ Add chef</button>
    </div>

    <div class="grid gap-4 sm:grid-cols-2 xl:grid-cols-3">
        <?php $__currentLoopData = $chefs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $chef): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200">
                <div class="flex items-start gap-4">
                    <?php if($chef->photo): ?>
                        <img src="<?php echo e(asset($chef->photo)); ?>" alt="<?php echo e($chef->name); ?>" class="h-14 w-14 shrink-0 rounded-2xl object-cover">
                    <?php else: ?>
                        <div class="flex h-14 w-14 shrink-0 items-center justify-center rounded-2xl bg-gradient-to-br from-orange-400 to-rose-500 text-xl font-extrabold text-white">👨‍🍳</div>
                    <?php endif; ?>
                    <div class="min-w-0 flex-1">
                        <p class="font-extrabold text-slate-900"><?php echo e($chef->name); ?> <?php if($chef->featured): ?><span>⭐</span><?php endif; ?></p>
                        <p class="text-xs font-bold uppercase tracking-wide text-orange-600"><?php echo e($chef->title); ?></p>
                        <p class="mt-0.5 text-xs text-slate-500"><?php echo e($chef->years_experience); ?> yrs experience · ★ <?php echo e($chef->rating); ?> · <?php echo e($chef->menu_items_count); ?> dishes</p>
                    </div>
                </div>
                <?php if($chef->specialties): ?><p class="mt-3 text-xs font-semibold text-slate-600">Specialties: <span class="font-normal"><?php echo e($chef->specialties); ?></span></p><?php endif; ?>
                <?php if($chef->bio): ?><p class="mt-2 text-xs leading-relaxed text-slate-500"><?php echo e(Str::limit($chef->bio, 140)); ?></p><?php endif; ?>
                <div class="mt-3 flex items-center justify-between">
                    <span class="rounded-full px-2.5 py-1 text-[10px] font-bold uppercase <?php echo e($chef->status === 'active' ? 'bg-emerald-100 text-emerald-700' : 'bg-slate-100 text-slate-500'); ?>"><?php echo e($chef->status); ?></span>
                    <button @click='edit = <?php echo e(json_encode($chef->only(['id','name','user_id','title','bio','specialties','years_experience','rating','featured','status']))); ?>'
                            class="rounded-lg bg-indigo-50 px-3 py-1.5 text-xs font-bold text-indigo-600 hover:bg-indigo-100">Edit profile</button>
                </div>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>

    
    <template x-for="mode in ['add', 'edit']" :key="mode">
        <div x-cloak x-show="(mode === 'add' && add) || (mode === 'edit' && edit)" class="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
            <div class="absolute inset-0 bg-slate-900/50 backdrop-blur-sm" @click="add = false; edit = null"></div>
            <div x-transition class="relative max-h-[92vh] w-full max-w-lg overflow-y-auto rounded-t-3xl bg-white p-6 shadow-2xl sm:rounded-3xl">
                <h2 class="mb-4 text-lg font-extrabold" x-text="mode === 'add' ? 'Add chef' : 'Edit chef profile'"></h2>
                <form method="POST" :action="mode === 'add' ? '<?php echo e(route('epelcon.chefs.store')); ?>' : '<?php echo e(url('epelcon/chefs')); ?>/' + edit?.id + '/update'" enctype="multipart/form-data" class="grid grid-cols-2 gap-4"><?php echo csrf_field(); ?>
                    <label class="col-span-2"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Profile photo</span>
                        <input type="file" name="photo" accept="image/*" class="w-full rounded-xl border border-slate-200 p-2 text-sm file:mr-3 file:rounded-lg file:border-0 file:bg-indigo-50 file:px-3 file:py-1.5 file:text-xs file:font-bold file:text-indigo-600"></label>
                    <label class="col-span-2"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Full name</span>
                        <input name="name" required :value="mode === 'edit' ? edit?.name : ''" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Title</span>
                        <input name="title" placeholder="Executive Chef" :value="mode === 'edit' ? edit?.title : ''" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Linked staff login</span>
                        <select name="user_id" class="w-full rounded-xl border-slate-200 text-sm" x-init="mode === 'edit' && edit && ($el.value = edit.user_id)">
                            <option value="">—</option>
                            <?php $__currentLoopData = $chefUsers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $chefUser): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($chefUser->id); ?>"><?php echo e($chefUser->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Years experience</span>
                        <input type="number" name="years_experience" min="0" :value="mode === 'edit' ? edit?.years_experience : 0" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Rating (0–5)</span>
                        <input type="number" step="0.1" name="rating" min="0" max="5" :value="mode === 'edit' ? edit?.rating : 4.5" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label class="col-span-2"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Specialties</span>
                        <input name="specialties" :value="mode === 'edit' ? edit?.specialties : ''" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label class="col-span-2"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Bio</span>
                        <textarea name="bio" rows="3" class="w-full rounded-xl border-slate-200 text-sm" x-init="mode === 'edit' && edit && ($el.value = edit.bio ?? '')"></textarea></label>
                    <label class="flex items-center gap-2 text-sm font-semibold text-slate-600"><input type="checkbox" name="featured" value="1" class="rounded text-indigo-600" :checked="mode === 'edit' && edit?.featured"> Featured on website</label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Status</span>
                        <select name="status" class="w-full rounded-xl border-slate-200 text-sm" x-init="mode === 'edit' && edit && ($el.value = edit.status)"><option value="active">Active</option><option value="inactive">Inactive</option></select></label>
                    <div class="col-span-2 flex justify-end gap-2">
                        <button type="button" @click="add = false; edit = null" class="rounded-xl px-4 py-2.5 text-sm font-bold text-slate-500">Cancel</button>
                        <button class="rounded-xl bg-indigo-600 px-5 py-2.5 text-sm font-bold text-white">Save</button>
                    </div>
                </form>
            </div>
        </div>
    </template>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.epelcon', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\hms\resources\views/epelcon/menu/chefs.blade.php ENDPATH**/ ?>