'use client';

import Link from 'next/link';
import { useState, useEffect } from 'react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Check, Loader2 } from 'lucide-react';
import { languages as allLanguages, getLanguageMultiplier } from '@/components/SearchableLanguageSelect';
import { api } from '@/lib/api';

const pricingTiers = [
  {
    name: 'AI Translation',
    price: '1',
    unit: 'credit/page',
    dollarEquiv: '$0.001',
    description: 'Perfect for quick translations',
    features: [
      'Instant AI translation',
      'Support for 100+ languages',
      'PDF output',
      'Good accuracy',
      '24/7 availability',
      'Scanned documents: 3 credits/page',
    ],
    cta: 'Get Started',
    popular: false,
  },
  {
    name: 'AI + Human Review',
    price: 'From 15,000',
    unit: 'credits/page',
    dollarEquiv: '$15-$30/page',
    description: 'Best for important documents',
    features: [
      'AI translation included',
      'Professional human review',
      'Quality guarantee',
      '99%-100% accuracy',
      '24-48 hour delivery',
      'Formatting preserved',
      'Price varies by language pair (15k-30k)',
    ],
    cta: 'Most Popular',
    popular: true,
  },
  {
    name: 'Translation Certificate',
    price: '+20,000',
    unit: 'credits/set',
    dollarEquiv: '+$20/set',
    description: 'Official certification addon',
    features: [
      'Requires Human Review',
      'Official certificate from Company',
      'Accepted by MOM (Singapore)',
      'English translations only for SG authorities',
      'Company seal & signature',
      'Per document SET (not per page)',
    ],
    cta: 'Add Certificate',
    popular: false,
  },
  {
    name: 'Full Notarization',
    price: '+250,000',
    unit: 'credits/set',
    dollarEquiv: '+$250/set',
    description: 'Required for ICA and other authorities',
    features: [
      'Requires Certificate',
      'Required for ICA and various authorities',
      'Notary public seal',
      'SAL authentication',
      'AGC apostille',
      'Per document SET (not per page)',
      '2-3 business days',
    ],
    cta: 'Premium Service',
    popular: false,
  },
];

// Use languages from SearchableLanguageSelect (synced with orders/new page)
const languages = allLanguages;

