from reportlab.lib.pagesizes import landscape, A4
from reportlab.lib import colors
from reportlab.pdfgen import canvas
from reportlab.lib.utils import simpleSplit
from pathlib import Path

OUT = Path('/home/wildlama/pitch_double_numerique_final.pdf')
W, H = landscape(A4)

BG = colors.HexColor('#071018')
BG2 = colors.HexColor('#0E1720')
CARD = colors.HexColor('#101B26')
CARD2 = colors.HexColor('#162433')
TEXT = colors.HexColor('#F3F7FB')
MUTED = colors.HexColor('#A9B7C5')
ACCENT = colors.HexColor('#F28C28')
ACCENT2 = colors.HexColor('#8CE0D4')
RED = colors.HexColor('#E26D5A')
GOLD = colors.HexColor('#E8C35D')
LINE = colors.HexColor('#243647')


def draw_bg(c, dark=True):
    c.setFillColor(BG if dark else colors.HexColor('#F6F8FB'))
    c.rect(0, 0, W, H, fill=1, stroke=0)
    if dark:
        c.setFillColor(BG2)
        c.circle(W * 0.92, H * 0.88, 180, fill=1, stroke=0)
        c.circle(W * 0.1, H * 0.1, 140, fill=1, stroke=0)
    else:
        c.setFillColor(colors.HexColor('#E9EEF4'))
        c.circle(W * 0.88, H * 0.9, 120, fill=1, stroke=0)


def footer(c, n):
    c.setFillColor(MUTED if n not in (1, 8) else colors.HexColor('#D2DCE6'))
    c.setFont('Helvetica', 9)
    c.drawRightString(W - 18, 12, f'{n:02d}')
    c.setStrokeColor(LINE)
    c.setLineWidth(0.7)
    c.line(18, 18, W - 18, 18)


def title_block(c, title, subtitle=None, dark=True):
    c.setFillColor(TEXT if dark else colors.HexColor('#0B1520'))
    c.setFont('Helvetica-Bold', 24)
    c.drawString(26, H - 44, title)
    if subtitle:
        c.setFillColor(MUTED if dark else colors.HexColor('#465566'))
        c.setFont('Helvetica', 10.5)
        lines = simpleSplit(subtitle, 'Helvetica', 10.5, W - 60)
        y = H - 58
        for ln in lines[:2]:
            c.drawString(26, y, ln)
            y -= 13


def rounded_card(c, x, y, w, h, fill=CARD, radius=14, stroke=LINE):
    c.setFillColor(fill)
    c.setStrokeColor(stroke)
    c.setLineWidth(1)
    c.roundRect(x, y, w, h, radius, fill=1, stroke=1)


def pill(c, x, y, w, txt, fill=ACCENT, txt_color=colors.white, size=9):
    c.setFillColor(fill)
    c.setStrokeColor(fill)
    c.roundRect(x, y, w, 16, 8, fill=1, stroke=0)
    c.setFillColor(txt_color)
    c.setFont('Helvetica-Bold', size)
    c.drawCentredString(x + w / 2, y + 4.8, txt)


def wrap_text(c, text, font='Helvetica', size=11, width=200):
    return simpleSplit(text, font, size, width)


def add_bullets(c, items, x, y, width, size=11, color=TEXT, bullet_color=ACCENT, gap=18):
    c.setFont('Helvetica', size)
    yy = y
    for item in items:
        lines = wrap_text(c, item, 'Helvetica', size, width - 18)
        c.setFillColor(bullet_color)
        c.circle(x + 4, yy + 3, 2, fill=1, stroke=0)
        c.setFillColor(color)
        for i, ln in enumerate(lines):
            c.drawString(x + 14, yy, ln)
            yy -= gap if i == len(lines) - 1 else 13
        yy -= 4
    return yy


