<?php $__env->startSection('title', $pageTitle); ?>

<?php $__env->startSection('content'); ?>
    <?php echo $__env->make('include.admin.toast', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <div class="page-header d-print-none">
        <div class="container-xl">
            <div class="row g-2 align-items-center">
                <div class="col">
                    <?php echo $__env->make('include.admin.breadcrumbs', ['module' => 'meeting'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                </div>
            </div>
        </div>
    </div>

    <div class="page-body">
        <div class="container-xl">
            <div class="card">
                <div class="card-body">
                    <form action="<?php echo e(route('admin.meeting.store')); ?>" method="POST" enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>

                        
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label class="form-label"><?php echo e(__('Title')); ?> *</label>
                                <input type="text" name="title" value="<?php echo e(old('title')); ?>"
                                    class="form-control <?php $__errorArgs = ['title'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                    maxlength="100" required>
                                <?php $__errorArgs = ['title'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label"><?php echo e(__('Meeting Type')); ?> *</label>
                                <select name="type" class="form-select <?php $__errorArgs = ['type'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" required>
                                    <option value="live" <?php echo e(old('type') == 'live' ? 'selected' : ''); ?>>
                                        <?php echo e(__('Live (regular meeting)')); ?>

                                    </option>
                                    <option value="automated" <?php echo e(old('type') == 'automated' ? 'selected' : ''); ?>>
                                        <?php echo e(__('Automated (prerecorded video)')); ?>

                                    </option>
                                </select>
                                <?php $__errorArgs = ['type'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <div class="row mb-3">
                            <div class="col-12">
                                <label class="form-label"><?php echo e(__('Description')); ?></label>
                                <textarea name="description" class="form-control <?php $__errorArgs = ['description'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                    maxlength="1000" rows="2"><?php echo e(old('description')); ?></textarea>
                                <?php $__errorArgs = ['description'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <div class="row mb-3">
                            <div class="col-md-4">
                                <label class="form-label"><?php echo e(__('Date')); ?></label>
                                <input type="date" name="date" value="<?php echo e(old('date')); ?>" class="form-control">
                            </div>
                            <div class="col-md-4">
                                <label class="form-label"><?php echo e(__('Time')); ?></label>
                                <input type="time" name="time" value="<?php echo e(old('time')); ?>" class="form-control">
                            </div>
                            <div class="col-md-4">
                                <label class="form-label"><?php echo e(__('Password')); ?></label>
                                <input type="text" name="password" value="<?php echo e(old('password')); ?>"
                                    class="form-control <?php $__errorArgs = ['password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                    minlength="4" maxlength="8">
                                <?php $__errorArgs = ['password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <div class="mb-4">
                            <label class="form-label"><?php echo e(__('Timezone')); ?></label>
                            <select name="timezone" class="form-select">
                                <option value=""><?php echo e(__('Select Timezone')); ?></option>
                                <?php $__currentLoopData = $timezones; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tz): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($tz['value']); ?>" <?php echo e(old('timezone') == $tz['value'] ? 'selected' : ''); ?>>
                                        <?php echo e($tz['value']); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>

                        <hr>

                        
                        <div class="d-flex align-items-center justify-content-between mb-3">
                            <h4 class="m-0"><?php echo e(__('Moderators')); ?></h4>
                            <button type="button" class="btn btn-sm btn-outline-primary" id="addModeratorBtn">
                                <i class="bi bi-plus-lg me-1"></i><?php echo e(__('Add Moderator')); ?>

                            </button>
                        </div>

                        <div id="moderatorRows">
                            
                        </div>

                        <div id="noModeratorsMsg" class="text-muted small mb-3">
                            <?php echo e(__('No moderators added yet. Click "Add Moderator" to assign one.')); ?>

                        </div>

                        <div class="mt-4">
                            <button type="submit" class="btn btn-primary"><?php echo e(__('Create Meeting')); ?></button>
                            <a href="<?php echo e(route('admin.meeting')); ?>" class="btn btn-link ms-2"><?php echo e(__('Cancel')); ?></a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    
    <template id="moderatorRowTemplate">
        <div class="moderator-row card mb-3 p-3">
            <div class="row g-3 align-items-end">
                <div class="col-md-5">
                    <label class="form-label"><?php echo e(__('User')); ?></label>
                    <select class="form-select" name="moderators[__INDEX__][user_id]" required>
                        <option value=""><?php echo e(__('— Select user —')); ?></option>
                        <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($u->id); ?>"><?php echo e($u->username); ?> (<?php echo e($u->email); ?>)</option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div class="col-md-5">
                    <label class="form-label">
                        <?php echo e(__('Prerecorded Video')); ?>

                        <span class="text-muted">(MP4 / WebM, max 500 MB)</span>
                    </label>
                    <input type="file" class="form-control" name="moderators[__INDEX__][video]"
                        accept="video/mp4,video/webm">
                </div>
                <div class="col-md-2 text-end">
                    <button type="button" class="btn btn-sm btn-outline-danger remove-moderator-btn">
                        <i class="bi bi-trash"></i> <?php echo e(__('Remove')); ?>

                    </button>
                </div>
            </div>
        </div>
    </template>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
<script>
    let moderatorIndex = 0;

    function updateNoModeratorsMsg() {
        const rows = document.querySelectorAll('.moderator-row');
        document.getElementById('noModeratorsMsg').style.display = rows.length ? 'none' : '';
    }

    function attachRowEvents(row) {
        row.querySelector('.remove-moderator-btn').addEventListener('click', function () {
            row.remove();
            updateNoModeratorsMsg();
        });
    }

    document.getElementById('addModeratorBtn').addEventListener('click', function () {
        const template = document.getElementById('moderatorRowTemplate');
        const clone    = template.content.cloneNode(true);
        const row      = clone.querySelector('.moderator-row');

        row.innerHTML = row.innerHTML.replaceAll('__INDEX__', moderatorIndex++);

        document.getElementById('moderatorRows').appendChild(row);
        attachRowEvents(document.querySelector('.moderator-row:last-child'));
        updateNoModeratorsMsg();
    });

    updateNoModeratorsMsg();
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\s.mutolib\Downloads\jupitermeet_pro\resources\views/admin/meeting/create.blade.php ENDPATH**/ ?>