'use client'

import { useState } from 'react'
import { Header } from '@/components/layout/header'
import { Footer } from '@/components/layout/footer'
import { Plus, Minus } from 'lucide-react'

const faqCategories = [
  {
    category: 'General',
    faqs: [
      {
        question: 'What does TwoTwentyTwo do?',
        answer: 'TwoTwentyTwo is a strategic consulting firm that helps businesses accelerate growth through market expansion, operational optimization, data-driven insights, brand positioning, and client retention strategies.',
      },
      {
        question: 'How much does an engagement cost?',
        answer: 'Every engagement is unique. We provide custom proposals based on scope, complexity, and timeline. Our engagements typically start with a discovery phase where we assess your needs and provide a detailed proposal with transparent pricing.',
      },
      {
        question: 'How long does a typical engagement take?',
        answer: 'Timeline varies by scope. A focused operational optimization typically takes 8-12 weeks, market expansion strategies 12-16 weeks, and comprehensive brand repositioning 10-14 weeks. We provide detailed timelines during our proposal phase.',
      },
    ],
  },
  {
    category: 'Services',
    faqs: [
      {
        question: 'What services do you offer?',
        answer: 'We offer five core services: Market Expansion Strategies, Streamlining Operations, Data-Driven Insights, Brand & Competitive Positioning, and Client Retention & Growth. Each service is tailored to your specific business needs and growth objectives.',
      },
      {
        question: 'Do you offer ongoing support after an engagement?',
        answer: 'Yes. We offer retainer-based advisory services, quarterly strategy reviews, and on-demand consulting. Many clients maintain long-term partnerships with us as their strategic advisory partner.',
      },
      {
        question: 'What industries do you work with?',
        answer: 'We have deep expertise across 25+ industries including FinTech, SaaS, Healthcare, Manufacturing, Retail, Logistics, and Professional Services. Our cross-industry perspective brings best practices from diverse sectors to your unique challenges.',
      },
    ],
  },
  {
    category: 'Business',
    faqs: [
      {
        question: 'Do you work internationally?',
        answer: 'Yes, we work with clients globally. Our team operates across time zones and we have extensive experience with international market entry, cross-border expansion, and global brand positioning.',
      },
      {
        question: 'Do you work with startups or only enterprises?',
        answer: 'We primarily serve mid-market to enterprise businesses with annual revenues of $10M+. However, we selectively work with high-growth startups preparing for rapid scaling.',
      },
      {
        question: 'How do you measure success?',
        answer: 'Every engagement begins with clearly defined KPIs tied to your business objectives — whether that\'s revenue growth, cost reduction, market share, customer retention, or brand metrics. We provide regular reporting dashboards for real-time tracking.',
      },
    ],
  },
]

export default function FAQsPage() {
  const [openIndex, setOpenIndex] = useState<string | null>('0-0')

  return (
    <main className="min-h-screen bg-background text-foreground">
      <Header />

      {/* Hero */}
      <section className="relative bg-white pt-28 pb-20 overflow-hidden">
        <div className="absolute inset-0 -z-0">
          <div className="absolute top-0 right-0 w-[500px] h-[500px] bg-blue-500/5 rounded-full blur-[120px]" />
          <div className="absolute bottom-0 left-0 w-[400px] h-[400px] bg-purple-500/5 rounded-full blur-[100px]" />
        </div>
        <div className="max-w-7xl mx-auto px-6 lg:px-8 relative z-10">
          <div className="max-w-3xl">
            <p className="text-sm font-semibold text-blue-600 uppercase tracking-wider mb-3">Support</p>
            <h1 className="text-4xl sm:text-5xl lg:text-6xl font-bold text-[#081B33] mb-6">
              Frequently Asked{' '}
              <span className="gradient-text">Questions</span>
            </h1>
            <p className="text-lg text-slate-500 leading-relaxed">
              Everything you need to know about working with TwoTwentyTwo.
            </p>
          </div>
        </div>
      </section>

      {/* FAQs */}
      <section className="py-20 bg-slate-50">
        <div className="max-w-3xl mx-auto px-6 lg:px-8">
          {faqCategories.map((category, catIndex) => (
            <div key={catIndex} className="mb-12 last:mb-0">
              <h2 className="text-xl font-bold text-[#081B33] mb-6">{category.category}</h2>
              <div className="space-y-3">
                {category.faqs.map((faq, faqIndex) => {
                  const key = `${catIndex}-${faqIndex}`
                  const isOpen = openIndex === key
                  return (
                    <div
                      key={faqIndex}
                      className="rounded-xl border border-slate-100 bg-white overflow-hidden hover:border-blue-100 transition-colors"
                    >
                      <button
                        onClick={() => setOpenIndex(isOpen ? null : key)}
                        className="w-full p-6 flex items-center justify-between text-left group"
                      >
                        <h3 className="text-base font-semibold text-[#081B33] group-hover:text-blue-600 transition-colors pr-4">
                          {faq.question}
                        </h3>
                        <div className={`flex-shrink-0 w-8 h-8 rounded-lg flex items-center justify-center transition-all duration-300 ${isOpen ? 'bg-blue-500 shadow-md shadow-blue-500/20' : 'bg-slate-50 group-hover:bg-blue-50'}`}>
                          {isOpen ? (
                            <Minus className="w-4 h-4 text-white" />
                          ) : (
                            <Plus className="w-4 h-4 text-slate-400 group-hover:text-blue-500 transition-colors" />
                          )}
                        </div>
                      </button>
                      {isOpen && (
                        <div className="px-6 pb-6">
                          <p className="text-sm text-slate-500 leading-relaxed">{faq.answer}</p>
                        </div>
                      )}
                    </div>
                  )
                })}
              </div>
            </div>
          ))}
        </div>
      </section>

      <Footer />
    </main>
  )
}
