import { BUNDLED_DRAFTS, RECOMMENDATION_TYPE_COUNT, TRIAL_DAYS } from '@/config/plan-limits';

export interface Faq {
  question: string;
  answer: string;
}

/** General FAQs — used on Welcome page and as base JSON-LD */
export const generalFaqs: Faq[] = [
  {
    question: 'Does RankWiz replace Ahrefs or Semrush?',
    answer:
      'No — RankWiz complements your existing tools. Use Ahrefs for backlink analysis and keyword research, Semrush for competitor tracking. RankWiz handles the action: it reads your real Google Search Console data, diagnoses which pages are losing traffic, generates AI content fixes, publishes them to WordPress, and tracks the ROI. Different tools for different jobs.',
  },
  {
    question: 'Is this just another AI writing tool?',
    answer:
      'No. AI writers generate content. RankWiz tells you WHICH content to fix — based on your real Google Search Console data — generates targeted AI drafts, and proves they worked with ROI tracking. The AI is one step in a diagnostic workflow, not the whole product.',
  },
  {
    question: 'Do I need an OpenAI API key?',
    answer: `No. Every plan includes bundled AI drafts — Free gets ${BUNDLED_DRAFTS.free}/month, Pro gets ${BUNDLED_DRAFTS.pro}, Team gets ${BUNDLED_DRAFTS.team}. No OpenAI account required. If you need unlimited drafts, you can connect your own OpenAI key on Pro and Team plans. You pay OpenAI directly at cost — we add zero markup.`,
  },
  {
    question: 'How quickly will I see results?',
    answer:
      'Most users see their first actionable recommendations within 10 minutes of connecting Google Search Console. Connect your site, run an analysis, and RankWiz immediately shows which pages need attention — prioritized by traffic impact.',
  },
  {
    question: "What if my traffic didn't drop?",
    answer:
      "RankWiz isn't just for recovery. It detects pages about to decline with content decay detection, finds striking-distance opportunities (pages ranking 11–20, close to the first page) you're close to ranking for, identifies keyword cannibalization between your own pages, and surfaces content gaps in your topic coverage.",
  },
  {
    question: 'How is my data protected?',
    answer:
      'Your GSC credentials and OpenAI account key are AES-256 encrypted at rest. We never read your API keys, never resell your data, and never use it to train models. All connections use HMAC-SHA256 authentication.',
  },
  {
    question: 'Is the free plan actually useful?',
    answer:
      `Yes. Free includes real traffic analysis on 1 site, all ${RECOMMENDATION_TYPE_COUNT} recommendation types, content intelligence (cannibalization, topic clusters, freshness), and ${BUNDLED_DRAFTS.free} AI drafts per month. It's a working tool, not a feature tour.`,
  },
  {
    question: 'Can I cancel anytime?',
    answer:
      'Yes. No long-term contract. Cancel monthly billing at the end of your period. Your data remains accessible on the free plan.',
  },
];

/** Feature-specific FAQs — used on Features page */
export const featureFaqs: Faq[] = [
  {
    question: 'What is Google Search Console integration?',
    answer:
      'Connect your GSC account and RankWiz pulls real performance data. Track clicks, impressions, CTR, and position changes across all your pages. No sampling, no guessing — just accurate metrics from Google.',
  },
  {
    question: 'How does traffic anomaly detection work?',
    answer:
      'Automatic monitoring after every analysis. A 20%+ traffic drop triggers an immediate alert. Three consecutive weeks of decline triggers a severity warning. Get notified before your clients notice.',
  },
  {
    question: 'What is cannibalization detection?',
    answer:
      'Automatically detect when multiple pages compete for the same keywords. Get consolidation recommendations to combine or redirect competing pages and boost overall rankings.',
  },
  {
    question: 'How does topic clustering help?',
    answer:
      'Discover content gaps in your site architecture. RankWiz clusters your pages by topic and identifies missing hub pages, supporting content, or FAQ sections to build topical authority.',
  },
  {
    question: 'What is E-E-A-T signal analysis?',
    answer:
      "E-E-A-T stands for Experience, Expertise, Authoritativeness, and Trust — Google's quality signals for evaluating content. RankWiz scores your content across all 4 pillars using 63 text analysis patterns and gives specific recommendations to strengthen each one.",
  },
  {
    question: 'How does AI draft generation work?',
    answer:
      'Every plan includes bundled AI drafts — no API key needed. For unlimited drafts, connect your own OpenAI account (BYOK) and pay ~$0.01 per draft direct to OpenAI — no markup.',
  },
];

