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

$pageTitle = "Corporate Sponsors";
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/../includes/auth.php';

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

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

<!-- Hero Header Section -->
<div class="bg-info bg-opacity-10 py-5 mb-5 rounded-4 text-center px-3 border border-info border-opacity-10">
    <div class="max-width-800 mx-auto">
        <span class="badge bg-info text-dark text-uppercase font-monospace mb-2" style="font-size: 0.75rem; letter-spacing: 1px;">Enterprise Partners</span>
        <h1 class="display-5 fw-bold text-dark mb-3">Our Corporate Sponsors</h1>
        <p class="lead text-secondary mb-0">Partnering with market leaders to deliver high-value experiences and network incentives.</p>
    </div>
</div>

<div class="container-fluid px-0 mb-5">
    <?php if (empty($sponsors)): ?>
        <div class="text-center py-5 text-muted bg-white rounded border shadow-sm">
            <i class="bi bi-briefcase-mute fs-2 mb-2 d-block text-secondary"></i>
            <span class="small">No corporate sponsors registered in the directory yet.</span>
        </div>
    <?php else: ?>
        <div class="row g-4">
            <?php foreach ($sponsors as $sps): ?>
                <div class="col-12 col-md-6 col-lg-4">
                    <div class="card border-0 shadow-sm h-100 p-4 hover-lift transition text-center d-flex flex-column justify-content-between">
                        <div>
                            <?php if (!empty($sps['logo_url'])): ?>
                                <img src="<?php echo htmlspecialchars($sps['logo_url']); ?>" class="img-fluid rounded mb-3 border object-fit-contain" style="max-height: 80px;" alt="Sponsor Logo">
                            <?php else: ?>
                                <div class="d-inline-flex p-3 bg-light rounded-circle text-info mx-auto mb-3">
                                    <i class="bi bi-building fs-2"></i>
                                </div>
                            <?php endif; ?>
                            <h5 class="fw-bold text-dark mb-1"><?php echo htmlspecialchars($sps['company_name']); ?></h5>
                            <span class="badge bg-info-subtle text-info font-monospace text-uppercase mb-3" style="font-size: 0.7rem;">
                                <?php echo htmlspecialchars($sps['default_tier']); ?> Sponsor
                            </span>
                            <p class="text-secondary small mb-3"><?php echo htmlspecialchars($sps['description']); ?></p>
                        </div>
                        <?php if (!empty($sps['website_url'])): ?>
                            <div class="pt-3 border-top mt-auto">
                                <a href="<?php echo htmlspecialchars($sps['website_url']); ?>" target="_blank" class="btn btn-outline-secondary btn-sm w-100 fw-bold">
                                    <i class="bi bi-box-arrow-up-right me-1"></i> Visit Website
                                </a>
                            </div>
                        <?php endif; ?>
                    </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';
?>
