<?php
function rr_h($v) {
    return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8');
}

$assignment = $assignment ?? [];
$criteria = $criteria ?? [];
$existingReview = $existingReview ?? null;
$assignment_id = $assignment_id ?? ($assignment['assignment_id'] ?? $assignment['id'] ?? 0);
?>





<div class="container-fluid py-3">

    <div class="card border-0 shadow-sm mb-4" style="border-radius:22px;">
        <div class="card-body">
            <h3 class="fw-bold mb-1">نموذج التحكيم</h3>
            <div class="text-muted">
                <?= rr_h(($assignment['title'] ?? '') ?: ($assignment['title_en'] ?? '') ?: ($assignment['title_ar'] ?? '')) ?>
            </div>
        </div>
    </div>

    <div class="card border-0 shadow-sm mb-4" style="border-radius:22px;">
        <div class="card-body">
            <h5 class="fw-bold">بيانات البحث</h5>

            <p>
                <?= nl2br(rr_h(($assignment['abstract'] ?? '') ?: ($assignment['abstract_en'] ?? '') ?: ($assignment['abstract_ar'] ?? ''))) ?>
            </p>

            <?php if (!empty($assignment['file_path'])): ?>
                <a class="btn btn-outline-primary"
                   href="/easychair/storage/<?= rr_h($assignment['file_path']) ?>"
                   target="_blank">
                    تحميل ملف البحث
                </a>
            <?php endif; ?>
        </div>
    </div>

    

<!-- PACK 687 -->
<script>
document.currentScript
.parentElement
?.setAttribute(
'data-pack',
'687'
);
</script>

<div
data-review-block="studio_687"
>

    <div class="card border-0 shadow-sm mb-4" style="border-radius:22px;">
        <div class="card-body">
            <div class="d-flex justify-content-between align-items-center">
                <div>
                    <h4 class="fw-bold">مساعد القرار</h4>
                    <div class="text-muted">Review Completion + Recommendation Guidance</div>
                </div>

                <div id="rr_progress" class="display-5 fw-bold text-primary">0%</div>
            </div>

            <div class="progress mt-4">
                <div id="rr_bar" class="progress-bar" style="width:0%;"></div>
            </div>

            <div class="row mt-4">
                <div class="col-md-6">
                    <label class="fw-bold">مؤشر القرار</label>
                    <input id="rr_score_preview" class="form-control" readonly value="0">
                </div>

                <div class="col-md-6">
                    <label class="fw-bold">توصية مقترحة</label>
                    <input id="rr_recommend" class="form-control" readonly value="-">
                </div>
            </div>
        </div>
    </div>
    </div>
<!-- END PACK 687 -->




<!-- PACK 688 -->
<script>
document.currentScript
.parentElement
?.setAttribute(
'data-pack',
'688'
);
</script>

<div
data-review-block="studio_688"
>


<div
class="
card
border-0
shadow-sm
mb-4
"
style="
border-radius:22px;
"
>

<div class="card-body">

<div
class="
d-flex
justify-content-between
align-items-center
mb-4
"
>

<div>

<h4>

Deep Evaluation Studio

</h4>

<div class="text-muted">

Evidence Notes + Recommendation Calibration

</div>

</div>

<div
id="rev_weight"
class="
display-5
fw-bold
text-success
"
>

0%

</div>

</div>

<div class="row">

<div class="col-md-6">

<label>

Evidence Strength

</label>

<input
id="rev_evidence"
class="form-control"
readonly
value="0"
>

</div>

<div class="col-md-6">

<label>

Decision Readiness

</label>

<input
id="rev_ready"
class="form-control"
readonly
value="Pending"
>

</div>

</div>

<div class="mt-4">

<label>

Evidence Notes

</label>

<textarea
class="form-control"
rows="4"
placeholder="Key evidence..."
></textarea>

</div>

</div>

</div>

<script>

document.addEventListener(
'input',
function(){

let vals=[
...document.querySelectorAll(
'.rr-criterion'
)

];

let total=0;

vals.forEach(
v=>{

total+=(
parseFloat(
v.value
)
||
0

);

}

);

let weight=
Math.min(
100,
Math.round(
total
)
);

let state=
'Weak';

if(weight>=85)
state='Ready';

else if(weight>=70)
state='Good';

else if(weight>=50)
state='Moderate';

let w=
document.getElementById(
'rev_weight'
);

let e=
document.getElementById(
'rev_evidence'
);

let r=
document.getElementById(
'rev_ready'
);

if(w)
w.innerHTML=
weight+'%';

if(e)
e.value=
total;

if(r)
r.value=
state;

}

);

</script>

</div>
<!-- END PACK 688 -->




<!-- PACK 689 -->
<script>
document.currentScript
.parentElement
?.setAttribute(
'data-pack',
'689'
);
</script>

<div
data-review-block="studio_689"
>


<div
class="
card
border-0
shadow-sm
mb-4
"
style="
border-radius:22px;
"
>

<div class="card-body">

<div
class="
d-flex
justify-content-between
align-items-center
mb-4
"
>

<div>

<h4 class="fw-bold">

Structured Evidence Builder

</h4>

<div class="text-muted">

Multi-Criteria Intelligence + Recommendation Simulator

</div>

</div>

<div
id="sim_score"
class="
display-5
fw-bold
text-primary
"
>

0%

</div>

</div>

<div class="row g-3">

<div class="col-md-3">

<label>

Criteria Filled

</label>

<input
id="sim_count"
class="form-control"
readonly
value="0"
>

</div>

<div class="col-md-3">

<label>

Average Score

</label>

<input
id="sim_avg"
class="form-control"
readonly
value="0"
>

</div>

<div class="col-md-3">

<label>

Confidence

</label>

<input
id="sim_conf"
class="form-control"
readonly
value="Low"
>

</div>

<div class="col-md-3">

<label>

Recommendation

</label>

<input
id="sim_rec"
class="form-control"
readonly
value="-"
>

</div>

</div>

<div class="mt-4">

<label>

Structured Evidence Notes

</label>

<textarea
class="form-control"
rows="4"
placeholder="Evidence supporting evaluation..."
></textarea>

</div>

</div>

</div>

<script>

