<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>حظر فترة زمنية — <?= e($facility->name_ar) ?><?php $__template->endSection(); ?>

<?php $__template->section('page_actions'); ?>
<a href="/facilities/<?= (int) $facility->id ?>" class="btn btn-outline"><i data-lucide="arrow-right" style="width:15px;height:15px;vertical-align:middle;margin-left:4px;"></i> العودة للمرفق</a>
<?php $__template->endSection(); ?>

<?php $__template->section('content'); ?>

<form method="POST" action="/facilities/<?= (int) $facility->id ?>/timeslots">
    <?= csrf_field() ?>

    <div class="card" style="margin-bottom:20px;">
        <div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;display:flex;align-items:center;gap:8px;">
            <i data-lucide="clock" style="width:18px;height:18px;color:#DC2626;"></i>
            <h3 style="margin:0;color:#DC2626;font-size:15px;">حظر فترة زمنية</h3>
        </div>
        <div style="padding:20px;">
            <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:20px;">
                <?php if (!empty($units)): ?>
                <div class="form-group">
                    <label class="form-label">الوحدة</label>
                    <select name="facility_unit_id" class="form-select">
                        <option value="0">— المرفق بالكامل —</option>
                        <?php foreach ($units as $unit): ?>
                        <option value="<?= (int) $unit['id'] ?>"><?= e($unit['name_ar']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <?php endif; ?>
                <div class="form-group">
                    <label class="form-label">اليوم <span style="color:#DC2626;">*</span></label>
                    <select name="day_of_week" class="form-select" required>
                        <option value="0">الأحد</option>
                        <option value="1">الإثنين</option>
                        <option value="2">الثلاثاء</option>
                        <option value="3">الأربعاء</option>
                        <option value="4">الخميس</option>
                        <option value="5">الجمعة</option>
                        <option value="6">السبت</option>
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label">النوع</label>
                    <select name="slot_type" class="form-select">
                        <option value="blocked">محظور</option>
                        <option value="maintenance">صيانة</option>
                        <option value="reserved">محجوز</option>
                    </select>
                </div>
            </div>
            <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:20px;margin-top:15px;">
                <div class="form-group">
                    <label class="form-label">وقت البداية <span style="color:#DC2626;">*</span></label>
                    <input type="time" name="start_time" class="form-input" required style="direction:ltr;text-align:left;">
                </div>
                <div class="form-group">
                    <label class="form-label">وقت النهاية <span style="color:#DC2626;">*</span></label>
                    <input type="time" name="end_time" class="form-input" required style="direction:ltr;text-align:left;">
                </div>
                <div class="form-group">
                    <label class="form-label">ملاحظة</label>
                    <input type="text" name="label" class="form-input" placeholder="سبب الحظر (اختياري)">
                </div>
            </div>
        </div>
    </div>

    <div style="display:flex;gap:10px;justify-content:flex-start;">
        <button type="submit" class="btn btn-primary" style="padding:12px 30px;font-size:15px;">
            <i data-lucide="lock" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> حظر الفترة
        </button>
        <a href="/facilities/<?= (int) $facility->id ?>" class="btn btn-outline" style="padding:12px 30px;font-size:15px;">إلغاء</a>
    </div>
</form>

<script>
document.addEventListener('DOMContentLoaded', function() {
    if (typeof lucide !== 'undefined') {
        lucide.createIcons();
    }
});
</script>

<?php $__template->endSection(); ?>
