<?php
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/seo.php';

$faqs = get_faqs();
$byCategory = [];
foreach ($faqs as $f) { $byCategory[$f['category']][] = $f; }

$seo = [
    'title' => 'Frequently Asked Questions | ' . SITE_NAME,
    'description' => 'Answers to common questions about buying, selling, renting, financing and investing in property in Rwanda.',
    'path' => '/faq',
];
$extraSchema = schema_faq($faqs);
include __DIR__ . '/includes/header.php';
?>
<section class="section-pad-sm">
  <div class="container-narrow">
    <?= breadcrumb_html([['name' => 'FAQ', 'url' => '/faq']]) ?>
    <div class="section-head center">
      <div class="eyebrow" style="justify-content:center;">Support</div>
      <h1>Frequently Asked Questions</h1>
      <p>Everything you need to know about buying, selling, renting, financing and investing in Rwandan real estate.</p>
    </div>

    <?php $qi = 0; foreach ($byCategory as $cat => $items): ?>
      <h2 class="mt-8" style="font-size:var(--fs-lg);"><?= e($cat) ?></h2>
      <div class="mb-6">
        <?php foreach ($items as $f): $qi++; $panelId = 'faq-panel-' . $qi; ?>
          <div class="accordion-item">
            <button class="accordion-trigger" aria-expanded="false" aria-controls="<?= $panelId ?>">
              <span><?= e($f['question']) ?></span>
              <span class="icon"><?= icon('close', 18) ?></span>
            </button>
            <div class="accordion-panel" id="<?= $panelId ?>">
              <div class="accordion-panel-inner"><?= e($f['answer']) ?></div>
            </div>
          </div>
        <?php endforeach; ?>
      </div>
    <?php endforeach; ?>

    <div class="cta-band mt-8">
      <h2 style="font-size:var(--fs-xl);">Still Have Questions?</h2>
      <p style="color:var(--color-fog);">Our advisors are one message away.</p>
      <div class="actions">
        <a href="/contact" class="btn btn-accent">Contact Us</a>
        <a href="<?= e(whatsapp_link('Hi, I have a question that is not covered in your FAQ.')) ?>" class="btn btn-outline-light" target="_blank" rel="noopener">WhatsApp Us</a>
      </div>
    </div>
  </div>
</section>
<?php include __DIR__ . '/includes/footer.php'; ?>