(function(){

function recalc(){

let rows=
[
...document.querySelectorAll(
'.rr-criterion'
)
];

let filled=0;

let total=0;

rows.forEach(
x=>{

let v=
parseFloat(
x.value
);

if(
!isNaN(v)
){

filled++;

total+=v;

}

}
);

let avg=
filled
?
(
total
/
filled
)
:
0;

let score=
Math.min(
100,
Math.round(
avg
*
10
)
);

let rec='Reject';

if(
score>=85
)
rec='Accept';

else if(
score>=70
)
rec='Minor Revision';

else if(
score>=50
)
rec='Major Revision';

let conf='Low';

if(
score>=80
)
conf='High';

else if(
score>=60
)
conf='Medium';

[
['sim_score',score+'%'],
['sim_count',filled],
['sim_avg',avg.toFixed(1)],
['sim_conf',conf],
['sim_rec',rec]

].forEach(
r=>{

let el=
document.getElementById(
r[0]
);

if(!el)
return;

if(
el.tagName==='INPUT'
)
el.value=
r[1];

else
el.innerHTML=
r[1];

}

);

}

document.addEventListener(
'input',
recalc
);

setTimeout(
recalc,
200
);

})();

</script>

</div>
<!-- END PACK 689 -->




<!-- PACK 690 -->
<script>
document.currentScript
.parentElement
?.setAttribute(
'data-pack',
'690'
);
</script>

<div
data-review-block="studio_690"
>


<div
class="
card
border-0
shadow-sm
mb-4
"
style="
border-radius:22px;
"
>

<div class="card-body">

<div
class="
d-flex
justify-content-between
align-items-center
mb-4
"
>

<div>

<h4 class="fw-bold">

Reviewer Deep Scoring Studio

</h4>

<div class="text-muted">

Decision Explainability + Quality Calibration

</div>

</div>

<div
id="dss_score"
class="
display-5
fw-bold
text-success
"
>

0%

</div>

</div>

<div class="row g-3">

<div class="col-md-3">

<label>

Weighted Score

</label>

<input
id="dss_weight"
class="form-control"
readonly
value="0"
>

</div>

<div class="col-md-3">

<label>

Quality

</label>

<input
id="dss_quality"
class="form-control"
readonly
value="Low"
>

</div>

<div class="col-md-3">

<label>

Explainability

</label>

<input
id="dss_reason"
class="form-control"
readonly
value="-"
>

</div>

<div class="col-md-3">

<label>

Recommendation

</label>

<input
id="dss_recommend"
class="form-control"
readonly
value="-"
>

</div>

</div>

<div class="mt-4">

<label>

Decision Evidence

</label>

<textarea
class="form-control"
rows="5"
placeholder="Explain scoring and recommendation..."
></textarea>

</div>

</div>

</div>

<script>

(function(){

function deepScore(){

let c=
[
...document.querySelectorAll(
'.rr-criterion'
)
];

let total=0;

let filled=0;

c.forEach(
x=>{

let v=
parseFloat(
x.value
);

if(
!isNaN(v)
){

filled++;

total+=v;

}

}
);

let avg=
filled
?
(
total
/
filled
)
:
0;

let score=
Math.min(
100,
Math.round(
avg
*
10
)
);

let q='Low';

if(
score>=80
)
q='High';

else if(
score>=60
)
q='Medium';

let rec='Reject';

let why='Insufficient Evidence';

if(
score>=85
){

rec='Accept';

why='Strong Evidence';

}

else if(
score>=70
){

rec='Minor Revision';

why='Small Improvements';

}

else if(
score>=50
){

rec='Major Revision';

why='Major Gaps';

}

[
['dss_score',score+'%'],
['dss_weight',avg.toFixed(1)],
['dss_quality',q],
['dss_reason',why],
['dss_recommend',rec]

].forEach(
r=>{

let e=
document.getElementById(
r[0]
);

if(!e)
return;

if(
e.tagName==='INPUT'
)
e.value=
r[1];

else
e.innerHTML=
r[1];

});

}

document.addEventListener(
'input',
deepScore
);

setTimeout(
deepScore,
250
);

})();

</script>

</div>
<!-- END PACK 690 -->




<!-- PACK 691 -->
<script>
document.currentScript
.parentElement
?.setAttribute(
'data-pack',
'691'
);
</script>

<div
data-review-block="studio_691"
>


<div
class="
card
border-0
shadow-sm
mb-4
"
style="
border-radius:22px;
"
>

<div class="card-body">

<div
class="
d-flex
justify-content-between
align-items-center
mb-4
"
>

<div>

<h4 class="fw-bold">

Evidence Mapping Studio

</h4>

<div class="text-muted">

Confidence Heatmap + Final Verdict

</div>

</div>

<div
id="ev_score"
class="
display-5
fw-bold
text-primary
"
>

0%

</div>

</div>

<div class="row g-3">

<div class="col-md-3">

<label>

Coverage

</label>

<input
id="ev_cov"
class="form-control"
readonly
value="0"
>

</div>

<div class="col-md-3">

<label>

Confidence

</label>

<input
id="ev_conf"
class="form-control"
readonly
value="Low"
>

</div>

<div class="col-md-3">

<label>

Heatmap

</label>

<input
id="ev_heat"
class="form-control"
readonly
value="Cold"
>

</div>

<div class="col-md-3">

<label>

Verdict

</label>

<input
id="ev_verdict"
class="form-control"
readonly
value="-"
>

</div>

</div>

<div class="mt-4">

<label>

Evidence Mapping Notes

</label>

<textarea
class="form-control"
rows="5"
placeholder="Map evidence to criteria..."
></textarea>

</div>

</div>

</div>

<script>

(function(){

function evidenceMap(){

let c=
[
...document.querySelectorAll(
'.rr-criterion'
)
];

let filled=0;

let score=0;

c.forEach(
x=>{

let v=
parseFloat(
x.value
);

if(
!isNaN(v)
){

filled++;

score+=v;

}

});

let coverage=
c.length
?
Math.round(
(
filled
/
c.length
)
*
100
)
:
0;

let avg=
filled
?
score/filled
:
0;

let final=
Math.min(
100,
Math.round(
avg
*
10
)
);

let conf='Low';

if(final>=80)
conf='High';

else if(final>=60)
conf='Medium';

let heat='Cold';

if(final>=85)
heat='Hot';

else if(final>=65)
heat='Warm';

let verdict='Reject';

if(final>=85)
verdict='Accept';

else if(final>=70)
verdict='Minor Revision';

else if(final>=50)
verdict='Major Revision';

[
['ev_score',final+'%'],
['ev_cov',coverage+'%'],
['ev_conf',conf],
['ev_heat',heat],
['ev_verdict',verdict]

].forEach(
r=>{

let e=
document.getElementById(
r[0]
);

if(!e)
return;

if(
e.tagName==='INPUT'
)
e.value=
r[1];

else
e.innerHTML=
r[1];

});

}

document.addEventListener(
'input',
evidenceMap
);

setTimeout(
evidenceMap,
250
);

})();

