<?php require __DIR__ . '/../../layouts/header.php'; ?>
<?php $r = $rule ?? []; ?>

<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="fw-bold mb-0"><?= e(trans('workflow_rules')) ?> — <?= e(current_lang() === 'ar' ? (string) $conference['title_ar'] : (string) $conference['title_en']) ?></h1>
    <a href="<?= e(base_path('admin/workflow')) ?>" class="btn ec-btn btn-outline-secondary rounded-3"><?= e(trans('back')) ?></a>
</div>

<div class="ec-card  ">
    <div class="ec-card-body p-4">
        <form method="post" action="<?= e(base_path('admin/workflow/edit?conference_id=' . (int) $conference['id'])) ?>">
            <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
            <input type="hidden" name="conference_id" value="<?= e((string) $conference['id']) ?>">

            <div class="row g-3">
                <div class="col-md-4">
                    <label class="form-label"><?= e(trans('min_reviewers')) ?></label>
                    <input type="number" min="1" name="min_reviewers" class="form-control rounded-3" value="<?= e((string) ($r['min_reviewers'] ?? 2)) ?>">
                </div>

                <div class="col-md-4">
                    <label class="form-label"><?= e(trans('blind_review_mode')) ?></label>
                    <select name="blind_review_mode" class="form-select rounded-3">
                        <?php foreach (['single','double','open'] as $mode): ?>
                            <option value="<?= e($mode) ?>" <?= (($r['blind_review_mode'] ?? 'double') === $mode) ? 'selected' : '' ?>><?= e($mode) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>

                <div class="col-md-4 d-flex align-items-end">
                    <div class="form-check"><input class="form-check-input" type="checkbox" name="allow_author_edit_before_deadline" <?= !empty($r['allow_author_edit_before_deadline']) ? 'checked' : '' ?>><label class="form-check-label"><?= e(trans('allow_author_registration')) ?></label></div>
                </div>

                <div class="col-md-4 d-flex align-items-end">
                    <div class="form-check"><input class="form-check-input" type="checkbox" name="allow_revision_round" <?= !empty($r['allow_revision_round']) ? 'checked' : '' ?>><label class="form-check-label"><?= e(trans('allow_revision_round')) ?></label></div>
                </div>
                <div class="col-md-4 d-flex align-items-end">
                    <div class="form-check"><input class="form-check-input" type="checkbox" name="require_camera_ready" <?= !empty($r['require_camera_ready']) ? 'checked' : '' ?>><label class="form-check-label"><?= e(trans('require_camera_ready')) ?></label></div>
                </div>

                <div class="col-md-12"><hr></div>

                <div class="col-md-4 d-flex align-items-end">
                    <div class="form-check"><input class="form-check-input" type="checkbox" name="auto_ack_email" <?= !empty($r['auto_ack_email']) ? 'checked' : '' ?>><label class="form-check-label">Auto Acknowledgement Email</label></div>
                </div>
                <div class="col-md-4 d-flex align-items-end">
                    <div class="form-check"><input class="form-check-input" type="checkbox" name="auto_reviewer_assignment_email" <?= !empty($r['auto_reviewer_assignment_email']) ? 'checked' : '' ?>><label class="form-check-label">Auto Reviewer Assignment Email</label></div>
                </div>
                <div class="col-md-4 d-flex align-items-end">
                    <div class="form-check"><input class="form-check-input" type="checkbox" name="auto_decision_email" <?= !empty($r['auto_decision_email']) ? 'checked' : '' ?>><label class="form-check-label">Auto Decision Email</label></div>
                </div>
                <div class="col-md-4 d-flex align-items-end">
                    <div class="form-check"><input class="form-check-input" type="checkbox" name="auto_revision_email" <?= !empty($r['auto_revision_email']) ? 'checked' : '' ?>><label class="form-check-label">Auto Revision Email</label></div>
                </div>
                <div class="col-md-4 d-flex align-items-end">
                    <div class="form-check"><input class="form-check-input" type="checkbox" name="auto_camera_ready_email" <?= !empty($r['auto_camera_ready_email']) ? 'checked' : '' ?>><label class="form-check-label">Auto Camera-ready Email</label></div>
                </div>
            </div>

            <div class="mt-4">
                <button type="submit" class="btn ec-btn btn-success rounded-3"><i class="fa-solid fa-floppy-disk me-1"></i><?= e(trans('save')) ?></button>
            </div>
        </form>
    </div>
</div>

<?php require __DIR__ . '/../../layouts/footer.php'; ?>
