<?php

$lang =
    $_SESSION['lang']
    ?? 'ar';

$isArabic =
    $lang === 'ar';

?>

<style>

.studio-hero{
border-radius:28px;
background:
linear-gradient(
135deg,
#0f172a,
#1d4ed8
);
color:#fff;
overflow:hidden;
position:relative;
}

.studio-card{
border:0;
border-radius:24px;
transition:.25s;
box-shadow:
0 10px 30px rgba(15,23,42,.08);
height:100%;
}

.studio-card:hover{
transform:translateY(-4px);
}

.metric-chip{
padding:10px 18px;
border-radius:999px;
background:#fff;
font-weight:700;
display:inline-flex;
align-items:center;
gap:8px;
color:#111827;
}

.flow-card{
border:0;
border-radius:24px;
box-shadow:
0 10px 30px rgba(15,23,42,.08);
}

.flow-item{
border-radius:18px;
padding:18px;
background:#f8fafc;
transition:.2s;
}

.flow-item:hover{
background:#eef2ff;
}

.flow-order{
width:42px;
height:42px;
border-radius:50%;
background:#1d4ed8;
color:#fff;
display:flex;
align-items:center;
justify-content:center;
font-weight:700;
}

.flow-type{
font-size:12px;
padding:6px 12px;
border-radius:999px;
background:#dbeafe;
color:#1e3a8a;
font-weight:700;
}

</style>

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

<div class="studio-hero p-5 mb-4">

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

<div>

<div class="opacity-75 mb-2">

<?= $isArabic
? 'استوديو إدارة الصفحة الرئيسية'
: 'Homepage Studio' ?>

</div>

<h1 class="fw-bold mb-3">

<?= htmlspecialchars(
$conference['title_en']
?? 'Conference'
) ?>

</h1>

<div class="fs-5 opacity-75">

<?= $isArabic
? 'إدارة الصفحة الرئيسية للمؤتمر'
: 'Conference Homepage Management Center' ?>

</div>

<div class="mt-4 d-flex flex-wrap gap-3">

<?php foreach ($stats as $k => $v): ?>

<div class="metric-chip">

<?= $v ?>

<?= ucfirst($k) ?>

</div>

<?php endforeach; ?>

</div>

</div>

<div>

<a
href="/easychair/conference/<?= urlencode(
$conference['slug']
?? ''
) ?>"
target="_blank"
class="btn btn-light btn-lg rounded-pill px-4 fw-bold"
>

<i class="fa fa-eye"></i>

<?= $isArabic
? 'معاينة الصفحة'
: 'Live Preview' ?>

</a>

</div>

</div>

</div>

<div class="row g-4">

<?php foreach ($modules as $m): ?>

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

<a
href="<?= htmlspecialchars($m['url']) ?>"
class="text-decoration-none"
>

<div class="card studio-card">

<div class="card-body p-4">

<div
class="
rounded-circle
bg-primary
text-white
d-flex
align-items-center
justify-content-center
mb-4
"
style="
width:70px;
height:70px;
font-size:28px;
"
>

<i class="fa <?= htmlspecialchars($m['icon']) ?>"></i>

</div>

<h4 class="fw-bold text-dark">

<?= htmlspecialchars($m['title']) ?>

</h4>

<div class="text-muted mb-3">

<?= $m['count'] ?>

<?= $isArabic
? 'عنصر'
: 'Items' ?>

</div>

<div class="btn btn-outline-primary rounded-pill">

<?= $isArabic
? 'إدارة'
: 'Manage' ?>

</div>

</div>

</div>

</a>

</div>

<?php endforeach; ?>

</div>

<div class="card flow-card mt-5">

<div class="card-body p-4">

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

<div>

<h3 class="fw-bold mb-1">

<?= $isArabic
? 'تسلسل الصفحة الرئيسية'
: 'Homepage Flow Sequence' ?>

</h3>

<div class="text-muted">

<?= $isArabic
? 'ترتيب ظهور عناصر الصفحة الرئيسية'
: 'Homepage rendering order orchestration' ?>

</div>

</div>

<a
href="/easychair/admin/conference-home-builder"
class="btn btn-primary rounded-pill px-4"
>

<i class="fa fa-panorama"></i>

<?= $isArabic
? 'إدارة البناء'
: 'Manage Builder' ?>

</a>

</div>

<div class="row g-3">

<?php foreach (($homepageFlow ?? []) as $f): ?>

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

<div
class="
flow-item
d-flex
align-items-center
justify-content-between
gap-3
"
>

<div class="d-flex align-items-center gap-3">

<div class="flow-order">

<?= (int)$f['sort_order'] ?>

</div>

<div>

<div class="fw-bold">

<?= htmlspecialchars(

$isArabic
? (
$f['title_ar']
?: $f['title_en']
)
: (
$f['title_en']
?: $f['title_ar']
)

) ?>

</div>

<div class="mt-2">

<span class="flow-type">

<?= htmlspecialchars(
$f['block_type']
) ?>

</span>

<?php if ((int)$f['is_active'] === 1): ?>

<span class="badge bg-success">

<?= $isArabic
? 'نشط'
: 'Active' ?>

</span>

<?php else: ?>

<span class="badge bg-secondary">

<?= $isArabic
? 'مخفي'
: 'Hidden' ?>

</span>

<?php endif; ?>

</div>

</div>

</div>

<div>

<a
href="/easychair/admin/homepage-content"
class="btn btn-sm btn-outline-primary rounded-pill"
>

<?= $isArabic
? 'تحرير'
: 'Edit' ?>

</a>

</div>

</div>

</div>

<?php endforeach; ?>

</div>

</div>

</div>

</div>
