import { ChevronDown } from "lucide-react";
import { Seo } from "@/components/Seo";
import { PageHero } from "@/components/PageHero";
import { Reveal } from "@/components/Reveal";
import { useQuote } from "@/components/QuoteModal";
import { useContent } from "@/lib/content";

export default function Faq() {
  const { openQuote } = useQuote();
  const { FAQS } = useContent();
  const faqLd = {
    "@context": "https://schema.org",
    "@type": "FAQPage",
    mainEntity: FAQS.map((f) => ({
      "@type": "Question",
      name: f.q,
      acceptedAnswer: { "@type": "Answer", text: f.a },
    })),
  };
  return (
    <>
      <Seo
        title="Solar FAQs — Rooftop Solar, Net Metering, Solar Pumps | DHIYAA SOLAR ENERGY"
        description="Answers to common questions about rooftop solar, net metering, solar system lifespan, cloudy-day generation, solar pumps and installation in Chennai."
        jsonLd={faqLd}
      />
      <PageHero
        eyebrow="Good to Know"
        title="Frequently Asked Questions"
        subtitle="Everything you want to know before going solar — answered simply."
      />
      <section className="mx-auto max-w-4xl px-4 py-16 sm:px-6" data-testid="faq-list">
        <div className="space-y-3">
          {FAQS.map((f, i) => (
            <Reveal key={f.q} delay={i * 0.03}>
              <details className="group rounded-xl border border-slate-100 bg-white px-6 py-4 open:border-brand-orange/30 open:shadow-md">
                <summary className="flex cursor-pointer list-none items-center justify-between gap-4 font-heading text-sm sm:text-base font-bold text-brand-navy" data-testid={`faq-item-${i}`}>
                  {f.q}
                  <ChevronDown className="h-4 w-4 shrink-0 text-brand-orange transition-transform group-open:rotate-180" />
                </summary>
                <p className="mt-3 text-sm leading-relaxed text-slate-600">{f.a}</p>
              </details>
            </Reveal>
          ))}
        </div>
        <Reveal className="mt-12 text-center">
          <p className="text-slate-600">Still have questions? Talk to our solar team.</p>
          <button onClick={() => openQuote()} className="mt-4 rounded-full bg-brand-orange px-8 py-4 font-heading text-sm font-bold uppercase tracking-wider text-white transition-colors hover:bg-brand-orangedark" data-testid="faq-quote-btn">
            Ask Us — Get Free Quote
          </button>
        </Reveal>
      </section>
    </>
  );
}