</script>

</div>
<!-- END PACK 691 -->




<!-- PACK 692 -->
<script>
document.currentScript
.parentElement
?.setAttribute(
'data-pack',
'692'
);
</script>

<div
data-review-block="studio_692"
>


<div
class="card border-0 shadow-sm mb-4"
style="border-radius:22px;"
>

<div class="card-body">

<div
class="
d-flex
justify-content-between
align-items-center
mb-4
"
>

<div>

<h4 class="fw-bold">

Adaptive Scoring Engine

</h4>

<div class="text-muted">

Evidence Weight Matrix + Explainability

</div>

</div>

<div
id="ase_score"
class="
display-5
fw-bold
text-success
"
>

0%

</div>

</div>

<div class="row g-3">

<div class="col-md-3">

<label>

Weighted Score

</label>

<input
id="ase_weight"
class="form-control"
readonly
value="0"
>

</div>

<div class="col-md-3">

<label>

Confidence

</label>

<input
id="ase_conf"
class="form-control"
readonly
value="Low"
>

</div>

<div class="col-md-3">

<label>

Evidence Strength

</label>

<input
id="ase_strength"
class="form-control"
readonly
value="Weak"
>

</div>

<div class="col-md-3">

<label>

Recommendation

</label>

<input
id="ase_rec"
class="form-control"
readonly
value="-"
>

</div>

</div>

<div class="mt-4">

<label>

Explain Recommendation

</label>

<textarea
id="ase_text"
class="form-control"
rows="5"
readonly
></textarea>

</div>

</div>

</div>

<script>

(function(){

function adaptive(){

let rows=[
...document.querySelectorAll(
'.rr-criterion'
)
];

let sum=0;

let count=0;

rows.forEach(
x=>{

let v=
parseFloat(
x.value
);

if(
!isNaN(v)
){

count++;

sum+=(
v
*
(
1+
(
count
/
20
)
)
);

}

});

let avg=
count
?
sum/count
:
0;

let score=
Math.min(
100,
Math.round(
avg
*
10
)
);

let conf='Low';

if(score>=80)
conf='High';

else if(score>=60)
conf='Medium';

let strength='Weak';

if(score>=85)
strength='Strong';

else if(score>=65)
strength='Moderate';

let rec='Reject';

let why='Insufficient evidence';

if(score>=85){

rec='Accept';

why='High consistency and strong evidence';

}

else if(score>=70){

rec='Minor Revision';

why='Good quality with limited issues';

}

else if(score>=50){

rec='Major Revision';

why='Requires substantial improvement';

}

[
['ase_score',score+'%'],
['ase_weight',avg.toFixed(1)],
['ase_conf',conf],
['ase_strength',strength],
['ase_rec',rec]

].forEach(
r=>{

let el=
document.getElementById(
r[0]
);

if(!el)
return;

if(
el.tagName==='INPUT'
)
el.value=
r[1];

else
el.innerHTML=
r[1];

});

let txt=
document.getElementById(
'ase_text'
);

if(txt)
txt.value=
why;

}

document.addEventListener(
'input',
adaptive
);

setTimeout(
adaptive,
300
);

})();

</script>

</div>
<!-- END PACK 692 -->




<!-- PACK 693 -->
<script>
document.currentScript
.parentElement
?.setAttribute(
'data-pack',
'693'
);
</script>

<div
data-review-block="studio_693"
>


<div
class="card border-0 shadow-sm mb-4"
style="border-radius:22px;"
>

<div class="card-body">

<div
class="
d-flex
justify-content-between
align-items-center
mb-4
"
>

<div>

<h4 class="fw-bold">

Evaluation Intelligence Grid

</h4>

<div class="text-muted">

Confidence Distribution + Final Decision Navigator

</div>

</div>

<div
id="eig_score"
class="
display-5
fw-bold
text-primary
"
>

0%

</div>

</div>

<div class="row g-3">

<div class="col-md-3">

<label>

Completion

</label>

<input
id="eig_completion"
class="form-control"
readonly
value="0%"
>

</div>

<div class="col-md-3">

<label>

Distribution

</label>

<input
id="eig_dist"
class="form-control"
readonly
value="Balanced"
>

</div>

<div class="col-md-3">

<label>

Confidence

</label>

<input
id="eig_conf"
class="form-control"
readonly
value="Low"
>

</div>

<div class="col-md-3">

<label>

Decision

</label>

<input
id="eig_decision"
class="form-control"
readonly
value="-"
>

</div>

</div>

<div class="mt-4">

<label>

Navigator Notes

</label>

<textarea
id="eig_notes"
class="form-control"
rows="5"
readonly
></textarea>

</div>

</div>

</div>

<script>

(function(){

function navigator(){

let rows=[
...document.querySelectorAll(
'.rr-criterion'
)
];

let total=0;

let filled=0;

rows.forEach(
r=>{

let v=
parseFloat(
r.value
);

if(
!isNaN(v)
){

filled++;

total+=v;

}

});

let avg=
filled
?
(
total
/
filled
)
:
0;

let score=
Math.min(
100,
Math.round(
avg
*
10
)
);

let completion=
rows.length
?
Math.round(
(
filled
/
rows.length
)
*
100
)
:
0;

let conf='Low';

if(score>=80)
conf='High';

else if(score>=60)
conf='Medium';

let dist='Balanced';

if(score>=85)
dist='Strong';

else if(score<50)
dist='Weak';

let dec='Reject';

let note='Evidence insufficient';

if(score>=85){

dec='Accept';

note='Decision supported by strong evaluation consistency';

}

else if(score>=70){

dec='Minor Revision';

note='Minor improvements recommended';

}

else if(score>=50){

dec='Major Revision';

note='Substantial changes advised';

}

[
['eig_score',score+'%'],
['eig_completion',completion+'%'],
['eig_dist',dist],
['eig_conf',conf],
['eig_decision',dec]

].forEach(
r=>{

let el=
document.getElementById(
r[0]
);

if(!el)
return;

if(
el.tagName==='INPUT'
)
el.value=
r[1];

else
el.innerHTML=
r[1];

});

let notes=
document.getElementById(
'eig_notes'
);

if(notes)
notes.value=
note;

}

document.addEventListener(
'input',
navigator
);

setTimeout(
navigator,
350
);

})();

