<?php

$title = 'Homepage Sections';

$sections =
    $sections ?? [];

?>

<div class="container py-5">

<h2 class="fw-bold mb-4">
Homepage Sections Manager
</h2>

<div class="row g-4">

<?php foreach($sections as $s): ?>

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

<div class="card border-0 shadow-lg rounded-4 h-100">

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

<div class="d-flex justify-content-between mb-3">

<div>

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

<i class="fa <?= htmlspecialchars(
(string)($s['icon_class'] ?? 'fa-layer-group')
) ?>"></i>

<?= htmlspecialchars(
(string)(
$s['section_title_en']
?? $s['section_key']
)
) ?>

</h4>

<div class="text-muted small">

<?= htmlspecialchars(
(string)(
$s['section_title_ar']
?? ''
)
) ?>

</div>

</div>

<span class="badge bg-<?=
($s['enabled'] ?? 0)
? 'success'
: 'secondary'
?>">

<?=
($s['enabled'] ?? 0)
? 'Enabled'
: 'Disabled'
?>

</span>

</div>

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

Key:
<?= htmlspecialchars(
(string)($s['section_key'] ?? '')
) ?>

</div>

<div class="small text-muted mb-4">

Sort:
<?= (int)($s['sort_order'] ?? 0) ?>

</div>

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

<a
href="/easychair/admin/homepage-sections/toggle?id=<?= (int)$s['id'] ?>"
class="btn btn-dark rounded-pill">

<?=
($s['enabled'] ?? 0)
? 'Disable'
: 'Enable'
?>

</a>

<a
href="/easychair/admin/homepage-sections/up?id=<?= (int)$s['id'] ?>"
class="btn btn-outline-primary rounded-pill">

↑

</a>

<a
href="/easychair/admin/homepage-sections/down?id=<?= (int)$s['id'] ?>"
class="btn btn-outline-primary rounded-pill">

↓

</a>

</div>

</div>

</div>

</div>

<?php endforeach; ?>

</div>

</div>
