<?php 
require_once 'db_connect.php';
include 'header.php'; 

// Fetch Advisers from Database
$advisers = [];
try {
    $stmt = $pdo->query("SELECT * FROM team_members WHERE team_type = 'adviser' AND status = 'active' ORDER BY id ASC");
    $advisers = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {}
?>

<style>
    .adviser-hero { background: linear-gradient(135deg, rgba(2, 44, 34, 0.95), rgba(6, 78, 59, 0.88)), url('https://images.unsplash.com/photo-1434030216411-0b793f4b4173?auto=format&fit=crop&w=800&q=60') center/cover; padding: 80px 0; color: white; text-align: center; border-bottom: 5px solid var(--accent); }
    .adviser-card-premium { background: #fff; border-radius: 25px; padding: 30px; border: 1px solid #f1f5f9; transition: 0.3s; height: 100%; text-align: center; }
    .adviser-card-premium:hover { background: var(--primary-dark); border-color: var(--accent); transform: translateY(-5px); }
    .adviser-card-premium:hover .adviser-name { color: #fff; }
    .adviser-img { width: 140px; height: 140px; border-radius: 50%; object-fit: cover; border: 5px solid var(--bg-soft); margin-bottom: 20px; transition: 0.3s; }
    .adviser-card-premium:hover .adviser-img { border-color: var(--accent); }
</style>

<section class="adviser-hero">
    <div class="container"><h1 class="fw-bold">Adviser Panel</h1><p class="lead opacity-75">Senior Scholars & Education Experts</p></div>
</section>

<section class="py-5" style="background: #e9fbf5;">
    <div class="container">
        <div class="row g-4 justify-content-center">
            <?php if(!empty($advisers)): foreach($advisers as $adv): ?>
            <div class="col-12 col-md-6 col-lg-4">
                <div class="adviser-card-premium shadow-sm">
                    <img src="<?= htmlspecialchars($adv['image_url']) ?>" loading="lazy" onerror="this.src='https://via.placeholder.com/150?text=Scholar'" class="adviser-img">
                    <h5 class="adviser-name fw-bold"><?= htmlspecialchars($adv['name']) ?></h5>
                    <p class="text-warning small fw-bold mb-0 text-uppercase"><?= htmlspecialchars($adv['role_or_spec']) ?></p>
                </div>
            </div>
            <?php endforeach; else: ?>
                <div class="col-12 text-center py-5"><h5 class="text-muted">Advisers panel is being updated.</h5></div>
            <?php endif; ?>
        </div>
    </div>
</section>

<?php include 'footer.php'; ?>