<?php
define('SECURE_ACCESS', true);

$pageTitle = "Speakers Directory";
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/../includes/auth.php';

// Fetch speakers
$speakers = [];
try {
    if ($pdo) {
        $stmt = $pdo->query("SELECT * FROM speaker_profiles ORDER BY full_name ASC");
        $speakers = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: [];
    }
} catch (PDOException $e) {}

require_once __DIR__ . '/../includes/header.php';
?>

<!-- Hero Header Section -->
<div class="bg-success bg-opacity-10 py-5 mb-5 rounded-4 text-center px-3 border border-success border-opacity-10">
    <div class="max-width-800 mx-auto">
        <span class="badge bg-success text-uppercase font-monospace mb-2" style="font-size: 0.75rem; letter-spacing: 1px;">Event Experts</span>
        <h1 class="display-5 fw-bold text-dark mb-3">Keynote Speakers & Experts</h1>
        <p class="lead text-secondary mb-0">Discover the industry experts, leading scientists, and researchers presenting at our upcoming events.</p>
    </div>
</div>

<div class="container-fluid px-0 mb-5">
    <?php if (empty($speakers)): ?>
        <div class="text-center py-5 text-muted bg-white rounded border shadow-sm">
            <i class="bi bi-mic-mute fs-2 mb-2 d-block text-secondary"></i>
            <span class="small">No keynote speakers registered in the directory yet.</span>
        </div>
    <?php else: ?>
        <div class="row g-4">
            <?php foreach ($speakers as $spk): ?>
                <div class="col-12 col-md-6">
                    <div class="card border-0 shadow-sm h-100 p-4 hover-lift transition d-flex flex-column justify-content-between">
                        <div>
                            <div class="d-flex align-items-center mb-3">
                                <div class="p-3 bg-success bg-opacity-10 text-success rounded-circle me-3">
                                    <i class="bi bi-mic fs-3"></i>
                                </div>
                                <div>
                                    <h5 class="fw-bold text-dark mb-0"><?php echo htmlspecialchars($spk['full_name']); ?></h5>
                                    <span class="text-muted font-monospace small" style="font-size: 0.75rem;"><?php echo htmlspecialchars($spk['expertise']); ?></span>
                                </div>
                            </div>
                            <p class="text-secondary small lh-base mb-3"><?php echo htmlspecialchars($spk['bio']); ?></p>
                        </div>
                        <div class="border-top pt-3 text-muted small">
                            <i class="bi bi-building me-1"></i> Representing: <strong><?php echo htmlspecialchars($spk['organization']); ?></strong>
                        </div>
                    </div>
                </div>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>
</div>

<style>
.hover-lift {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.08) !important;
}
</style>

<?php
include __DIR__ . '/../includes/footer.php';
?>
