"""
Gera cena IA da noiva feliz + convidados no ambiente da Chacara Sonho Verde Top.
Abordagem A: cena unica com noiva no pergolado com bougainvillea, ao estilo da foto_33.
"""
import os, base64, sys
from pathlib import Path
from openai import OpenAI

OUT = Path("/opt/mia/workspace/clientes/chacara-sonho-verde/variacoes_casamento_2026-08-11")
OUT.mkdir(parents=True, exist_ok=True)

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

PROMPT = (
    "Cinematic editorial wedding photograph, golden hour late afternoon light. "
    "A joyful Brazilian bride in her mid-twenties wearing an elegant flowing "
    "off-white A-line wedding dress with delicate lace details, holding a small "
    "bouquet of white and cream flowers, standing in the center smiling genuinely "
    "with tears of happiness in her eyes. Around her, 4 to 5 wedding guests "
    "(mix of Brazilian ethnicities, ages 25-55, natural diverse group of family "
    "and friends in semi-formal wedding attire in soft neutral tones) are laughing "
    "and celebrating, some clapping, one throwing rice petals. "
    "Setting: outdoor Brazilian countryside wedding venue in Valinhos SP mountains, "
    "white wooden pergola covered with vibrant magenta bougainvillea flowers on the "
    "right side, lush green tropical garden, mature trees, small pond with plants "
    "in the foreground softly out of focus, brick pathway. Warm golden sun flare "
    "coming from the left, dreamy soft focus background, high-end wedding "
    "photography aesthetic like Vogue Brides. Shot on medium format, 85mm lens, "
    "shallow depth of field, warm color grade, natural authentic emotion. "
    "Vertical composition, 4:5 aspect ratio. No text, no logo, no watermark."
)

print("Gerando cena da noiva via gpt-image-1...")
resp = client.images.generate(
    model="gpt-image-1",
    prompt=PROMPT,
    size="1024x1536",
    quality="high",
    n=1,
)

b64 = resp.data[0].b64_json
raw_path = OUT / "v4_noiva_raw.png"
with open(raw_path, "wb") as f:
    f.write(base64.b64decode(b64))
print(f"OK bruta: {raw_path}")
