/**
 * Persona Tooltips and Insights
 * Comprehensive explanations for every metric and field
 */

export interface TooltipInfo {
  title: string;
  description: string;
  howWeCalculated: string;
  whyItMatters: string;
  example?: string;
}

/**
 * Core Persona Tooltips
 */
export const corePersonaTooltips = {
  // Identity Section
  personaName: {
    title: "Persona Name",
    description: "A descriptive name that captures the essence of your writing personality and brand identity.",
    howWeCalculated: "Generated by analyzing your writing style patterns, tone consistency, and brand positioning across all analyzed content.",
    whyItMatters: "A memorable persona name helps you maintain consistency and makes it easier to switch between different writing contexts.",
    example: "E.g., 'The Tech Educator', 'Strategic Storyteller', 'Data-Driven Advisor'"
  },
  
  archetype: {
    title: "Writing Archetype",
    description: "The fundamental character or role your writing embodies - defines how readers perceive you.",
    howWeCalculated: "AI analyzed your content themes, communication style, and how you position yourself relative to your audience (teacher, peer, expert, etc.).",
    whyItMatters: "Your archetype guides tone, structure, and content approach - ensuring your writing consistently reflects your intended professional image.",
    example: "Expert Educator teaches, Innovator challenges conventions, Sage provides wisdom"
  },
  
  coreBelief: {
    title: "Core Belief",
    description: "The fundamental philosophy or conviction that drives your content and messaging.",
    howWeCalculated: "Extracted from recurring themes, value statements, and the underlying message across your content. We looked at what you emphasize repeatedly.",
    whyItMatters: "Your core belief creates authentic, purpose-driven content that resonates with your audience and builds trust over time.",
    example: "'Knowledge should be accessible to everyone' or 'Data-driven decisions lead to success'"
  },
  
  brandVoice: {
    title: "Brand Voice Description",
    description: "A comprehensive characterization of your unique communication style and personality.",
    howWeCalculated: "Synthesized from analyzing tone patterns, word choices, sentence structure, and how you engage with different topics across platforms.",
    whyItMatters: "Consistent brand voice makes your content instantly recognizable and builds a stronger connection with your audience.",
    example: "Professional yet approachable, confident without being arrogant, educational while staying engaging"
  },

  // Linguistic Fingerprint - Sentence Metrics
  avgSentenceLength: {
    title: "Average Sentence Length",
    description: "The typical number of words per sentence in your writing - affects readability and pacing.",
    howWeCalculated: "Analyzed 100+ sentences across your content, calculated mean word count, and identified your natural rhythm.",
    whyItMatters: "Shorter sentences (10-15 words) are punchy and clear. Longer sentences (20-30 words) allow for more complex ideas. Your natural length affects engagement.",
    example: "15 words = 'Clean and digestible'; 25 words = 'Detailed and thoughtful'"
  },
  
  sentenceType: {
    title: "Preferred Sentence Type",
    description: "The grammatical structure you naturally favor (simple, compound, complex, or compound-complex).",
    howWeCalculated: "Parsed sentence structures using NLP to identify patterns in how you combine independent and dependent clauses.",
    whyItMatters: "Sentence variety keeps readers engaged. Your preferred type reflects your communication sophistication and should match audience expectations.",
    example: "Simple (one idea), Compound (two related ideas), Complex (main + supporting idea)"
  },
  
  activePassiveRatio: {
    title: "Active to Passive Voice Ratio",
    description: "How often you use active voice ('I analyzed data') vs passive voice ('Data was analyzed').",
    howWeCalculated: "Used linguistic analysis to identify verb constructions and calculate the percentage of active vs passive sentences.",
    whyItMatters: "Active voice (80:20 ratio) is more engaging and direct. Passive voice can add formality or objectivity when needed. Your ratio shows your natural authority level.",
    example: "80:20 = Direct and engaging; 50:50 = More formal/academic"
  },
  
  complexityLevel: {
    title: "Sentence Complexity Level",
    description: "Overall sophistication of your sentence structures - simple, moderate, or complex.",
    howWeCalculated: "Evaluated using Flesch-Kincaid readability metrics, clause depth, and vocabulary difficulty across your content.",
    whyItMatters: "Complexity should match audience education level. Too simple feels condescending; too complex loses readers. We found your natural sweet spot.",
    example: "Simple = Grade 8, Moderate = Grade 10-12, Complex = College+"
  },

  // Linguistic Fingerprint - Lexical Features
  goToWords: {
    title: "Go-To Words",
    description: "Words and terms you use frequently that define your communication style.",
    howWeCalculated: "Performed frequency analysis excluding common words, identified terms appearing 3x more than average in your industry.",
    whyItMatters: "These signature words make your voice distinctive and memorable. They reveal your focus areas and expertise.",
    example: "'innovative', 'strategic', 'actionable', 'framework', 'optimize'"
  },
  
  goToPhrases: {
    title: "Go-To Phrases",
    description: "Signature expressions and turns of phrase that make your writing uniquely yours.",
    howWeCalculated: "Used n-gram analysis to find frequently repeated 2-5 word phrases unique to your writing style.",
    whyItMatters: "Signature phrases build recognition and trust. They're your verbal brand markers that audiences associate with you.",
    example: "'in my experience', 'here's the thing', 'let me show you', 'the reality is'"
  },
  
  avoidWords: {
    title: "Words to Avoid",
    description: "Terms that don't fit your authentic voice or that your analysis rarely uses.",
    howWeCalculated: "Identified words common in your industry but conspicuously absent or rare in your content, suggesting conscious avoidance.",
    whyItMatters: "Knowing what NOT to say is as important as what to say. These words might feel inauthentic or overused in your industry.",
    example: "'basically', 'literally', 'synergy', 'leverage', 'disrupt' (if you avoid business jargon)"
  },
  
  contractions: {
    title: "Contractions Usage",
    description: "How often you use contractions ('don't' vs 'do not') - affects formality level.",
    howWeCalculated: "Counted contraction frequency and compared to total verb phrases to determine your natural usage pattern.",
    whyItMatters: "Frequent contractions = conversational and approachable. Rare contractions = formal and professional. Your pattern reflects your relationship with readers.",
    example: "Frequent = casual/friendly; Occasional = balanced; Rare = formal/academic"
  },
  
  vocabularyLevel: {
    title: "Vocabulary Level",
    description: "The sophistication of words you choose - accessible, intermediate, or advanced.",
    howWeCalculated: "Analyzed using Dale-Chall word lists and academic word frequency databases to classify your typical vocabulary tier.",
    whyItMatters: "Vocabulary level must match your audience. Too basic = not credible; too advanced = loses readers. We found your effective range.",
    example: "Accessible = common words; Intermediate = some technical terms; Advanced = specialized jargon"
  },

  // Linguistic Fingerprint - Rhetorical Devices
  metaphors: {
    title: "Metaphor Usage",
    description: "How you use metaphorical language to explain concepts ('the market is a battlefield').",
    howWeCalculated: "Identified figurative language patterns and categorized types of comparisons you frequently employ.",
    whyItMatters: "Effective metaphors make complex ideas accessible and memorable. Your metaphor style reveals how you think and teach.",
    example: "Business metaphors, sports analogies, nature comparisons, journey narratives"
  },
  
  analogies: {
    title: "Analogy Strategy",
    description: "How you use analogies to connect new concepts to familiar ones.",
    howWeCalculated: "Detected 'like/as/similar to' patterns and analyzed the domains you draw comparisons from.",
    whyItMatters: "Good analogies bridge knowledge gaps. Your analogy sources should resonate with your specific audience's experiences.",
    example: "Tech explained through cooking, business through sports, strategy through chess"
  },
  
  rhetoricalQuestions: {
    title: "Rhetorical Questions",
    description: "How you use questions to engage readers without expecting literal answers.",
    howWeCalculated: "Identified question patterns that appear in non-interrogative contexts and analyzed their positioning (openings, transitions).",
    whyItMatters: "Rhetorical questions grab attention, create curiosity, and make readers think. Your usage pattern affects engagement flow.",
    example: "'What if I told you...?', 'Sound familiar?', 'Here's the question:'"
  },
  
  storytelling: {
    title: "Storytelling Style",
    description: "How you incorporate narrative elements to make content engaging and relatable.",
    howWeCalculated: "Detected narrative structures, personal anecdotes, and story-based explanations in your content.",
    whyItMatters: "Stories make content memorable and emotional. Your storytelling approach determines how deeply readers connect with your message.",
    example: "Personal anecdotes, case studies, hypothetical scenarios, customer journeys"
  },

  // Tonal Range
  defaultTone: {
    title: "Default Tone",
    description: "The baseline emotional quality and attitude of your writing.",
    howWeCalculated: "Sentiment analysis across 100+ pieces of content to identify your consistent emotional baseline and communication approach.",
    whyItMatters: "Your default tone sets expectations. It should align with your brand and make your audience comfortable engaging with your content.",
    example: "Professional yet approachable, confident and authoritative, friendly and supportive"
  },
  
  permissibleTones: {
    title: "Permissible Tones",
    description: "Tones you can authentically use while staying true to your brand voice.",
    howWeCalculated: "Identified tonal variations that appeared naturally in your content without feeling forced or inconsistent.",
    whyItMatters: "Tonal flexibility prevents monotony while maintaining authenticity. These tones expand your range without diluting your brand.",
    example: "Inspirational, educational, analytical, conversational, empathetic"
  },
  
  forbiddenTones: {
    title: "Forbidden Tones",
    description: "Tones that feel inauthentic or contradict your established voice and brand.",
    howWeCalculated: "Identified tones absent from your content that commonly appear in your industry, suggesting intentional avoidance.",
    whyItMatters: "Knowing what to avoid prevents off-brand content. These tones would erode trust and confuse your audience.",
    example: "Overly salesy, condescending, apologetic, pessimistic, aggressive"
  },
  
  emotionalRange: {
    title: "Emotional Range",
    description: "The spectrum of emotions you express in your writing, from calm to enthusiastic.",
    howWeCalculated: "Analyzed emotional vocabulary, punctuation intensity, and sentiment strength across different content types.",
    whyItMatters: "Emotional range creates engaging content that resonates. Too narrow = boring; too wide = inconsistent. Your range fits your brand.",
    example: "Calm to moderately enthusiastic, thoughtful to inspired, objective to passionate"
  },

  // Stylistic Constraints - Punctuation
  ellipses: {
    title: "Ellipses Usage (...)",
    description: "How you use ellipses for pauses, trailing thoughts, or dramatic effect.",
    howWeCalculated: "Counted ellipses frequency and analyzed their contextual usage patterns in your writing.",
    whyItMatters: "Ellipses create suspense or informality. Overuse can seem unprofessional; strategic use adds personality.",
    example: "Rarely = professional; Occasionally = conversational; Frequent = very casual"
  },
  
  emDash: {
    title: "Em-Dash Usage (—)",
    description: "How you use em-dashes for emphasis, interruption, or additional information.",
    howWeCalculated: "Analyzed em-dash frequency and function (parenthetical, emphasis, or dramatic pause).",
    whyItMatters: "Em-dashes add sophistication and flow. They're more dynamic than commas but less formal than semicolons.",
    example: "Frequent = sophisticated writer; Sparingly = traditional; Never = very formal"
  },
  
  exclamations: {
    title: "Exclamation Points (!)",
    description: "How you use exclamation points for emphasis and excitement.",
    howWeCalculated: "Counted exclamation frequency and context (announcements, enthusiasm, urgency).",
    whyItMatters: "Exclamations convey energy and emotion. Too many seem unprofessional; too few seem cold. Your usage fits your brand.",
    example: "Minimal = very professional; Moderate = enthusiastic; Frequent = highly energetic"
  },

  // Stylistic Constraints - Formatting
  paragraphs: {
    title: "Paragraph Structure",
    description: "Your typical paragraph length and organization style.",
    howWeCalculated: "Analyzed average sentences per paragraph, paragraph transitions, and whitespace patterns.",
    whyItMatters: "Paragraph length affects readability. Short paragraphs (3-4 sentences) are scannable; longer ones (6-8) are detailed. Your style fits your medium.",
    example: "Short paragraphs = blog/social; Medium = articles; Long = academic/formal"
  },
  
  lists: {
    title: "Lists Preference",
    description: "How and when you use bulleted or numbered lists in your content.",
    howWeCalculated: "Detected list frequency, type preferences (bullets vs numbers), and usage contexts.",
    whyItMatters: "Lists improve scannability and comprehension. Your list style affects how readers process information.",
    example: "Frequent bullets = practical/actionable; Numbered = sequential/ranked; Rare = narrative-focused"
  },
  
  markdown: {
    title: "Markdown/Formatting Usage",
    description: "How you use formatting like bold, italics, headers, and other text styling.",
    howWeCalculated: "Analyzed formatting markup patterns across different content platforms and types.",
    whyItMatters: "Strategic formatting guides attention and improves reading flow. Your style balances visual hierarchy with readability.",
    example: "Heavy formatting = attention-guiding; Minimal = clean/traditional; Moderate = balanced"
  },
};

