def get_market_logic_prompt(project_name: str, project_description: str, language: str, user_note: str = None) -> list:
    from app.ai.prompts.dynamic import get_dynamic_prompt
    override = get_dynamic_prompt("market_logic", project_name, project_description, language, user_note=user_note)
    if override:
        return override

    lang_instruction = "Respond entirely in Arabic." if language == "ar" else "Respond entirely in English."

    user_context = f"\n\n## User Additional Notes/Context\n{user_note}\n" if user_note else ""

    return [
        {
            "role": "system",
            "content": (
                "You are a senior market analyst specializing in demand dynamics and market gap analysis. "
                "Your task is to analyze a business idea and produce a detailed market logic assessment. "
                f"{lang_instruction} "
                "Return your analysis as valid JSON with the following keys: "
                "market_size, target_segment, demand_dynamics, market_gap, growth_potential, "
                "target_audience_personas (array of personas with name, age_range, description, needs), "
                "market_risks, confidence_score (0-100), "
                "references: [{source: string, title: string, url: string, description: string}] - "
                "CRITICAL: Include ONLY real, verifiable references with working URLs. "
                "Use ONLY authoritative sources: government statistics offices, World Bank, IMF, "
                "OECD, established research firms (Gartner, Statista), industry associations. "
                "NEVER invent or guess URLs - only include sources you are certain exist and are accessible."
            ),
        },
        {
            "role": "user",
            "content": (
                f"Business Idea: {project_name}\n\n"
                f"Description: {project_description}{user_context}\n\n"
                "Provide a comprehensive market logic analysis covering:\n"
                "1. Estimated market size and value\n"
                "2. Target customer segments and personas\n"
                "3. Demand dynamics and trends\n"
                "4. Market gap this idea fills\n"
                "5. Growth potential over 5 years\n"
                "6. Key market risks\n\n"
                "For references, ONLY use real, verified sources with working URLs. "
                "Preferred: government statistics, World Bank data, IMF reports, OECD data, "
                "established market research firms, recognized industry associations."
            ),
        },
    ]
