<?php

require_once BASE_PATH . '/app/helpers/media_helper.php';

$lang =
    $lang ?? 'en';

$heroSlides =
    $heroSlides ?? [];

$heroBanner =
    ec_safe_string(
        $conference['homepage_banner']
        ?? ''
    );

if ($heroBanner === '') {

    $heroBanner =
        ec_safe_string(
            $conference['banner_path']
            ?? ''
        );
}

if ($heroBanner === '') {

    $heroBanner =
        ec_safe_string(
            $conference['featured_image']
            ?? ''
        );
}

if (
    $heroBanner !== ''
    && str_starts_with(
        $heroBanner,
        'storage/'
    )
) {

    $heroBanner =
        substr($heroBanner, 8);
}

$heroBannerUrl =
    $heroBanner !== ''
    ? ec_media_url($heroBanner)
    : '';

?>

<section class="pcb-hero-wrap">

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

<div
class="pcb-hero-slide"

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

style="
background-image:
linear-gradient(
rgba(15,23,42,.72),
rgba(15,23,42,.84)
),
url('<?= pcb_h($heroBannerUrl) ?>');

background-size: cover;
background-position: center;
background-repeat: no-repeat;
"

<?php endif; ?>

>

<div class="container">

<div class="row align-items-center min-vh-100">

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

<div class="pcb-hero-badge text-white">

LIVE EVENT • IEEE STYLE

</div>

<h1 class="pcb-hero-title text-white">

<?= pcb_h(
$lang === 'ar'
? (
    $conference['title_ar']
    ?? $conference['title']
    ?? ''
)
: (
    $conference['title_en']
    ?? $conference['title']
    ?? ''
)
) ?>

</h1>

<p class="pcb-hero-text text-white">

<?= pcb_h(
$lang === 'ar'
? 'منصة أكاديمية متكاملة للمؤتمرات العلمية'
: 'Integrated Academic Conference Platform'
) ?>

</p>

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

<a
href="/easychair/author/submit?id=<?= urlencode(
$conference['id']
) ?>"
class="btn btn-primary btn-lg rounded-pill px-5">

<?= pcb_h(
$lang === 'ar'
? 'إرسال بحث'
: 'Submit Paper'
) ?>

</a>

<a
href="#program"
class="btn btn-outline-light btn-lg rounded-pill px-5">

<?= pcb_h(
$lang === 'ar'
? 'البرنامج العلمي'
: 'Scientific Program'
) ?>

</a>

</div>

</div>

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

<div class="pcb-hero-visual-card">

<div class="pcb-hero-live-badge">

<span class="pcb-live-dot"></span>

LIVE EVENT

</div>

<div class="pcb-hero-ieee">

IEEE STYLE

</div>

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

<img
src="<?= pcb_h($heroBannerUrl) ?>"
class="img-fluid rounded-4 shadow-lg w-100"
style="
min-height:340px;
object-fit:cover;
display:block;
"
alt="Conference Banner">

<?php endif; ?>

</div>

</div>

</div>

</div>

</div>

<?php else: ?>

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

<?php

$slideImage =
    $slide['image_path']
    ?? $slide['banner_path']
    ?? '';

if (
    $slideImage !== ''
    && str_starts_with(
        $slideImage,
        'storage/'
    )
) {

    $slideImage =
        substr($slideImage, 8);
}

$slideImageUrl =
    $slideImage !== ''
    ? ec_media_url($slideImage)
    : '';

?>

<div
class="pcb-hero-slide"

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

style="
background-image:
linear-gradient(
rgba(15,23,42,.78),
rgba(15,23,42,.88)
),
url('<?= pcb_h($slideImageUrl) ?>');

background-size: cover;
background-position: center;
background-repeat: no-repeat;
"

<?php endif; ?>

>

<div class="container">

<div class="row align-items-center min-vh-100">

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

<div class="pcb-hero-badge text-white">

LIVE EVENT • IEEE STYLE

</div>

<h1 class="pcb-hero-title text-white">

<?= pcb_h(
$lang === 'ar'
? (
    $slide['title_ar']
    ?? ''
)
: (
    $slide['title_en']
    ?? ''
)
) ?>

</h1>

<p class="pcb-hero-text text-white">

<?= pcb_h(
$lang === 'ar'
? (
    $slide['subtitle_ar']
    ?? ''
)
: (
    $slide['subtitle_en']
    ?? ''
)
) ?>

</p>

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

<a
href="<?= pcb_h(
$slide['button_url']
?? '#'
) ?>"
class="btn btn-primary btn-lg rounded-pill px-5">

<?= pcb_h(
$lang === 'ar'
? (
    $slide['button_text_ar']
    ?? 'إرسال بحث'
)
: (
    $slide['button_text_en']
    ?? 'Submit Paper'
)
) ?>

<div class="ec-live-strip mt-5">

<div class="ec-live-pill bg-<?= pcb_h(
$conferenceLiveStatus['badge']
) ?>">

<i class="fa fa-broadcast-tower"></i>

<?php

switch (
    $conferenceLiveStatus['status']
) {

    case 'cfp_open':

        echo pcb_h(
            $lang === 'ar'
            ? 'استقبال الأبحاث مفتوح'
            : 'Call For Papers Open'
        );

    break;

    case 'reviewing':

        echo pcb_h(
            $lang === 'ar'
            ? 'مرحلة التحكيم'
            : 'Review Phase Active'
        );

    break;

    case 'decision':

        echo pcb_h(
            $lang === 'ar'
            ? 'مرحلة القرارات'
            : 'Decision Phase'
        );

    break;

    default:

        echo pcb_h(
            $lang === 'ar'
            ? 'تم النشر'
            : 'Published Conference'
        );

}
?>

</div>

<?php if (
$conferenceLiveStatus['countdown_days'] > 0
): ?>

<div class="ec-live-countdown">

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

<?= (int)$conferenceLiveStatus['countdown_days'] ?>

<?= pcb_h(
$lang === 'ar'
? 'يوم متبقي'
: 'Days Remaining'
) ?>

</div>

<?php endif; ?>

</div>

</a>

</div>

</div>

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

<div class="pcb-hero-visual-card">

<div class="pcb-hero-live-badge">

<span class="pcb-live-dot"></span>

LIVE EVENT

</div>

<div class="pcb-hero-ieee">

IEEE STYLE

</div>

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

<img
src="<?= pcb_h($slideImageUrl) ?>"
class="img-fluid rounded-4 shadow-lg w-100"
style="
min-height:340px;
object-fit:cover;
display:block;
"
alt="Conference Banner">

<?php endif; ?>

</div>

</div>

</div>

</div>

</div>

<?php endforeach; ?>

<?php endif; ?>

</section>