/** Integration & Technical FAQs — used in structured data to reach 30+ item threshold */
export const technicalFaqs: Faq[] = [
  {
    question: 'Does RankWiz work with any WordPress site?',
    answer:
      'Yes. RankWiz works with any self-hosted WordPress site (wordpress.org). You install the lightweight RankWiz plugin, authenticate with an HMAC secret, and publishing is immediately available. Hosted WordPress.com sites are not supported.',
  },
  {
    question: 'How often does RankWiz sync with Google Search Console?',
    answer:
      'Daily, automatically. RankWiz syncs your GSC data every night so your analysis always reflects the latest performance. You can also trigger a manual sync at any time from the site settings.',
  },
  {
    question: 'Can I use RankWiz for client sites as an agency?',
    answer:
      'Yes. Pro allows up to 5 sites and Team allows unlimited sites with white-label reports, custom domain, and role-based team permissions. Invite clients or team members as viewers, editors, or admins per site.',
  },
  {
    question: 'What content types does RankWiz analyze?',
    answer:
      'RankWiz analyzes any page indexed in Google Search Console — blog posts, landing pages, product pages, category pages. The WordPress plugin also pulls post metadata and content for AI draft generation and SERP scoring.',
  },
  {
    question: 'Does RankWiz work with Shopify or other CMS platforms?',
    answer:
      'Currently RankWiz integrates with WordPress for one-click publishing. GSC analysis works for any domain regardless of CMS. WordPress publishing requires the RankWiz WordPress plugin.',
  },
  {
    question: 'How do I publish AI drafts to WordPress?',
    answer:
      'After generating a draft, click "Publish to WordPress" in the content editor. RankWiz sends the content to your WordPress site via the REST API. You choose the target post, review the diff, and confirm. No copy-paste required.',
  },
  {
    question: 'What is the difference between the Pro and Team plans?',
    answer:
      "Pro supports up to 5 sites with 30 bundled AI drafts/month, batch AI generation, SERP scoring, and traffic alerts. Team adds unlimited sites and pages, unlimited AI drafts, white-label reports with custom domain, team roles with audit trail, and bulk operations. Team is billed per seat.",
  },
  {
    question: 'How does SERP content scoring work?',
    answer:
      'Connect your DataForSEO API key, enter a target keyword, and RankWiz fetches the top 10 results for that keyword. It extracts NLP terms (TF-IDF unigrams/bigrams/trigrams) and scores your draft across 4 weighted dimensions: term coverage (50%), word count (20%), heading structure (15%), and readability (15%).',
  },
  {
    question: "What are 'striking distance' keywords?",
    answer:
      "Striking distance keywords are queries where your pages rank in positions 11–20 — one page below the first page of Google results. These represent your highest-leverage opportunities: small content improvements or link-building efforts can push them to page 1 and dramatically increase clicks.",
  },
  {
    question: 'Can multiple team members use the same RankWiz account?',
    answer:
      'Yes — on the Team plan, you invite collaborators per site with role-based permissions (viewer, editor, admin). Each action is logged in the full audit trail. Pro users can share read-only reports via signed links.',
  },
  {
    question: 'What happens to my data if I cancel?',
    answer:
      'Your data remains accessible on the free plan after cancellation. You retain read access to your analysis history, recommendations, and ROI tracking. WordPress connection and AI draft generation revert to free-tier limits.',
  },
  {
    question: 'How does RankWiz handle multilingual WordPress sites?',
    answer:
      'RankWiz syncs GSC data per domain and can analyze performance by country segment. For multilingual sites using WPML or Polylang, each language version is tracked separately in GSC. RankWiz surfaces per-country traffic data and generates recommendations for underperforming language variants.',
  },
];

/** Pricing FAQs — used on Pricing page and comparison pages */
export const pricingFaqs: Faq[] = [
  {
    question: 'How long is the free trial?',
    answer: `Pro and Team plans include a ${TRIAL_DAYS}-day free trial — no credit card required to start. You get full access to all paid features during the trial period. After ${TRIAL_DAYS} days, you can subscribe to continue or stay on the free plan.`,
  },
  {
    question: 'Do I need an OpenAI account to use RankWiz?',
    answer:
      'No — every plan includes bundled AI drafts. An OpenAI account is only needed if you want unlimited drafts via BYOK (Bring Your Own Key), which lets you pay OpenAI directly at cost with no markup.',
  },
  {
    question: "What's included in the free plan?",
    answer:
      `Free includes 1 WordPress site, monthly analysis runs, up to 25 pages analyzed per run, and ${BUNDLED_DRAFTS.free} AI drafts per month. You get full access to traffic change detection, all ${RECOMMENDATION_TYPE_COUNT} recommendation types, cannibalization detection, topic clustering, and freshness analysis. No credit card required.`,
  },
  {
    question: 'How does the BYOK (Bring Your Own Key) model work?',
    answer:
      "You connect your OpenAI account, and RankWiz uses it to generate content drafts. You pay OpenAI directly for each draft — typically $0.01–$0.05 per draft. RankWiz doesn't mark up the cost. You keep full visibility into usage and can set spending limits in your OpenAI account.",
  },
  {
    question: 'Can I cancel anytime?',
    answer:
      "Yes. There's no long-term contract. Monthly billing can be cancelled at the end of your current period. Annual billing can be downgraded to monthly at any time, and refunds are handled per Stripe's policy.",
  },
  {
    question: 'What if I need a custom plan?',
    answer:
      'Contact our sales team for enterprise pricing. We offer custom site limits, dedicated support, and volume discounts for agencies and large publishers.',
  },
  {
    question: 'Is my data private?',
    answer:
      'Your Google Search Console connection, WordPress content, and AI drafts are private by default. We never resell data or use it to train models. Data is encrypted in transit and at rest. See our privacy policy for full details.',
  },
];

/**
 * Combined FAQ set for structured data (JSON-LD FAQPage schema).
 * Merges general, feature, pricing, and technical FAQs to reach 30+ items
 * for comprehensive schema coverage.
 */
export const allFaqs: Faq[] = [
  ...generalFaqs,
  ...featureFaqs,
  ...pricingFaqs,
  ...technicalFaqs,
];