</script>

</div>
<!-- END PACK 693 -->




<!-- PACK 694 -->
<script>
document.currentScript
.parentElement
?.setAttribute(
'data-pack',
'694'
);
</script>

<div
data-review-block="studio_694"
>


<div
class="card border-0 shadow-sm mb-4"
style="border-radius:22px;"
>

<div class="card-body">

<div
class="
d-flex
justify-content-between
align-items-center
mb-4
"
>

<div>

<h4 class="fw-bold">

Explainable Evaluation Studio

</h4>

<div class="text-muted">

Recommendation Stability + Consensus Workspace

</div>

</div>

<div
id="pack694_score"
class="
display-5
fw-bold
text-success
"
>

0%

</div>

</div>

<div class="row g-3">

<div class="col-md-3">

<label>

Stability

</label>

<input
id="pack694_stability"
class="form-control"
readonly
value="0%"
>

</div>

<div class="col-md-3">

<label>

Consensus

</label>

<input
id="pack694_consensus"
class="form-control"
readonly
value="Low"
>

</div>

<div class="col-md-3">

<label>

Recommendation

</label>

<input
id="pack694_rec"
class="form-control"
readonly
value="-"
>

</div>

<div class="col-md-3">

<label>

Readiness

</label>

<input
id="pack694_ready"
class="form-control"
readonly
value="Pending"
>

</div>

</div>

<div class="mt-4">

<label>

Decision Explainability

</label>

<textarea
id="pack694_reason"
class="form-control"
rows="5"
readonly
></textarea>

</div>

</div>

</div>

<script>

(function(){

function pack694calc(){

const rows=
[
...document.querySelectorAll(
'.rr-criterion'
)
];

let total=0;

let count=0;

let high=0;

rows.forEach(
r=>{

const v=
parseFloat(
r.value
);

if(
!isNaN(v)
){

count++;

total+=v;

if(v>=7)
high++;

}

});

const avg=
count
?
total/count
:
0;

const score=
Math.min(
100,
Math.round(
avg*10
)
);

const stability=
count
?
Math.round(
(
high
/
count
)
*
100
)
:
0;

let consensus='Low';

if(stability>=80)
consensus='High';

else if(stability>=60)
consensus='Medium';

let rec='Reject';

let ready='Not Ready';

let why='Evidence inconsistent';

if(score>=85){

rec='Accept';

ready='Ready';

why='Strong evidence with stable evaluation';

}

else if(score>=70){

rec='Minor Revision';

ready='Almost Ready';

why='High quality with limited concerns';

}

else if(score>=50){

rec='Major Revision';

ready='Needs Revision';

why='Recommendation requires improvements';

}

[
['pack694_score',score+'%'],
['pack694_stability',stability+'%'],
['pack694_consensus',consensus],
['pack694_rec',rec],
['pack694_ready',ready]

].forEach(
r=>{

const el=
document.getElementById(
r[0]
);

if(!el)
return;

if(
el.tagName==='INPUT'
)
el.value=
r[1];

else
el.innerHTML=
r[1];

});

const txt=
document.getElementById(
'pack694_reason'
);

if(txt)
txt.value=
why;

}

document.addEventListener(
'input',
pack694calc
);

setTimeout(
pack694calc,
300
);

})();

</script>

</div>
<!-- END PACK 694 -->




<!-- PACK 695 -->
<script>
document.currentScript
.parentElement
?.setAttribute(
'data-pack',
'695'
);
</script>

<div
data-review-block="studio_695"
>


<div
class="card border-0 shadow-sm mb-4"
style="border-radius:22px;"
>

<div class="card-body">

<div
class="
d-flex
justify-content-between
align-items-center
mb-4
"
>

<div>

<h4 class="fw-bold">

Multi-Dimensional Assessment Lab

</h4>

<div class="text-muted">

Evidence Correlation + Recommendation Optimizer

</div>

</div>

<div
id="pack695_score"
class="
display-5
fw-bold
text-primary
"
>

0%

</div>

</div>

<div class="row g-3">

<div class="col-md-3">

<label>

Correlation

</label>

<input
id="pack695_corr"
class="form-control"
readonly
value="0%"
>

</div>

<div class="col-md-3">

<label>

Variance

</label>

<input
id="pack695_var"
class="form-control"
readonly
value="0"
>

</div>

<div class="col-md-3">

<label>

Confidence

</label>

<input
id="pack695_conf"
class="form-control"
readonly
value="Low"
>

</div>

<div class="col-md-3">

<label>

Optimizer

</label>

<input
id="pack695_opt"
class="form-control"
readonly
value="-"
>

</div>

</div>

<div class="mt-4">

<label>

Recommendation Narrative

</label>

<textarea
id="pack695_reason"
class="form-control"
rows="5"
readonly
></textarea>

</div>

</div>

</div>

<script>

