<?php
require_once __DIR__ . '/includes/functions.php';
$currentPage = 'contact';
$s = get_settings();
$branches = db()->query('SELECT * FROM branch_offices ORDER BY sort_order')->fetchAll();
$sent = $_GET['sent'] ?? '';
$pageSeoTitle = 'Contact Us';
$pageSeoDescription = 'Get in touch with ' . ($s['site_name'] ?? '') . ' for a free consultation.';
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">Contact Us</span>
<h1 class="text-white font-heading font-extrabold text-3xl md:text-5xl leading-tight mb-4">We'd Love to Hear From You</h1>
<p class="text-gray-300 max-w-2xl mx-auto">Reach out for a free counselling session or visit one of our branch offices.</p>
</div>
</section>
<section class="py-20">
<div class="max-w-7xl mx-auto px-6 grid lg:grid-cols-2 gap-12">
<div data-aos="fade-right">
<h2 class="font-heading font-extrabold text-2xl md:text-3xl mb-6">Send Us a <span class="gradient-text">Message</span></h2>
<?php if ($sent === '1'): ?>
<div class="mb-6 bg-brand-green/10 border border-brand-green text-brand-green text-sm font-medium rounded-xl px-5 py-3">
<i class="fa-solid fa-circle-check mr-2"></i>Thank you! Your message has been sent — we'll get back to you shortly.
</div>
<?php elseif ($sent === 'error'): ?>
<div class="mb-6 bg-red-50 border border-red-200 text-brand-red text-sm font-medium rounded-xl px-5 py-3">
<i class="fa-solid fa-circle-exclamation mr-2"></i>Please fill in all required fields and try again.
</div>
<?php endif; ?>
<form method="post" action="contact_submit.php" class="grid sm:grid-cols-2 gap-5">
<?= csrf_field() ?>
<input type="text" name="hp_field" class="hidden" tabindex="-1" autocomplete="off">
<input type="text" name="name" placeholder="Full Name" required class="rounded-xl border border-gray-300 dark:border-gray-600 bg-white/70 dark:bg-gray-800/60 px-5 py-3.5 focus:outline-none focus:ring-2 focus:ring-brand-green">
<input type="tel" name="phone" placeholder="Phone Number" class="rounded-xl border border-gray-300 dark:border-gray-600 bg-white/70 dark:bg-gray-800/60 px-5 py-3.5 focus:outline-none focus:ring-2 focus:ring-brand-green">
<input type="email" name="email" placeholder="Email Address" class="rounded-xl border border-gray-300 dark:border-gray-600 bg-white/70 dark:bg-gray-800/60 px-5 py-3.5 focus:outline-none focus:ring-2 focus:ring-brand-green sm:col-span-2">
<textarea name="message" placeholder="Message" rows="5" required class="rounded-xl border border-gray-300 dark:border-gray-600 bg-white/70 dark:bg-gray-800/60 px-5 py-3.5 focus:outline-none focus:ring-2 focus:ring-brand-green sm:col-span-2"></textarea>
<button type="submit" class="gradient-btn text-white font-semibold py-4 rounded-xl sm:col-span-2">Send Message <i class="fa-solid fa-paper-plane ml-2"></i></button>
</form>
<?php if ($branches): ?>
<div class="mt-10 space-y-4">
<h3 class="font-heading font-bold text-lg mb-2">Branch Offices</h3>
<?php $colors = ['red','green','gold']; foreach ($branches as $i => $b): ?>
<div class="flex items-start gap-3"><i class="fa-solid fa-location-dot text-brand-<?= $colors[$i % 3] ?> mt-1"></i><p class="text-sm text-gray-500 dark:text-gray-400"><strong><?= e($b['label']) ?>:</strong> <?= e($b['address']) ?></p></div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<div data-aos="fade-left">
<div class="rounded-2xl overflow-hidden shadow-xl h-72 mb-6">
<iframe src="<?= e($s['google_map_embed'] ?: ('https://www.google.com/maps?q=' . urlencode($s['address'] ?? 'Kathmandu, Nepal') . '&output=embed')) ?>" class="w-full h-full border-0" loading="lazy"></iframe>
</div>
<div class="glass-light dark:glass rounded-2xl p-6 border-t-4 border-brand-gold">
<p class="font-heading font-bold mb-3">Quick Contact</p>
<p class="text-sm text-gray-500 dark:text-gray-400 mb-2"><i class="fa-solid fa-phone text-brand-green mr-2"></i><?= e($s['phone'] ?? '') ?></p>
<p class="text-sm text-gray-500 dark:text-gray-400 mb-2"><i class="fa-solid fa-envelope text-brand-gold mr-2"></i><?= e($s['email'] ?? '') ?></p>
<a href="https://wa.me/<?= e(preg_replace('/\D/', '', $s['whatsapp_number'] ?? '')) ?>" class="inline-flex items-center gap-2 mt-3 bg-[#25D366] text-white px-5 py-2.5 rounded-full text-sm font-semibold"><i class="fa-brands fa-whatsapp"></i> Chat on WhatsApp</a>
</div>
</div>
</div>
</section>
<?php require __DIR__ . '/partials/footer.php'; ?>