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

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

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

        <div>

            <h1 class="fw-bold mb-1">
                Conference Speakers
            </h1>

            <div class="text-muted">
                Manage keynote speakers and distinguished experts
            </div>

        </div>

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

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

        </a>

    </div>

    <?php if (!empty($_SESSION['success'])): ?>

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

            <?= 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>Speaker</th>

                            <th>Institution</th>

                            <th>Actions</th>

                        </tr>

                    </thead>

                    <tbody>

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

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

                                <tr>

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

                                    <td>

                                        <div class="fw-bold">

                                            <?= htmlspecialchars($speaker['full_name']) ?>

                                        </div>

                                        <div class="small text-muted">

                                            <?= htmlspecialchars(
                                                $speaker['title_en']
                                                ?? ''
                                            ) ?>

                                        </div>

                                    </td>

                                    <td>

                                        <?= htmlspecialchars(
                                            $speaker['institution_name']
                                            ?? ''
                                        ) ?>

                                    </td>

                                    <td>

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

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

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

                                            </a>

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

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

                                            </a>

                                        </div>

                                    </td>

                                </tr>

                            <?php endforeach; ?>

                        <?php else: ?>

                            <tr>

                                <td colspan="4" class="text-center py-5 text-muted">

                                    No speakers found.

                                </td>

                            </tr>

                        <?php endif; ?>

                    </tbody>

                </table>

            </div>

        </div>

    </div>

</div>