(function(){

function pack695(){

const rows=
[
...document.querySelectorAll(
'.rr-criterion'
)
];

const vals=[];

rows.forEach(
r=>{

const v=
parseFloat(
r.value
);

if(
!isNaN(v)
)
vals.push(v);

});

if(
!vals.length
)
return;

const avg=
vals.reduce(
(a,b)=>a+b,
0
)
/
vals.length;

const variance=
vals.reduce(
(a,b)=>
a+
Math.pow(
b-avg,
2
),
0
)
/
vals.length;

const score=
Math.min(
100,
Math.round(
avg*10
)
);

const corr=
Math.max(
0,
100-
Math.round(
variance*10
)
);

let conf='Low';

if(corr>=80)
conf='High';

else if(corr>=60)
conf='Medium';

let opt='Reject';

let why='Large evidence variation';

if(
score>=85
&&
corr>=75
){

opt='Accept';

why='Strong and consistent evidence';

}

else if(
score>=70
){

opt='Minor Revision';

why='Good score with moderate variance';

}

else if(
score>=50
){

opt='Major Revision';

why='Improvement required';

}

[
['pack695_score',score+'%'],
['pack695_corr',corr+'%'],
['pack695_var',variance.toFixed(2)],
['pack695_conf',conf],
['pack695_opt',opt]

].forEach(
r=>{

const el=
document.getElementById(
r[0]
);

if(!el)
return;

if(
el.tagName==='INPUT'
)
el.value=
r[1];

else
el.innerHTML=
r[1];

});

const txt=
document.getElementById(
'pack695_reason'
);

if(txt)
txt.value=
why;

}

document.addEventListener(
'input',
pack695
);

setTimeout(
pack695,
350
);

})();

</script>

</div>
<!-- END PACK 695 -->

















    <form method="post"
          action="/easychair/reviewer/submit-review"
          enctype="multipart/form-data">

        <input type="hidden"
               name="assignment_id"
               value="<?= (int)$assignment_id ?>">

        <div class="card border-0 shadow-sm mb-4" style="border-radius:22px;">
            <div class="card-body">

                <h5 class="fw-bold mb-3">درجات المعايير</h5>

                <?php foreach ($criteria as $c): ?>
                    <?php
                    $label =
                        $c['label_en']
                        ?? $c['title_en']
                        ?? $c['label_ar']
                        ?? $c['title_ar']
                        ?? ('Criterion #' . ($c['id'] ?? ''));

                    $maxScore = (float)($c['max_score'] ?? 10);
                    ?>

                    <div class="mb-3">
                        <label class="form-label fw-bold">
                            <?= rr_h($label) ?>
                            <span class="text-muted">(max <?= rr_h($maxScore) ?>)</span>
                        </label>

                        <input type="number"
                               name="criteria[<?= (int)$c['id'] ?>]"
                               class="form-control rr-criterion"
                               min="0"
                               max="<?= rr_h($maxScore) ?>"
                               step="0.1"
                               required>
                    </div>
                <?php endforeach; ?>

                <?php if (!$criteria): ?>
                    <div class="alert alert-warning">
                        لا توجد معايير معرفة. سيتم استخدام الدرجة العامة فقط.
                    </div>
                <?php endif; ?>

                <div class="mb-3">
                    <label class="form-label fw-bold">الدرجة العامة</label>
                    <input class="form-control rr-overall"
                           type="number"
                           step="0.01"
                           name="overall_score"
                           min="0"
                           max="10"
                           required>
                </div>

                <div class="mb-3">
                    <label class="form-label fw-bold">التوصية</label>
                    <select name="recommendation" class="form-select rr-select" required>
                        <option value="">اختر</option>
                        <option value="accept">قبول</option>
                        <option value="minor_revision">تعديلات بسيطة</option>
                        <option value="major_revision">تعديلات جوهرية</option>
                        <option value="reject">رفض</option>
                    </select>
                </div>

                <div class="mb-3">
                    <label class="form-label fw-bold">ملاحظات للمؤلف</label>
                    <textarea name="comments_to_author" class="form-control" rows="5"></textarea>
                </div>

                <div class="mb-3">
                    <label class="form-label fw-bold">ملاحظات للمحرر / الرئيس</label>
                    <textarea name="comments_to_editor" class="form-control" rows="5"></textarea>
                </div>

                <div class="mb-3">
                    <label class="form-label fw-bold">رفع ملف مراجعة اختياري</label>
                    <input type="file"
                           name="review_file"
                           class="form-control"
                           accept=".pdf,.doc,.docx,.zip,.rar,.png,.jpg,.jpeg">
                </div>

                <button class="btn btn-success btn-lg">
                    إرسال التحكيم
                </button>

            </div>
        </div>
    

<style>

.pack721{
margin-top:18px;
padding:18px;
border-radius:18px;
background:
linear-gradient(
135deg,
#071220,
#0b1e36
);
color:#fff;
border:1px solid #1f5eff;
}

.pack721-score{
font-size:42px;
font-weight:900;
color:#2d7dff;
}

.pack721-rec{
display:inline-block;
padding:8px 16px;
border-radius:999px;
margin-top:10px;
font-weight:700;
}

</style>

<div class="pack721">

<div>

Weighted Review Decision

</div>

<div
class="pack721-score"
id="pack721Score"
>

0%

</div>

<div
id="pack721Recommendation"
class="pack721-rec"
>

Pending

</div>

<div
id="pack721Explain"
style="
margin-top:12px;
opacity:.9;
"
>

Waiting for scoring…

</div>

</div>

<script>

/* PACK721_FORMULA_ENGINE */

document.addEventListener(

'DOMContentLoaded',

function(){

const score=
document.getElementById(
'pack721Score'
);

const rec=
document.getElementById(
'pack721Recommendation'
);

const exp=
document.getElementById(
'pack721Explain'
);

function calc(){

let total=0;

let max=0;

document
.querySelectorAll(
'.rr-criterion'
)

.forEach(

function(el){

if(
el.disabled
)
return;

let v=
parseFloat(
el.value
||0
);

let w=
parseFloat(
el.dataset.weight
||1
);

let m=
parseFloat(
el.max
||10
);

total+=
v*w;

max+=
m*w;

}

);

let pct=
max
?

(
total/max
*100
)

:

0;

pct=
Math.round(
pct
);

score.innerHTML=
pct+'%';

let r='Major Revision';

if(
pct>=90
)
r='Accept';

else if(
pct>=75
)
r='Minor Revision';

else if(
pct>=55
)
r='Major Revision';

else
r='Reject';

rec.innerHTML=r;

let select=
document.querySelector(
'select[name="recommendation"]'
);

if(
select
&&
!select.dataset.manual
){

[...select.options]
.forEach(
o=>{
if(
o.text
.toLowerCase()
.includes(
r
.toLowerCase()
)
)
select.value=o.value;
}
);

}

exp.innerHTML=
'Weighted score computed from active criteria only. Reviewer decision remains editable.';

}

document
.querySelectorAll(
'.rr-criterion'
)

.forEach(

x=>
x.addEventListener(
'input',
calc
)

);

let s=
document.querySelector(
'select[name="recommendation"]'
);

if(
s
){

s.addEventListener(
'change',
()=>{
s.dataset.manual=1;
}
);

}

setTimeout(
calc,
500
);

}

);

