<!DOCTYPE html>
<html lang="{{ locale|default('fr') }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ email_subject }}</title>
</head>
<body style="margin:0; padding:0; background:#f7f2ea; color:#201917; font-family:Arial, Helvetica, sans-serif;">
    <div style="display:none; max-height:0; overflow:hidden; opacity:0; color:transparent; mso-hide:all;">
        {{ email_preheader }}
    </div>
    <div style="display:none; max-height:0; overflow:hidden; mso-hide:all;" aria-hidden="true">
        &#847; &zwnj; &nbsp; &#847; &zwnj; &nbsp; &#847; &zwnj; &nbsp; &#847; &zwnj; &nbsp;
    </div>
    <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="width:100%; background:#f7f2ea;">
        <tr>
            <td align="center" style="padding:32px 16px;">
                <table role="presentation" width="640" cellspacing="0" cellpadding="0" style="width:100%; max-width:640px; background:#ffffff;">
                    <tr>
                        <td style="padding:40px; text-align:center;">
                            {% if contact and contact.image and contact.image.path %}
                                <img src="{{ absolute_url(asset(contact.image.path)|imagine_filter('logo_email_filter')) }}" alt="{{ company }}" width="180" style="display:block; max-width:180px; margin:0 auto 28px;">
                            {% endif %}
                            <h1 style="margin:0 0 20px; font-family:Georgia, 'Times New Roman', serif; font-size:32px; font-weight:400;">
                                {{ email_title }}
                            </h1>
                            <p style="margin:0 0 28px; font-size:16px; line-height:1.7; color:#5d4b41;">
                                {{ 'marketing.abandoned_cart.mail.intro'|trans({'%company%': company}, 'messages', locale|default('fr')) }}
                            </p>

                            <div style="margin:0 0 28px; padding:22px 24px; background:#f7f2ea; text-align:left;">
                                <div style="margin:0 0 12px; font-size:12px; letter-spacing:0.16em; text-transform:uppercase; color:#806f65;">
                                    {{ 'marketing.abandoned_cart.mail.cart_heading'|trans({}, 'messages', locale|default('fr')) }}
                                </div>
                                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="width:100%; border-collapse:collapse;">
                                    {% for item in cart.items %}
                                        {% set variant = item.variant %}
                                        {% set product_name = variant ? (variant.fullName ?: (variant.product ? variant.product.fullName : '')) : '' %}
                                        <tr>
                                            <td style="padding:12px 12px 12px 0; border-bottom:1px solid #eadfce; vertical-align:top;">
                                                <strong style="font-size:15px; line-height:1.5; color:#201917;">{{ product_name ?: '-' }}</strong>
                                                {% if item.selectedOptionName %}
                                                    <div style="margin-top:4px; font-size:13px; line-height:1.5; color:#806f65;">
                                                        {{ 'shop.option_label'|trans({}, 'messages', locale|default('fr')) }} : {{ item.selectedOptionName }}
                                                    </div>
                                                {% endif %}
                                            </td>
                                            <td align="right" style="padding:12px 0; border-bottom:1px solid #eadfce; vertical-align:top; white-space:nowrap;">
                                                <div style="font-size:13px; line-height:1.5; color:#806f65;">
                                                    {{ 'marketing.abandoned_cart.mail.cart_quantity'|trans({'%quantity%': item.quantity}, 'messages', locale|default('fr')) }}
                                                    {{ item.finalPriceTTC|price_format }} €
                                                </div>
                                                <strong style="font-size:15px; line-height:1.5; color:#201917;">{{ item.totalFinalTTC|price_format }} €</strong>
                                            </td>
                                        </tr>
                                    {% endfor %}
                                    <tr>
                                        <td style="padding:16px 12px 0 0; font-size:14px; font-weight:700; color:#201917;">
                                            {{ 'marketing.abandoned_cart.mail.cart_subtotal'|trans({}, 'messages', locale|default('fr')) }}
                                        </td>
                                        <td align="right" style="padding:16px 0 0; font-size:18px; font-weight:700; color:#201917; white-space:nowrap;">
                                            {{ cart_subtotal_ttc|price_format }} €
                                        </td>
                                    </tr>
                                    {% if has_existing_cart_discounts %}
                                        <tr>
                                            <td colspan="2" style="padding:20px 0 4px; font-size:12px; letter-spacing:0.12em; text-transform:uppercase; color:#806f65;">
                                                {{ 'marketing.abandoned_cart.mail.existing_discounts_heading'|trans({}, 'messages', locale|default('fr')) }}
                                            </td>
                                        </tr>
                                        {% if cart_catalog_discount_ttc > 0 %}
                                            <tr>
                                                <td style="padding:8px 12px 0 0; font-size:14px; color:#806f65;">
                                                    {{ 'shop.discount'|trans({}, 'messages', locale|default('fr')) }}
                                                </td>
                                                <td align="right" style="padding:8px 0 0; font-size:14px; color:#806f65; white-space:nowrap;">
                                                    -{{ cart_catalog_discount_ttc|price_format }} €
                                                </td>
                                            </tr>
                                        {% endif %}
                                        {% if cart_degressive_discount_ttc > 0 %}
                                            <tr>
                                                <td style="padding:8px 12px 0 0; font-size:14px; color:#806f65;">
                                                    {{ (cart_degressive_is_bottle_offered ? 'shop.of_which_bottle_offered' : 'shop.of_which_degressive')|trans({}, 'messages', locale|default('fr')) }}
                                                </td>
                                                <td align="right" style="padding:8px 0 0; font-size:14px; color:#806f65; white-space:nowrap;">
                                                    -{{ cart_degressive_discount_ttc|price_format }} €
                                                </td>
                                            </tr>
                                        {% endif %}
                                        {% for cart_promo in existing_cart_promos %}
                                            {% if cart_promo.discountItemsTTC > 0 %}
                                                <tr>
                                                    <td style="padding:8px 12px 0 0; font-size:14px; color:#806f65;">
                                                        {{ 'shop.discount'|trans({}, 'messages', locale|default('fr')) }}
                                                        {% if cart_promo.code %} — {{ cart_promo.code }}{% endif %}
                                                        {% if cart_promo.percent is not null %} — {{ (cart_promo.percent * 100)|number_format(0, ',', ' ') }}%{% endif %}
                                                    </td>
                                                    <td align="right" style="padding:8px 0 0; font-size:14px; color:#806f65; white-space:nowrap;">
                                                        -{{ cart_promo.discountItemsTTC|price_format }} €
                                                    </td>
                                                </tr>
                                            {% endif %}
                                            {% if cart_promo.discountShippingTTC > 0 %}
                                                <tr>
                                                    <td style="padding:8px 12px 0 0; font-size:14px; color:#806f65;">
                                                        {{ 'shop.discount_shipping'|trans({}, 'messages', locale|default('fr')) }}
                                                        {% if cart_promo.code %} — {{ cart_promo.code }}{% endif %}
                                                    </td>
                                                    <td align="right" style="padding:8px 0 0; font-size:14px; color:#806f65; white-space:nowrap;">
                                                        -{{ cart_promo.discountShippingTTC|price_format }} €
                                                    </td>
                                                </tr>
                                            {% endif %}
                                        {% endfor %}
                                    {% endif %}
                                </table>
                            </div>

                            {% if promo %}
                                <div style="margin:0 0 28px; padding:20px; background:#f7f2ea;">
                                    <strong>{{ 'marketing.abandoned_cart.mail.coupon_heading'|trans({}, 'messages', locale|default('fr')) }}</strong>
                                    <div style="margin-top:10px; font-size:22px; letter-spacing:2px;">{{ promo.title }}</div>
                                    <div style="margin-top:8px;">
                                        {% if promo.amountTTC is not null %}
                                            {{ 'marketing.abandoned_cart.mail.fixed_discount'|trans({'%amount%': promo.amountTTC|price_format}, 'messages', locale|default('fr')) }}
                                        {% elseif promo.percent is not null %}
                                            {{ (has_existing_cart_discounts ? 'marketing.abandoned_cart.mail.percent_discount_additional' : 'marketing.abandoned_cart.mail.percent_discount')|trans({'%percent%': (promo.percent * 100)|round(2)}, 'messages', locale|default('fr')) }}
                                        {% elseif promo.percentShippingCost is not null %}
                                            {{ 'marketing.abandoned_cart.mail.free_shipping'|trans({}, 'messages', locale|default('fr')) }}
                                        {% endif %}
                                    </div>
                                    <div style="margin-top:12px; font-size:13px; line-height:1.5; color:#806f65;">
                                        {{ 'marketing.abandoned_cart.mail.coupon_cart_change_warning'|trans({}, 'messages', locale|default('fr')) }}
                                    </div>
                                </div>
                            {% endif %}

                            <p style="margin:0 0 30px;">
                                <a href="{{ recovery_url }}" style="display:inline-block; padding:15px 26px; background:#201917; color:#ffffff; text-decoration:none; font-weight:700;">
                                    {{ 'marketing.abandoned_cart.mail.button'|trans({}, 'messages', locale|default('fr')) }}
                                </a>
                            </p>
                            <p style="margin:0; font-size:13px; color:#806f65;">
                                {{ 'marketing.abandoned_cart.mail.expiry'|trans({'%date%': expires_at|date('d/m/Y')}, 'messages', locale|default('fr')) }}
                            </p>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