def slide1(c):
    draw_bg(c, True)
    c.setFillColor(ACCENT)
    c.rect(0, 0, 18, H, fill=1, stroke=0)
    c.setFillColor(TEXT)
    c.setFont('Helvetica-Bold', 26)
    c.drawString(42, H - 84, 'Always present.')
    c.drawString(42, H - 116, 'Even when she’s not.')
    c.setFont('Helvetica', 15)
    c.setFillColor(MUTED)
    body = 'Un studio de continuité numérique premium pour les modèles qui veulent garder une présence active, cohérente et monétisable quand la production réelle s’arrête.'
    for i, ln in enumerate(wrap_text(c, body, 'Helvetica', 15, 470)[:3]):
        c.drawString(42, H - 150 - i * 18, ln)

    pill(c, 42, 56, 168, 'DOUBLE NUMÉRIQUE PREMIUM')
    rounded_card(c, W - 360, 92, 290, 320, fill=CARD2, stroke=LINE)
    c.setFillColor(colors.HexColor('#0B1520'))
    c.roundRect(W - 330, 122, 230, 260, 26, fill=1, stroke=0)
    c.setFillColor(colors.HexColor('#162433'))
    c.roundRect(W - 305, 146, 180, 210, 22, fill=1, stroke=0)
    c.setFillColor(ACCENT2)
    c.circle(W - 225, 218, 26, fill=1, stroke=0)
    c.setFillColor(TEXT)
    c.setFont('Helvetica-Bold', 14)
    c.drawCentredString(W - 225, 210, 'CONTINUITY')
    c.setFillColor(MUTED)
    c.setFont('Helvetica', 10)
    c.drawCentredString(W - 225, 186, 'branding + validation + cadence')

    xs = [42, 190, 338]
    labels = ['Présence', 'Contrôle', 'ROI']
    vals = ['continue', 'validé', 'mesurable']
    fills = [CARD, CARD2, CARD]
    for x, lab, val, f in zip(xs, labels, vals, fills):
        rounded_card(c, x, 208, 128, 88, fill=f, stroke=LINE)
        c.setFillColor(ACCENT)
        c.setFont('Helvetica-Bold', 18)
        c.drawString(x + 14, 256, val)
        c.setFillColor(MUTED)
        c.setFont('Helvetica', 10.5)
        c.drawString(x + 14, 234, lab)

    footer(c, 1)


def slide2(c):
    draw_bg(c, False)
    title_block(c, 'Le vrai problème : le trou de présence', 'Quand la créatrice ne publie pas, la communauté n’attend pas indéfiniment. Le rythme casse, l’attention baisse, et la relance coûte plus cher que la continuité.', dark=False)
    rounded_card(c, 24, 78, W - 48, 250, fill=colors.white, stroke=colors.HexColor('#D6DEE7'))
    c.setFillColor(colors.HexColor('#132030'))
    c.roundRect(40, 104, 180, 202, 18, fill=1, stroke=0)
    c.setFillColor(ACCENT)
    c.setFont('Helvetica-Bold', 18)
    c.drawString(58, 274, 'Pain points')
    c.setFillColor(colors.HexColor('#D7E0EA'))
    c.setFont('Helvetica', 11.3)
    for i, t in enumerate(['Pas le temps de produire', 'Pause = chute d’engagement', 'La communauté décroche', 'L’algorithme punit l’absence']):
        c.drawString(58, 246 - i * 26, '• ' + t)
    cards = [
        ('Risque business', 'Le vide éditorial crée une perte de revenus. Pas seulement une baisse d’ego.'),
        ('Risque de marque', 'L’incohérence visuelle détruit la confiance plus vite qu’elle ne se construit.'),
        ('Risque opérationnel', 'Sans système, tout repose sur la disponibilité humaine et le stress.'),
    ]
    x0 = 230
    for i, (t, b) in enumerate(cards):
        rounded_card(c, x0 + i * 182, 104, 170, 202, fill=colors.HexColor('#F7FAFD'), stroke=colors.HexColor('#D6DEE7'))
        c.setFillColor(colors.HexColor('#0B1520'))
        c.setFont('Helvetica-Bold', 13)
        c.drawString(x0 + 14 + i * 182, 284, t)
        c.setFillColor(colors.HexColor('#526273'))
        c.setFont('Helvetica', 10.2)
        for j, ln in enumerate(wrap_text(c, b, 'Helvetica', 10.2, 142)[:6]):
            c.drawString(x0 + 14 + i * 182, 260 - j * 13.5, ln)
        c.setFillColor(ACCENT)
        c.rect(x0 + 14 + i * 182, 124, 34, 34, fill=1, stroke=0)
        c.setFillColor(colors.white)
        c.setFont('Helvetica-Bold', 16)
        c.drawCentredString(x0 + 31 + i * 182, 134, str(i + 1))
    c.setFillColor(colors.HexColor('#0B1520'))
    c.setFont('Helvetica-Bold', 17)
    c.drawString(24, 46, 'La demande reste. Le rythme, lui, casse. C’est là qu’intervient la continuité.')
    footer(c, 2)


