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

<?php $__env->startSection('content'); ?>
<div x-data="{ tab: 'promos', addPromo: false }">
    <div class="mb-5 flex items-center justify-between">
        <div>
            <h1 class="text-xl font-extrabold text-slate-900 lg:text-2xl">Room settings</h1>
            <p class="text-sm text-slate-500">Promo codes, bed types, booking channels and complementary perks.</p>
        </div>
        <button x-show="tab === 'promos'" @click="addPromo = 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">+ New promo</button>
    </div>

    
    <div class="no-scrollbar mb-5 flex gap-2 overflow-x-auto">
        <?php $__currentLoopData = [['promos', 'Promo codes'], ['beds', 'Bed types'], ['btypes', 'Booking types'], ['comp', 'Complementary']]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$key, $label]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <button @click="tab = '<?php echo e($key); ?>'"
                    :class="tab === '<?php echo e($key); ?>' ? 'bg-slate-900 text-white' : 'bg-white text-slate-600 ring-1 ring-slate-200'"
                    class="shrink-0 rounded-full px-4 py-2 text-xs font-bold"><?php echo e($label); ?></button>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>

    
    <div x-show="tab === 'promos'" x-cloak>
        <div class="mb-5 grid gap-3 sm:grid-cols-3">
            <div class="rounded-2xl bg-white p-4 shadow-sm ring-1 ring-slate-200"><p class="text-xs font-bold uppercase text-slate-400">Active promos</p><p class="mt-1 text-2xl font-extrabold text-emerald-600"><?php echo e($promoStats['active']); ?></p></div>
            <div class="rounded-2xl bg-white p-4 shadow-sm ring-1 ring-slate-200"><p class="text-xs font-bold uppercase text-slate-400">Total redemptions</p><p class="mt-1 text-2xl font-extrabold text-indigo-600"><?php echo e(number_format($promoStats['redemptions'])); ?></p></div>
            <div class="rounded-2xl bg-white p-4 shadow-sm ring-1 ring-slate-200"><p class="text-xs font-bold uppercase text-slate-400">All codes</p><p class="mt-1 text-2xl font-extrabold text-slate-900"><?php echo e($promos->count()); ?></p></div>
        </div>

        <div class="overflow-x-auto rounded-2xl bg-white shadow-sm ring-1 ring-slate-200">
            <table class="w-full min-w-[820px] text-sm">
                <thead><tr class="border-b border-slate-100 bg-slate-50 text-left text-xs font-bold uppercase text-slate-400">
                    <th class="px-4 py-3">Code</th><th class="px-4 py-3">Discount</th><th class="px-4 py-3">Applies to</th><th class="px-4 py-3">Uses</th><th class="px-4 py-3">Validity</th><th class="px-4 py-3">Status</th><th class="px-4 py-3"></th>
                </tr></thead>
                <tbody class="divide-y divide-slate-100">
                <?php $__empty_1 = true; $__currentLoopData = $promos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $promo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="hover:bg-slate-50">
                        <td class="px-4 py-3 font-mono font-extrabold text-slate-900"><?php echo e($promo->code); ?></td>
                        <td class="px-4 py-3 font-bold text-slate-800"><?php echo e($promo->type === 'percent' ? rtrim(rtrim(number_format($promo->value, 2), '0'), '.') . '%' : $CUR . number_format($promo->value, 2)); ?> off</td>
                        <td class="px-4 py-3"><span class="rounded-full bg-slate-100 px-2.5 py-1 text-[10px] font-bold uppercase text-slate-600"><?php echo e($promo->applies_to); ?></span></td>
                        <td class="px-4 py-3 text-slate-600"><?php echo e(number_format($promo->used_count)); ?> / <?php echo e($promo->max_uses > 0 ? number_format($promo->max_uses) : '∞'); ?></td>
                        <td class="px-4 py-3 text-xs text-slate-500">
                            <?php if($promo->starts_at || $promo->expires_at): ?>
                                <?php echo e($promo->starts_at?->format('j M Y') ?? 'Anytime'); ?> → <?php echo e($promo->expires_at?->format('j M Y') ?? 'No expiry'); ?>

                            <?php else: ?>
                                Always valid
                            <?php endif; ?>
                        </td>
                        <td class="px-4 py-3">
                            <?php if($promo->isValid()): ?>
                                <span class="rounded-full bg-emerald-100 px-2.5 py-1 text-[10px] font-bold uppercase text-emerald-700">Active</span>
                            <?php elseif($promo->status === 'active'): ?>
                                <span class="rounded-full bg-amber-100 px-2.5 py-1 text-[10px] font-bold uppercase text-amber-700">Expired / used up</span>
                            <?php else: ?>
                                <span class="rounded-full bg-slate-100 px-2.5 py-1 text-[10px] font-bold uppercase text-slate-500">Inactive</span>
                            <?php endif; ?>
                        </td>
                        <td class="px-4 py-3">
                            <form method="POST" action="<?php echo e(route('epelcon.roomsettings.promos.toggle', $promo)); ?>" class="flex justify-end"><?php echo csrf_field(); ?>
                                <?php if($promo->status === 'active'): ?>
                                    <button class="rounded-lg bg-rose-50 px-2.5 py-1.5 text-[11px] font-bold text-rose-600 hover:bg-rose-100">Deactivate</button>
                                <?php else: ?>
                                    <button class="rounded-lg bg-emerald-50 px-2.5 py-1.5 text-[11px] font-bold text-emerald-700 hover:bg-emerald-100">Activate</button>
                                <?php endif; ?>
                            </form>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="7" class="px-4 py-10 text-center text-slate-400">No promo codes yet — create one to boost direct bookings.</td></tr>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>

    
    <div x-show="tab === 'beds'" x-cloak class="grid gap-5 lg:grid-cols-3">
        <div class="overflow-x-auto rounded-2xl bg-white shadow-sm ring-1 ring-slate-200 lg:col-span-2">
            <table class="w-full text-sm">
                <thead><tr class="border-b border-slate-100 bg-slate-50 text-left text-xs font-bold uppercase text-slate-400">
                    <th class="px-4 py-3">Name</th><th class="px-4 py-3">Description</th><th class="px-4 py-3"></th>
                </tr></thead>
                <tbody class="divide-y divide-slate-100">
                <?php $__empty_1 = true; $__currentLoopData = $bedTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bed): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="hover:bg-slate-50">
                        <td class="px-4 py-3 font-bold text-slate-800"><?php echo e($bed->name); ?></td>
                        <td class="px-4 py-3 text-slate-500"><?php echo e($bed->description ?? '—'); ?></td>
                        <td class="px-4 py-3">
                            <form method="POST" action="<?php echo e(route('epelcon.roomsettings.beds.delete', $bed)); ?>" class="flex justify-end" onsubmit="return confirm('Remove this bed type?')"><?php echo csrf_field(); ?>
                                <button class="rounded-lg bg-rose-50 px-2.5 py-1.5 text-[11px] font-bold text-rose-600 hover:bg-rose-100">Delete</button>
                            </form>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="3" class="px-4 py-10 text-center text-slate-400">No bed types configured.</td></tr>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
        <div class="h-fit rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200">
            <h2 class="mb-3 font-bold text-slate-900">Add bed type</h2>
            <form method="POST" action="<?php echo e(route('epelcon.roomsettings.beds.store')); ?>" class="space-y-3"><?php echo csrf_field(); ?>
                <label class="block"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Name</span>
                    <input name="name" required maxlength="80" placeholder="e.g. King" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label class="block"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Description</span>
                    <input name="description" maxlength="255" placeholder="Optional" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <button class="w-full rounded-xl bg-indigo-600 py-2.5 text-sm font-bold text-white hover:bg-indigo-700">Add bed type</button>
            </form>
        </div>
    </div>

    
    <div x-show="tab === 'btypes'" x-cloak class="grid gap-5 lg:grid-cols-3">
        <div class="overflow-x-auto rounded-2xl bg-white shadow-sm ring-1 ring-slate-200 lg:col-span-2">
            <table class="w-full text-sm">
                <thead><tr class="border-b border-slate-100 bg-slate-50 text-left text-xs font-bold uppercase text-slate-400">
                    <th class="px-4 py-3">Name</th><th class="px-4 py-3 text-right">Commission</th><th class="px-4 py-3"></th>
                </tr></thead>
                <tbody class="divide-y divide-slate-100">
                <?php $__empty_1 = true; $__currentLoopData = $bookingTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="hover:bg-slate-50">
                        <td class="px-4 py-3 font-bold text-slate-800"><?php echo e($type->name); ?></td>
                        <td class="px-4 py-3 text-right font-extrabold text-slate-900"><?php echo e(rtrim(rtrim(number_format($type->commission_percent, 2), '0'), '.')); ?>%</td>
                        <td class="px-4 py-3">
                            <form method="POST" action="<?php echo e(route('epelcon.roomsettings.btypes.delete', $type)); ?>" class="flex justify-end" onsubmit="return confirm('Remove this booking type?')"><?php echo csrf_field(); ?>
                                <button class="rounded-lg bg-rose-50 px-2.5 py-1.5 text-[11px] font-bold text-rose-600 hover:bg-rose-100">Delete</button>
                            </form>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="3" class="px-4 py-10 text-center text-slate-400">No booking types configured.</td></tr>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
        <div class="h-fit rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200">
            <h2 class="mb-3 font-bold text-slate-900">Add booking type</h2>
            <form method="POST" action="<?php echo e(route('epelcon.roomsettings.btypes.store')); ?>" class="space-y-3"><?php echo csrf_field(); ?>
                <label class="block"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Name</span>
                    <input name="name" required maxlength="80" placeholder="e.g. Travel Agent" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label class="block"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Commission %</span>
                    <input type="number" step="0.01" min="0" max="100" name="commission_percent" value="0" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <button class="w-full rounded-xl bg-indigo-600 py-2.5 text-sm font-bold text-white hover:bg-indigo-700">Add booking type</button>
            </form>
        </div>
    </div>

    
    <div x-show="tab === 'comp'" x-cloak class="grid gap-5 lg:grid-cols-3">
        <div class="overflow-x-auto rounded-2xl bg-white shadow-sm ring-1 ring-slate-200 lg:col-span-2">
            <table class="w-full min-w-[520px] text-sm">
                <thead><tr class="border-b border-slate-100 bg-slate-50 text-left text-xs font-bold uppercase text-slate-400">
                    <th class="px-4 py-3">Item</th><th class="px-4 py-3">Room type</th><th class="px-4 py-3"></th>
                </tr></thead>
                <tbody class="divide-y divide-slate-100">
                <?php $__empty_1 = true; $__currentLoopData = $complementaryItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="hover:bg-slate-50">
                        <td class="px-4 py-3"><p class="font-bold text-slate-800"><?php echo e($item->name); ?></p><?php if($item->description): ?><p class="text-xs text-slate-400"><?php echo e($item->description); ?></p><?php endif; ?></td>
                        <td class="px-4 py-3">
                            <?php if($item->roomType): ?>
                                <span class="rounded-full bg-indigo-50 px-2.5 py-1 text-[10px] font-bold uppercase text-indigo-700"><?php echo e($item->roomType->name); ?></span>
                            <?php else: ?>
                                <span class="text-xs text-slate-400">All rooms</span>
                            <?php endif; ?>
                        </td>
                        <td class="px-4 py-3">
                            <form method="POST" action="<?php echo e(route('epelcon.roomsettings.comp.delete', $item)); ?>" class="flex justify-end" onsubmit="return confirm('Remove this complementary item?')"><?php echo csrf_field(); ?>
                                <button class="rounded-lg bg-rose-50 px-2.5 py-1.5 text-[11px] font-bold text-rose-600 hover:bg-rose-100">Delete</button>
                            </form>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="3" class="px-4 py-10 text-center text-slate-400">No complementary items configured.</td></tr>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
        <div class="h-fit rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200">
            <h2 class="mb-3 font-bold text-slate-900">Add complementary item</h2>
            <form method="POST" action="<?php echo e(route('epelcon.roomsettings.comp.store')); ?>" class="space-y-3"><?php echo csrf_field(); ?>
                <label class="block"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Name</span>
                    <input name="name" required maxlength="120" placeholder="e.g. Welcome drink" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label class="block"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Description</span>
                    <input name="description" maxlength="255" placeholder="Optional" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label class="block"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Room type</span>
                    <select name="room_type_id" class="w-full rounded-xl border-slate-200 text-sm">
                        <option value="">All room types</option>
                        <?php $__currentLoopData = $roomTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $roomType): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($roomType->id); ?>"><?php echo e($roomType->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select></label>
                <button class="w-full rounded-xl bg-indigo-600 py-2.5 text-sm font-bold text-white hover:bg-indigo-700">Add item</button>
            </form>
        </div>
    </div>

    
    <div x-cloak x-show="addPromo" 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="addPromo = false"></div>
        <div x-show="addPromo" 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">New promo code</h2>
            <form method="POST" action="<?php echo e(route('epelcon.roomsettings.promos.store')); ?>" 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">Code</span>
                    <input name="code" required maxlength="30" placeholder="e.g. WELCOME10" value="<?php echo e(old('code')); ?>" class="w-full rounded-xl border-slate-200 font-mono text-sm uppercase" style="text-transform: uppercase"></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Type</span>
                    <select name="type" class="w-full rounded-xl border-slate-200 text-sm">
                        <option value="percent">Percent off</option>
                        <option value="fixed">Fixed amount (<?php echo e($CUR); ?>)</option>
                    </select></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Value</span>
                    <input type="number" step="0.01" min="0.01" name="value" required value="<?php echo e(old('value')); ?>" 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">Applies to</span>
                    <select name="applies_to" class="w-full rounded-xl border-slate-200 text-sm">
                        <option value="bookings">Bookings</option>
                        <option value="orders">Orders</option>
                        <option value="both">Both</option>
                    </select></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Max uses (0 = unlimited)</span>
                    <input type="number" min="0" name="max_uses" value="<?php echo e(old('max_uses', 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">Starts</span>
                    <input type="date" name="starts_at" value="<?php echo e(old('starts_at')); ?>" 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">Expires</span>
                    <input type="date" name="expires_at" value="<?php echo e(old('expires_at')); ?>" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <div class="col-span-2 flex justify-end gap-2">
                    <button type="button" @click="addPromo = false" 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">Create promo</button>
                </div>
            </form>
        </div>
    </div>
</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/roomsettings/index.blade.php ENDPATH**/ ?>