<?php $page='Contact'; define('BASE','../'); require __DIR__.'/../includes/header.php'; require __DIR__.'/../includes/hero.php';
hero('Contact', 'Contact', $FACULTY['tagline'], '../assets/images/hero.jpg', $FACULTY['primary']);
?>
<section class="max-w-6xl mx-auto px-4 py-16">
<?php
$errors=[]; $ok=false;
if($_SERVER['REQUEST_METHOD']==='POST'){
  $name = trim($_POST['name'] ?? '');
  $email = trim($_POST['email'] ?? '');
  $message = trim($_POST['message'] ?? '');
  if(!$name) $errors[]='Name required';
  if(!filter_var($email,FILTER_VALIDATE_EMAIL)) $errors[]='Valid email required';
  if(!$message) $errors[]='Message required';
  if(!$errors){
    @file_put_contents(__DIR__.'/../messages.log', json_encode(compact('name','email','message'))."\n", FILE_APPEND);
    $ok=true;
  }
}
?>
<div class="grid md:grid-cols-2 gap-10">
  <div>
    <h2 class="font-serif text-3xl font-bold">Contact us</h2>
    <p class="mt-3 text-slate-600">Reach the <?= htmlspecialchars($FACULTY['name']) ?> office directly.</p>
    <div class="mt-8 space-y-4 text-slate-700">
      <div><p class="text-xs uppercase tracking-widest text-slate-500">Address</p><p><?= htmlspecialchars($PARENT['address']) ?></p></div>
      <div><p class="text-xs uppercase tracking-widest text-slate-500">Email</p><p><?= htmlspecialchars($FACULTY['slug']) ?>@nahda.edu</p></div>
      <div><p class="text-xs uppercase tracking-widest text-slate-500">Phone</p><p><?= htmlspecialchars($PARENT['phone']) ?></p></div>
      <div><p class="text-xs uppercase tracking-widest text-slate-500">Office hours</p><p>Sunday–Thursday, 8:00 – 16:00</p></div>
    </div>
  </div>
  <div>
    <?php if($ok): ?>
      <div class="rounded-xl p-6 bg-green-50 border border-green-200">
        <p class="font-semibold text-green-800">Message received — thank you.</p>
      </div>
    <?php else: ?>
    <form method="post" class="rounded-xl border bg-white p-6 space-y-4">
      <h3 class="font-serif text-xl font-semibold">Send us a message</h3>
      <?php if($errors): ?><div class="text-sm text-red-600"><?= implode('; ', $errors) ?></div><?php endif; ?>
      <input name="name" placeholder="Full name" required class="w-full border rounded-md px-3 py-2">
      <input type="email" name="email" placeholder="Email" required class="w-full border rounded-md px-3 py-2">
      <textarea name="message" rows="5" placeholder="Message" required class="w-full border rounded-md px-3 py-2"></textarea>
      <button class="w-full px-5 py-3 rounded-md text-white font-medium" style="background: <?= $FACULTY['primary'] ?>">Send</button>
    </form>
    <?php endif; ?>
  </div>
</div>
</section>
<?php require __DIR__.'/../includes/footer.php'; ?>