def slide3(c):
    draw_bg(c, True)
    title_block(c, 'Ce que le client critique a encore besoin d’entendre', 'On ne vend pas un remplacement de la personne. On vend un système de présence contrôlée, vérifiable et exploitable.', dark=True)
    xs = [24, 212, 400]
    titles = ['Ce qu’on ne vend pas', 'Ce qu’on vend', 'Ce que ça change']
    fills = [CARD, CARD2, CARD]
    bullets = [
        ['Pas un avatar autonome', 'Pas de publication hors validation', 'Pas de promesse de revenu garanti', 'Pas de “fake” non assumé'],
        ['Workflow de continuité', 'Validation humaine', 'Publication déléguée', 'Traçabilité des contenus'],
        ['Moins de trous éditoriaux', 'Moins de charge mentale', 'Plus de régularité', 'Une marque plus stable'],
    ]
    for x, t, f, b in zip(xs, titles, fills, bullets):
        rounded_card(c, x, 128, 170, 240, fill=f, stroke=LINE)
        pill(c, x + 14, 340, 132, t, fill=ACCENT if t != 'Ce qu’on vend' else ACCENT2, txt_color=colors.HexColor('#0B1520'))
        add_bullets(c, b, x + 14, 306, 142, size=10.5, color=TEXT, bullet_color=ACCENT2 if t == 'Ce qu’on vend' else ACCENT, gap=19)
    rounded_card(c, 598, 128, 168, 240, fill=colors.HexColor('#F7FAFD'), stroke=colors.HexColor('#D6DEE7'))
    c.setFillColor(colors.HexColor('#0B1520'))
    c.setFont('Helvetica-Bold', 13)
    c.drawString(612, 330, 'Réponse simple')
    c.setFillColor(colors.HexColor('#566676'))
    c.setFont('Helvetica', 11)
    text = 'Le modèle garde la main. Le service garde le rythme. Le community manager garde l’exécution.'
    yy = 308
    for ln in wrap_text(c, text, 'Helvetica', 11, 138)[:4]:
        c.drawString(612, yy, ln)
        yy -= 15
    c.setFillColor(ACCENT)
    c.roundRect(612, 182, 132, 78, 16, fill=1, stroke=0)
    c.setFillColor(colors.white)
    c.setFont('Helvetica-Bold', 16)
    c.drawCentredString(678, 226, 'CONTROL')
    c.setFont('Helvetica', 9)
    c.drawCentredString(678, 210, 'validation • audit • stop button')
    footer(c, 3)


