"""Prompt templates for garment analysis and ghost mannequin generation."""

GARMENT_ANALYSIS_PROMPT = """\
You are a fashion expert AI. Analyze the clothing items worn by the person in this image.

For EACH distinct garment visible, provide:
1. category_main: one of [top, bottom, outer, dress]
2. category_sub: specific type (e.g., t-shirt, jeans, hoodie, blazer)
3. description: A concise Korean description of the item (색상, 소재, 디자인 특징 포함)
4. tags: an object with these fields (all values in English):
   - color: array of colors (e.g., ["black", "white"])
   - pattern: one of [solid, striped, checkered, floral, graphic, logo]
   - material: one of [cotton, denim, polyester, wool, leather, knit, silk, nylon, mixed]
   - style: array from [casual, formal, sporty, streetwear]
   - fit: one of [slim, regular, oversized, cropped]
   - occasion: array from [daily, office, date, workout, travel]
   - brand: detected brand name or "unknown"

You MUST return a JSON object with a single key "garments" containing an array.
Example:
{"garments": [
  {
    "category_main": "top",
    "category_sub": "t-shirt",
    "description": "블랙 코튼 라운드넥 반팔 티셔츠, 가슴에 작은 로고 프린트",
    "tags": {
      "color": ["black"],
      "pattern": "logo",
      "material": "cotton",
      "style": ["casual", "streetwear"],
      "fit": "regular",
      "occasion": ["daily"],
      "brand": "unknown"
    }
  }
]}

Important:
- Only include clearly visible garments (exclude bags, accessories, and shoes).
- If a layered garment is mostly hidden (approximately 70% or more covered by \
other clothing and nearly impossible to identify), do NOT include it. \
Only analyze garments that are clearly visible and identifiable.
- Return ONLY the JSON object {"garments": [...]}, no markdown fences or extra text.
- description must be in Korean.
- All tag values must be in English.
"""

GHOST_MANNEQUIN_EDIT_PROMPT = """\
Look at this photo of a person wearing clothes. \
Extract ONLY the {category_sub} ({category_main}) from this photo.

Instructions:
1. Remove the person completely — body, skin, face, hair, all other garments.
2. Keep ONLY the {category_sub}, preserving its EXACT original colors, textures, \
wrinkles, stitching, logos, buttons, and every visual detail from the photo.
3. Shape the garment as if displayed on an invisible ghost mannequin — \
maintaining the natural 3D form as worn, but with no visible body inside.
4. Place the garment on a plain, solid, evenly-lit pure white background — \
no props, no gradient, no cast shadows on the backdrop, no checkerboard pattern. \
(The white backdrop is removed in post-processing, so keep it clean and uniform.)
5. Output should look like a professional e-commerce product photo.

CRITICAL: The output garment must be IDENTICAL to what appears in the input photo. \
Same exact color, same pattern, same fabric texture, same brand markings. \
Do NOT generate a different or generic version of this garment type.
"""

STYLE_ANALYSIS_PROMPT = """\
You are a professional fashion stylist AI. Analyze the overall outfit style in this image.

Evaluate the following categories and provide a score (1-5) and detailed Korean commentary for each:

1. **color_palette** (색상의 균형 / Color Palette):
   - How well do the colors of all garments and accessories coordinate?
   - Consider color harmony, contrast, and seasonal appropriateness.

2. **silhouette** (핏과 실루엣 / Fit & Silhouette):
   - How well do the proportions and fits of the garments work together?
   - Consider body proportions, layering, and overall shape.

3. **detail** (디테일 포인트 / Detail Points):
   - How effectively are details, accessories, and finishing touches used?
   - Consider textures, patterns, accessories, and unique style elements.

Also provide:
4. **overall_score**: Average of the three scores (rounded to nearest 0.5).
5. **overall_comment**: A comprehensive Korean paragraph summarizing the entire outfit style, \
including strengths, notable features, and styling tips (2-4 sentences).
6. **style_tags**: Array of English style keywords that describe this outfit \
(e.g., ["casual", "minimal", "streetwear", "layered"]).

You MUST return a JSON object with the following structure:
{
  "color_palette": {
    "score": 5,
    "comment": "가장 칭찬하고 싶은 부분입니다. 차분한 파스텔 톤의 스카이 블루와..."
  },
  "silhouette": {
    "score": 4,
    "comment": "상의(Slightly Cropped): 골반 위로 떨어지는 세미 크롭 기장이..."
  },
  "detail": {
    "score": 4,
    "comment": "카디건 이너의 원포인트 티셔츠로 살짝 노출하여..."
  },
  "overall_score": 4.5,
  "overall_comment": "전체적으로 차분하면서도 세련된 파스텔 코디네이션이 돋보입니다...",
  "style_tags": ["casual", "minimal", "pastel", "layered"]
}

Important:
- All comments and overall_comment MUST be in Korean.
- style_tags MUST be in English.
- Scores are integers from 1 to 5.
- overall_score can be a float (e.g., 4.5).
- Return ONLY the JSON object, no markdown fences or extra text.
"""

