<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>إضافة لوكر جديد<?php $__template->endSection(); ?>

<?php $__template->section('page_actions'); ?>
<a href="/sa/lockers" 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="/sa/lockers">
    <?= 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="lock" style="width:18px;height:18px;color:#0D7377;"></i>
            <h3 style="margin:0;color:#0D7377;font-size:15px;">بيانات اللوكر</h3>
        </div>
        <div style="padding:20px;">
            <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:20px;">
                <div class="form-group">
                    <label class="form-label">كود اللوكر <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="code" value="<?= e(old('code')) ?>" class="form-input" required maxlength="30" placeholder="مثال: LK-001" style="direction:ltr;text-align:left;text-transform:uppercase;">
                </div>
                <div class="form-group">
                    <label class="form-label">الاسم بالعربي <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="name_ar" value="<?= e(old('name_ar')) ?>" class="form-input" required maxlength="200" placeholder="اسم اللوكر بالعربي">
                </div>
                <div class="form-group">
                    <label class="form-label">الاسم بالإنجليزي</label>
                    <input type="text" name="name_en" value="<?= e(old('name_en')) ?>" class="form-input" maxlength="200" placeholder="Locker name in English" style="direction:ltr;text-align:left;">
                </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">المرفق</label>
                    <select name="facility_id" class="form-select">
                        <option value="">-- اختر المرفق --</option>
                        <?php foreach ($facilities as $fac): ?>
                        <option value="<?= (int) $fac['id'] ?>" <?= old('facility_id') == $fac['id'] ? 'selected' : '' ?>><?= e($fac['name_ar']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label">اللعبة</label>
                    <select name="discipline_id" class="form-select">
                        <option value="">-- اختر اللعبة --</option>
                        <?php foreach ($disciplines as $disc): ?>
                        <option value="<?= (int) $disc['id'] ?>" <?= old('discipline_id') == $disc['id'] ? 'selected' : '' ?>><?= e($disc['name_ar']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label">نوع اللوكر <span style="color:#DC2626;">*</span></label>
                    <select name="locker_type" class="form-select" required>
                        <option value="">-- اختر النوع --</option>
                        <?php foreach ($typeOptions as $key => $label): ?>
                        <option value="<?= e($key) ?>" <?= old('locker_type') === $key ? 'selected' : '' ?>><?= e($label) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>
            <div style="margin-top:15px;">
                <div class="form-group">
                    <label class="form-label">ملاحظات الموقع</label>
                    <textarea name="location_note" class="form-input" rows="3" placeholder="مثال: الدور الثاني - الجهة اليمنى..."><?= e(old('location_note')) ?></textarea>
                </div>
            </div>
        </div>
    </div>

    <!-- Submit -->
    <div style="display:flex;gap:10px;justify-content:flex-start;">
        <button type="submit" class="btn btn-primary"><i data-lucide="check" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> حفظ اللوكر</button>
        <a href="/sa/lockers" class="btn btn-outline">إلغاء</a>
    </div>
</form>

<script>
document.addEventListener('DOMContentLoaded', function() {
    if (typeof lucide !== 'undefined') {
        lucide.createIcons();
    }
});
</script>
<?php $__template->endSection(); ?>
