<?php
require_once __DIR__ . '/includes/functions.php';
$currentPage = 'test-preparation';
$slug = $_GET['slug'] ?? '';
$stmt = db()->prepare("SELECT * FROM test_preparations WHERE slug = ? AND status = 'active' LIMIT 1");
$stmt->execute([$slug]);
$program = $stmt->fetch();
if (!$program) {
http_response_code(404);
$pageSeoTitle = 'Page Not Found';
require __DIR__ . '/partials/header.php';
echo '<section class="py-32 text-center"><h1 class="font-heading font-extrabold text-3xl mb-4">Program Not Found</h1><a href="test-preparation.php" class="text-brand-red font-semibold">Back to Test Preparation</a></section>';
require __DIR__ . '/partials/footer.php';
exit;
}
$syllabus = jd($program['syllabus']);
$schedule = jd($program['schedule']);
$faqs = jd($program['faqs']);
$pageSeoTitle = $program['seo_title'] ?: ($program['name'] . ' Preparation');
$pageSeoDescription = $program['seo_description'] ?: $program['overview'];
require __DIR__ . '/partials/header.php';
?>
<section class="page-banner relative py-24 md:py-32 overflow-hidden">
<div class="max-w-7xl mx-auto px-6 relative z-10 text-center" data-aos="fade-up">
<span class="inline-block px-4 py-1.5 rounded-full bg-brand-gold/20 border border-brand-gold text-brand-gold text-xs font-semibold mb-5">Test Preparation</span>
<h1 class="text-white font-heading font-extrabold text-3xl md:text-5xl leading-tight mb-4"><?= e($program['name']) ?></h1>
<p class="text-gray-300 max-w-2xl mx-auto"><?= e($program['full_name']) ?></p>
</div>
</section>
<section class="py-20">
<div class="max-w-7xl mx-auto px-6 grid md:grid-cols-3 gap-10">
<div class="md:col-span-2" data-aos="fade-right">
<span class="text-brand-red font-semibold text-sm tracking-widest uppercase">Overview</span>
<h2 class="font-heading font-extrabold text-2xl md:text-3xl mt-3 mb-5">About the <span class="gradient-text"><?= e($program['name']) ?></span> Program</h2>
<p class="text-gray-500 dark:text-gray-400 mb-8"><?= e($program['overview']) ?></p>
<?php if ($syllabus): ?>
<h3 class="font-heading font-bold text-xl mb-4">Syllabus</h3>
<div class="grid sm:grid-cols-2 gap-4 mb-8">
<?php foreach ($syllabus as $s): ?>
<div class="flex items-center gap-3 bg-gray-50 dark:bg-gray-800 rounded-xl p-4"><i class="fa-solid fa-book text-brand-green"></i><span class="text-sm"><?= e($s) ?></span></div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($schedule): ?>
<h3 class="font-heading font-bold text-xl mb-4">Class Schedule</h3>
<div class="overflow-x-auto">
<table class="w-full text-sm border-collapse">
<thead><tr class="bg-brand-black text-white"><th class="p-3 text-left rounded-l-lg">Batch</th><th class="p-3 text-left">Days</th><th class="p-3 text-left rounded-r-lg">Time</th></tr></thead>
<tbody>
<?php foreach ($schedule as $row): ?>
<tr class="border-b dark:border-gray-700"><td class="p-3 font-medium"><?= e($row['batch'] ?? '') ?></td><td class="p-3"><?= e($row['days'] ?? '') ?></td><td class="p-3"><?= e($row['time'] ?? '') ?></td></tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
<div data-aos="fade-left">
<div class="glass-light dark:glass rounded-2xl p-6 shadow-xl border-t-4 border-brand-gold sticky top-24">
<?php if ($program['duration']): ?>
<div class="flex items-center justify-between mb-4 pb-4 border-b dark:border-gray-700">
<span class="text-sm text-gray-500 dark:text-gray-400">Duration</span>
<span class="font-semibold"><?= e($program['duration']) ?></span>
</div>
<?php endif; ?>
<?php if ($program['fee']): ?>
<div class="flex items-center justify-between mb-6">
<span class="text-sm text-gray-500 dark:text-gray-400">Course Fee</span>
<span class="font-heading font-extrabold text-xl gradient-text"><?= e($program['fee']) ?></span>
</div>
<?php endif; ?>
<h4 class="font-heading font-bold mb-4">Registration Form</h4>
<form method="post" action="lead_submit.php" class="space-y-3">
<?= csrf_field() ?>
<input type="hidden" name="source_page" value="test-preparation-<?= e($program['slug']) ?>">
<input type="hidden" name="interested_course" value="<?= e($program['name']) ?>">
<input type="text" name="hp_field" class="hidden" tabindex="-1" autocomplete="off">
<input type="text" name="name" placeholder="Full Name" required class="w-full rounded-xl border border-gray-300 dark:border-gray-600 bg-white/70 dark:bg-gray-800/60 px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-brand-green">
<input type="tel" name="phone" placeholder="Phone Number" required class="w-full rounded-xl border border-gray-300 dark:border-gray-600 bg-white/70 dark:bg-gray-800/60 px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-brand-green">
<input type="email" name="email" placeholder="Email Address" class="w-full rounded-xl border border-gray-300 dark:border-gray-600 bg-white/70 dark:bg-gray-800/60 px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-brand-green">
<button type="submit" class="w-full gradient-btn text-white font-semibold py-3 rounded-xl text-sm">Register Now <i class="fa-solid fa-arrow-right ml-1"></i></button>
</form>
</div>
</div>
</div>
</section>
<?php if ($faqs): ?>
<section class="py-20 bg-gray-50 dark:bg-gray-900/40">
<div class="max-w-3xl mx-auto px-6">
<div class="text-center mb-12" data-aos="fade-up">
<span class="text-brand-green font-semibold text-sm tracking-widest uppercase">FAQ</span>
<h2 class="font-heading font-extrabold text-3xl mt-3"><?= e($program['name']) ?> Frequently Asked Questions</h2>
</div>
<div class="space-y-4" x-data="{ open: 0 }">
<?php foreach ($faqs as $i => $f): ?>
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-sm overflow-hidden" data-aos="fade-up">
<button @click="open = open === <?= $i ?> ? null : <?= $i ?>" class="w-full flex items-center justify-between px-6 py-4 text-left font-semibold text-sm">
<?= e($f['q'] ?? '') ?>
<i class="fa-solid fa-chevron-down transition-transform" :class="open === <?= $i ?> ? 'rotate-180 text-brand-red' : ''"></i>
</button>
<div x-show="open === <?= $i ?>" x-collapse class="px-6 pb-4 text-sm text-gray-500 dark:text-gray-400"><?= e($f['a'] ?? '') ?></div>
</div>
<?php endforeach; ?>
</div>
</div>
</section>
<?php endif; ?>
<?php require __DIR__ . '/partials/footer.php'; ?>