from pathlib import Path

root = Path(__file__).parent
image_root = "https://news.jeanmarcphilippe.com/pro/2026/20261110/images"

icons = {
    "✦": "icon-early-access.png",
    "□": "icon-stock.png",
    "%": "icon-offers.png",
    "!": "icon-news.png",
}

for lang in ("fr", "en", "de"):
    path = root / lang / "index.html"
    html = path.read_text(encoding="utf-8")

    html = html.replace(
        'padding: 34px 20px 26px 20px',
        'padding: 42px 20px 32px 20px',
    )
    html = html.replace(
        'font-size: 25px; line-height: 1.2',
        'font-size: 26px; line-height: 1.2',
    )
    html = html.replace(
        'style="padding: 0px 18px 38px 18px"',
        'style="padding: 0px 22px 52px 22px"',
    )
    html = html.replace(
        'style="padding: 0px 7px"',
        'style="padding: 0px 10px"',
    )
    html = html.replace(
        'font-size: 15px; line-height: 1.2; font-weight: bold; margin: 14px 0px 5px 0px',
        'font-size: 14px; line-height: 1.2; font-weight: bold; min-height: 34px; margin: 15px 0px 6px 0px',
    )
    html = html.replace(
        'font-size: 12px; line-height: 1.3; margin: 0px',
        'font-size: 11px; line-height: 1.35; min-height: 48px; margin: 0px',
    )

    for symbol, filename in icons.items():
        old = f'''<table width="72" height="72" border="0" cellpadding="0" cellspacing="0" align="center" style="background-color: #eef1e5; border-radius: 16px"><tr><td align="center" style="font-family: Arial, Helvetica, sans-serif; color: #0b4022; font-size: 31px; font-weight: bold">{symbol}</td></tr></table>'''
        new = f'''<img src="{image_root}/{filename}" width="72" height="72" border="0" alt="" style="display: block; border-radius: 16px" />'''
        html = html.replace(old, new)

    html = html.replace(
        'style="background-color: #eef1e5; border-radius: 20px; margin-bottom: 28px"',
        'style="background-color: #eef1e5; border-radius: 20px; margin-bottom: 34px"',
    )
    html = html.replace(
        '<table width="500" border="0" cellpadding="0" cellspacing="0" align="center">',
        '<table width="540" border="0" cellpadding="0" cellspacing="0" align="center">',
    )
    html = html.replace(
        'border-radius: 18px; padding: 18px 20px',
        'border-radius: 18px; padding: 17px 20px',
    )
    html = html.replace(
        'font-size: 23px; line-height: 1.2; font-weight: bold; text-decoration: none">',
        f'font-size: 23px; line-height: 1.2; font-weight: bold; text-decoration: none"><img src="{image_root}/icon-whatsapp.png" width="34" height="34" border="0" alt="WhatsApp" style="display: inline-block; vertical-align: middle; margin-right: 12px" />',
    )
    html = html.replace(
        'style="padding: 32px 30px 18px 30px"',
        'style="padding: 38px 30px 20px 30px"',
    )
    html = html.replace(
        'style="padding: 12px 0px 45px 0px;',
        'style="padding: 16px 0px 52px 0px;',
    )

    path.write_text(html, encoding="utf-8", newline="")