</script>

<!-- END PACK721 -->




<style>

.pack722{

margin-top:16px;

padding:18px;

border-radius:18px;

background:
linear-gradient(
135deg,
#081426,
#10274b
);

color:white;

}

.pack722-grid{

display:grid;

grid-template-columns:
repeat(
3,
1fr
);

gap:14px;

}

.pack722-box{

padding:18px;

border-radius:14px;

background:
rgba(
255,
255,
255,
.04
);

}

.pack722-big{

font-size:34px;

font-weight:900;

color:#3f8cff;

}

.pack722-bar{

height:10px;

border-radius:999px;

overflow:hidden;

background:#0b1420;

margin-top:10px;

}

.pack722-fill{

height:100%;

background:
linear-gradient(
90deg,
#2d7dff,
#5df0ff
);

}

</style>

<div class="pack722">

<h4>

Reviewer Confidence Engine

</h4>

<div class="pack722-grid">

<div class="pack722-box">

Confidence

<div
class="pack722-big"
id="pack722Confidence"
>

0%

</div>

</div>

<div class="pack722-box">

Chair Decision

<div
id="pack722Decision"
class="pack722-big"
>

—

</div>

</div>

<div class="pack722-box">

Consistency

<div
id="pack722Variance"
class="pack722-big"
>

—

</div>

</div>

</div>

<div
style="
margin-top:20px;
"
>

Criteria Heatmap

<div
class="pack722-bar"
>

<div
class="pack722-fill"
id="pack722Heat"
style="
width:0%;
"
>

</div>

</div>

<div
id="pack722Explain"
style="
margin-top:12px;
"
>

Waiting…

</div>

</div>

</div>

<script>

/* PACK722_INTELLIGENCE */

document.addEventListener(

'DOMContentLoaded',

function(){

function calc(){

let vals=[];

document
.querySelectorAll(
'.rr-criterion'
)

.forEach(

function(el){

if(
el.disabled
)
return;

let v=
parseFloat(
el.value
||0
);

let m=
parseFloat(
el.max
||10
);

vals.push(
v/m
);

}

);

if(
!vals.length
)
return;

let avg=
vals.reduce(
(a,b)=>a+b,
0
)
/vals.length;

let variance=
vals.reduce(
(a,b)=>
a+
Math.pow(
b-avg,
2
),
0
)
/vals.length;

let conf=
Math.round(
avg
*100
);

let consistency=
Math.max(
0,
100-
Math.round(
variance
*300
)
);

document
.getElementById(
'pack722Confidence'
)
.innerHTML=
conf+'%';

document
.getElementById(
'pack722Variance'
)
.innerHTML=
consistency+'%';

document
.getElementById(
'pack722Heat'
)
.style.width=
conf+'%';

let decision=
'Major Revision';

if(
conf>=90
)
decision='Accept';

else if(
conf>=75
)
decision='Minor Revision';

else if(
conf<55
)
decision='Reject';

document
.getElementById(
'pack722Decision'
)
.innerHTML=
decision;

let txt=
'Confidence derived from weighted reviewer inputs. Chair preview is advisory only.';

if(
consistency<70
){

txt+=
' High scoring variance detected.';

}

document
.getElementById(
'pack722Explain'
)
.innerHTML=
txt;

}

document
.querySelectorAll(
'.rr-criterion'
)

.forEach(

x=>
x.addEventListener(
'input',
calc
)

);

setTimeout(
calc,
800
);

}

);

</script>

<!-- END PACK722 -->




<style>

.pack723{
margin-top:18px;
padding:20px;
border-radius:18px;

background:
linear-gradient(
135deg,
#071625,
#0f2748
);

color:#fff;
}

.pack723-grid{
display:grid;
grid-template-columns:
repeat(
4,
1fr
);
gap:14px;
}

.pack723-card{

padding:16px;

border-radius:14px;

background:
rgba(
255,
255,
255,
.05
);

}

.pack723-big{

font-size:32px;

font-weight:900;

color:#63a8ff;

}

</style>

<div class="pack723">

<h4>

Consensus Intelligence Studio

</h4>

<div class="pack723-grid">

<div class="pack723-card">

Current

<div
id="pack723Current"
class="pack723-big"
>

0%

</div>

</div>

<div class="pack723-card">

Consensus

<div
id="pack723Consensus"
class="pack723-big"
>

0%

</div>

</div>

<div class="pack723-card">

Conflict

<div
id="pack723Conflict"
class="pack723-big"
>

Low

</div>

</div>

<div class="pack723-card">

Chair Preview

<div
id="pack723Chair"
class="pack723-big"
>

—

</div>

</div>

</div>

<div
style="
margin-top:18px;
"
>

<div
id="pack723Explain"
>

Waiting for reviewer input…

</div>

</div>

</div>

<script>

/* PACK723_CONSENSUS */

document.addEventListener(

'DOMContentLoaded',

function(){

function calc(){

let vals=[];

document
.querySelectorAll(
'.rr-criterion'
)

.forEach(

function(el){

if(
el.disabled
)
return;

vals.push(

parseFloat(
el.value
||0
)

);

}

);

if(
!vals.length
)
return;

let total=
vals.reduce(
(a,b)=>a+b,
0
);

let current=
Math.round(
(
total
/
(
vals.length
*
10
)
)
*
100
);

let consensus=
Math.round(
current
*
0.9
+
(
vals.length
*
2
)
);

consensus=
Math.min(
100,
consensus
);

let diff=
Math.abs(
current
-
consensus
);

let conflict='Low';

if(
diff>=20
)
conflict='High';

else if(
diff>=10
)
conflict='Medium';

let chair='Major Revision';

if(
consensus>=90
)
chair='Accept';

else if(
consensus>=75
)
chair='Minor Revision';

else if(
consensus<55
)
chair='Reject';

document
.getElementById(
'pack723Current'
)
.innerHTML=
current+'%';

document
.getElementById(
'pack723Consensus'
)
.innerHTML=
consensus+'%';

document
.getElementById(
'pack723Conflict'
)
.innerHTML=
conflict;

document
.getElementById(
'pack723Chair'
)
.innerHTML=
chair;

let txt=
'Consensus is simulated and does not modify decisions.';

if(
conflict==='High'
){

txt+=
' Significant divergence detected.';

}

document
.getElementById(
'pack723Explain'
)
.innerHTML=
txt;

}

document
.querySelectorAll(
'.rr-criterion'
)

.forEach(

x=>
x.addEventListener(
'input',
calc
)

);

setTimeout(
calc,
700
);

}

);

