<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>تعديل اللوكر: <?= e($locker['name_ar'] ?? '') ?><?php $__template->endSection(); ?>

<?php $__template->section('page_actions'); ?>
<a href="/sa/lockers/<?= (int) $locker['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="/sa/lockers/<?= (int) $locker['id'] ?>">
    <?= 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') ?: $locker['code'] ?? '') ?>" class="form-input" required maxlength="30" 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') ?: $locker['name_ar'] ?? '') ?>" class="form-input" required maxlength="200">
                </div>
                <div class="form-group">
                    <label class="form-label">الاسم بالإنجليزي</label>
                    <input type="text" name="name_en" value="<?= e(old('name_en') ?: $locker['name_en'] ?? '') ?>" class="form-input" maxlength="200" 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') ?: $locker['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') ?: $locker['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') ?: $locker['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"><?= e(old('location_note') ?: $locker['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/<?= (int) $locker['id'] ?>" class="btn btn-outline">إلغاء</a>
    </div>
</form>

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