<?php
$title = "Conference Themes";
?>

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

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

        <div>

            <h1 class="fw-bold">
                Conference Themes
            </h1>

            <div class="text-muted">
                Manage conference tracks and research themes
            </div>

        </div>

        <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($_SESSION['success'])): ?>

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

            <?= htmlspecialchars($_SESSION['success']) ?>

        </div>

        <?php unset($_SESSION['success']); ?>

    <?php endif; ?>

    <div class="card border-0 shadow-lg rounded-5">

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

            <div class="table-responsive">

                <table class="table align-middle">

                    <thead class="table-light">

                        <tr>

                            <th>ID</th>

                            <th>Theme</th>

                            <th>Actions</th>

                        </tr>

                    </thead>

                    <tbody>

                        <?php foreach (($themes ?? []) as $theme): ?>

                            <tr>

                                <td>
                                    <?= (int)$theme['id'] ?>
                                </td>

                                <td>

                                    <div class="fw-bold">

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

                                    </div>

                                    <div class="text-muted small">

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

                                    </div>

                                </td>

                                <td>

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

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

                                    </a>

                                </td>

                            </tr>

                        <?php endforeach; ?>

                    </tbody>

                </table>

            </div>

        </div>

    </div>

</div>
