# -*- coding: utf-8 -*-
"""
tools/update_banana_turnaround_prompts.py
Cập nhật danh mục prompt Turnaround Model Sheet (Character Sheet 4-view)
cho toàn bộ hệ thống nhân vật trong 02_AI_Prompts/gemini_banana_prompts.json
"""

import json
import sys
from pathlib import Path

sys.stdout.reconfigure(encoding='utf-8')

BASE_DIR = Path(__file__).resolve().parent.parent
PROMPTS_FILE = BASE_DIR / "02_AI_Prompts" / "gemini_banana_prompts.json"

TURNAROUND_TEMPLATE_PREFIX = (
    "Professional character turnaround model sheet, production-ready 3D CGI character design sheet, "
    "multiple orthographic views of the SAME character on a single horizontal layout: "
    "far left close-up front bust portrait showing refined facial features, "
    "center-left full-body right side profile view standing straight, "
    "center-right full-body front view in neutral standing pose, "
    "far right full-body back view showing hair and back robe drape. "
)

TURNAROUND_TEMPLATE_SUFFIX = (
    " Studio Setup: Pure clean white background, seamless studio backdrop, even diffuse cinematic studio lighting, "
    "soft subtle contact shadows on the floor, no background props, no environment. "
    "Style: Unreal Engine 5 Metahuman render, hyper-detailed ZBrush cloth sculpt, Maya xGen groom, Octane Render 8K UHD, photorealistic CGI character asset."
)

