#!/usr/bin/env python3
"""Visuel de couverture DALL-E pour la fiche produit export comptable 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" / "amexportcompta-product"
FILENAME = "product-export-comptable-featured.png"

PROMPT = (
    "Premium PrestaShop module marketing hero banner, landscape 16:10, photorealistic 3D style. "
    "Concept: e-commerce orders transformed into a clean accounting CSV in one click. "
    "LEFT third: elegant white card with badge 'MODULE PRESTASHOP', bold French headline "
    "'Export Comptable CSV', orange subheadline 'De vos commandes au fichier comptable en 2 minutes', "
    "three short French bullets with green checkmarks: 'Comptes & TVA configurables', "
    "'Export automatique par cron', 'Compatible PS 1.7 à 9'. "
    "CENTER-RIGHT: stylized PrestaShop back-office silhouette merging into a glowing spreadsheet "
    "with columns Date, Compte, Débit, Crédit, Libellé — green rows, subtle euro symbols. "
    "A curved arrow or light trail shows orders (shopping cart icons) flowing into the CSV file. "
    "Small accountant-friendly icons: calculator, ledger, checkmark shield. "
    "Color palette: deep teal and emerald green (accounting trust), warm orange accents (PrestaShop), "
    "clean white background, soft shadows, modern SaaS marketplace aesthetic. "
    "Mood: simple, reliable, time-saving, professional. French text only, crisp readable typography. "
    "No watermarks, no fake brand logos, no cluttered UI."
)


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)
    out_path = OUT / FILENAME
    model = cfg.llm_image_model or "dall-e-3"

    print(f"Génération {FILENAME} (1792x1024)…")
    generate_featured_image(api_key, PROMPT, out_path, model=model, size="1792x1024")
    print(f"  → {out_path} ({out_path.stat().st_size // 1024} Ko)")


if __name__ == "__main__":
    main()
