<?php die("CONFERENCE_HOME_SLUG_DIE_TEST"); ?>
<?php
function pch_h($v) {
    return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8');
}

$title = ($conference['title_ar'] ?? '') ?: ($conference['title_en'] ?? $conference['short_name']);
$brief = ($conference['brief_ar'] ?? '') ?: ($conference['brief_en'] ?? $conference['description_ar'] ?? $conference['description_en'] ?? '');
$slug = $conference['slug'] ?? '';
$base = '/easychair/c/' . rawurlencode($slug);
$heroBanner = ($conference['banner_path'] ?? '') ?: ($conference['org_banner'] ?? '');

$registrationOpen = in_array(($conference['status'] ?? ''), ['open','reviewing','decision'], true)
    && (($conference['cfp_status'] ?? 'open') === 'open');

if (!empty($conference['submission_start']) && strtotime($conference['submission_start']) > time()) {
    $registrationOpen = false;
}


if (!empty($conference['submission_end']) && strtotime($conference['submission_end']) < time()) {
    $registrationOpen = false;
}

/*
|--------------------------------------------------------------------------
| LANGUAGE MODE
|--------------------------------------------------------------------------
*/

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

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

$dir =
    $isArabic
        ? 'rtl'
        : 'ltr';

?>
<!DOCTYPE html>
<html lang="<?= pch_h($lang) ?>" dir="<?= pch_h($dir) ?>">
<head>
<meta charset="UTF-8">
<title><?= pch_h($title) ?></title>
<meta name="description" content="<?= pch_h(mb_substr(strip_tags($brief),0,155)) ?>">
<meta property="og:title" content="<?= pch_h($title) ?>">
<meta property="og:description" content="<?= pch_h(mb_substr(strip_tags($brief),0,155)) ?>">
<meta property="og:type" content="website">
<link rel="canonical" href="<?= pch_h($base) ?>">
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;700;900&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.rtl.min.css" rel="stylesheet">
<style>
body{font-family:Cairo,sans-serif;background:#f8fafc;color:#0f172a}
.hero.has-banner{background-image:linear-gradient(135deg,rgba(15,23,42,.86),rgba(29,78,216,.82)),var(--hero-bg);background-size:cover;background-position:center}
.hero{background:linear-gradient(135deg,#0f172a,#1d4ed8);color:white;padding:56px 0 42px;border-radius:0 0 42px 42px;box-shadow:0 20px 55px rgba(15,23,42,.22)}
.hero h1{font-weight:900}
.cardx{border:0;border-radius:24px;box-shadow:0 16px 42px rgba(15,23,42,.08)}
.avatar{width:88px;height:88px;border-radius:50%;object-fit:cover}
.noavatar{width:88px;height:88px;border-radius:50%;background:#e2e8f0;display:flex;align-items:center;justify-content:center;color:#64748b;font-weight:900}
.btn-main{background:linear-gradient(135deg,#16a34a,#22c55e);border:0;color:#fff;border-radius:999px;font-weight:900;padding:13px 24px}
.btn-main:hover{color:#fff;filter:brightness(.96)}
.nav-pill{border-radius:999px}
.meta-chip{display:inline-flex;gap:6px;align-items:center;background:rgba(255,255,255,.12);padding:8px 12px;border-radius:999px;margin:3px}
.section-title{font-weight:900;margin-bottom:18px}

.carousel-item{
border-radius:28px;
overflow:hidden;
}

.carousel-control-prev,
.carousel-control-next{
width:6%;
}

.timeline-dates .border-bottom:last-child{
border-bottom:0!important;
}

.ec-committee-fallback{
width:130px;
height:130px;
border-radius:50%;
display:flex;
align-items:center;
justify-content:center;
background:linear-gradient(135deg,#2563eb,#0ea5e9);
color:#fff;
margin:auto;
}

.ec-committee-fallback i{
font-size:52px;
}

</style>
</head>
<body>

<div style="position:fixed;top:0;left:0;z-index:999999;background:red;color:white;padding:20px;font-size:28px">REAL conference_home_slug.php LOADED</div>

<div class="hero <?= $heroBanner ? 'has-banner' : '' ?>" <?= $heroBanner ? 'style="--hero-bg:url(/easychair/' . pch_h($heroBanner) . ')"' : '' ?>>
    <div class="container">
        <div class="row g-4 align-items-center">
            <div class="col-lg-8">
                <div class="mb-2 opacity-75"><?= pch_h($conference['org_name'] ?? '') ?></div>
                <h1><?= pch_h($title) ?></h1>
                <div class="fs-5 opacity-75"><?= pch_h($conference['short_name'] ?? '') ?></div>

                <div class="mt-3">
                    <?php if (!empty($conference['start_date'])): ?>
                        <span class="meta-chip">Start: <?= pch_h($conference['start_date']) ?></span>
                    <?php endif; ?>
                    <?php if (!empty($conference['end_date'])): ?>
                        <span class="meta-chip">End: <?= pch_h($conference['end_date']) ?></span>
                    <?php endif; ?>
                    <?php if (!empty($conference['venue_ar']) || !empty($conference['venue_en'])): ?>
                        <span class="meta-chip"><?= pch_h($conference['venue_ar'] ?: $conference['venue_en']) ?></span>
                    <?php endif; ?>
                    <span class="meta-chip"><?= pch_h($conference['status']) ?></span>
                </div>

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

    <span class="meta-chip">
        <?= count($tracks ?: $themes) ?>
        <?= $isArabic ? 'مسار' : 'Tracks' ?>
    </span>

    <span class="meta-chip">
        <?= count($speakers) ?>
        <?= $isArabic ? 'متحدث' : 'Speakers' ?>
    </span>

    <span class="meta-chip">
        <?= count($sponsors) ?>
        <?= $isArabic ? 'راعٍ' : 'Sponsors' ?>
    </span>

    <span class="meta-chip">
        <?= count($blocks ?? []) ?>
        <?= $isArabic ? 'قسم' : 'Sections' ?>
    </span>

</div>
                <div class="mt-4 d-flex gap-2 flex-wrap">
                    <?php if ($registrationOpen): ?>
                        <a class="btn btn-main" href="<?= pch_h($base) ?>/register"><?= $isArabic ? 'تسجيل / إرسال بحث' : 'Register as Author' ?></a>
                    <?php else: ?>
                        <button class="btn btn-secondary nav-pill" disabled><?= $isArabic ? 'تم إغلاق التسجيل' : 'Registration Closed' ?></button>
                    <?php endif; ?>
                    <a class="btn btn-outline-light nav-pill" href="<?= pch_h($base) ?>/program"><?= $isArabic ? 'البرنامج' : 'Program' ?></a>
                    <a class="btn btn-outline-light nav-pill" href="<?= pch_h($base) ?>/proceedings"><?= $isArabic ? 'وقائع المؤتمر' : 'Proceedings' ?></a>
                    <a class="btn btn-outline-light nav-pill" href="/easychair/login"><?= $isArabic ? 'تسجيل الدخول' : 'Login' ?></a>
                </div>
            </div>
            <div class="col-lg-4 text-center">
                <?php if (!empty($conference['logo_path'])): ?>
                    <img src="/easychair/<?= pch_h($conference['logo_path']) ?>" style="max-height:150px;max-width:100%;background:white;border-radius:24px;padding:18px;">
                <?php elseif (!empty($conference['org_logo'])): ?>
                    <img src="/easychair/<?= pch_h($conference['org_logo']) ?>" style="max-height:150px;max-width:100%;background:white;border-radius:24px;padding:18px;">
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>

<div class="container py-5">

<?php

$heroSlides =
    array_filter(
        $blocks ?? [],
        fn($x) =>
            ($x['block_type'] ?? '')
            === 'hero_slide'
    );

?>

<?php if (!empty($heroSlides)): ?>

<div
id="conferenceHeroCarousel"
class="carousel slide carousel-fade mb-5"
data-bs-ride="carousel"
>

<div class="carousel-inner rounded-4 overflow-hidden shadow-lg">

<?php $heroIndex = 0; ?>

<?php foreach ($heroSlides as $hero): ?>

<div class="carousel-item <?= $heroIndex === 0 ? 'active' : '' ?>">

<div
class="position-relative"
style="
min-height:540px;
background:
linear-gradient(
135deg,
rgba(15,23,42,.92),
rgba(29,78,216,.82)
);
"
>

<?php if (!empty($hero['image_path'])): ?>

<img
src="/easychair/<?= pch_h($hero['image_path']) ?>"
class="w-100 h-100 position-absolute top-0 start-0"
style="
object-fit:cover;
opacity:.25;
"
>

<?php endif; ?>

<div
class="
position-relative
z-2
text-white
d-flex
align-items-center
"
style="min-height:540px;"
>

<div class="container">

<div class="row">

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

<span class="badge bg-light text-dark px-3 py-2 mb-3">

<?= $isArabic
    ? 'مؤتمر علمي دولي محكّم'
    : 'International Peer-Reviewed Conference' ?>

</span>

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

<?php

$blockTitle =
    '';

if ($isArabic) {

    $blockTitle =
        $b['title_ar']
        ?? $b['name_ar']
        ?? $b['full_name_ar']
        ?? $b['full_name']
        ?? $b['title_en']
        ?? $b['name_en']
        ?? '';

} else {

    $blockTitle =
        $b['title_en']
        ?? $b['name_en']
        ?? $b['full_name_en']
        ?? $b['full_name']
        ?? $b['title_ar']
        ?? $b['name_ar']
        ?? '';
}

echo pch_h($blockTitle);

?>
</h1>

<div class="fs-5 mb-4" style="line-height:1.9;">

<?php

$blockBody =
    '';

if ($isArabic) {

    $blockBody =
        $b['body_ar']
        ?? $b['description_ar']
        ?? $b['bio_ar']
        ?? $b['body_en']
        ?? $b['description_en']
        ?? $b['bio_en']
        ?? '';

} else {

    $blockBody =
        $b['body_en']
        ?? $b['description_en']
        ?? $b['bio_en']
        ?? $b['body_ar']
        ?? $b['description_ar']
        ?? $b['bio_ar']
        ?? '';
}

echo nl2br(
    pch_h($blockBody)
);

?>
</div>

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

<?php if ($registrationOpen): ?>

<a
href="/easychair/author/submit"
class="btn btn-light btn-lg rounded-pill px-4"
>

<i class="fa fa-paper-plane"></i>

<?= $isArabic
    ? 'إرسال بحث'
    : 'Submit Paper' ?>

</a>

<?php endif; ?>

<a
href="/easychair/login"
class="btn btn-outline-light btn-lg rounded-pill px-4"
>

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

<?= $isArabic
    ? 'دخول النظام'
    : 'Portal Login' ?>

</a>

</div>

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

<div class="meta-chip bg-white text-dark">
    <?= count($tracks ?: $themes) ?>
    <?= $isArabic ? 'مسار' : 'Tracks' ?>
</div>

<div class="meta-chip bg-white text-dark">
    <?= count($speakers) ?>
    <?= $isArabic ? 'متحدث' : 'Speakers' ?>
</div>

<div class="meta-chip bg-white text-dark">
    <?= count($sponsors) ?>
    <?= $isArabic ? 'راعٍ' : 'Sponsors' ?>
</div>

<div class="meta-chip bg-white text-dark">
    <?= count($committees ?? []) ?>
    <?= $isArabic ? 'لجنة' : 'Committees' ?>
</div>

</div>

</div>

</div>

</div>

</div>

</div>

</div>

<?php $heroIndex++; ?>

<?php endforeach; ?>

</div>

<button
class="carousel-control-prev"
type="button"
data-bs-target="#conferenceHeroCarousel"
data-bs-slide="prev"
>

<span class="carousel-control-prev-icon"></span>

</button>

<button
class="carousel-control-next"
type="button"
data-bs-target="#conferenceHeroCarousel"
data-bs-slide="next"
>

<span class="carousel-control-next-icon"></span>

</button>

</div>

<?php endif; ?>

<?php

$hasDynamicConferenceAbout = false;

if (!empty($cmsSections) && is_array($cmsSections)) {

    foreach ($cmsSections as $__cmsCheck) {

        if (
            (($__cmsCheck['section_key'] ?? '') === 'conference_about')
            &&
            (int)($__cmsCheck['enabled'] ?? 1) === 1
        ) {
            $hasDynamicConferenceAbout = true;
            break;
        }
    }
}

?>

<?php if (!$hasDynamicConferenceAbout): ?>

    <div class="card cardx mb-4">
        <div class="card-body p-4">
            <h3 class="section-title"> <?= $isArabic ? 'حول المؤتمر' : 'About the Conference' ?></h3>
            <div style="line-height:1.9"><?= nl2br(pch_h($brief)) ?></div>
        </div>
    </div>

<?php endif; ?>

    <?php if (!empty($conference['cfp_ar']) || !empty($conference['cfp_en'])): ?>
        <div class="card cardx mb-4">
            <div class="card-body p-4">
                <h3 class="section-title"> <?= $isArabic ? 'الدعوة لتقديم الأبحاث' : 'Call for Papers' ?></h3>
                <div style="line-height:1.9"><?= nl2br(pch_h($conference['cfp_ar'] ?: $conference['cfp_en'])) ?></div>
                <?php if ($registrationOpen): ?>
                    <a class="btn btn-main mt-3" href="<?= pch_h($base) ?>/register"><?= $isArabic ? 'التقديم / التسجيل' : 'Submit / Register' ?></a>
                <?php endif; ?>
            </div>
        </div>
    <?php endif; ?>

    <?php if (!empty($themes)): ?>
        <div class="card cardx mb-4">
            <div class="card-body p-4">
<h3 class="section-title"> 
    <?= $isArabic ? 'المحاور والمسارات' : 'Themes & Tracks' ?>
</h3>                
                <div class="row g-3">
                    <?php foreach (($tracks ?: $themes) as $t): ?>
                        <div class="col-md-4">
                            <div class="border rounded-4 p-3 h-100">
                                <span class="badge bg-primary"><?= pch_h(
    $t['track_code']
    ?? $t['theme_type']
    ?? 'Track'
) ?></span>
                                <h5 class="fw-bold mt-2"><?php

$blockTitle =
    '';

if ($isArabic) {

    $blockTitle =
        $b['title_ar']
        ?? $b['name_ar']
        ?? $b['full_name_ar']
        ?? $b['full_name']
 ?? $b['affiliation_ar']
 ?? $b['role_title_ar']
        ?? $b['title_en']
        ?? $b['name_en']
        ?? '';

} else {

    $blockTitle =
        $b['title_en']
        ?? $b['name_en']
        ?? $b['full_name_en']
        ?? $b['full_name']
 ?? $b['affiliation_en']
 ?? $b['role_title_en']   
     ?? $b['title_ar']
        ?? $b['name_ar']
        ?? '';
}

echo pch_h($blockTitle);

?></h5>
                                <div class="text-muted small"><?= nl2br(pch_h($t['description_ar'] ?: $t['description_en'])) ?></div>
                            </div>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>
        </div>
    <?php endif; ?>


<?php foreach (($blocks ?? []) as $b): ?>

<?php

if (
    ($b['block_type'] ?? '')
    === 'hero_slide'
) {
    continue;
}

?>

<div class="card cardx mb-4">

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

<h3 class="section-title"> 

<?php

$blockTitle =
    '';

if ($isArabic) {

    $blockTitle =
        $b['title_ar']
        ?? $b['name_ar']
        ?? $b['full_name_ar']
        ?? $b['full_name']
        ?? $b['title_en']
        ?? $b['name_en']
        ?? '';

} else {

    $blockTitle =
        $b['title_en']
        ?? $b['name_en']
        ?? $b['full_name_en']
        ?? $b['full_name']
        ?? $b['title_ar']
        ?? $b['name_ar']
        ?? '';
}

?>

<h3 class="section-title"> 

<?= pch_h($blockTitle) ?>

</h3>
</h3>

<?php

$imagePath =
    $b['image_path']
    ?? $b['photo_path']
    ?? $b['logo']
    ?? '';

$imageUrl =
    '';

if (!empty($imagePath)) {

    /*
    ------------------------------------------
    STORAGE MEDIA
    ------------------------------------------
    */

    if (
        str_contains(
            $imagePath,
            'committees/'
        )
    ) {

        $imageUrl =
            '/easychair/storage/'
            . ltrim(
                $imagePath,
                '/'
            );

    }

    /*
    ------------------------------------------
    STANDARD PUBLIC UPLOADS
    ------------------------------------------
    */

    else {

        $imageUrl =
            '/easychair/'
            . ltrim(
                $imagePath,
                '/'
            );
    }
}

?>

<?php if (!empty($imageUrl)): ?>

<img
src="<?= pch_h($imageUrl) ?>"
class="img-fluid rounded-4 mb-3"
style="
max-height:320px;
width:100%;
object-fit:cover;
"
>

<?php endif; ?>


<?php if (($b['block_type'] ?? '') === 'important_date'): ?>

<?php

$dateContent =
    $isArabic
        ? ($b['body_ar'] ?: $b['body_en'])
        : ($b['body_en'] ?: $b['body_ar']);

$dateLines =
    preg_split(
        '/\r\n|\r|\n/',
        $dateContent
    );

?>

<div class="timeline-dates mt-4">

<?php foreach ($dateLines as $line): ?>

<?php if (trim($line) !== ''): ?>

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

<div
class="rounded-circle bg-primary"
style="
width:14px;
height:14px;
"
></div>

<div class="fw-semibold">

<?= pch_h($line) ?>

</div>

</div>

<?php endif; ?>

<?php endforeach; ?>

</div>

<?php else: ?>

<div style="line-height:1.9">

<?php

$blockBody =
    '';

if ($isArabic) {

    $blockBody =
        $b['body_ar']
        ?? $b['description_ar']
        ?? $b['bio_ar']
        ?? $b['body_en']
        ?? $b['description_en']
        ?? $b['bio_en']
        ?? '';

} else {

    $blockBody =
        $b['body_en']
        ?? $b['description_en']
        ?? $b['bio_en']
        ?? $b['body_ar']
        ?? $b['description_ar']
        ?? $b['bio_ar']
        ?? '';
}

?>

<div style="line-height:1.9">

<?= nl2br(
    pch_h($blockBody)
) ?>

</div>

</div>

<?php endif; ?>

<?php if (!empty($b['link_url'])): ?>

<a
class="btn btn-outline-primary mt-3"
href="<?= pch_h($b['link_url']) ?>"
>

<?= $isArabic ? 'المزيد' : 'More' ?>

</a>

<?php endif; ?>

</div>

</div>

<?php endforeach; ?>    

<?php if (!empty($speakers)): ?>

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

        <h3 class="section-title"> 
            <?= $isArabic ? 'المتحدثون الرئيسيون' : 'Keynote Speakers' ?>
        </h3>

        <div class="row g-4">

            <?php foreach ($speakers as $sp): ?>

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

                    <div class="border rounded-4 p-4 text-center h-100">

                        <?php if (!empty($sp['photo_path'])): ?>

                            <img
                                class="avatar mb-3"
                                src="/easychair/<?= pch_h($sp['photo_path']) ?>"
                            >

                        <?php else: ?>

                            <div class="noavatar mx-auto mb-3">
                                <?= mb_substr(
                                    pch_h($sp['full_name']),
                                    0,
                                    1
                                ) ?>
                            </div>

                        <?php endif; ?>

                        <h5 class="fw-bold">
                            <?= pch_h($sp['full_name']) ?>
                        </h5>

                        <div class="text-primary fw-bold">
                            <?= pch_h(
                                $isArabic
                                    ? ($sp['title_ar'] ?: $sp['title_en'])
                                    : ($sp['title_en'] ?: $sp['title_ar'])
                            ) ?>
                        </div>

                        <div class="small text-muted mt-2">
                            <?= pch_h($sp['institution_name']) ?>
                        </div>

                    </div>

                </div>

            <?php endforeach; ?>

        </div>

    </div>
</div>

<?php endif; ?>
    
<?php if (false && !empty($committees)): ?>

<style>

.ec-committee-grid{
display:grid;
grid-template-columns:repeat(auto-fit,minmax(280px,1fr));
gap:24px;
}

.ec-committee-card{
background:#fff;
border-radius:24px;
padding:28px;
text-align:center;
box-shadow:0 20px 50px rgba(0,0,0,.08);
transition:.25s;
height:100%;
}

.ec-committee-card:hover{
transform:translateY(-6px);
}

.ec-committee-photo{
width:130px;
height:130px;
border-radius:50%;
object-fit:cover;
border:5px solid #fff;
box-shadow:0 15px 40px rgba(37,99,235,.20);
}

.ec-committee-fallback{
width:130px;
height:130px;
border-radius:50%;
display:flex;
align-items:center;
justify-content:center;
font-size:42px;
font-weight:900;
color:#fff;
background:linear-gradient(135deg,#2563eb,#0ea5e9);
margin:auto;
}

.ec-committee-name{
margin-top:18px;
font-size:20px;
font-weight:800;
color:#0f172a;
}

.ec-committee-title{
margin-top:8px;
color:#2563eb;
font-weight:700;
}

.ec-committee-aff{
margin-top:8px;
font-size:14px;
color:#64748b;
}

</style>

<div class="card cardx mb-5">

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

<h3 class="section-title"> 
<?= $isArabic ? 'اللجان العلمية والتنظيمية' : 'Committees' ?>
</h3>

<div class="ec-committee-grid">

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

<?php

$name =
$isArabic
? ($m['full_name_ar'] ?: $m['full_name_en'])
: ($m['full_name_en'] ?: $m['full_name_ar']);

$title =
$isArabic
? ($m['title_ar'] ?: $m['title_en'])
: ($m['title_en'] ?: $m['title_ar']);

$aff =
$isArabic
? ($m['affiliation_ar'] ?: $m['affiliation_en'])
: ($m['affiliation_en'] ?: $m['affiliation_ar']);

$img='';

if(!empty($m['image_path']))
{
    $img='/easychair/' . ltrim($m['image_path'],'/');
}

?>

<div class="ec-committee-card">

<?php if($img): ?>

<img
src="<?= pch_h($img) ?>"
class="ec-committee-photo"
alt="<?= pch_h($name) ?>"
>

<?php else: ?>

<div class="ec-committee-fallback">
    <i class="fa fa-user-tie"></i>
</div>

<?php endif; ?>

<div class="ec-committee-name">
<?= pch_h($name) ?>
</div>

<div class="ec-committee-title">
<?= pch_h($title) ?>
</div>

<div class="ec-committee-aff">
<?= pch_h($aff) ?>
</div>

<span class="badge bg-primary mt-3">
<?= pch_h($m['committee_type']) ?>
</span>

</div>

<?php endforeach; ?>

</div>

</div>

</div>

<?php endif; ?>


<?php
/*
|--------------------------------------------------------------------------
| PACK1020
| Live Dynamic CMS Sections
|--------------------------------------------------------------------------
*/

if (!empty($cmsSections) && is_array($cmsSections)):

    $__registryReturn = [];

    if (file_exists(BASE_PATH . '/app/views/partials/_section_registry.php')) {
        $__registryReturn =
            require BASE_PATH . '/app/views/partials/_section_registry.php';
    }

    $__sectionRegistry =
        is_array($__registryReturn)
            ? $__registryReturn
            : (
                $sectionRegistry
                ?? $sectionsRegistry
                ?? $sectionPartials
                ?? []
            );

    foreach ($cmsSections as $currentSection):


echo '<div style="background:black;color:yellow;padding:10px;margin:5px">';
echo 'SECTION ID = ' . ($currentSection['id'] ?? 'NULL');
echo ' | KEY = ' . ($currentSection['section_key'] ?? 'NULL');

echo '<div style="background:black;color:lime;padding:8px;font-size:12px">';
echo 'CMS='
     . ($currentSection['id'] ?? 0)
     . ' | '
     . ($currentSection['section_key'] ?? '');
echo '</div>';


echo '<div style="display:none">';
echo 'CMS-ID=' . ($currentSection['id'] ?? 0);
echo '|KEY=' . ($currentSection['section_key'] ?? '');
echo '</div>';
?>
<?php
echo '<div style="
background:black;
color:lime;
padding:4px;
font-size:12px;
">';
echo ($currentSection['id'] ?? 0)
     . ' :: '
     . ($currentSection['section_key'] ?? '');
echo '</div>';
?>
<?php
$section = $currentSection;

$__sectionKey =
    (string)(
        $currentSection['section_key']
        ?? $currentSection['section_code']
        ?? $currentSection['section_type']
        ?? $currentSection['block_type']
        ?? $currentSection['type']
        ?? ''
    );

$__settings =
json_decode(
    (string)($currentSection['settings_json'] ?? '{}'),
    true
);

$__partial =
(
    is_array($__settings)
    &&
    !empty($__settings['layout_type'])
)
? 'dynamic_layout.php'
: (
    $__sectionRegistry[$__sectionKey]
    ?? ''
);


$__partialPath =
    $__partial !== ''
        ? BASE_PATH . '/app/views/partials/' . $__partial
        : '';

if (
    $__partialPath !== ''
    &&
    file_exists($__partialPath)
):

echo '<div style="background:yellow;color:black;padding:20px">';
echo 'SECTION=' . $__sectionKey;
echo '<br>PARTIAL=' . $__partial;
echo '<br>FILE=' . $__partialPath;
echo '</div>';
    
echo '<div style="
background:orange;
color:black;
padding:6px;
font-size:14px;
">
PARTIAL=' . htmlspecialchars($__partial) .
' | KEY=' . htmlspecialchars($__sectionKey) .
'</div>';

require $__partialPath;


else:
?>

<section
class="ec-dynamic-section card cardx mb-5"
id="<?= pch_h($__sectionKey) ?>"
>

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

<?php if (!empty($__title)): ?>

<h2 class="section-title">

<?php if (!empty($currentSection['icon_class'])): ?>
<i class="fa <?= pch_h($currentSection['icon_class']) ?>"></i>
<?php endif; ?>

<?= pch_h($__title) ?>

</h2>

<?php endif; ?>

<?php

$__subtitle =
$isArabic
? (
$currentSection['subtitle_ar']
?? ''
)
: (
$currentSection['subtitle_en']
?? ''
);

?>

<?php if (!empty($__subtitle)): ?>

<p class="lead text-muted mb-4">

<?= pch_h($__subtitle) ?>

</p>

<?php endif; ?>

<?php

$__content =
$isArabic
? (
$currentSection['content_ar']
?? ''
)
: (
$currentSection['content_en']
?? ''
);

?>

<?php if (!empty($__content)): ?>

<div class="ec-dynamic-content">

<?= $__content ?>

</div>

<?php else: ?>

<div class="alert alert-info">

<strong>
<?= pch_h($__title) ?>
</strong>

<br>

Dynamic section is active and ready for content.

</div>

<?php endif; ?>

</div>

</section>

<?php
        endif;

    endforeach;

endif;
?>

<?php if (!empty($sponsors)): ?>

<div class="card cardx mb-4">

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

        <h3 class="section-title"> 
            <?= $isArabic ? 'الرعاة والشركاء' : 'Sponsors & Partners' ?>
        </h3>

        <div class="row g-4 align-items-center">

            <?php foreach ($sponsors as $sp): ?>

                <div class="col-lg-3 col-md-4 col-sm-6 text-center">

                    <div class="border rounded-4 p-4 h-100">

                        <?php if (!empty($sp['logo'])): ?>

                            <img
                                src="/easychair/<?= pch_h($sp['logo']) ?>"
                                class="img-fluid mb-3"
                                style="max-height:90px"
                            >

                        <?php endif; ?>

                        <div class="fw-bold">
                            <?= pch_h(
                                $isArabic
                                    ? ($sp['name_ar'] ?: $sp['name_en'])
                                    : ($sp['name_en'] ?: $sp['name_ar'])
                            ) ?>
                        </div>

                        <div class="small text-muted mt-2">
                            <?= pch_h($sp['sponsor_tier']) ?>
                        </div>

                        <?php if (!empty($sp['website'])): ?>

                            <a
                                href="<?= pch_h($sp['website']) ?>"
                                target="_blank"
                                class="btn btn-sm btn-outline-primary mt-3"
                            >
                                <?= $isArabic ? 'زيارة الموقع' : 'Visit Website' ?>
                            </a>

                        <?php endif; ?>

                    </div>

                </div>

            <?php endforeach; ?>

        </div>

    </div>

</div>

<?php endif; ?>

</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>

</body>
</html>