VTON_PROMPT = """\
You are a professional photo retoucher producing PHOTOREALISTIC virtual try-on \
images. The output must be indistinguishable from a real photograph taken with \
the SAME camera in the SAME scene as the input person photo.

You are given:
- 1 PERSON photo (the FIRST image).
- {garment_count} isolated GARMENT images on transparent backgrounds \
(the remaining images, in order).

Each garment's category (parallel to image order) is: {catalog}
For example "#1=top, #2=bottom" means image #1 is a top and image #2 is pants/skirt.

Your task:
1. Composite each APPLICABLE garment onto the person, replacing whatever \
they are currently wearing in the same body region.
2. PRESERVE the person's face, hair, skin tone, pose, body proportions, \
background, and identity EXACTLY. Do not alter the face or identity in any way.
3. PRESERVE each garment's hue, pattern, logos, and overall shape from the \
supplied garment image. You MAY (and should) adjust the garment's exposure, \
brightness, and white balance to match the lighting of the PERSON photo — do \
NOT carry over the clean studio tone of the ghost cutout.
4. If the PERSON photo is an UPPER-BODY CROP (legs / lower body are NOT \
visible in the frame), SKIP any garment whose category is "bottom" \
(pants, skirt, shorts). Do NOT extend the frame, do NOT invent legs, \
do NOT try to render the lower garment. Simply leave the bottom garment \
OUT of the composition.
5. If multiple tops/outers are provided, layer them naturally \
(outer on top of inner top).
6. PHOTOREALISM (apply to every garment you composite):
   - Lighting match: analyze the direction, color temperature, intensity, and \
hard/soft quality of the light in the PERSON photo. The garment's highlights \
and shadows MUST follow that same lighting. If the scene is lit by overhead \
fluorescents, the garment must show overhead-lit shading; if by a window from \
the side, side-lit shading; etc.
   - Natural fabric behavior: render realistic folds, pulls, and drape at the \
shoulders, inside the elbows, around the waist, at the cuffs, and at the hem, \
following the person's pose and gravity. Do NOT render fabric as a flat, \
perfectly smooth surface.
   - Contact shadows: add subtle shadows where the garment meets the body or \
other garments (neckline, inside the sleeves, hem against pants, layer seams) \
so the garment does not look like it is floating or pasted on.
   - Edge integration: keep the garment's silhouette as soft as the rest of \
the photo. Match the focus and lens characteristics of the PERSON photo — do \
NOT leave razor-sharp cutout edges in an otherwise softer image.
   - Camera & color matching: match the saturation, contrast, and white \
balance of the PERSON photo. If the input photo has visible noise or grain, \
the garment surface must carry equivalent noise/grain. The garment must not \
look "cleaner" or "sharper" than the surrounding pixels.
   - Perspective & wrap: the garment must wrap around the person's body \
contours (shoulder slope, chest, torso, legs) following their pose. Do NOT \
render the garment as a flat front-facing projection.
7. Return exactly ONE composited image matching the original person photo's \
framing and aspect ratio.

CRITICAL:
- The person's face MUST be identical to the input photo. \
No face edits, no identity changes.
- Do NOT invent garments that were not provided.
- Do NOT change garment hue, pattern, or print (exposure / white-balance \
adjustments to match the scene are required and do not count as a change).
- Do NOT make the result look like a 3D render, CG composite, sticker, or \
studio cutout pasted onto the person. The garment must look as if the person \
actually wore it and was photographed — not added in post.
- If you cannot achieve photorealistic integration for a garment, still \
composite it but prioritize believability over saturation/sharpness of the \
garment.
- If a garment clearly cannot fit the visible body region, SKIP it \
rather than distorting the image.
"""

STYLE_ANALYSIS_TEMP = """\
You are a professional fashion stylist AI. Analyze the overall outfit style in this image.

Use the following context for your analysis:
- 현재 시간대: 출근 시간 (아침)
- 오늘 일정: 센터장님께 보고가 예정되어 있음
- 오늘 날씨: 화창함

Provide analysis in exactly 5 sections. Each section MUST be 1 sentence in Korean.
Each section MUST be between 70 and 75 characters long (including spaces).
Each section MUST start with the specified opening phrase.

1. **time_context** (시간 관련): \
"출근룩으로는 "으로 시작. 출근룩으로 이 옷차림이 얼마나 적절한지 평가.
2. **occasion_context** (일정 관련): \
"오늘 일정은 "으로 시작. 센터장님 보고에 있어 이 옷차림이 얼마나 적절한지 평가.
3. **weather_context** (날씨 관련): \
"오늘 날씨는 "으로 시작. 화창한 날씨에 이 옷차림이 적합한지 평가.
4. **color_harmony** (배색 관련): \
"전체적인 배색은 "으로 시작. 상하의 및 전체 배색의 조화를 평가.
5. **improvement_tips** (보완점): \
"더 완벽한 코디를 위해"로 시작. 오늘 상황에 맞게 스타일을 보완할 구체적 팁 제시.

You MUST return a JSON object with the following structure:
{
  "time_context": "출근룩으로는 단정한 셔츠와 차분한 톤의 아우터 조합이라 무난하지만, 다소 캐주얼해 보여 아침 출근용으로는 약간 보완하면 더 좋습니다.",
  "occasion_context": "오늘 일정은 센터장님께 보고가 예정되어 있으므로, 격식 있는 재킷과 단정한 구두를 매치하면 신뢰감 있는 인상을 줄 수 있습니다.",
  "weather_context": "오늘 날씨는 화창하여 밝은 베이지 상의가 전체 분위기를 한층 부드럽고 산뜻하게 만들어주며, 가벼운 소재라 쾌적합니다.",
  "color_harmony": "전체적인 배색은 베이지와 블랙의 클래식한 조합으로 안정감 있고 고급스러운 느낌을 잘 살리면서도 세련된 인상을 줍니다.",
  "improvement_tips": "더 완벽한 코디를 위해서는 얇은 블레이저나 심플한 가죽 시계를 더해 포멀한 완성도와 디테일을 높여주는 것을 추천합니다."
}

Important:
- All text MUST be in Korean.
- Each section value MUST be between 70 and 75 characters long (including spaces). This is critical.
- Return ONLY the JSON object, no markdown fences or extra text.
"""
