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

$pageTitle = "Event Organizers";
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/../includes/auth.php';

// Fetch organizers
$organizers = [];
try {
    if ($pdo) {
        $stmt = $pdo->query("
            SELECT op.*, u.email 
            FROM organizer_profiles op
            LEFT JOIN users u ON op.user_id = u.id
            ORDER BY op.full_name ASC
        ");
        $organizers = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: [];
    }
} catch (PDOException $e) {}

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

<!-- Hero Header Section -->
<div class="bg-primary bg-opacity-10 py-5 mb-5 rounded-4 text-center px-3 border border-primary border-opacity-10">
    <div class="max-width-800 mx-auto">
        <span class="badge bg-primary text-uppercase font-monospace mb-2" style="font-size: 0.75rem; letter-spacing: 1px;">Operations & Logistics</span>
        <h1 class="display-5 fw-bold text-dark mb-3">Event Organizing Committee</h1>
        <p class="lead text-secondary mb-0">Meet the conference planners and logistics coordinators managing our platform events portfolio.</p>
    </div>
</div>

<div class="container-fluid px-0 mb-5">
    <?php if (empty($organizers)): ?>
        <div class="text-center py-5 text-muted bg-white rounded border shadow-sm">
            <i class="bi bi-person-x fs-2 mb-2 d-block text-secondary"></i>
            <span class="small">No organizers registered in the committee directory yet.</span>
        </div>
    <?php else: ?>
        <div class="row g-4">
            <?php foreach ($organizers as $org): ?>
                <div class="col-12 col-md-6 col-lg-4">
                    <div class="card border-0 shadow-sm h-100 p-4 text-center hover-lift transition">
                        <div class="d-inline-flex p-3 bg-light rounded-circle text-primary mx-auto mb-3" style="width: fit-content;">
                            <i class="bi bi-shield-check fs-2"></i>
                        </div>
                        <h5 class="fw-bold text-dark mb-1"><?php echo htmlspecialchars($org['full_name']); ?></h5>
                        <span class="badge bg-primary-subtle text-primary font-monospace text-uppercase mb-3" style="font-size: 0.7rem;">
                            <?php echo htmlspecialchars($org['department'] ?: 'Event Coordinator'); ?>
                        </span>
                        <p class="text-secondary small mb-3">Planner at <strong><?php echo htmlspecialchars($org['company'] ?: 'EventPortal'); ?></strong>.</p>
                        
                        <div class="border-top pt-3 mt-auto font-monospace small text-start">
                            <?php if (!empty($org['phone'])): ?>
                                <div class="text-secondary mb-1">
                                    <i class="bi bi-telephone me-1 text-primary"></i> <?php echo htmlspecialchars($org['phone']); ?>
                                </div>
                            <?php endif; ?>
                            <div class="text-secondary">
                                <i class="bi bi-envelope me-1 text-primary"></i> <?php echo htmlspecialchars($org['email']); ?>
                            </div>
                        </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';
?>
