<?xml version="1.0"?>
<!--
/**
 * Simplyin HyvaPayment - Checkout Layout XML
 * Simplified layout for Hyva Checkout integration
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    
    <head>
        <css src="Simplyin_HyvaPayment::css/simplyin-hyva.css"/>
    </head>
    <body>
        <!-- CSRF form_key injection for SimplyIN API calls (must load before other SimplyIN blocks) -->
        <referenceContainer name="before.body.end">
            <block class="Magento\Framework\View\Element\Template"
                   name="simplyin.checkout.csrf.formkey"
                   template="Simplyin_HyvaPayment::checkout/csrf-form-key.phtml"/>
        </referenceContainer>

        <!-- Add Simplyin Email Integration HTML to guest details section -->
        <referenceContainer name="checkout.guest-details.section">
            <block class="Magento\Framework\View\Element\Template"
                   name="simplyin.checkout.email.integration"
                   template="Simplyin_HyvaPayment::checkout/email-integration.phtml"
                   before="-">
                <arguments>
                    <argument name="checkout_config" xsi:type="object">Simplyin\HyvaPayment\ViewModel\CheckoutConfig</argument>
                    <argument name="payment_config" xsi:type="object">Simplyin\HyvaPayment\ViewModel\PaymentConfig</argument>
                </arguments>
            </block>
        </referenceContainer>

        <!-- Register Simplyin Payment Method config (no script, just data div) -->
        <referenceContainer name="hyva.checkout.api-v1.payment-methods">
            <block class="Magento\Framework\View\Element\Template"
                   name="simplyin.checkout.payment.init"
                   template="Simplyin_HyvaPayment::checkout/payment-method-init.phtml">
                <arguments>
                    <argument name="payment_config" xsi:type="object">Simplyin\HyvaPayment\ViewModel\PaymentConfig</argument>
                    <argument name="checkout_config" xsi:type="object">Simplyin\HyvaPayment\ViewModel\CheckoutConfig</argument>
                </arguments>
            </block>
        </referenceContainer>
    </body>
</page>