TURNAROUND_PROMPTS = {
    # 01_Main_Protagonists
    "thuy_kieu_maiden": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and poetic melancholic expression from reference image. "
        "Character: Exceptionally radiant and beautiful 16-year-old East Asian noble maiden representing Thuy Kieu, "
        "luminous snow-white porcelain skin, intensely soulful clear autumn water eyes ('lan thu thuy'), "
        "poised sharp delicate features, neat aristocratic high updo with carved white jade flower hairpin and long silky black hair. "
        "Costume: Traditional celadon jade green and ivory silk Giao Linh cross-collar robe, delicate embroidered pear blossoms on collar, "
        "layered delicate trim, embroidered waist sash with white jade pendant and silk tassels, matching cloth shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "thuy_kieu_courtesan": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity and bone structure of Thuy Kieu, aged to 20 years old in Lam Tri courtesan chamber. "
        "Character: Stunning delicate beauty with sorrowful soulful eyes with unshed tears, refined noble composure amidst tragic fate, "
        "loosely styled coiffure with dangling silver filigree flower hairpin and silk ribbons. "
        "Costume: Elegant dusty rose and soft lilac silk robes with cascading translucent sleeves, layered embroidered undercollar, "
        "delicate floral embroidered waist sash with silver pendant, soft embroidered fabric slippers." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "thuy_kieu_flower_slave": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and melancholic servant expression from reference image. "
        "Character: Tragic noble maiden enslaved as servant girl Hoa No representing Thuy Kieu, pale delicate porcelain skin, "
        "sorrowful almond eyes, neat modest low bun secured with a simple dark wooden hairpin. "
        "Costume: Rustic indigo-dyed linen cross-collar servant tunic, faded pale grey inner collar, dark fabric waist tie, humble plain cloth slippers." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "thuy_kieu_general_wife": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and majestic empress expression from reference image. "
        "Character: Majestic 28-year-old rebel queen consort representing Thuy Kieu as Trieu Doanh Phu Nhan, radiant porcelain skin, "
        "sharp regal eyes, ornate golden phoenix crown inlaid with rubies and emeralds, dangling gold bead tassels. "
        "Costume: Luxurious crimson and imperial gold embroidered brocade silk court robe, wide ceremonial sleeves with golden wave embroidery, "
        "structured gold phoenix collar, ornate court sash with jade medallions, royal embroidered shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "thuy_kieu_ao_nau_song": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and serene enlightened expression from reference image. "
        "Character: Spiritual 31-year-old Buddhist novice nun representing Thuy Kieu in monastic retreat, pure porcelain skin, "
        "tranquil eyes free from worldly suffering, subtle compassionate smile, wearing a simple rustic brown monastic cloth hood. "
        "Costume: Humble earth-brown and dark chocolate linen Buddhist tunic (ao nau song), simple fabric waist cord, "
        "holding small sandalwood prayer beads, plain grey monk cloth shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "kim_trong": (
        "Professional cinematic character turnaround sheet of the EXACT SAME East Asian live-action male actor representing 18-year-old scholar Kim Trong from the reference image. "
        "The image is strictly divided into EXACTLY FOUR distinct views on a clean pure white studio background from left to right: "
        "1. Far Left: Close-up front bust portrait showing his handsome refined face, fair porcelain skin, sparkling intelligent eyes, neat high topknot with jade scholar hairpin cap, and embroidered crane cross-collar. "
        "2. Center-Left: Full-body right side profile view standing upright in dignified scholarly posture. "
        "3. Center-Right: Full-body front view standing straight in neutral pose, displaying full-length two-tone charcoal-navy and silvery-blue silk brocade Giao Linh robe with archaic seal script patterns and jade-studded belt. "
        "4. Far Right: Full-body rear back view showing the back of the high topknot hair bun and the elegant drape of the navy silk robe. "
        "Studio setup: Clean solid white background, diffuse studio lighting, soft subtle ground shadows. Real human actor, 35mm film still, photorealistic live-action cinema drama production asset, ultra-detailed textile weave. "
        "Absolutely NO anime, NO cartoon, NO 3D CGI animation, NO duplicate figures, strictly four views only."
    ),
    "kim_trong_mandarin_33yo": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and loyal devoted scholar-mandarin expression from reference image. "
        "Character: Distinguished 33-year-old imperial prefect magistrate representing mature Kim Trong, remarkably handsome mature features, "
        "neatly trimmed mustache and goatee, clear deeply devoted eyes, official black winged court hat (guan mao). "
        "Costume: Luxurious deep cyan-navy and celestial blue silk brocade magistrate court robe, gold embroidered civil crane rank insignia (buzi), "
        "jade court belt plaque, high black satin boots." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "thuy_van": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and serene full-moon expression from reference image. "
        "Character: Extraordinarily beautiful 16-year-old East Asian noble maiden representing Thuy Van, identical twin sister of Thuy Kieu, "
        "with soft blooming crescent eyebrows, gentle dewy cheeks, peaceful contented almond eyes, serene radiant gentle smile ('khuon trang day dan, net ngai no nang'). "
        "Sleek lustrous black hair neatly pinned in a noble updo with lustrous white freshwater pearl and silver floral hairpins. "
        "Costume: Traditional Giao Linh cross-collar silk robe in pure snow white and layered ivory cream chiffon with soft flowing sleeves, "
        "white jade sash pendant, matching silk cloth shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "tu_hai": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, square jaw, and imposing warrior expression from reference image. "
        "Character: Mighty 35-year-old East Asian heroic warlord representing Tu Hai, broad upright shoulders, piercing resolute gaze, "
        "dignified trimmed beard and mustache, hair tied in high warrior bun with bronze hair ring. "
        "Costume: Heavy battle armor crafted from dark bronze scales with embossed dragon motifs, weathered crimson war cape over shoulders, "
        "studded leather bracers, ornate commander belt with bronze beast buckle, sturdy military boots." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "thuy_kieu_maiden_tam_thap_luc": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity and bone structure of 16-year-old Thuy Kieu. "
        "Character: Tender, poetic noble maiden seated beside an antique wooden hammered dulcimer (tam thap luc). "
        "Soulful clear autumn water eyes, fair porcelain skin, delicate high updo with carved white jade flower hairpin. "
        "Costume: Light pastel celadon jade green silk Giao Linh cross-collar robe, fine ivory silk trim, embroidered waist sash with jade pendant." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),

    # 02_Vuong_Family_And_Fate
    "vuong_ong": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and gentle honorable patriarch expression from reference image. "
        "Character: Honorable 55-year-old East Asian patriarch representing Vuong Ong, weathered dignified face with sorrowful gentle eyes, "
        "trimmed salt-and-pepper beard and mustache, neat traditional black silk headwrap (khan dong). "
        "Costume: Modest dark charcoal-brown and indigo silk long tunic (ao the dai), subtle woven pattern, white inner collar band, "
        "simple fabric waist sash, traditional dark cloth shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "vuong_ba": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and compassionate mother expression from reference image. "
        "Character: Kind gentle 50-year-old East Asian mother representing Vuong Ba, warm maternal face with gentle wrinkles, "
        "sorrowful caring eyes, neat dark headwrap covering graying hair. "
        "Costume: Traditional rustic earth-toned chestnut-brown and warm amber silk robes, layered light cream inner collar, "
        "simple dark fabric sash, humble dark cloth shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "vuong_quan": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and studious young brother expression from reference image. "
        "Character: Studious 16-year-old East Asian student representing Vuong Quan, youthful innocent handsome face, fair porcelain skin, "
        "earnest almond eyes, sleek black hair tied in neat adolescent topknot with dark wooden hairpin. "
        "Costume: Modest pale slate-blue and soft ivory silk Giao Linh cross-collar robe, white inner collar band, "
        "simple fabric sash belt with tassel, traditional student cloth shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "dam_tien": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and melancholic ghost spirit expression from reference image. "
        "Character: Ethereal 20-year-old East Asian courtesan ghost spirit representing Dam Tien, translucent pale porcelain skin, "
        "delicate tragic almond eyes, subtle mournful gaze, antique updo with aged silver floral hairpin and silk ribbons. "
        "Costume: Flowing spectral white and pale mist-grey translucent silk gauze robes, layered ethereal flowing sleeves, "
        "delicate silver lotus embroidery, floating sash ribbons." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "quan_gia_vuong": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and devoted steward expression from reference image. "
        "Character: Devoted 60-year-old East Asian senior steward representing Quan Gia Vuong, weathered caring face, "
        "silver-grey beard and mustache, simple dark brown fabric cap. "
        "Costume: Modest slate-brown linen cross-collar servant robe, fabric belt with small brass key ring, humble dark cloth shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "gia_no_nu_vuong": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and loyal rural maidservant expression from reference image. "
        "Character: Modest 18-year-old East Asian maidservant representing Gia No Nu Vuong, round gentle face, warm honest eyes, "
        "neat low bun with green linen kerchief and rustic carved wooden hairpin. "
        "Costume: Rustic terracotta-amber and muted olive-brown linen cross-collar tunic, simple dark fabric waist tie, "
        "holding woven bamboo basket with fresh greens, plain dark cloth slippers." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "tieu_dong_kim_trong": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and lively young attendant expression from reference image. "
        "Character: Sprightly 14-year-old East Asian pageboy representing Tieu Dong Kim Trong, round innocent youthful face, "
        "bright smiling eyes, clean hair tied in neat topknot with red cord ribbon. "
        "Costume: Crisp light celadon-blue and ivory linen attendant cross-collar tunic, dark sash belt with small cloth document bag, "
        "sturdy cloth slippers, holding small antique carved wooden book box." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "quan_gia_kim_trong": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and loyal elite steward expression from reference image. "
        "Character: Aristocratic 58-year-old head steward of noble Kim estate representing Quan Gia Kim Trong, "
        "neat salt-and-pepper beard and mustache, refined composed eyes, dark silk headwrap. "
        "Costume: Deep navy and slate-blue silk brocade robe with woven cloud motifs, crisp white inner collar band, "
        "neat fabric waist sash, dark polished shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "quan_chung_thanh_minh": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: 16th century elegant festival crowd attendee in Qingming Festival spring excursion ('tai tu giai nhan dap thanh'). "
        "Refined youthful scholar, bright pleasant face, neat scholar bun. "
        "Costume: Traditional spring pastel mint-green and ivory silk robe, folding paper fan, cloth slippers." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),

    # 03_Thuc_Clan_And_Hoan_Mansion
    "thuc_sinh": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and weak-willed scholar expression from reference image. "
        "Character: Wealthy 25-year-old East Asian merchant scholar representing Thuc Sinh, fair complexion, slightly nervous eyes, "
        "delicate mouth, neat topknot with carved amber and silver hairpin. "
        "Costume: Luxurious pale golden-yellow and ivory cream silk Giao Linh cross-collar robe, embroidered silk lapel, "
        "patterned waist sash with amber pendant, matching cloth boots." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "hoan_thu": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and haughty noble expression from reference image. "
        "Character: Aristocratic 24-year-old noble lady representing Hoan Thu, fair ivory skin, sharp slender nose, "
        "piercing calculating almond eyes, subtle chilling composed smile, high regal updo with ornate gold phoenix hairpin and dangling tassels. "
        "Costume: Luxurious deep imperial purple and midnight violet silk brocade robe, structured gold-embroidered collar, "
        "wide flowing sleeves with dark plum lining, embroidered waist sash with circular jade buckle and tassels, traditional embroidered silk slippers." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "thuc_ong": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Wealthy 62-year-old seasoned merchant patriarch representing Thuc Ong (father of Thuc Sinh), "
        "strict furrowed brow, sharp calculating eyes hardened by commercial law and trade disputes, silver-streaked square beard, dark brown brocade headwrap. "
        "Costume: High-grade deep bronze and olive silk merchant robe, fur-lined collar trim, heavy jade belt, merchant ledger bag." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "me_hoan_thu": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Formidable 52-year-old high aristocratic matriarch representing Mother of Hoan Thu (Wife of Ministry Minister), "
        "stern haughty aristocratic gaze, unyielding authority, elaborate towering coiffure with gold filigree and jade pins. "
        "Costume: Opulent dark crimson and black silk court robe embroidered with imperial lotuses and gold lace, heavy jade pendant collar, gold rings." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "khuyen_ung": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Sinister 30-year-old clandestine henchman assassin of Hoan mansion representing Khuyen and Ung, "
        "cold dead eyes, sharp razor-like scars on jaw, hair wrapped tightly in a black cloth bandana. "
        "Costume: Practical stealth charcoal-black and dark indigo padded leather tunic, arm wrappings, concealed dagger sheath at waist, quiet soft-soled boots." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "ba_quan_gia": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Kindly 55-year-old senior female housekeeper of Hoan mansion representing Ba Quan Gia, "
        "gentle sympathetic eyes bearing hidden compassion for Thuy Kieu, graying hair pinned with a modest horn hairpin. "
        "Costume: Dignified dark navy and muted plum silk tunic, clean white inner collar, linen apron tie, cloth slippers." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),

    # 04_Brokers_And_Brothels
    "mu_moi": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Sly talkative 48-year-old professional marriage broker representing Mu Moi, "
        "exaggerated painted eyebrows, flattering oily smile, sharp money-counting gaze, loud floral hair ornament in loose updo. "
        "Costume: Flashy orange-gold and plum patterned silk cross-collar robe, embroidered matchmaker handkerchief in hand, red satin shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "ma_giam_sinh": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and dishonest trafficker expression from reference image. "
        "Character: Middle-aged 40-year-old East Asian human trafficker disguised as a student representing Ma Giam Sinh, "
        "suspiciously clean-shaven cheeks ('may rau nhan nhui'), sharp calculating slit eyes, gaudy appearance ('ao quan banh bao'), "
        "wearing an ornate black scholar headwrap. "
        "Costume: Flashy peacock-green and deep teal silk cross-collar robe, glossy patterned collar trim, "
        "gaudy embroidered belt with imitation jade ring and tassel, dark cloth boots." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "tu_ba": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and greedy brothel madam expression from reference image. "
        "Character: Shrewd plump 45-year-old East Asian brothel madam representing Tu Ba, pale heavy face coated in powder and rouge ('nhon nhot mau da'), "
        "fleshy jowls, sharp predatory eyes, smug harsh smirk, tall extravagant coiffure with gold pins and silk peony flowers. "
        "Costume: Gaudy multicolored silk robe in emerald green and vivid magenta floral brocade, wide sleeves with gold trim, "
        "loose layered collar, wide sash belt around plump waist, gold bangles on wrists." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "so_khanh": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and deceitful playboy expression from reference image. "
        "Character: Deceitful 28-year-old East Asian playboy representing So Khanh, slick grooming ('chai chuot phong luu'), "
        "narrow calculating seductive eyes, insincere smile, sleek black hair with loose stray bangs and silver pin. "
        "Costume: Flashy dusty peach-pink and ivory embroidered silk Giao Linh robe, loose neckline, "
        "ornate waist sash with dangling embroidered perfume pouch, light embroidered shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "bac_ba": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Vicious 50-year-old seedy brothel keeper of Chau Thai representing Bac Ba, "
        "leathery gaunt face with harsh greedy scowl, deep tobacco-stained lines, messy grey-flecked bun with cheap wooden pins. "
        "Costume: Dull faded olive-green and muddy brown coarse silk tunic, frayed hem, brass opium pipe in hand, worn cloth shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "bac_hanh": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Devious 32-year-old rogue swindler and kidnapper representing Bac Hanh, "
        "cunning wolfish eyes, false affable smirk, disheveled oily hair partially bound with a grey rag. "
        "Costume: Dusty ochre-yellow and charcoal cotton tunic with travel stains, worn leather belt, cloth leggings, straw sandals." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),

    # 05_Imperial_Court_And_Officials
    "ho_ton_hien": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and ruthless calculating expression from reference image. "
        "Character: Authoritative 48-year-old imperial governor-general representing Ho Ton Hien, weathered stern face, "
        "sharp calculating gaze, trimmed dark goatee, official black winged court hat (guan mao). "
        "Costume: Imperial crimson court robe with gold embroidered python insignia badge (buzi), wide ceremonial sleeves, "
        "jade plaque court belt, heavy dark boots." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "thang_ban_to": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and shifty peddler expression from reference image. "
        "Character: Cunning 26-year-old East Asian silk peddler false accuser representing Thang Ban To, thin scruffy face, "
        "darting rat-like eyes, patchy stubble, dusty dark cloth headwrap over untidy black hair. "
        "Costume: Rustic patched earth-brown and coarse hemp tunic, hemp rope waist cord, coarse shoulder satchel, straw sandals." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "quan_phu": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Stern 50-year-old provincial magistrate judge representing Quan Phu in Thuc family lawsuit, "
        "imposing legalistic scowl, heavy black judicial beard, rigid black winged magistrate hat. "
        "Costume: Deep sapphire-blue silk court robe with embroidered civil bird badge, wide formal sleeves, horn plaque court belt, dark magistrate boots." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "sai_nha": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and ruthless constable expression from reference image. "
        "Character: Brutal 35-year-old East Asian magistrate bailiff constable representing Sai Nha, weathered scarred face, "
        "rough stubble, sinister sneering grimace, conical dark magistrate runner hat. "
        "Costume: Heavy charcoal-grey and dark maroon runner tunic with riveted leather shoulder guards, studded leather arm bracers, "
        "thick leather waist belt with iron chain cuffs and wooden baton, rough military boots." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "tho_quan": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Corrupt 45-year-old local border official representing Tho Quan who forces Kieu into a concubine marriage, "
        "flabby smug face, greedy small eyes, greasy thin mustache, dark official cap with brass finial. "
        "Costume: Garish maroon and ochre silk provincial official robe, loose sash, embroidered tiger badge, black satin slippers." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),

    # 06_Buddhist_And_Spiritual
    "giac_duyen": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and compassionate nun expression from reference image. "
        "Character: Serene compassionate 45-year-old East Asian Buddhist nun representing Su Giac Duyen, "
        "shaved head under simple brown monastic cloth cap, calm gentle eyes exuding spiritual benevolence, tranquil faint smile. "
        "Costume: Authentic rustic earth-brown and dark ochre linen Buddhist robes (ao ca sa nau song), draped kasaya mantle over shoulder, "
        "holding smooth dark wooden prayer beads, simple brown monk cloth shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "tam_hop": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Mystical 60-year-old Taoist hermit prophetess representing Tam Hop Dao Co, "
        "wise transcendent eyes piercing into past and future karmic cycles, weathered serene countenance, white hair tied in a high Taoist topknot with a wooden hairpin. "
        "Costume: Flowing midnight blue and cloud-grey Taoist robe with embroidered Bagua yin-yang collar, holding a horsehair Taoist fly-whisk, hemp woven shoes." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),

    # 07_Warlord_Camp_And_Rebels
    "pho_tuong_tu_hai": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Maintain exact facial identity, bone structure, and fierce warrior expression from reference image. "
        "Character: Fierce 32-year-old East Asian rebel vanguard officer representing Pho Tuong Tu Hai, seasoned weathered face, "
        "trimmed dark beard and mustache, tight warrior topknot with iron ring clasp. "
        "Costume: Heavy charcoal-grey and dark crimson studded brigandine armor, riveted leather shoulder guards, "
        "thick leather sword belt, spiked iron combat boots." +
        TURNAROUND_TEMPLATE_SUFFIX
    ),
    "nu_binh_kieu": (
        TURNAROUND_TEMPLATE_PREFIX +
        "Character: Disciplined 22-year-old elite female royal guard soldier in Kieu's royal detachment, "
        "resolute martial gaze, athletic poised stance, sleek black hair bound tightly under a black leather archer cap. "
        "Costume: Fitted crimson and black leather brigandine armor, reinforced forearm guards, crimson sash belt with curved dao sword, leather combat boots." +
        TURNAROUND_TEMPLATE_SUFFIX
    )
}