/**
 * Platform Persona Tooltips (LinkedIn-specific shown, similar for others)
 */
export const platformPersonaTooltips = {
  // Content Format Rules
  characterLimit: {
    title: "Character Limit",
    description: "Platform-specific maximum character count per post.",
    howWeCalculated: "Based on official platform limits and optimal engagement data from platform research.",
    whyItMatters: "Staying within limits ensures content isn't truncated. Knowing optimal ranges (often 50-70% of max) drives better engagement.",
    example: "LinkedIn: 3,000 chars max, optimal 1,300-2,000 for highest engagement"
  },
  
  paragraphStructure: {
    title: "Paragraph Structure",
    description: "Platform-optimized paragraph formatting for maximum readability and engagement.",
    howWeCalculated: "Analyzed top-performing content on this platform to identify optimal paragraph patterns and whitespace usage.",
    whyItMatters: "Each platform has different reading behaviors. Mobile-first platforms need shorter paragraphs; desktop allows longer.",
    example: "LinkedIn: 2-3 sentence paragraphs with line breaks for scannability"
  },
  
  ctaStyle: {
    title: "Call-to-Action Style",
    description: "How to craft effective CTAs that drive engagement on this specific platform.",
    howWeCalculated: "Analyzed your successful CTAs and platform best practices to determine what drives action from your audience.",
    whyItMatters: "Platform-specific CTA styles align with user behavior. LinkedIn users respond to professional invitations; Instagram to emotional appeals.",
    example: "LinkedIn: 'What's your experience with this?' drives comments; 'Share your thoughts' drives shares"
  },
  
  linkPlacement: {
    title: "Link Placement Strategy",
    description: "Where and how to place links for optimal visibility and click-through rates.",
    howWeCalculated: "Based on platform algorithms, user behavior data, and A/B testing results showing highest link engagement.",
    whyItMatters: "Link placement affects both algorithm visibility and user clicks. Wrong placement can reduce reach by 50%+.",
    example: "LinkedIn: First comment often better than in post body for algorithm"
  },

  // Engagement Strategy
  postingFrequency: {
    title: "Posting Frequency",
    description: "Optimal posting cadence for maintaining visibility without overwhelming your audience.",
    howWeCalculated: "Analyzed your historical engagement patterns, follower growth, and platform algorithm preferences for your niche.",
    whyItMatters: "Posting too much causes unfollows; too little reduces visibility. Your optimal frequency balances growth and sustainability.",
    example: "LinkedIn: 3-5x/week for max reach; daily can work for established accounts"
  },
  
  optimalTimes: {
    title: "Optimal Posting Times",
    description: "When your specific audience is most active and engaged on this platform.",
    howWeCalculated: "Analyzed your audience timezone data, historical engagement patterns, and industry benchmarks for your sector.",
    whyItMatters: "Posting when your audience is active increases initial engagement, which signals algorithms to boost your reach.",
    example: "Tue-Thu 8-10am and 12-2pm often best for B2B; adjust for your audience"
  },
  
  engagementTactics: {
    title: "Engagement Tactics",
    description: "Specific strategies to increase likes, comments, shares, and meaningful interactions.",
    howWeCalculated: "Identified tactics that correlate with your highest-performing content and match platform algorithm priorities.",
    whyItMatters: "Platform algorithms reward engagement. These tactics are proven to work for your content type and audience.",
    example: "Ask specific questions, respond within 60 mins, use polls, tag relevant people"
  },

  // Algorithm Optimization
  algorithmInsights: {
    title: "Algorithm Optimization",
    description: "Platform-specific strategies to maximize content visibility and reach.",
    howWeCalculated: "Based on documented platform algorithm factors, reverse-engineering of high-performing content, and your historical data.",
    whyItMatters: "Algorithms determine who sees your content. Optimization can increase organic reach by 200-500%.",
    example: "LinkedIn values dwell time, meaningful conversations, and professional network engagement"
  }
};

/**
 * Get tooltip info for a specific field
 */
export const getTooltip = (category: 'core' | 'platform', fieldKey: string): TooltipInfo | null => {
  if (category === 'core') {
    return corePersonaTooltips[fieldKey as keyof typeof corePersonaTooltips] || null;
  } else {
    return platformPersonaTooltips[fieldKey as keyof typeof platformPersonaTooltips] || null;
  }
};

/**
 * Format tooltip content for display
 */
export const formatTooltipContent = (tooltip: TooltipInfo): string => {
  return `
📊 ${tooltip.title}

${tooltip.description}

🔍 How we calculated this:
${tooltip.howWeCalculated}

💡 Why it matters:
${tooltip.whyItMatters}

${tooltip.example ? `📝 Example: ${tooltip.example}` : ''}
  `.trim();
};

