<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card shadow-sm border-0 mt-4">
            <div class="card-header bg-white pb-0 border-bottom-0 pt-4">
                <h4 class="fw-bold text-primary mb-0"><i class="fa-solid fa-pen-to-square me-2"></i>تعديل السجل التعليمي</h4>
            </div>
            <div class="card-body">
                <form action="<?= BASE_URL ?>/education/update" method="POST">
                    <?= csrf_field() ?>
                    <input type="hidden" name="table_name" value="<?= htmlspecialchars($table) ?>">
                    <input type="hidden" name="item_id" value="<?= $item->id ?>">
                    
                    <?php 
                    $skipFields = ['id', 'user_id', 'created_at', 'updated_at', 'deleted_at'];
                    foreach($item as $key => $val): 
                        if(in_array($key, $skipFields)) continue;
                        $label = ucwords(str_replace('_', ' ', $key));
                        $isDate = (strpos($key, 'date') !== false);
                        
                        $type = 'text';
                        if ($isDate) {
                            $type = 'date';
                        } elseif (is_numeric($val) && strpos((string)$val, '.') !== false) {
                            $type = 'number" step="0.01';
                        } elseif (is_numeric($val) && strpos($key, 'progress') === false && strpos($key, 'mastery') === false && strpos($key, 'is_paid') === false) {
                            $type = 'number';
                        }
                    ?>
                    <div class="mb-3">
                        <label class="form-label fw-bold"><?= htmlspecialchars($label) ?></label>
                        <input type="<?= $type ?>" name="<?= htmlspecialchars($key) ?>" class="form-control" value="<?= htmlspecialchars($val) ?>" required>
                    </div>
                    <?php endforeach; ?>
                    
                    <div class="d-flex justify-content-between mt-4">
                        <a href="<?= BASE_URL ?>/education" class="btn btn-outline-secondary">إلغاء والعودة</a>
                        <button type="submit" class="btn btn-primary px-4">حفظ التعديلات</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
