import Link from "next/link";
import { ChevronDown } from "lucide-react";
import PageHeader from "@/components/ui/PageHeader";
import { FALLBACK_SITE_CONFIG, getSiteConfig } from "@/lib/api/site";

export const metadata = {
  title: "FAQ – Frequently Asked Questions | Biznie",
  description: "Common questions about Biznie's B2B raw materials platform, ordering, payments, delivery and credit.",
};

const FAQS: { q: string; a: string }[] = [
  {
    q: "What is Biznie?",
    a: "Biznie is India's leading B2B raw materials procurement and credit platform. We connect buyers and suppliers across Steel, Aluminium, Polymers, Chemicals, Energy, Construction, Agri and Apparel categories.",
  },
  {
    q: "How do I place an order?",
    a: "Browse products or live prices, click 'Get Quote' or 'Buy Now', submit your requirement and our team will share confirmed rates and delivery timelines within hours.",
  },
  {
    q: "What payment methods are supported?",
    a: "We support bank transfers, UPI, RTGS/NEFT, and approved buyers can avail credit lines up to 90 days. See our Payment Methods page for more.",
  },
  {
    q: "Do you deliver pan-India?",
    a: "Yes. Biznie supplies across India. Pick your delivery city and the F.O.R price you see already includes freight to it.",
  },
  {
    q: "How do I become a supplier on Biznie?",
    a: "Sign up, complete your KYC, list your products, and our team will verify and onboard you within 48 hours.",
  },
  {
    q: "Can I get credit on my purchases?",
    a: "Yes. Approved buyers can avail credit lines based on credit assessment. Submit a credit request from your dashboard.",
  },
  {
    q: "How is pricing determined?",
    a: "Live prices are aggregated from verified mandis, mills and supplier networks. Quotes are tailored based on quantity, location and grade.",
  },
  {
    q: "What is your return policy?",
    a: "Material that does not meet the agreed specification can be returned within 7 days. See our Return Policy page for details.",
  },
  {
    q: "Is Biznie data secure?",
    a: "We use industry-standard encryption, role-based access controls and regular security audits to protect your business data.",
  },
];

/**
 * The contact answer is built from Website Setup, not typed into the page — it
 * used to quote a phone and email that matched no other page (B21).
 */
export default async function FaqPage() {
  const site = await getSiteConfig({ next: { revalidate: 300 } }).catch(() => FALLBACK_SITE_CONFIG);
  const faqs = [
    ...FAQS,
    {
      q: "How can I contact support?",
      a: `Email ${site.email} or call ${site.phone}. You can also raise a ticket from your dashboard.`,
    },
  ];

  return (
    <div className="min-h-screen bg-white">
      <PageHeader
        title="Frequently Asked Questions"
        subtitle="Quick answers to the most common questions about Biznie."
      />

      <div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
        <div className="space-y-3">
          {faqs.map((item, idx) => (
            <details
              key={idx}
              className="group bg-white rounded-xl border border-gray-200 shadow-sm open:shadow-md transition-shadow"
            >
              <summary className="flex items-center justify-between cursor-pointer p-5 list-none">
                <span className="font-semibold text-gray-900 pr-4">{item.q}</span>
                <ChevronDown
                  size={18}
                  className="shrink-0 text-gray-500 transition-transform group-open:rotate-180"
                />
              </summary>
              <div className="px-5 pb-5 text-gray-600 leading-relaxed text-sm">{item.a}</div>
            </details>
          ))}
        </div>

        <div className="mt-10 bg-gradient-to-r from-gray-50 to-gray-100 border border-gray-200 rounded-2xl p-6 text-center">
          <h3 className="font-bold text-gray-900 mb-1">Still have questions?</h3>
          <p className="text-sm text-gray-600 mb-4">Our team is happy to help.</p>
          <Link
            href="/contact"
            className="inline-block bg-[#CC1414] text-white font-semibold px-6 py-2.5 rounded-lg hover:bg-[#a80f0f] transition-colors text-sm"
          >
            Contact Support
          </Link>
        </div>
      </div>
    </div>
  );
}
