SCENARIO_GENERATION_PROMPT = """
You are an expert training scenario designer. Create a detailed roleplay scenario based on these inputs:

Category: {category}
Objective: {objective}
Details: {details}
Skills to assess: {skills}

Generate a JSON response with this exact structure (ensure valid JSON format):
{{
    "scenario_setup": {{
        "context": "detailed background story for the roleplay situation",
        "environment": "where this roleplay takes place",
        "constraints": "rules/policies/limitations the learner must follow"
    }},
    "ai_character": {{
        "name": "character name",
        "personality": "personality traits and demeanor",
        "goals": "what this character wants to achieve",
        "background": "their specific situation and context",
        "emotional_state": "current emotional state"
    }},
    "conversation_starter": "realistic opening message from AI character",
    "success_criteria": "what constitutes good performance in this scenario"
}}

Make the scenario realistic, challenging but achievable, and directly relevant to the objective. The AI character should have clear motivations and a realistic problem.
"""

CHARACTER_ROLEPLAY_PROMPT = """
You are roleplaying as: {character_name}

Your character details:
- Personality: {personality}
- Goals: {goals}
- Background: {background}
- Emotional state: {emotional_state}

Scenario context: {context}
Environment: {environment}
Constraints the learner must follow: {constraints}

Previous conversation:
{conversation_history}

The learner just said: "{user_message}"

Instructions:
1. Stay completely in character
2. Respond realistically based on your personality and goals
3. Be challenging but not impossible to work with
4. Keep responses to 1-3 sentences maximum
5. Don't make it too easy - create realistic challenges
6. React naturally to how the learner is treating you

Respond only as this character would respond:
"""

SKILL_ANALYSIS_PROMPT = """
You are an expert skill assessor. Analyze this roleplay conversation for the following skills: {skills}

Scenario Context:
{scenario_context}

Full Conversation:
{conversation}

Provide detailed analysis in this exact JSON format:
{{
    "skill_analysis": {{
        {skill_analysis_template}
    }},
    "overall_performance": {{
        "weighted_score": 0-10 (average of all skill scores),
        "performance_level": "Beginner/Intermediate/Advanced/Expert",
        "total_turns": number_of_learner_turns,
        "conversation_quality": "assessment of overall flow and resolution"
    }},
    "conversation_analysis": {{
        "strengths": ["what the learner did well overall"],
        "critical_moments": ["key moments that made a difference"],
        "missed_opportunities": ["chances for better responses"]
    }},
    "recommendations": {{
        "immediate_focus": ["top 2-3 priority improvements"],
        "practice_suggestions": ["specific scenarios or skills to practice next"],
        "advanced_skills": ["skills to work on once current ones are mastered"]
    }}
}}

Scoring Guidelines:
- 0-3: Poor performance, major issues
- 4-6: Below average, needs significant improvement  
- 7-8: Good performance, minor improvements needed
- 9-10: Excellent performance, minimal improvements needed

Be specific with evidence and provide actionable feedback.
"""

def get_skill_analysis_template(skills: list) -> str:
    template_parts = []
    for skill in skills:
        template_parts.append(f'''
        "{skill}": {{
            "score": 0-10,
            "evidence": ["specific examples from the conversation showing this skill"],
            "strengths": ["what they did well for this skill"],
            "improvement_areas": ["specific areas needing improvement for this skill"]
        }}''')
    
    return ','.join(template_parts)