{% set method = payment.paymentMethod %}

<style>
    .stripe-payment {
        display: inline-flex;
        justify-content: start;

        min-width: 400px;
        padding: 10px 15px;

        border: 1px solid #e3e3e3;
        border-radius: 5px;
        box-shadow: 0 2px 12px rgba(205,216,228,.5);

        & ul {
            display: flex;
            flex-direction: column;
            gap: 5px;

            margin: 0;
            padding: 0;
            list-style: none;

            & li {
                display: grid;
                grid-template-columns: 120px max-content;
                align-items: start;
            }
        }

        .stripe-icon {
            display: inline-block;
            width: 50px;

            background: #635bff;
            border-radius: 4px;
        }

        .stripe-amount {
            font-weight: bold;
            font-size: 1.2em;
        }

        .stripe-status {
            font-weight: bold;

            &.succeeded {
                color: #28a745;
            }

            &.failed {
                color: #dc3545;
            }
        }

        .payment-icon {
            display: inline-block;
            width: 50px;

            border-radius: 4px;
        }

        .payment-method {

            &.card {
                display: grid;
                grid-template-columns: min-content max-content;
                grid-template-areas: 'icon brand' 'card-number card-number';
                column-gap: 10px;
                row-gap: 2px;
                padding: 10px;

                .icon {
                    grid-area: icon;
                    width: 40px;
                }

                .brand {
                    grid-area: brand;
                    font-weight: bold;
                    margin-top: auto;
                    margin-bottom: auto;
                }

                .card-number {
                    grid-area: card-number;

                    font-size: 0.8em;
                    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

                    &:before {
                        content: "•••• •••• •••• ";
                    }
                }
            }
        }
    }
</style>

<div class="field">
    <div class="heading">
        <label class="stripe-label" for="">
            <span>{{ field.label }}</span>
        </label>
    </div>
    <div class="stripe-payment">
        <ul>
            <li>
                <div>
                    <span class="stripe-icon">{{ stripeSvg|raw }}</span>
                </div>
                <span>
                    {% if payment.type == "payment" %}
                        {{ "Single Payment"|t('freeform') }}
                    {% else %}
                        {{ "Subscription"|t('freeform') }}
                    {% endif %}
                </span>
            </li>
            <li>
                <div>{{ "Amount"|t('freeform') }}</div>
                <span class="stripe-amount">
                    {{ amount }} {{ currency|upper }}
                </span>
            </li>
            <li>
                <div>{{ "Status"|t('freeform') }}</div>
                <span class="stripe-status {{ payment.status == "succeeded" ? "succeeded" : "failed" }}">
                    {{ payment.status|replace('_', ' ')|capitalize|t('freeform') }}
                </span>
            </li>

            {% if paymentMethod %}
                <li>
                    <div>{{ "Method"|t('freeform') }}</div>
                    <span class="payment-method card">
                        {% if paymentMethod.type == "card" %}

                            <div class="icon">
                                {% if paymentMethodIcon %}
                                    <img src="{{ paymentMethodIcon }}" alt="Payment Method Icon" class="payment-icon">
                                {% endif %}
                            </div>
                            <div class="brand">
                                {{ paymentMethod.details.brand|replace('_', ' ')|title|t('freeform') }}
                            </div>
                            <div class="card-number">
                                {{ paymentMethod.details.last4 }}
                            </div>

                        {% elseif paymentMethodIcon %}

                            <div class="icon">
                                <img src="{{ paymentMethodIcon }}" alt="Payment Method Icon" class="payment-icon">
                            </div>
                            <div class="brand">
                                {{ paymentMethod.type|replace('_', ' ')|title|t('freeform') }}
                            </div>

                        {% else %}

                            <div class="brand">
                                {{ paymentMethod.type|replace('_', ' ')|title|t('freeform') }}
                            </div>

                        {% endif %}
                    </span>
                </li>
            {% endif %}

            <li>
                <div></div>
                <a href="{{ payment.link }}" target="_blank">
                    {{ 'Open in Stripe'|t('freeform') }}
                    <span class="icon-link-ext"></span>
                </a>
            </li>
        </ul>

    </div>
</div>
