<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="1">

        <record id="mail_template_clover_receipt" model="mail.template">
            <field name="name">Clover: Payment/Refund Receipt</field>
            <field name="model_id" ref="payment.model_payment_transaction"/>
            <field name="subject">{{ object.company_id.name }} - {{ 'Refund Receipt' if (object.operation == 'refund' or object.amount &lt; 0) else 'Payment Receipt' }} {{ object.reference or 'n/a' }}</field>
            <field name="email_from">{{ (object.company_id.email_formatted or user.email_formatted) }}</field>
            <field name="email_to">{{ object.partner_id.email }}</field>
            <field name="report_template_ids"
                   eval="[(4, ref('fusion_clover.action_report_clover_receipt'))]"/>
            <field name="body_html"><![CDATA[
<t t-set="is_refund" t-value="object.operation == 'refund' or object.amount &lt; 0"/>
<t t-set="accent" t-value="'#dc3545' if is_refund else '#28a745'"/>
<div style="font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Arial,sans-serif;max-width:600px;margin:0 auto;color:#2d3748;">
    <div t-attf-style="height:4px;background-color:{{ accent }};"></div>
    <div style="background:#ffffff;padding:32px 28px;border:1px solid #e2e8f0;border-top:none;">
        <p t-attf-style="color:{{ accent }};font-size:13px;font-weight:600;letter-spacing:0.5px;text-transform:uppercase;margin:0 0 24px 0;">
            <t t-out="object.company_id.name"/>
        </p>
        <h2 style="color:#1a202c;font-size:22px;font-weight:700;margin:0 0 6px 0;line-height:1.3;">
            <t t-if="is_refund">Refund Receipt</t>
            <t t-else="">Payment Receipt</t>
        </h2>
        <p style="color:#718096;font-size:15px;line-height:1.5;margin:0 0 24px 0;">
            <t t-if="is_refund">
                Your refund for <strong style="color:#2d3748;"><t t-out="object.reference"/></strong> has been processed.
            </t>
            <t t-else="">
                Your payment for <strong style="color:#2d3748;"><t t-out="object.reference"/></strong> has been processed successfully.
            </t>
        </p>

        <table style="width:100%;border-collapse:collapse;margin:0 0 24px 0;">
            <tr><td colspan="2" style="padding:10px 14px;font-size:12px;font-weight:600;color:#718096;text-transform:uppercase;letter-spacing:0.5px;border-bottom:2px solid #e2e8f0;">Transaction Details</td></tr>
            <tr>
                <td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;width:35%;">Type</td>
                <td style="padding:10px 14px;font-size:14px;border-bottom:1px solid #f0f0f0;">
                    <t t-if="is_refund"><strong style="color:#dc3545;">Refund</strong></t>
                    <t t-else=""><strong style="color:#28a745;">Payment</strong></t>
                </td>
            </tr>
            <tr>
                <td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Reference</td>
                <td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.reference"/></td>
            </tr>
            <tr>
                <td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Date</td>
                <td style="padding:10px 14px;color:#2d3748;font-size:14px;border-bottom:1px solid #f0f0f0;"><t t-out="object.create_date.strftime('%B %d, %Y')"/></td>
            </tr>
            <tr>
                <td style="padding:10px 14px;color:#718096;font-size:14px;border-bottom:1px solid #f0f0f0;">Status</td>
                <td style="padding:10px 14px;font-size:14px;border-bottom:1px solid #f0f0f0;">
                    <t t-if="is_refund"><strong style="color:#dc3545;">Refunded</strong></t>
                    <t t-else=""><strong style="color:#28a745;">Confirmed</strong></t>
                </td>
            </tr>
            <tr>
                <td style="padding:10px 14px;color:#718096;font-size:14px;font-weight:600;border-top:2px solid #e2e8f0;">Amount</td>
                <td t-attf-style="padding:10px 14px;color:{{ accent }};font-size:14px;font-weight:700;border-top:2px solid #e2e8f0;">
                    <t t-if="is_refund">- </t><t t-out="object.currency_id.symbol"/><t t-out="'%.2f' % abs(object.amount)"/> <t t-out="object.currency_id.name"/>
                </td>
            </tr>
        </table>

        <div style="padding:10px 14px;border:1px dashed #e2e8f0;border-radius:6px;margin:0 0 24px 0;">
            <p style="margin:0;font-size:13px;color:#718096;"><strong style="color:#2d3748;">Attached:</strong> Transaction Receipt (PDF)</p>
        </div>

        <div t-attf-style="border-left:3px solid {{ accent }};padding:12px 16px;margin:0 0 24px 0;background:#f7fafc;">
            <p style="margin:0;font-size:14px;line-height:1.5;color:#2d3748;">
                <t t-if="is_refund">
                    The refund will appear on your card within 3-5 business days. If you have any questions, please do not hesitate to contact us.
                </t>
                <t t-else="">
                    Thank you for your payment. If you have any questions about this transaction, please do not hesitate to contact us.
                </t>
            </p>
        </div>

        <t t-if="object.company_id.phone or object.company_id.email">
            <p style="margin:0 0 4px 0;font-size:13px;color:#718096;">
                <t t-if="object.company_id.phone"><t t-out="object.company_id.phone"/></t>
                <t t-if="object.company_id.phone and object.company_id.email"> | </t>
                <t t-if="object.company_id.email"><t t-out="object.company_id.email"/></t>
            </p>
        </t>
    </div>
</div>
]]></field>
            <field name="lang">{{ object.partner_id.lang }}</field>
            <field name="auto_delete" eval="True"/>
        </record>

    </data>
</odoo>