def slide4(c):
    draw_bg(c, False)
    title_block(c, 'Le produit : un studio de continuité numérique premium', 'Un système qui produit du contenu fidèle à l’identité, mais encadré par des règles claires de validation, de publication et d’arrêt.', dark=False)
    steps = [
        ('1', 'Calibration identité', 'Références visuelles, style, ton, limites.'),
        ('2', 'Création contrôlée', 'Génération du contenu dans le cadre défini.'),
        ('3', 'Validation humaine', 'La créatrice approuve ou corrige.'),
        ('4', 'Publication déléguée', 'Le CM publie selon le calendrier.'),
    ]
    y = 274
    for i, (num, tt, desc) in enumerate(steps):
        rounded_card(c, 28, y - i * 66, 310, 54, fill=colors.white, stroke=colors.HexColor('#D6DEE7'))
        c.setFillColor(ACCENT)
        c.circle(54, y - i * 66 + 27, 12, fill=1, stroke=0)
        c.setFillColor(colors.white)
        c.setFont('Helvetica-Bold', 10)
        c.drawCentredString(54, y - i * 66 + 23, num)
        c.setFillColor(colors.HexColor('#0B1520'))
        c.setFont('Helvetica-Bold', 12)
        c.drawString(74, y - i * 66 + 32, tt)
        c.setFillColor(colors.HexColor('#5C6D7C'))
        c.setFont('Helvetica', 9.8)
        c.drawString(74, y - i * 66 + 16, desc)
    rounded_card(c, 362, 112, 352, 226, fill=colors.HexColor('#101B26'))
    c.setFillColor(TEXT)
    c.setFont('Helvetica-Bold', 14)
    c.drawString(380, 312, 'Architecture de contrôle')
    ax = 382
    ay = 154
    items = [('Accès', 'qui peut voir / modifier / publier'), ('Journal', 'quoi a été généré et validé'), ('Arrêt', 'stop immédiat si doute'), ('Limites', 'pas de sortie hors cadre')]
    for i, (a, b) in enumerate(items):
        xx = ax + (i % 2) * 156
        yy = ay + (i // 2) * 74
        c.setFillColor(colors.HexColor('#162433'))
        c.roundRect(xx, yy, 140, 58, 12, fill=1, stroke=0)
        c.setFillColor(ACCENT2 if i % 2 == 0 else ACCENT)
        c.setFont('Helvetica-Bold', 11)
        c.drawString(xx + 12, yy + 37, a)
        c.setFillColor(MUTED)
        c.setFont('Helvetica', 8.8)
        for j, ln in enumerate(wrap_text(c, b, 'Helvetica', 8.8, 116)[:2]):
            c.drawString(xx + 12, yy + 22 - j * 10, ln)
    rounded_card(c, 728, 112, 116, 226, fill=colors.HexColor('#F7FAFD'), stroke=colors.HexColor('#D6DEE7'))
    c.setFillColor(colors.HexColor('#0B1520'))
    c.setFont('Helvetica-Bold', 12)
    c.drawString(744, 312, 'Clause clé')
    c.setFillColor(colors.HexColor('#506273'))
    c.setFont('Helvetica', 9.6)
    text = 'Le système améliore la continuité, mais aucune publication ne se fait sans cadre défini par la modèle.'
    yy = 292
    for ln in wrap_text(c, text, 'Helvetica', 9.6, 84)[:5]:
        c.drawString(744, yy, ln)
        yy -= 12
    c.setFillColor(RED)
    c.roundRect(744, 176, 84, 58, 12, fill=1, stroke=0)
    c.setFillColor(colors.white)
    c.setFont('Helvetica-Bold', 11)
    c.drawCentredString(786, 214, 'STOP')
    c.setFont('Helvetica', 8.2)
    c.drawCentredString(786, 201, 'à tout moment')
    footer(c, 4)


def slide5(c):
    draw_bg(c, True)
    title_block(c, 'Ce qu’un acheteur sérieux veut voir', 'Le discours doit survivre aux objections: conformité, contrôle, délais, audit, retrait du consentement et preuve du bénéfice.', dark=True)
    rounded_card(c, 24, 110, 300, 248, fill=CARD, stroke=LINE)
    c.setFillColor(TEXT)
    c.setFont('Helvetica-Bold', 14)
    c.drawString(42, 324, 'Garde-fous obligatoires')
    items = ['Validation humaine explicite', 'Traçabilité des contenus et versions', 'Droit d’arrêt immédiat', 'Séparation claire entre assistance et autonomie', 'Procédure de retrait / suppression']
    add_bullets(c, items, 42, 294, 254, size=10.4, color=TEXT, bullet_color=ACCENT2, gap=18)
    rounded_card(c, 340, 110, 154, 248, fill=CARD2, stroke=LINE)
    rounded_card(c, 504, 110, 154, 248, fill=CARD, stroke=LINE)
    rounded_card(c, 668, 110, 154, 248, fill=CARD2, stroke=LINE)
    cols = [
        ('Risque', ['“ça fait fake”', '“je perds le contrôle”', '“la plateforme bloque”'], RED),
        ('Réponse', ['qualité + validation', 'workflow auditable', 'règles de publication'], ACCENT2),
        ('Mesure', ['délai de validation', 'taux de publication', 'continuité sur 30 jours'], GOLD),
    ]
    xs = [340, 504, 668]
    for (title, b, color), x in zip(cols, xs):
        c.setFillColor(color)
        c.setFont('Helvetica-Bold', 14)
        c.drawString(x + 12, 324, title)
        c.setFillColor(TEXT)
        add_bullets(c, b, x + 12, 294, 130, size=10.0, color=TEXT, bullet_color=color, gap=17)
    c.setFillColor(colors.HexColor('#D7E0EA'))
    c.setFont('Helvetica-Bold', 12)
    c.drawString(24, 74, 'Message clé: on ne promet pas l’infini. On promet un système propre, contrôlé et mesurable.')
    footer(c, 5)


def slide6(c):
    draw_bg(c, False)
    title_block(c, 'Pourquoi ça vaut de l’argent', 'Le bénéfice n’est pas seulement de publier. Le bénéfice est de préserver le rythme, la cohérence et la valeur de la marque quand la créatrice n’est pas disponible.', dark=False)
    kpis = [('Rythme', 'pas de trous éditoriaux'), ('Rétention', 'moins de désengagement'), ('Charge mentale', 'moins de production d’urgence'), ('Monétisation', 'plus de présence active')]
    x = 28
    for i, (t, b) in enumerate(kpis):
        rounded_card(c, x + i * 188, 262, 168, 86, fill=colors.white, stroke=colors.HexColor('#D6DEE7'))
        c.setFillColor(ACCENT if i % 2 == 0 else ACCENT2)
        c.setFont('Helvetica-Bold', 18)
        c.drawString(x + i * 188 + 14, 316, t)
        c.setFillColor(colors.HexColor('#5A6B7A'))
        c.setFont('Helvetica', 10)
        c.drawString(x + i * 188 + 14, 296, b)
    rounded_card(c, 28, 114, 360, 124, fill=colors.white, stroke=colors.HexColor('#D6DEE7'))
    c.setFillColor(colors.HexColor('#0B1520'))
    c.setFont('Helvetica-Bold', 14)
    c.drawString(46, 212, 'Ce qu’il faut mesurer en pilote')
    measures = ['temps de validation', 'contenus publiés / semaine', 'jours sans publication', 'variation du revenu sur période comparable']
    add_bullets(c, measures, 46, 186, 310, size=10.1, color=colors.HexColor('#0B1520'), bullet_color=ACCENT, gap=17)
    rounded_card(c, 408, 114, 320, 124, fill=colors.HexColor('#101B26'), stroke=LINE)
    c.setFillColor(TEXT)
    c.setFont('Helvetica-Bold', 14)
    c.drawString(426, 212, 'Formule simple de vente')
    c.setFont('Helvetica', 10.3)
    txt = 'Le produit se vend comme un abonnement de continuité premium: il sécurise la présence, délègue la publication, et réduit la dépendance au temps disponible.'
    yy = 188
    for ln in wrap_text(c, txt, 'Helvetica', 10.3, 292)[:5]:
        c.drawString(426, yy, ln)
        yy -= 14
    c.setFillColor(ACCENT)
    c.roundRect(736, 126, 86, 104, 18, fill=1, stroke=0)
    c.setFillColor(colors.white)
    c.setFont('Helvetica-Bold', 13)
    c.drawCentredString(779, 184, '30')
    c.drawCentredString(779, 168, 'jours')
    c.setFont('Helvetica', 8.5)
    c.drawCentredString(779, 150, 'pilote')
    c.drawCentredString(779, 139, 'mesurable')
    footer(c, 6)


def slide7(c):
    draw_bg(c, True)
    title_block(c, 'Une équipe qui couvre la création, l’opération et la continuité', 'Le client n’achète pas une promesse abstraite. Il achète une exécution: image, projet, contenu et gestion terrain.', dark=True)
    people = [
        ('Florian Girardot', 'Head of AI and VFX', 'Génération d’image avec continuité, réalisme, cohérence de personnage et rendu premium.'),
        ('Maria Leon', 'Producer AI', 'Gestion de projet IA, orchestration de production image, suivi et livraison opérationnelle.'),
        ('David Leon', 'Content Ops for Models', 'Gestion de contenu pour modèles OnlyFans, calendrier éditorial, publication et relation opérationnelle.'),
    ]
    x = 24
    for i, (name, role, desc) in enumerate(people):
        rounded_card(c, x + i * 202, 136, 186, 226, fill=CARD2 if i % 2 else CARD, stroke=LINE)
        c.setFillColor(ACCENT2 if i == 0 else ACCENT)
        c.circle(x + i * 202 + 32, 314, 18, fill=1, stroke=0)
        c.setFillColor(TEXT)
        c.setFont('Helvetica-Bold', 13)
        c.drawString(x + i * 202 + 58, 324, name)
        c.setFillColor(MUTED)
        c.setFont('Helvetica-Bold', 9.8)
        c.drawString(x + i * 202 + 58, 308, role)
        c.setFillColor(TEXT)
        c.setFont('Helvetica', 10)
        yy = 282
        for ln in wrap_text(c, desc, 'Helvetica', 10, 150)[:6]:
            c.drawString(x + i * 202 + 16, yy, ln)
            yy -= 14
    rounded_card(c, 24, 74, 864, 44, fill=colors.HexColor('#132230'), stroke=LINE)
    c.setFillColor(TEXT)
    c.setFont('Helvetica-Bold', 12)
    c.drawString(42, 90, 'Création. Production. Activation. Trois expertises, un seul système pour garder la marque active sans casser le contrôle.')
    footer(c, 7)


def slide8(c):
    draw_bg(c, False)
    c.setFillColor(colors.HexColor('#0B1520'))
    c.rect(0, 0, W, H, fill=1, stroke=0)
    c.setFillColor(TEXT)
    c.setFont('Helvetica-Bold', 27)
    c.drawString(34, H - 78, 'Construisons une présence numérique qui ne s’arrête pas.')
    c.setFillColor(MUTED)
    c.setFont('Helvetica', 15)
    body = 'Le bon cadrage n’est pas “on remplace la personne”. Le bon cadrage est: on sécurise la continuité, on garde le contrôle, et on protège la valeur de la marque.'
    y = H - 116
    for ln in wrap_text(c, body, 'Helvetica', 15, 620)[:4]:
        c.drawString(34, y, ln)
        y -= 18
    rounded_card(c, 34, 126, 300, 120, fill=colors.HexColor('#101B26'), stroke=LINE)
    rounded_card(c, 356, 126, 300, 120, fill=colors.HexColor('#101B26'), stroke=LINE)
    rounded_card(c, 678, 126, 166, 120, fill=colors.HexColor('#101B26'), stroke=LINE)
    cards = [
        ('Ce qu’on garantit', ['présence', 'cadre', 'validation']),
        ('Ce qu’on mesure', ['délai', 'régularité', 'impact']),
        ('Ce qu’on veut', ['un pilote', 'un oui', 'un vrai cas d’usage']),
    ]
    for (t, items), x in zip(cards, [34, 356, 678]):
        c.setFillColor(ACCENT if x == 34 else ACCENT2 if x == 356 else GOLD)
        c.setFont('Helvetica-Bold', 13)
        c.drawString(x + 16, 214, t)
        c.setFillColor(TEXT)
        c.setFont('Helvetica', 11)
        for i, item in enumerate(items):
            c.drawString(x + 16, 190 - i * 18, '• ' + item)
    pill(c, 34, 44, 118, 'PITCH FINAL')
    c.setFillColor(colors.white)
    c.setFont('Helvetica-Bold', 18)
    c.drawString(168, 50, 'Always present, without always being on.')
    footer(c, 8)


def main():
    c = canvas.Canvas(str(OUT), pagesize=landscape(A4))
    for fn in [slide1, slide2, slide3, slide4, slide5, slide6, slide7, slide8]:
        fn(c)
        c.showPage()
    c.save()
    print(OUT)


if __name__ == '__main__':
    main()
