<?php $__env->startSection('content'); ?>
    <div class="side-title">
        <h3><?php echo e($head ?? ''); ?></h3>
    </div>

    <div class="border-item">
        <form class="form-row" method="post" action="<?php echo e($action); ?>" onsubmit="saveForm(this)" enctype="multipart/form-data">
            <?php if($page ?? '' && $page->id): ?>
                <?php echo method_field('PUT'); ?>
            <?php endif; ?>
            <?php echo csrf_field(); ?>

            <?php $__currentLoopData = $languages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="form-group col-lg-6">
                                    <label>
                                        <?php if($page->id == 1): ?>
                                            <?php echo e(__('pages.page_title')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?>

                                        <?php else: ?>
                                            <?php echo e(meta('title', $language->local) ?? __('pages.title')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?>

                                        <?php endif; ?>
                                    </label>
                                    <input type="text" class="form-control <?php echo e($errors->has('title_' . $language->local) ? 'is-invalid' : ''); ?>"
                                        name="title_<?php echo e($language->local); ?>"
                                        placeholder="<?php if($page->id == 1): ?><?php echo e(__('pages.page_title')); ?><?php else: ?><?php echo e(meta('title', $language->local) ?? __('pages.title')); ?><?php endif; ?>"
                                        value='<?php echo e(old("title_{$language->local}", $page[$language->local]->title ?? "")); ?>'
                                        <?php if(in_array($page->id ?? null, [11,12,13,14,15,16,17,18,19], true)): ?> readonly <?php endif; ?> />
                                </div>
                <?php if(in_array($page->id,[10,1,19])): ?>
                    <div class="form-group col-lg-6">
                        <label><?php echo e($page->id == 19 ? __('pages.page_title_19_1') : __('pages.title_2')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?></label>
                        <input type="text" class="form-control <?php echo e($errors->has('title_2_' . $language->local) ? 'is-invalid' : ''); ?>"
                            name="title_2_<?php echo e($language->local); ?>" placeholder="<?php echo e(__('pages.title_2')); ?>"
                            value='<?php echo e(old("title_2_{$language->local}", $page[$language->local]->title_2 ?? "")); ?>' />
                    </div>
                     <div class="form-group col-lg-6">
                        <label><?php echo e($page->id == 19 ? __('pages.page_title_19_2') :__('pages.title_3')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?></label>
                        <input type="text" class="form-control <?php echo e($errors->has('title_3_' . $language->local) ? 'is-invalid' : ''); ?>"
                            name="title_3_<?php echo e($language->local); ?>" placeholder="<?php echo e(__('pages.title_3')); ?>"
                            value='<?php echo e(old("title_3_{$language->local}", $page[$language->local]->title_3 ?? "")); ?>'
                            maxlength="200" />
                        <small class="form-text text-muted"><?php echo e(__('pages.char_limit_200')); ?></small>
                    </div>
                    <?php if($page->id == 1): ?>
                        <!--<div class="form-group col-lg-12">-->
                        <!--    <label><?php echo e(__('pages.description')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?></label>-->
                        <!--    <textarea name="title_4_<?php echo e($language->local); ?>" class="form-control <?php echo e($errors->has('title_4_' . $language->local) ? 'is-invalid' : ''); ?>"-->
                        <!--        placeholder="<?php echo e(__('pages.description')); ?>" maxlength="500" rows="4"><?php echo e(old("title_4_{$language->local}", $page[$language->local]->title_4 ?? "")); ?></textarea>-->
                        <!--    <small class="form-text text-muted"><?php echo e(__('pages.char_limit_500')); ?></small>-->
                        <!--</div>-->
                    <?php else: ?>
                        <div class="form-group col-lg-6">
                            <label><?php echo e($page->id == 19 ? __('pages.page_title_19_3') : meta('title', $language->local) ?? __('pages.title')); ?>

                                <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> <?php echo e($page->id != 19 ? '(4)' : ''); ?></label>
                            <input type="text" class="form-control <?php echo e($errors->has('title_4_' . $language->local) ? 'is-invalid' : ''); ?>"
                                name="title_4_<?php echo e($language->local); ?>" placeholder="<?php echo e(meta('title', $language->local) ?? __('pages.title')); ?>"
                                value='<?php echo e(old("title_4_{$language->local}", $page[$language->local]->title_4 ?? "")); ?>' />
                        </div>
                    <?php endif; ?>
                <?php endif; ?>

                <?php if($page->id != 10 ): ?>
                                    <div class="form-group col-lg-12" >
                                        <label><?php echo e($page->id == 19 ? __('pages.page_description_19_1') : meta('description', $language->local) ?? __('pages.description')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                                        <textarea name="description_<?php echo e($language->local); ?>" class="form-control <?php echo e($errors->has('description_' . $language->local) ? 'is-invalid' : ''); ?>" placeholder="<?php echo e(meta('description', $language->local) ?? __('pages.description')); ?>"><?php echo e(old("description_{$language->local}", $page[$language->local]->description ?? "")); ?></textarea>
                                    </div>
                <?php endif; ?>
                  <?php if($page->id == 19): ?>
                   <div class="form-group col-lg-12" >
                                        <label><?php echo e($page->id == 19 ? __('pages.page_description_19_2') : meta('description', $language->local) ?? __('pages.description')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                                        <textarea name="description_2_<?php echo e($language->local); ?>" class="form-control <?php echo e($errors->has('description_2_' . $language->local) ? 'is-invalid' : ''); ?>" placeholder="<?php echo e(meta('description', $language->local) ?? __('pages.description')); ?>"><?php echo e(old("description_2_{$language->local}", $page[$language->local]->description_2 ?? "")); ?></textarea>
                                    </div>
                                     <div class="form-group col-lg-12" >
                                        <label><?php echo e($page->id == 19 ? __('pages.page_description_19_3') : meta('description', $language->local) ?? __('pages.description')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                                        <textarea name="description_3_<?php echo e($language->local); ?>" class="form-control <?php echo e($errors->has('description_3_' . $language->local) ? 'is-invalid' : ''); ?>" placeholder="<?php echo e(meta('description', $language->local) ?? __('pages.description')); ?>"><?php echo e(old("description_3_{$language->local}", $page[$language->local]->description_3 ?? "")); ?></textarea>
                                    </div>
                  <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php if($page->id == 10): ?>
            <div class="form-group col-lg-6">
                    <label><?php echo e(__('pages.value_1')); ?> </label>
                    <input type="text" class="form-control integers-only <?php echo e($errors->has('value_1') ? 'is-invalid' : ''); ?>" name="value_1" placeholder="<?php echo e(__('pages.value_1')); ?>" value='<?php echo e(old("value_1", $page->value_1 ?? "")); ?>'/>
                </div>
            <div class="form-group col-lg-6">
                    <label><?php echo e(__('pages.value_2')); ?> </label>
                    <input type="text" class="form-control integers-only <?php echo e($errors->has('value_2') ? 'is-invalid' : ''); ?>" name="value_2" placeholder="<?php echo e(__('pages.value_2')); ?>" value='<?php echo e(old("value_2", $page->value_2 ?? "")); ?>'/>
                </div>
            <div class="form-group col-lg-6">
                    <label><?php echo e(__('pages.value_3')); ?> </label>
                    <input type="text" class="form-control integers-only <?php echo e($errors->has('value_3') ? 'is-invalid' : ''); ?>" name="value_3" placeholder="<?php echo e(__('pages.value_3')); ?>" value='<?php echo e(old("value_3", $page->value_3 ?? "")); ?>'/>
                </div>
            <div class="form-group col-lg-6">
                    <label><?php echo e(__('pages.value_4')); ?> </label>
                    <input type="text" class="form-control integers-only <?php echo e($errors->has('value_4') ? 'is-invalid' : ''); ?>" name="value_4" placeholder="<?php echo e(__('pages.value_4')); ?>" value='<?php echo e(old("value_4", $page->value_4 ?? "")); ?>'/>
                </div>



            <div class="form-group col-lg-6">
                <label><?php echo e(__('pages.image')); ?> (1)</label>
                <input type="hidden" name="old_image_1" value="<?php echo e($page->image_1 ?? ''); ?>"/>
                <input type="file" class="form-control <?php echo e($errors->has('image_1') ? 'is-invalid' : ''); ?>" name="image_1" accept="image/*"/>
                <?php if(($page->image_1 ?? null) && ($page->image_1_url ?? null)): ?>
                    <a href="<?php echo e($page->image_1_url); ?>" class="btn btn-primary mt-2" target="_new"><i class="fas fa-download"></i></a>
                <?php endif; ?>
            </div>

            <div class="form-group col-lg-6">
                <label><?php echo e(__('pages.image')); ?> (2)</label>
                <input type="hidden" name="old_image_2" value="<?php echo e($page->image_2 ?? ''); ?>"/>
                <input type="file" class="form-control <?php echo e($errors->has('image_2') ? 'is-invalid' : ''); ?>" name="image_2" accept="image/*"/>
                <?php if(($page->image_2 ?? null) && ($page->image_2_url ?? null)): ?>
                    <a href="<?php echo e($page->image_2_url); ?>" class="btn btn-primary mt-2" target="_new"><i class="fas fa-download"></i></a>
                <?php endif; ?>
            </div>

            <div class="form-group col-lg-6">
                <label><?php echo e(__('pages.image')); ?> (3)</label>
                <input type="hidden" name="old_image_3" value="<?php echo e($page->image_3 ?? ''); ?>"/>
                <input type="file" class="form-control <?php echo e($errors->has('image_3') ? 'is-invalid' : ''); ?>" name="image_3" accept="image/*"/>
                <?php if(($page->image_3 ?? null) && ($page->image_3_url ?? null)): ?>
                    <a href="<?php echo e($page->image_3_url); ?>" class="btn btn-primary mt-2" target="_new"><i class="fas fa-download"></i></a>
                <?php endif; ?>
            </div>

            <div class="form-group col-lg-6">
                <label><?php echo e(__('pages.image')); ?> (4)</label>
                <input type="hidden" name="old_image_4" value="<?php echo e($page->image_4 ?? ''); ?>"/>
                <input type="file" class="form-control <?php echo e($errors->has('image_4') ? 'is-invalid' : ''); ?>" name="image_4" accept="image/*"/>
                <?php if(($page->image_4 ?? null) && ($page->image_4_url ?? null)): ?>
                    <a href="<?php echo e($page->image_4_url); ?>" class="btn btn-primary mt-2" target="_new"><i class="fas fa-download"></i></a>
                <?php endif; ?>
            </div>

            <?php endif; ?>
<?php if($page->id == 19): ?>
  <div class="form-group col-lg-6">
                <label><?php echo e(__('pages.image')); ?> (2)</label>
                <input type="hidden" name="old_image_2" value="<?php echo e($page->image_2 ?? ''); ?>"/>
                <input type="file" class="form-control <?php echo e($errors->has('image_2') ? 'is-invalid' : ''); ?>" name="image_2" accept="image/*"/>
                <?php if(($page->image_2 ?? null) && ($page->image_2_url ?? null)): ?>
                    <a href="<?php echo e($page->image_2_url); ?>" class="btn btn-primary mt-2" target="_new"><i class="fas fa-download"></i></a>
                <?php endif; ?>
            </div>

            <div class="form-group col-lg-6">
                <label><?php echo e(__('pages.image')); ?> (3)</label>
                <input type="hidden" name="old_image_3" value="<?php echo e($page->image_3 ?? ''); ?>"/>
                <input type="file" class="form-control <?php echo e($errors->has('image_3') ? 'is-invalid' : ''); ?>" name="image_3" accept="image/*"/>
                <?php if(($page->image_3 ?? null) && ($page->image_3_url ?? null)): ?>
                    <a href="<?php echo e($page->image_3_url); ?>" class="btn btn-primary mt-2" target="_new"><i class="fas fa-download"></i></a>
                <?php endif; ?>
            </div>
              <?php endif; ?>
            <?php if(!in_array($page->id ?? null, [11,12,13,14,16,17,18], true)): ?>
                <div class="form-group col-lg-6">
                    <label><?php echo e(__('pages.image')); ?> </label>
                    <input id="old_image" class="old_image" type="hidden" name="old_image" value="<?php echo e($page->image ?? ""); ?>"/>
                    <input type="file" class="form-control <?php echo e($errors->has('image') ? 'is-invalid' : ''); ?>" name="image" placeholder="<?php echo e(__('pages.image')); ?>" value='<?php echo e(old('image', '')); ?>' accept="image/*"/>
                    <?php if(($page->image ?? null) && ($page->image_url ?? null)): ?>
                        <a href="<?php echo e($page->image_url); ?>" class="btn btn-primary" target="_new"><i class="fas fa-download"></i></a>
                    <?php endif; ?>
                </div>
            <?php endif; ?>


            <div class="text-center mt-5 col-12">
                <button class="butn"><span><?php echo e(__('dashboard.save')); ?></span></button>
            </div>
        </form>
    </div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('inner_js'); ?>
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            // Number inputs
            const numberInputs = document.querySelectorAll('input.numbers-only');
            numberInputs.forEach(input => {
                input.addEventListener('input', function () {
                    this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');
                });
            });

            // Integer inputs
            const integerInputs = document.querySelectorAll('input.integers-only');
            integerInputs.forEach(input => {
                input.addEventListener('input', function () {
                    this.value = this.value.replace(/\D/g, '');
                });
            });

            // Character count for limited fields
            const limitedInputs = document.querySelectorAll('input[maxlength], textarea[maxlength]');
            limitedInputs.forEach(input => {
                const maxLength = input.getAttribute('maxlength');
                const helpText = input.parentNode.querySelector('.form-text');

                if (helpText) {
                    const updateCount = () => {
                        const currentLength = input.value.length;
                        const remaining = maxLength - currentLength;
                        helpText.textContent = helpText.textContent.split('(')[0] + `(${currentLength}/${maxLength} حرف)`;

                        // Change color based on remaining characters
                        if (remaining < 50) {
                            helpText.style.color = '#dc3545'; // Red
                        } else if (remaining < 100) {
                            helpText.style.color = '#ffc107'; // Yellow
                        } else {
                            helpText.style.color = '#6c757d'; // Gray
                        }
                    };

                    input.addEventListener('input', updateCount);
                    updateCount(); // Initial count
                }
            });
        });
    </script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.container', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/alyomhostorg/public_html/madar/resources/views/admin/pages/form.blade.php ENDPATH**/ ?>