</script>

<!-- END PACK723 -->




<style>

.pack724{

margin-top:18px;

padding:20px;

border-radius:20px;

background:
linear-gradient(
135deg,
#07131f,
#0e2744
);

color:#fff;

}

.pack724-grid{

display:grid;

grid-template-columns:
1.2fr 1fr 1fr;

gap:14px;

}

.pack724-card{

padding:16px;

border-radius:16px;

background:
rgba(
255,
255,
255,
.05
);

}

.pack724-big{

font-size:34px;

font-weight:900;

color:#63a8ff;

}

.pack724-track{

height:12px;

background:#08131e;

border-radius:999px;

overflow:hidden;

margin-top:12px;

}

.pack724-fill{

height:100%;

width:0;

transition:.5s;

background:
linear-gradient(
90deg,
#3d7eff,
#55d7ff
);

}

.pack724-timeline{

display:flex;

gap:8px;

margin-top:14px;

}

.pack724-dot{

width:16px;

height:16px;

border-radius:50%;

background:#173253;

}

.pack724-active{

background:#4aa8ff;

}

</style>

<div class="pack724">

<h4>

Reviewer Calibration Studio

</h4>

<div class="pack724-grid">

<div class="pack724-card">

Calibration

<div
id="pack724Calibration"
class="pack724-big"
>

0%

</div>

<div
class="pack724-track"
>

<div
id="pack724Fill"
class="pack724-fill"
>

</div>

</div>

</div>

<div class="pack724-card">

Outlier

<div
id="pack724Outlier"
class="pack724-big"
>

No

</div>

</div>

<div class="pack724-card">

Confidence Drift

<div
id="pack724Drift"
class="pack724-big"
>

Stable

</div>

</div>

</div>

<div
class="pack724-timeline"
id="pack724Timeline"
>

</div>

<div
style="
margin-top:18px;
opacity:.9;
"
id="pack724Explain"
>

Waiting for calibration…

</div>

</div>

<script>

/* PACK724_CALIBRATION */

document.addEventListener(

'DOMContentLoaded',

function(){

let history=[];

function calc(){

let vals=[];

document
.querySelectorAll(
'.rr-criterion'
)

.forEach(

function(el){

if(
el.disabled
)
return;

vals.push(

parseFloat(
el.value
||0

)

);

}

);

if(
!vals.length
)
return;

let avg=
vals.reduce(
(a,b)=>a+b,
0
)
/vals.length;

let variance=
vals.reduce(

(a,b)=>

a+

Math.pow(
b-avg,
2
),

0

)

/vals.length;

let cal=
Math.max(

0,

100-

Math.round(
variance*8
)

);

history.push(
cal
);

if(
history.length>12
)
history.shift();

let drift='Stable';

if(
history.length>2
){

let delta=

Math.abs(

history[
history.length-1
]

-

history[0]

);

if(
delta>20
)
drift='High';

else if(
delta>10
)
drift='Medium';

}

let out=
variance>10;

document
.getElementById(
'pack724Calibration'
)
.innerHTML=
cal+'%';

document
.getElementById(
'pack724Outlier'
)
.innerHTML=
out
?
'Yes'
:
'No';

document
.getElementById(
'pack724Drift'
)
.innerHTML=
drift;

document
.getElementById(
'pack724Fill'
)
.style.width=
cal+'%';

let tl=
document.getElementById(
'pack724Timeline'
);

tl.innerHTML='';

history.forEach(

function(v){

let d=
document.createElement(
'div'
);

d.className=
'pack724-dot';

if(
v>=70
)
d.classList.add(
'pack724-active'
);

tl.appendChild(
d
);

}

);

let txt=
'Calibration estimates reviewer consistency over time.';

if(
out
){

txt+=
' Extreme score spread detected.';

}

document
.getElementById(
'pack724Explain'
)
.innerHTML=
txt;

}

document
.querySelectorAll(
'.rr-criterion'
)

.forEach(

x=>
x.addEventListener(
'input',
calc
)

);

setTimeout(
calc,
900
);

}

);

</script>

<!-- END PACK724 -->


</form>

</div>

<script>
document.addEventListener('input', function () {
    const criteria = [...document.querySelectorAll('.rr-criterion')];
    const overall = document.querySelector('.rr-overall');
    const select = document.querySelector('.rr-select');

    let total = 0;
    let max = 0;

    criteria.forEach(function (x) {
        total += parseFloat(x.value || 0);
        max += parseFloat(x.getAttribute('max') || 10);
    });

    let percent = 0;

    if (max > 0) {
        percent = Math.round((total / max) * 100);
    } else if (overall) {
        percent = Math.round((parseFloat(overall.value || 0) / 10) * 100);
        total = parseFloat(overall.value || 0);
    }

    percent = Math.max(0, Math.min(100, percent));

    let rec = 'major_revision';
    let label = 'Major Revision';

    if (percent >= 85) {
        rec = 'accept';
        label = 'Accept';
    } else if (percent >= 70) {
        rec = 'minor_revision';
        label = 'Minor Revision';
    } else if (percent >= 50) {
        rec = 'major_revision';
        label = 'Major Revision';
    } else {
        rec = 'reject';
        label = 'Reject';
    }

    const p = document.getElementById('rr_progress');
    const b = document.getElementById('rr_bar');
    const s = document.getElementById('rr_score_preview');
    const r = document.getElementById('rr_recommend');

    if (p) p.innerHTML = percent + '%';
    if (b) b.style.width = percent + '%';
    if (s) s.value = total.toFixed(1);
    if (r) r.value = label;

    if (select && !select.value) {
        select.value = rec;
    }
});
</script>


<!-- PACK708D SAFE -->







<!-- END PACK715_SAFE_BLOCK_BINDING -->


<script>

/* PACK716_FORCE_HIDE */

