<?xml version="1.0"?>
<!--
  ~ Bring the Magento native sales/order/view page in line with the portal's
  ~ MYOB-backed order view (`portal/order/view`). A Magento order eventually
  ~ syncs to MYOB and renders through the portal view, so dealers should see
  ~ the same panel sequence on both. Changes:
  ~
  ~   - Move `sales.order.info` to render BEFORE the items block so the page
  ~     flow matches portal: Order Information → Shipping → Items → Totals.
  ~   - Drop status + date from the H1 (they live inside the Order Info
  ~     panel via the overridden info.phtml).
  ~   - Drop the actions toolbar container (Reorder button, etc.) from the
  ~     H1 — keep things visually clean.
  -->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <!-- Pull in the portal/MYOB stylesheet so .order-info-table /
             .order-info-box / .order-items-table classes resolve the same
             way they do on portal/order/view. Without this, the marked-up
             panels render unstyled because dealers.css is normally only
             loaded on portal pages. -->
        <css src="Zhik_Portal::css/dealers.css"/>
    </head>
    <body>
        <referenceBlock name="order.status" remove="true"/>
        <referenceBlock name="order.date" remove="true"/>
        <referenceContainer name="order.actions.container" remove="true"/>
        <!-- "Items Ordered / Invoices / Shipments / Refunds" tab nav is
             redundant on a portal where only the items view is exposed
             (and the Items Ordered panel already carries the heading). -->
        <referenceBlock name="sales.order.info.links" remove="true"/>
        <!-- Wrap both blocks in a single `.order-info-container` div so
             the portal CSS (`dealers.css:1256-1262`) — which scopes
             panel borders/padding to `.order-info-container > .order-
             info-table/.order-info-box/.order-items-list` — actually
             applies here. Without this wrapper, the marked-up panels
             render flat. -->
        <referenceContainer name="content">
            <container name="zhik.sales.order.wrapper" htmlTag="div" htmlClass="order-info-container"/>
        </referenceContainer>
        <move element="sales.order.view" destination="zhik.sales.order.wrapper"/>
        <move element="sales.order.info" destination="zhik.sales.order.wrapper" before="sales.order.view"/>
        <!-- Drop the 20-item pager so the order shows ALL lines on one page,
             sorted A→Z by items.phtml — matches the portal MYOB order view and
             lets a dealer scan a big order without paging. With no pager,
             Items::getItems() returns the full (unlimited) item set. -->
        <referenceBlock name="sales_order_item_pager" remove="true"/>
        <!-- View model gives items.phtml a batched SKU → barcode map (one
             catalog query) without an Object Manager call in the template. -->
        <referenceBlock name="order_items">
            <arguments>
                <argument name="barcode_view_model" xsi:type="object">Zhik\Portal\ViewModel\OrderItemBarcodes</argument>
            </arguments>
        </referenceBlock>
        <!-- 8-column items table (Name | Size | SKU | Barcode | Price |
             Ordered | Shipped | Subtotal) → totals label spans the first 7. -->
        <referenceBlock name="order_totals">
            <arguments>
                <argument name="label_properties" xsi:type="string">colspan="7" class="a-right"</argument>
                <argument name="value_properties" xsi:type="string">class="a-right"</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>
