#!/usr/bin/env python3
"""Hero piloto 05 D VERTICAL (1024x1536) — para formato 9:16 (story/reels).

Mesma cena do hero_tempo_D.png (fotógrafo relaxado + café + grid de fotos no
notebook + luz dourada de fim de tarde), agora em composição vertical.
"""
import os
import base64
from pathlib import Path

env_path = Path("/opt/mia/.env")
for line in env_path.read_text().splitlines():
    if line.startswith("OPENAI_API_KEY="):
        os.environ["OPENAI_API_KEY"] = line.split("=", 1)[1].strip()
        break

try:
    from openai import OpenAI
except ImportError:
    os.system("pip install --break-system-packages openai -q")
    from openai import OpenAI

client = OpenAI()
OUT = Path("/opt/mia/workspace/clientes/px3lab/lancamento_photorf2/criativos_oferta")

prompt = (
    "Cinematic photorealistic editorial VERTICAL photograph (9:16 aspect) of a relaxed professional photographer in his 30s or 40s, "
    "wearing a casual dark t-shirt, standing calmly next to a wooden desk inside his home photography studio, "
    "holding a warm ceramic coffee mug in his left hand, slight genuine smile, looking down at an open modern laptop screen with content expression, body posture is clearly RELAXED and SATISFIED, NOT tired, NOT stressed, "
    "the laptop sits open on the desk below him and prominently displays a clear visible grid of real portrait photos arranged in a gallery layout, "
    "the photos on screen show different young people wearing graduation gowns and formal attire smiling at a graduation ceremony, each thumbnail is clearly a recognizable human face photograph with natural warm skin tones and real event backgrounds, "
    "the photos look like typical professional event photography thumbnails being auto-organized in a photo management app, "
    "GOLDEN HOUR WARM SUNLIGHT streams in from a large window behind the photographer on the left side, casting warm orange and amber tones across the scene, soft rim light on the photographer's hair and shoulders, late afternoon golden light flooding the room, "
    "the atmosphere strongly suggests end-of-afternoon calm, warm productive quietness, as if the day is ending early and the work is already done, "
    "visible background: tasteful home photography studio with wooden shelves, a camera on a tripod blurred in the far background, framed photo prints softly out of focus on the wall, warm wood tones everywhere, "
    "the mood is RELIEF and CALM MASTERY — a man enjoying his evening coffee while his software does the heavy work for him, "
    "very subtle lime-green glow (hex #87C925) coming only from a thin accent line on the laptop screen edge, extremely discreet, barely noticeable, "
    "the dominant palette is warm golden amber from the sunset light and natural human skin tones, "
    "shot on 50mm lens at f/2.8, shallow depth of field with sharp focus on the photographer's face and the laptop screen, "
    "VERTICAL FULL-BODY framing: head and torso of photographer visible in upper two thirds, laptop and desk visible in lower portion, "
    "editorial lifestyle technology photography, hyper detailed, 8k, photorealistic, "
    "NO clocks, NO digital numbers, NO watches, NO timestamps, NO text overlays, no readable logos on the screen, no watermarks, no visible laptop brand, "
    "vertical 9:16 composition, cinematic depth, full scene fills the frame edge-to-edge"
)

print("Gerando hero D VERTICAL (tempo/alivio) via gpt-image-1 (30-60s)...")
r = client.images.generate(
    model="gpt-image-1",
    prompt=prompt,
    size="1024x1536",
    quality="high",
    n=1,
)
b64 = r.data[0].b64_json
dest = OUT / "hero_tempo_D_vertical.png"
dest.write_bytes(base64.b64decode(b64))
print(f"OK -> {dest}")