document.addEventListener(

'DOMContentLoaded',

function(){

const cfg=
<?= json_encode($reviewBlocks ?? []) ?>;

function disabled(k){

return (
cfg[k]
&&
Number(cfg[k].is_enabled)===0
);

}

function kill(words){

document
.querySelectorAll('.card')

.forEach(

function(card){

const txt=
(
card.innerText
||
''
)
.toLowerCase();

for(
const w
of words
){

if(
txt.includes(
w.toLowerCase()
)
){

card.remove();

return;

}

}

}

);

}

if(
disabled('criteria')
){

kill([
'مساعد القرار',
'deep evaluation studio',
'درجات المعايير'
]);

}

if(
disabled('recommendation')
){

kill([
'structured evidence builder',
'reviewer deep scoring studio',
'evidence mapping studio',
'التوصية'
]);

}

if(
disabled('comments_author')
){

kill([
'adaptive scoring engine',
'ملاحظات للمؤلف'
]);

}

if(
disabled('comments_editor')
){

kill([
'evaluation intelligence grid',
'ملاحظات للمحرر'
]);

}

if(
disabled('upload_review_file')
){

kill([
'explainable evaluation studio',
'multi-dimensional assessment lab',
'رفع ملف مراجعة'
]);

}

});

</script>

<!-- END PACK716 -->


<?php if(isset($_GET['debug_review_blocks'])): ?>

<pre style="
position:fixed;
top:20px;
right:20px;
z-index:999999;
background:#111;
color:#0f0;
padding:20px;
max-height:80vh;
overflow:auto;
">

<?= htmlspecialchars(
print_r(
$reviewBlocks ?? null,
true
)
) ?>

</pre>

<?php endif; ?>


<?php if(isset($_GET['debug_review_blocks'])): ?>

<div style="
position:fixed;
top:20px;
right:20px;
z-index:999999;
background:#111;
color:#0f0;
padding:20px;
max-width:700px;
overflow:auto;
">

<pre>

<?= htmlspecialchars(
print_r(
$reviewBlocks ?? [],
true
)
) ?>

</pre>

</div>

<?php endif; ?>



<script>
/* PACK719_FINAL_RUNTIME_BINDING */
document.addEventListener('DOMContentLoaded', function () {
    const cfg = <?= json_encode($reviewBlocks ?? []) ?> || {};

    function isOff(keys) {
        for (const k of keys) {
            if (cfg[k] && Number(cfg[k].is_enabled) === 0) return true;
        }
        return false;
    }

    function isReq(keys) {
        for (const k of keys) {
            if (cfg[k] && Number(cfg[k].is_required) === 1) return true;
        }
        return false;
    }

    function removeClosest(selector) {
        document.querySelectorAll(selector).forEach(function (el) {
            const box = el.closest('.mb-3,.card,.row,.form-group') || el.parentElement;
            if (box) box.remove();
        });
    }

    function markRequired(selector) {
        document.querySelectorAll(selector).forEach(function (el) {
            el.required = true;
            const box = el.closest('.mb-3,.card,.row,.form-group') || el.parentElement;
            const lbl = box ? box.querySelector('label') : null;
            if (lbl && !lbl.innerHTML.includes('pack719-required')) {
                lbl.innerHTML += ' <span class="pack719-required" style="color:#ef4444">*</span>';
            }
        });
    }

    function removeCardsByText(words) {
        document.querySelectorAll('.card').forEach(function (card) {
            const txt = (card.innerText || card.textContent || '').toLowerCase();
            for (const w of words) {
                if (txt.includes(w.toLowerCase())) {
                    card.remove();
                    return;
                }
            }
        });
    }

    if (isOff(['criteria'])) {
        removeClosest('.rr-criterion,input[name^="criteria"]');
        removeCardsByText(['مساعد القرار','Deep Evaluation Studio','درجات المعايير']);
    } else if (isReq(['criteria'])) {
        markRequired('.rr-criterion,input[name^="criteria"]');
    }

    if (isOff(['recommendation'])) {
        removeClosest('select[name="recommendation"]');
        removeCardsByText(['Structured Evidence Builder','Reviewer Deep Scoring Studio','Evidence Mapping Studio','التوصية']);
    } else if (isReq(['recommendation'])) {
        markRequired('select[name="recommendation"]');
    }

    if (isOff(['comments_author'])) {
        removeClosest('textarea[name="comments_to_author"]');
        removeCardsByText(['Adaptive Scoring Engine','ملاحظات للمؤلف']);
    } else if (isReq(['comments_author'])) {
        markRequired('textarea[name="comments_to_author"]');
    }

    if (isOff(['comments_editor'])) {
        removeClosest('textarea[name="comments_to_editor"]');
        removeCardsByText(['Evaluation Intelligence Grid','ملاحظات للمحرر']);
    } else if (isReq(['comments_editor'])) {
        markRequired('textarea[name="comments_to_editor"]');
    }

    if (isOff(['upload','upload_review_file'])) {
        removeClosest('input[name="review_file"],input[type="file"]');
        removeCardsByText(['Explainable Evaluation Studio','Multi-Dimensional Assessment Lab','رفع ملف مراجعة']);
    } else if (isReq(['upload','upload_review_file'])) {
        markRequired('input[name="review_file"],input[type="file"]');
    }
});
</script>
<!-- END PACK719_FINAL_RUNTIME_BINDING -->


<script>

/* PACK720_SAFE_RUNTIME */

document.addEventListener(

'DOMContentLoaded',

function(){

const gov=
<?= json_encode(
$reviewGovernance
??[]
) ?>;

document
.querySelectorAll(
'.rr-criterion'
)

.forEach(

function(el){

const key=
el.dataset.key
||
el.name
||
'';

if(
gov[key]
&&
Number(
gov[key].is_active
)===0
){

el.disabled=true;

el.style.opacity=.35;

}

}

);

const f=
document.querySelector(
'form'
);

if(
f
){

f.addEventListener(

'submit',

function(e){

let invalid=false;

document
.querySelectorAll(
'.rr-criterion'
)

.forEach(

function(el){

if(
el.required
&&
!el.value
){

invalid=true;

}

}

);

if(
invalid
){

e.preventDefault();

alert(
'Complete required review criteria.'
);

}

}

);

}

});

</script>

<!-- END PACK720 -->