def main():
    with open(PROMPTS_FILE, "r", encoding="utf-8") as f:
        data = json.load(f)

    # Cập nhật master_turnaround_anchor
    data["turnaround_style_anchor"] = (
        "Professional character turnaround model sheet, production-ready 3D CGI character design sheet, "
        "multiple orthographic views of the SAME character on a single horizontal layout: "
        "close-up front bust portrait, full-body side profile, full-body front view (neutral A-pose), full-body back view. "
        "Pure clean white background, seamless studio backdrop, diffuse cinematic studio lighting, soft subtle floor contact shadow. "
        "Unreal Engine 5 Metahuman render, hyper-detailed ZBrush cloth sculpt, Maya xGen groom, Octane Render 8K UHD --ar 16:9"
    )

    chars_group = data.get("characters", {})
    updated_count = 0

    # Ensure missing variations in 01_Main_Protagonists exist
    if "01_Main_Protagonists" in chars_group:
        g01 = chars_group["01_Main_Protagonists"]
        if "thuy_kieu_ao_nau_song" not in g01:
            g01["thuy_kieu_ao_nau_song"] = {
                "character_name": "Thúy Kiều (Áo Nâu Sòng Cửa Phật Giác Duyên)",
                "role_type": "Nhân vật chính",
                "folder": "01_Main_Protagonists",
                "prompt_16x9": "Cinematic portrait of Thuy Kieu in peaceful Buddhist retreat wearing simple brown robe, serene eyes, 85mm lens --ar 16:9",
                "prompt_9x16": "Cinematic vertical portrait of Thuy Kieu in rustic brown linen robe holding prayer beads, serene soft lighting --ar 9:16"
            }
        if "kim_trong_mandarin_33yo" not in g01:
            g01["kim_trong_mandarin_33yo"] = {
                "character_name": "Kim Trọng (Quan Tri Phủ 33 Tuổi)",
                "role_type": "Nhân vật chính",
                "folder": "01_Main_Protagonists",
                "prompt_16x9": "Cinematic portrait of mature 33yo Kim Trong in imperial cyan-navy magistrate robe with winged hat, 85mm lens --ar 16:9",
                "prompt_9x16": "Cinematic vertical portrait of 33yo Kim Trong as high imperial magistrate, winged hat, dignified gaze --ar 9:16"
            }

    # Inject prompt_turnaround_sheet and reference_image for all characters
    for group_key, chars_dict in chars_group.items():
        for char_id, char_data in chars_dict.items():
            if char_id in TURNAROUND_PROMPTS:
                char_data["prompt_turnaround_sheet"] = TURNAROUND_PROMPTS[char_id]
                # Dynamic resolution to character-centric directory
                cand_matches = list((BASE_DIR / "04_Assets" / "characters" / folder).glob(f"**/*{char_id}*turnaround_sheet_master.png"))
                if cand_matches:
                    m_file = cand_matches[0]
                    p_file = m_file.parent / m_file.name.replace("master", "720p")
                    char_data["turnaround_asset_master"] = str(m_file.relative_to(BASE_DIR)).replace("\\", "/")
                    char_data["turnaround_asset_720p"] = str(p_file.relative_to(BASE_DIR)).replace("\\", "/")
                else:
                    char_data["turnaround_asset_master"] = f"04_Assets/characters/{folder}/{char_id}/{char_id}_turnaround_sheet_master.png"
                    char_data["turnaround_asset_720p"] = f"04_Assets/characters/{folder}/{char_id}/{char_id}_turnaround_sheet_720p.png"
                updated_count += 1
                print(f"[✓] Cập nhật Turnaround Sheet: [{group_key}] -> {char_id}")
            else:
                print(f"[!] Chưa có prompt turnaround cho: {char_id}")

    with open(PROMPTS_FILE, "w", encoding="utf-8") as f:
        json.dump(data, f, ensure_ascii=False, indent=2)

    print(f"\n🎉 HOÀN TẤT: Đã cập nhật thành công {updated_count} nhân vật vào {PROMPTS_FILE}")

if __name__ == "__main__":
    main()
