#!/usr/bin/env python3
"""Visuels marketing DALL-E pour la fiche produit module Choose × PrestaShop."""

from __future__ import annotations

import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))

from article_studio.config import load_config
from article_studio.image_gen import generate_featured_image

OUT = ROOT / "exports" / "amchoose-product"

PROMPTS: list[tuple[str, str, str]] = [
    (
        "product-amchoose-featured.png",
        "1792x1024",
        (
            "Professional premium PrestaShop module marketing hero banner, landscape 16:10. "
            "LEFT: white panel, badge MODULE PRESTASHOP, huge headline 'Synchronisation Choose', "
            "orange subheadline 'Importez vos ventes marketplace et remontez les numéros de suivi', "
            "four French feature bullets: import commandes automatique, export suivi colis, "
            "tâches cron planifiables, tableau de bord back-office. "
            "RIGHT: dramatic visual flow diagram Choose marketplace → PrestaShop → colis expédié "
            "with glowing sync arrows and order cards. Cinematic premium SaaS marketing. "
            "French text only. No watermarks."
        ),
    ),
    (
        "product-amchoose-admin-config.png",
        "1792x1024",
        (
            "Ultra-realistic screenshot of PrestaShop 8 admin module configuration page, French UI. "
            "Dark grey left sidebar with Sell/Improve/Configure menu. Main white content: breadcrumb "
            "'Modules > Choose × PrestaShop > Configuration'. Hero header with stats: "
            "Commandes synchronisées, Suivis en attente, Fichiers de log. "
            "Section flux de synchronisation with three steps Import CRON, Expédition BO, Export CRON. "
            "Form fields: clé API Choose, Sale ID, filtre commandes, groupe client, transporteur. "
            "Blue Save button. Sharp readable text, authentic PrestaShop 8 Symfony back-office, "
            "no blur, no watermark."
        ),
    ),
    (
        "product-amchoose-flow.png",
        "1792x1024",
        (
            "Professional infographic diagram explaining e-commerce synchronization flow, landscape 16:10, "
            "clean modern SaaS style on white background. Three connected steps left to right with bold arrows: "
            "STEP 1 (purple): CHOOSE marketplace, Import CRON, commandes récupérées via API. "
            "STEP 2 (orange PrestaShop): PrestaShop, client adresse commande créés, Expédition back-office. "
            "STEP 3 (purple): Export CRON vers Choose, numéro de suivi API createParcel. "
            "Title in French: Flux de synchronisation Choose × PrestaShop. "
            "Colors purple and orange, flat vector infographic, French text only, no watermark."
        ),
    ),
    (
        "product-amchoose-cron.png",
        "1792x1024",
        (
            "Ultra-realistic PrestaShop 8 admin module sidebar panel, French interface. "
            "Title 'Tâches automatiques CRON' with two URL blocks: Import orders and Update orders, "
            "each with copy button and CLI variant below. Green badges 'Actif'. "
            "Secondary panel 'Mode développeur' with dry-run toggle ON, buttons "
            "'Tester l'import (dry-run)' and 'Tester l'export (dry-run)'. "
            "Clean modern Symfony PrestaShop BO design, photorealistic UI screenshot, "
            "crisp typography, no watermark."
        ),
    ),
    (
        "product-amchoose-module.png",
        "1024x1024",
        (
            "Square app icon for PrestaShop marketplace module, rounded square with smooth gradient "
            "from deep purple to vibrant orange. Center: white bidirectional sync arrows between "
            "a shopping bag (marketplace) and a gear (PrestaShop), suggesting order synchronization. "
            "Minimal flat modern icon, subtle depth, professional software marketplace quality, "
            "no text, no watermark."
        ),
    ),
]


def main() -> None:
    cfg = load_config()
    api_key = cfg.openai_api_key
    if not api_key:
        raise ValueError("OPENAI_API_KEY requis dans .secrets/.env")

    OUT.mkdir(parents=True, exist_ok=True)
    model = cfg.llm_image_model or "dall-e-3"

    for filename, size, prompt in PROMPTS:
        out_path = OUT / filename
        print(f"Génération {filename} ({size})…")
        generate_featured_image(
            api_key,
            prompt,
            out_path,
            model=model,
            size=size,
        )
        print(f"  → {out_path}")

    print("\nVisuels générés. Lancez package_amchoose.py puis create_wc_product_amchoose.py.")


if __name__ == "__main__":
    main()
