<?php

$title = 'Conference Themes';

$themes =
    $themes ?? [];

?>

<div class="container py-5">

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

        <h2 class="fw-bold">

            Conference Themes / Tracks

        </h2>

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

            <i class="fa fa-plus"></i>
            Add Theme

        </a>

    </div>

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

        <div class="alert alert-warning rounded-4">

            No conference themes found.

        </div>

    <?php else: ?>

        <div class="row g-4">

            <?php foreach ($themes as $t): ?>

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

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

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

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

                                <div>

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

                                        <?= htmlspecialchars(
                                            (string)($t['name_en'] ?? '')
                                        ) ?>

                                    </h4>

                                    <div dir="rtl" class="text-muted">

                                        <?= htmlspecialchars(
                                            (string)($t['name_ar'] ?? '')
                                        ) ?>

                                    </div>

                                </div>

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

                                    <?= (($t['is_active'] ?? 0))
                                        ? 'Active'
                                        : 'Disabled'
                                    ?>

                                </span>

                            </div>

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

                                Min Reviewers:
                                <?= (int)($t['min_reviewers'] ?? 0) ?>

                                |

                                Max Reviewers:
                                <?= (int)($t['max_reviewers'] ?? 0) ?>

                            </div>

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

                                <a
                                    href="/easychair/admin/conference-themes/edit?id=<?= (int)$t['id'] ?>"
                                    class="btn btn-outline-primary rounded-pill">

                                    Edit

                                </a>

                                <a
                                    href="/easychair/admin/conference-themes/delete?id=<?= (int)$t['id'] ?>"
                                    class="btn btn-outline-danger rounded-pill"
                                    onclick="return confirm('Delete theme?')">

                                    Delete

                                </a>

                            </div>

                        </div>

                    </div>

                </div>

            <?php endforeach; ?>

        </div>

    <?php endif; ?>

</div>