export default function PricingPage() {
  // Credit packages from database
  const [creditPackages, setCreditPackages] = useState<any[]>([]);
  const [isLoadingPackages, setIsLoadingPackages] = useState(true);

  // Calculator state
  const [pages, setPages] = useState(10);
  const [sourceLang, setSourceLang] = useState('EN');
  const [targetLang, setTargetLang] = useState('ZH');
  const [serviceLevel, setServiceLevel] = useState('human'); // 'ai' or 'human'
  const [includeCertificate, setIncludeCertificate] = useState(true);
  const [includeNotarization, setIncludeNotarization] = useState(false);

  // Fetch credit packages from API
  useEffect(() => {
    const fetchPackages = async () => {
      try {
        const response = await api.getPackages();
        if (response.success && response.packages) {
          setCreditPackages(response.packages);
        }
      } catch (error) {
        console.error('Failed to fetch packages:', error);
      } finally {
        setIsLoadingPackages(false);
      }
    };
    fetchPackages();
  }, []);

  // Calculate price based on selections
  const calculatePrice = () => {
    let total = 0;

    // AI translation (always 1 credit/page)
    if (serviceLevel === 'ai' || serviceLevel === 'human') {
      total += pages * 1;
    }

    // Human review (varies by language)
    if (serviceLevel === 'human') {
      const sourceLangData = languages.find(l => l.code === sourceLang);
      const targetLangData = languages.find(l => l.code === targetLang);
      const multiplier = Math.max(
        sourceLangData?.multiplier || 1.0,
        targetLangData?.multiplier || 1.0
      );
      total += pages * 15000 * multiplier;
    }

    // Certificate addon
    if (includeCertificate && serviceLevel === 'human') {
      total += 20000;
    }

    // Notarization addon
    if (includeNotarization && includeCertificate && serviceLevel === 'human') {
      total += 250000;
    }

    return Math.round(total);
  };

  const totalCredits = calculatePrice();
  const totalDollars = (totalCredits / 1000).toFixed(2);
  return (
    <div className="min-h-screen">
      {/* Header */}
      <section className="bg-gradient-to-b from-blue-50 to-white py-20 px-4">
        <div className="container mx-auto max-w-6xl text-center">
          <h1 className="text-4xl md:text-5xl font-bold mb-4">
            Professional Translation Services
          </h1>
          <p className="text-xl text-gray-600 max-w-2xl mx-auto mb-2">
            Starting from 15,000 credits/page ($15/page)
          </p>
          <p className="text-sm text-gray-500 mb-6">
            Pricing varies by language pair: $15-$30/page • 1000 credits = $1
          </p>
          <Link href="#calculator">
            <Button size="lg" className="text-lg px-8">
              Calculate Your Price
            </Button>
          </Link>
        </div>
      </section>

      {/* Service Tiers */}
      <section className="py-16 px-4">
        <div className="container mx-auto max-w-7xl">
          <h2 className="text-3xl font-bold text-center mb-4">Service Tiers</h2>
          <p className="text-center text-gray-600 mb-12">
            Build your service by adding what you need. Human Review, Certificate, and Notarization are optional addons.
          </p>
          <div className="grid md:grid-cols-2 lg:grid-cols-4 gap-6">
            {pricingTiers.map((tier) => (
              <Card
                key={tier.name}
                className={tier.popular ? 'border-2 border-blue-600 shadow-lg' : ''}
              >
                {tier.popular && (
                  <div className="bg-blue-600 text-white text-center py-2 text-sm font-semibold rounded-t-lg">
                    Most Popular
                  </div>
                )}
                <CardHeader>
                  <CardTitle className="text-xl">{tier.name}</CardTitle>
                  <CardDescription>{tier.description}</CardDescription>
                  <div className="mt-4">
                    <div className="text-3xl font-bold">{tier.price}</div>
                    <div className="text-sm text-gray-600">{tier.unit}</div>
                    <div className="text-xs text-gray-500 mt-1">{tier.dollarEquiv}</div>
                  </div>
                </CardHeader>
                <CardContent>
                  <ul className="space-y-3 mb-6">
                    {tier.features.map((feature) => (
                      <li key={feature} className="flex items-start">
                        <Check className="h-5 w-5 text-green-600 mr-2 flex-shrink-0 mt-0.5" />
                        <span className="text-sm">{feature}</span>
                      </li>
                    ))}
                  </ul>
                  <Link href="/signup">
                    <Button
                      className="w-full"
                      variant={tier.popular ? 'default' : 'outline'}
                    >
                      {tier.cta}
                    </Button>
                  </Link>
                </CardContent>
              </Card>
            ))}
          </div>
        </div>
      </section>

      {/* Pricing Example */}
      <section className="py-16 px-4 bg-blue-50">
        <div className="container mx-auto max-w-4xl">
          <h2 className="text-3xl font-bold text-center mb-8">Pricing Example</h2>
          <Card className="bg-white">
            <CardHeader>
              <CardTitle>ICA Citizenship Application Documents</CardTitle>
              <CardDescription>10 pages (Birth Certificate, Education Certificates, Household Registry) - Chinese → English with Notarization</CardDescription>
            </CardHeader>
            <CardContent>
              <div className="space-y-3">
                <div className="flex justify-between py-2 border-b">
                  <span>AI + Human Review (10 pages × 15,000 credits)</span>
                  <span className="font-semibold">150,000 credits</span>
                </div>
                <div className="flex justify-between py-2 border-b">
                  <span>Translation Certificate (1 set)</span>
                  <span className="font-semibold">20,000 credits</span>
                </div>
                <div className="flex justify-between py-2 border-b">
                  <span>Full Notarization (1 set)</span>
                  <span className="font-semibold">250,000 credits</span>
                </div>
                <div className="flex justify-between py-3 bg-blue-100 px-4 rounded-lg font-bold text-lg">
                  <span>Total</span>
                  <span>420,000 credits = $420.00</span>
                </div>
                <p className="text-sm text-gray-600 mt-4 italic">
                  Delivery: 3-5 business days (2 days translation + 2-3 days notarization)
                </p>
              </div>
            </CardContent>
          </Card>
        </div>
      </section>

      {/* AI Translation Value Proposition */}
      <section className="py-16 px-4 bg-gradient-to-r from-green-50 to-blue-50">
        <div className="container mx-auto max-w-4xl">
          <Card className="border-2 border-green-500 shadow-xl">
            <CardContent className="p-8 text-center">
              <h3 className="text-3xl font-bold mb-4 text-green-700">
                Incredibly Affordable AI Translation
              </h3>
              <div className="text-6xl font-bold text-blue-600 mb-4">
                $1 = 1,000 Pages
              </div>
              <p className="text-xl text-gray-700 mb-6">
                With AI-only translation, just <span className="font-bold text-green-600">$1</span> can translate up to <span className="font-bold text-blue-600">1,000 pages</span>
              </p>
              <div className="grid md:grid-cols-3 gap-4 mt-6">
                <div className="bg-white p-4 rounded-lg shadow">
                  <div className="text-2xl font-bold text-green-600">$0.001</div>
                  <div className="text-sm text-gray-600">Per Page</div>
                </div>
                <div className="bg-white p-4 rounded-lg shadow">
                  <div className="text-2xl font-bold text-blue-600">Instant</div>
                  <div className="text-sm text-gray-600">5-8 Seconds</div>
                </div>
                <div className="bg-white p-4 rounded-lg shadow">
                  <div className="text-2xl font-bold text-purple-600">100+</div>
                  <div className="text-sm text-gray-600">Languages</div>
                </div>
              </div>
              <p className="text-sm text-gray-500 mt-6 italic">
                Compare to industry standard: $0.05-0.30 per word (50-300× more expensive)
              </p>
              <Button className="mt-6 bg-green-600 hover:bg-green-700 text-white px-8 py-6 text-lg" asChild>
                <Link href="/auth/signup">Try AI Translation Free</Link>
              </Button>
            </CardContent>
          </Card>
        </div>
      </section>

      {/* Popular Language Pairs */}
      <section className="py-16 px-4">
        <div className="container mx-auto max-w-6xl">
          <h2 className="text-3xl font-bold text-center mb-4">Most Popular Translation Services</h2>
          <p className="text-center text-gray-600 mb-8">
            Select your language pair to see exact pricing with our calculator
          </p>
          <div className="grid md:grid-cols-2 lg:grid-cols-3 gap-4">
            {[
              { source: 'EN', target: 'ZH', price: '$15/page', credits: '15,000' },
              { source: 'EN', target: 'ZH-TW', price: '$15/page', credits: '15,000' },
              { source: 'EN', target: 'MS', price: '$15/page', credits: '15,000' },
              { source: 'ZH', target: 'EN', price: '$15/page', credits: '15,000' },
              { source: 'EN', target: 'ES', price: '$19.50/page', credits: '19,500' },
              { source: 'EN', target: 'JA', price: '$22.50/page', credits: '22,500' },
              { source: 'EN', target: 'TA', price: '$18/page', credits: '18,000' },
              { source: 'EN', target: 'HI', price: '$18/page', credits: '18,000' },
              { source: 'EN', target: 'AR', price: '$27/page', credits: '27,000' },
            ].map((pair, idx) => {
              const sourceLang = languages.find(l => l.code === pair.source);
              const targetLang = languages.find(l => l.code === pair.target);
              return (
                <Card
                  key={idx}
                  className="hover:border-blue-500 hover:shadow-lg transition-all cursor-pointer"
                  onClick={() => {
                    setSourceLang(pair.source);
                    setTargetLang(pair.target);
                    setServiceLevel('human');
                    document.getElementById('calculator')?.scrollIntoView({ behavior: 'smooth' });
                  }}
                >
                  <CardContent className="p-4">
                    <div className="flex justify-between items-center mb-2">
                      <div className="flex items-center gap-2 text-2xl">
                        <span>{sourceLang?.flag}</span>
                        <span className="text-gray-400 text-lg">→</span>
                        <span>{targetLang?.flag}</span>
                      </div>
                      <div className="text-right">
                        <div className="font-bold text-blue-600 text-lg">{pair.price}</div>
                        <div className="text-xs text-gray-500">{pair.credits} credits</div>
                      </div>
                    </div>
                    <div className="text-sm text-gray-700">
                      {sourceLang?.name} → {targetLang?.name}
                    </div>
                    <div className="text-xs text-gray-500 mt-2">
                      Click to calculate
                    </div>
                  </CardContent>
                </Card>
              );
            })}
          </div>
        </div>
      </section>

      {/* Credit Rewards Program */}
      <section className="py-16 px-4 bg-gradient-to-r from-purple-50 to-pink-50">
        <div className="container mx-auto max-w-4xl">
          <Card className="border-2 border-purple-500 shadow-xl">
            <CardContent className="p-8">
              <div className="text-center mb-6">
                <div className="text-4xl mb-3">⭐</div>
                <h3 className="text-3xl font-bold text-purple-900 mb-2">
                  Credit Rewards Program
                </h3>
                <p className="text-lg text-purple-700">
                  Earn 10% more bonus credits when you use bonus credits
                </p>
              </div>

              <div className="bg-white p-6 rounded-lg mb-6">
                <h4 className="font-semibold text-lg mb-3 text-gray-900">How It Works:</h4>
                <div className="space-y-3 text-gray-700">
                  <div className="flex items-start gap-3">
                    <span className="text-purple-600 font-bold">1.</span>
                    <p>Use bonus credits for AI translation services</p>
                  </div>
                  <div className="flex items-start gap-3">
                    <span className="text-purple-600 font-bold">2.</span>
                    <p>Automatically earn 10% back as new bonus credits</p>
                  </div>
                  <div className="flex items-start gap-3">
                    <span className="text-purple-600 font-bold">3.</span>
                    <p>Keep translating, keep earning more credits!</p>
                  </div>
                </div>
              </div>

              <div className="bg-purple-100 p-6 rounded-lg">
                <h4 className="font-semibold text-lg mb-3 text-purple-900">Example:</h4>
                <div className="space-y-2 text-purple-800">
                  <div className="flex justify-between items-center">
                    <span>Use 10,000 bonus credits for translation</span>
                    <span className="font-semibold">-10,000</span>
                  </div>
                  <div className="flex justify-between items-center text-green-700 font-semibold">
                    <span>✓ Earn 10% Credit Rewards</span>
                    <span>+1,000</span>
                  </div>
                  <div className="flex justify-between items-center pt-2 border-t border-purple-300">
                    <span>Use those 1,000 rewards</span>
                    <span className="font-semibold">-1,000</span>
                  </div>
                  <div className="flex justify-between items-center text-green-700 font-semibold">
                    <span>✓ Earn 10% more</span>
                    <span>+100</span>
                  </div>
                </div>
                <p className="text-sm text-purple-700 mt-4 pt-4 border-t border-purple-300">
                  Your credits go further with every translation!
                </p>
              </div>

              <p className="text-xs text-gray-500 mt-6 text-center italic">
                Credit Rewards are bonus credits for platform use only (non-refundable, not convertible to cash).
                Active users (login every 90 days) keep all rewards without expiration.
              </p>
            </CardContent>
          </Card>
        </div>
      </section>

      {/* Credit Packages */}
      <section className="py-16 px-4 bg-gray-50">
        <div className="container mx-auto max-w-6xl">
          <h2 className="text-3xl font-bold text-center mb-4">Credit Packages</h2>
          <p className="text-center text-gray-600 mb-12">
            Purchase credits in bulk and earn bonus credits. 1000 credits = $1
          </p>
          {isLoadingPackages ? (
            <div className="flex justify-center py-12">
              <Loader2 className="h-12 w-12 text-blue-600 animate-spin" />
            </div>
          ) : (
          <div className="grid md:grid-cols-2 lg:grid-cols-5 gap-6">
            {creditPackages.map((pkg, index) => {
              const name = pkg.name || pkg.Name || '';
              const credits = pkg.base_credits || pkg.Credits || 0;
              const bonus = pkg.bonus_credits || pkg['Bonus Credits'] || 0;
              const price = pkg.price_sgd || pkg['Price SGD'] || 0;
              const badge = pkg.badge || pkg.Badge || null;

              return (
              <Card key={index} className={`relative ${badge ? 'border-2 border-blue-600' : ''}`}>
                {badge && (
                  <div className="absolute -top-3 left-1/2 transform -translate-x-1/2">
                    <span className="bg-blue-600 text-white px-4 py-1 rounded-full text-sm font-semibold whitespace-nowrap">
                      {badge}
                    </span>
                  </div>
                )}
                <CardHeader className="text-center pt-6">
                  <CardTitle className="text-lg">{name}</CardTitle>
                  <CardDescription className="text-sm">
                    {bonus > 0 ? `+${bonus.toLocaleString()} bonus` : 'Starter package'}
                  </CardDescription>
                </CardHeader>
                <CardContent className="text-center">
                  <div className="mb-4">
                    <span className="text-3xl font-bold">${price}</span>
                    <div className="text-gray-600 mt-2 text-sm">
                      {credits.toLocaleString()} credits
                    </div>
                    {bonus > 0 && (
                      <div className="inline-block bg-green-50 text-green-700 px-2 py-1 rounded-full text-xs font-semibold mt-2">
                        + {bonus.toLocaleString()} Bonus
                      </div>
                    )}
                    {bonus > 0 && (
                      <div className="text-xs text-gray-500 mt-2">
                        Total: {(credits + bonus).toLocaleString()} credits
                      </div>
                    )}
                  </div>
                  <Link href="/signup">
                    <Button className="w-full" variant={badge ? 'default' : 'outline'} size="sm">
                      Purchase
                    </Button>
                  </Link>
                </CardContent>
              </Card>
            )})}
          </div>
          )}
        </div>
      </section>

      {/* Price Calculator */}
      <section id="calculator" className="py-16 px-4 bg-gray-50">
        <div className="container mx-auto max-w-4xl">
          <Card>
            <CardHeader>
              <CardTitle className="text-2xl">Price Calculator</CardTitle>
              <CardDescription>Select your language pair and service level to see exact pricing</CardDescription>
            </CardHeader>
            <CardContent>
              <div className="space-y-4">
                <div className="grid md:grid-cols-2 gap-4">
                  <div>
                    <label className="text-sm font-medium block mb-2">Translate From</label>
                    <select
                      value={sourceLang}
                      onChange={(e) => setSourceLang(e.target.value)}
                      className="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                    >
                      {languages.map((lang) => (
                        <option key={lang.code} value={lang.code}>
                          {lang.flag} {lang.name}
                        </option>
                      ))}
                    </select>
                  </div>
                  <div>
                    <label className="text-sm font-medium block mb-2">Translate To</label>
                    <select
                      value={targetLang}
                      onChange={(e) => setTargetLang(e.target.value)}
                      className="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                    >
                      {languages.map((lang) => (
                        <option key={lang.code} value={lang.code}>
                          {lang.flag} {lang.name}
                        </option>
                      ))}
                    </select>
                  </div>
                </div>

                <div className="grid md:grid-cols-2 gap-4">
                  <div>
                    <label className="text-sm font-medium block mb-2">Number of Pages</label>
                    <input
                      type="number"
                      min="1"
                      value={pages}
                      onChange={(e) => setPages(Math.max(1, parseInt(e.target.value) || 1))}
                      className="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                    />
                  </div>
                  <div>
                    <label className="text-sm font-medium block mb-2">Service Level</label>
                    <select
                      value={serviceLevel}
                      onChange={(e) => setServiceLevel(e.target.value)}
                      className="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                    >
                      <option value="ai">AI Only (1 credit/page)</option>
                      <option value="human">AI + Human Review</option>
                    </select>
                  </div>
                </div>

                {serviceLevel === 'human' && (
                  <div className="space-y-3">
                    <label className="text-sm font-medium block">Optional Add-ons</label>
                    <div className="flex items-center gap-2">
                      <input
                        type="checkbox"
                        id="certificate"
                        checked={includeCertificate}
                        onChange={(e) => {
                          setIncludeCertificate(e.target.checked);
                          if (!e.target.checked) setIncludeNotarization(false);
                        }}
                        className="w-4 h-4 text-blue-600 rounded focus:ring-2 focus:ring-blue-500"
                      />
                      <label htmlFor="certificate" className="text-sm text-gray-700">
                        Translation Certificate (+20,000 credits / +$20)
                      </label>
                    </div>
                    {includeCertificate && (
                      <div className="flex items-center gap-2 ml-6">
                        <input
                          type="checkbox"
                          id="notarization"
                          checked={includeNotarization}
                          onChange={(e) => setIncludeNotarization(e.target.checked)}
                          className="w-4 h-4 text-blue-600 rounded focus:ring-2 focus:ring-blue-500"
                        />
                        <label htmlFor="notarization" className="text-sm text-gray-700">
                          Full Notarization (+250,000 credits / +$250)
                        </label>
                      </div>
                    )}
                  </div>
                )}

                <div className="bg-blue-50 p-6 rounded-lg border-2 border-blue-200">
                  <div className="flex justify-between items-center mb-2">
                    <span className="font-medium text-gray-700">Estimated Cost:</span>
                    <span className="text-3xl font-bold text-blue-600">{totalCredits.toLocaleString()} credits</span>
                  </div>
                  <div className="text-right text-lg text-gray-700 font-semibold">
                    = ${totalDollars}
                  </div>
                  <div className="text-sm text-gray-600 mt-3 pt-3 border-t border-blue-200">
                    {pages} page{pages !== 1 ? 's' : ''} • {languages.find(l => l.code === sourceLang)?.name} → {languages.find(l => l.code === targetLang)?.name}
                  </div>
                </div>

                <Link href="/signup">
                  <Button size="lg" className="w-full text-lg">
                    Get Started with This Quote
                  </Button>
                </Link>
              </div>
            </CardContent>
          </Card>
        </div>
      </section>

      {/* FAQ */}
      <section className="py-16 px-4">
        <div className="container mx-auto max-w-4xl">
          <h2 className="text-3xl font-bold text-center mb-12">Frequently Asked Questions</h2>
          <div className="space-y-6">
            <Card>
              <CardHeader>
                <CardTitle className="text-lg">How does the credit system work?</CardTitle>
              </CardHeader>
              <CardContent>
                <p className="text-gray-600 mb-3">
                  We use two types of credits:
                </p>
                <div className="space-y-2 text-sm text-gray-700">
                  <div>
                    <span className="font-semibold">Regular Credits:</span> Purchased credits (1000 = $1) that can be used for any service. Never expire.
                  </div>
                  <div>
                    <span className="font-semibold">Bonus Credits:</span> Earned through referrals, promotions, and Credit Rewards. Can only be used for AI translation services. Expire after 90 days of account inactivity.
                  </div>
                </div>
              </CardContent>
            </Card>

            <Card>
              <CardHeader>
                <CardTitle className="text-lg">What are Credit Rewards?</CardTitle>
              </CardHeader>
              <CardContent>
                <p className="text-gray-600 mb-3">
                  Credit Rewards are bonus credits you earn automatically when you use bonus credits for translation.
                  For every 10,000 bonus credits you use, you earn 1,000 new bonus credits (10% reward rate).
                </p>
                <div className="bg-purple-50 p-4 rounded-lg text-sm text-gray-700 mt-3">
                  <div className="font-semibold mb-2">Example:</div>
                  <div className="space-y-1">
                    <div>• Use 10,000 bonus credits for AI translation</div>
                    <div>• Automatically earn 1,000 reward credits</div>
                    <div>• Use those 1,000 credits, earn 100 more</div>
                    <div>• Keep translating, keep earning!</div>
                  </div>
                </div>
              </CardContent>
            </Card>

            <Card>
              <CardHeader>
                <CardTitle className="text-lg">Can I convert Credit Rewards to cash?</CardTitle>
              </CardHeader>
              <CardContent>
                <p className="text-gray-600 mb-3">
                  No. All credits on our platform (regular, bonus, and rewards) are non-refundable
                  and cannot be converted to cash. They can only be used for translation services.
                </p>
                <div className="text-sm text-gray-600 mt-2">
                  <div className="font-semibold mb-1">Key differences:</div>
                  <div>• Cashback = Money back to your account (refundable)</div>
                  <div>• Credit Rewards = Credits for platform use (non-refundable)</div>
                </div>
              </CardContent>
            </Card>

            <Card>
              <CardHeader>
                <CardTitle className="text-lg">Do Credit Rewards expire?</CardTitle>
              </CardHeader>
              <CardContent>
                <p className="text-gray-600">
                  Credit Rewards follow the same rules as bonus credits:
                </p>
                <div className="space-y-2 text-sm text-gray-700 mt-3">
                  <div>✓ <span className="font-semibold">Active accounts</span> (login every 90 days): No expiration</div>
                  <div>✗ <span className="font-semibold">Inactive accounts</span> (90+ days no activity): Rewards expire with bonus credits</div>
                  <div>✓ <span className="font-semibold">Regular credits</span>: Never expire, regardless of activity</div>
                </div>
              </CardContent>
            </Card>

            <Card>
              <CardHeader>
                <CardTitle className="text-lg">Why per-page pricing instead of per-word?</CardTitle>
              </CardHeader>
              <CardContent>
                <p className="text-gray-600">
                  Per-page pricing is simpler and more transparent. You know the exact cost upfront based on
                  the number of pages in your PDF. No surprises from word count variations.
                </p>
              </CardContent>
            </Card>

            <Card>
              <CardHeader>
                <CardTitle className="text-lg">Are Certificate and Notarization separate from translation?</CardTitle>
              </CardHeader>
              <CardContent>
                <p className="text-gray-600">
                  Yes! Certificate (20,000 credits/set) and Notarization (250,000 credits/set) are optional
                  add-ons that don't affect the base AI+Human translation price. You only pay for what you need.
                </p>
              </CardContent>
            </Card>

            <Card>
              <CardHeader>
                <CardTitle className="text-lg">What payment methods do you accept?</CardTitle>
              </CardHeader>
              <CardContent>
                <p className="text-gray-600">
                  We currently accept PayNow (Singapore) for instant credit purchases. Credit card payments
                  via Stripe will be available soon.
                </p>
              </CardContent>
            </Card>

            <Card>
              <CardHeader>
                <CardTitle className="text-lg">What is your refund policy?</CardTitle>
              </CardHeader>
              <CardContent>
                <p className="text-gray-600 mb-3">
                  All credits purchased are non-refundable. However, we stand behind the quality of our translations.
                </p>
                <div className="bg-blue-50 p-4 rounded-lg text-sm text-gray-700 mt-3">
                  <div className="font-semibold mb-2">Quality Guarantee:</div>
                  <div className="space-y-1">
                    <div>• Not satisfied with your translation? Send us your feedback and comments</div>
                    <div>• We will review and provide free revisions</div>
                    <div>• Up to 2 rounds of revisions included</div>
                    <div>• Must be requested within 1 month of delivery</div>
                  </div>
                </div>
              </CardContent>
            </Card>

            <Card>
              <CardHeader>
                <CardTitle className="text-lg">How long does translation take?</CardTitle>
              </CardHeader>
              <CardContent>
                <p className="text-gray-600">
                  AI translations are instant (5-8 seconds). AI + Human takes 24-48 hours. Certificate adds
                  1 day. Notarization takes 3-5 business days total.
                </p>
              </CardContent>
            </Card>

            <Card>
              <CardHeader>
                <CardTitle className="text-lg">Why do prices vary by language?</CardTitle>
              </CardHeader>
              <CardContent>
                <p className="text-gray-600 mb-4">
                  Human review pricing varies based on language complexity and translator availability:
                </p>
                <div className="space-y-2 text-sm">
                  <div className="flex items-start gap-2">
                    <span className="font-semibold text-green-600 min-w-[100px]">Group 1 (1.0×):</span>
                    <span className="text-gray-700">English, Chinese, Malay, Indonesian - 15,000 credits/page ($15)</span>
                  </div>
                  <div className="flex items-start gap-2">
                    <span className="font-semibold text-yellow-600 min-w-[100px]">Group 2-3:</span>
                    <span className="text-gray-700">Hindi, Tamil, Spanish, French, German - 18,000-19,500 credits/page ($18-$19.50)</span>
                  </div>
                  <div className="flex items-start gap-2">
                    <span className="font-semibold text-orange-600 min-w-[100px]">Group 4-6:</span>
                    <span className="text-gray-700">Japanese, Korean, Thai, Arabic - 21,000-27,000 credits/page ($21-$27)</span>
                  </div>
                  <div className="flex items-start gap-2">
                    <span className="font-semibold text-red-600 min-w-[100px]">Group 7 (2.0×):</span>
                    <span className="text-gray-700">Russian, Polish, Finnish - 30,000 credits/page ($30)</span>
                  </div>
                </div>
                <p className="text-gray-600 mt-4 text-sm italic">
                  Note: AI translation is always 1 credit/page regardless of language. Only Human Review pricing varies.
                </p>
              </CardContent>
            </Card>
          </div>
        </div>
      </section>

      {/* CTA */}
      <section className="py-16 px-4 bg-blue-600 text-white">
        <div className="container mx-auto max-w-4xl text-center">
          <h2 className="text-3xl font-bold mb-4">Ready to Get Started?</h2>
          <p className="text-xl mb-8 opacity-90">
            Sign up now and get 10 free credits to try our service
          </p>
          <Link href="/signup">
            <Button size="lg" variant="secondary" className="text-lg px-8">
              Create Free Account
            </Button>
          </Link>
        </div>
      </section>

      {/* Footer */}
      <footer className="py-8 px-4 border-t">
        <div className="container mx-auto max-w-6xl">
          <div className="flex flex-col md:flex-row justify-between items-center gap-4">
            <div className="text-gray-600">
              © 2025 TransLynx. All rights reserved.
            </div>
            <div className="flex gap-6">
              <Link href="/" className="text-gray-600 hover:text-blue-600">
                Home
              </Link>
              <Link href="/about" className="text-gray-600 hover:text-blue-600">
                About
              </Link>
              <Link href="/terms" className="text-gray-600 hover:text-blue-600">
                Terms
              </Link>
              <Link href="/privacy" className="text-gray-600 hover:text-blue-600">
                Privacy
              </Link>
              <Link href="/login" className="text-gray-600 hover:text-blue-600">
                Login
              </Link>
            </div>
          </div>
        </div>
      </footer>
    </div>
  );
}
