/* Compact side-by-side layout shared by the Settlement cash screens:
     - Schedule Payment (SchedulePaymentForInvoices) -- PR 307810, now its only layout
     - Record Cash (RecordCashForInvoices) -- behind FEATURE_RECORD_CASH_COMPACT_LAYOUT, PBI 452918

   Global rather than component-scoped because two pages use it, and because several rules
   target markup that child components render (the <form> EditForm emits, Telerik's grid header).
   Scoped CSS needs ::deep for those; a global sheet matches them directly.

   The spfi- prefix is historical (Schedule Payment For Invoices). It is kept because
   wwwroot/js/schedulePaymentLayout.js writes --spfi-left and toggles .spfi-dragging, and the
   document viewer's stack (InvoiceGroupedDocuments.razor.css) uses the same prefix.

   Page markup contract:
     <div id="..." class="spfi-shell">          grid: form pane | handle | document pane
       <form class="spfi-form">                 the EditForm; display:contents
         .spfi-header  .spfi-pane.spfi-pane-left  .spfi-footer
       </form>
       .spfi-handle                             a SIBLING of the form, not a child
       .spfi-pane.spfi-pane-right               a SIBLING of the form, not a child
     </div>
   The document pane must stay outside the <form>: Telerik's PDF toolbar renders <button>s with
   no type attribute, and a typeless button inside a form defaults to type="submit". */

/* A three-column grid: form pane | drag handle | document pane, with the header and footer
   spanning all three. */
.spfi-shell {
    display: grid;
    grid-template-columns: var(--spfi-left, 42%) 12px 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    /* Fit the viewport rather than exceed it. A min-height here would reintroduce the page
       scrollbar on shorter windows, which is the one scroll container this layout does not
       need -- the grid pane and the document stack each scroll on their own. overflow:hidden
       makes that guarantee hold even if the chrome offset is slightly off on some screen. */
    /* 225px, not 200: measured against the real page chrome (nav 100 + sub-nav 40 + title bar
       50 + footer 40). At 200 the page overflowed by ~10px, which is enough for Chrome to show
       a full-height page scrollbar next to the stack's own. */
    height: calc(100vh - 225px);
    min-height: 0;
    overflow: hidden;
}

/* The form generates no box of its own, so header/grid/footer participate directly in the
   grid above. Submission, validation and EditContext are unaffected. */
.spfi-form {
    display: contents;
}

.spfi-header {
    grid-column: 1 / -1;
    grid-row: 1;
}

.spfi-footer {
    grid-column: 1 / -1;
    grid-row: 3;
}

.spfi-pane {
    display: flex;
    flex-direction: column;
    /* Without this a grid child refuses to shrink below its content width, which would let
       the grid push the document panel narrower than the divider allows. */
    min-width: 0;
}

.spfi-pane-left {
    grid-column: 1;
    grid-row: 2;
    overflow: auto;
}

.spfi-pane-right {
    grid-column: 3;
    grid-row: 2;
    min-height: 0;
}

.spfi-handle {
    grid-column: 2;
    grid-row: 2;
    cursor: col-resize;
    position: relative;
    touch-action: none;
}

/* The grab affordance: a hairline that thickens on hover/drag. */
.spfi-handle::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 5px;
    width: 2px;
    background: #dee2e6;
    border-radius: 1px;
}

.spfi-handle:hover::before,
.spfi-dragging .spfi-handle::before {
    background: #007bff;
    left: 4px;
    width: 4px;
}

/* Keep a resize cursor across the whole row while dragging, and stop the grid and PDF from
   swallowing the drag as a text selection. */
.spfi-dragging {
    cursor: col-resize;
    user-select: none;
}

/* SectionTitle is shared app-wide and sets line-height:40px + margin-bottom:20px, which costs
   ~60px per heading. Tighten it inside this layout only. `.spfi-shell h3.section-title` (0,2,1)
   beats the component's own scoped `.section-title[b-id]` (0,2,0) without !important. */
.spfi-shell h3.section-title {
    line-height: 1.3;
    margin-bottom: 0.35rem;
}

/* The pane is the scroll container, so the grid's own header needs pinning here. */
.spfi-pane-left .k-grid-header,
.spfi-pane-left .k-grid-header-wrap {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #fff;
}

/* Below xl the panes stack, matching the behaviour the Bootstrap columns had. */
@media (max-width: 1199.98px) {
    .spfi-shell {
        display: block;
        height: auto;
        min-height: 0;
    }

    .spfi-form {
        display: block;
    }

    .spfi-pane-left,
    .spfi-pane-right {
        width: auto;
        overflow: visible;
    }

    .spfi-pane-right {
        height: 620px;
        margin-top: 1rem;
    }

    .spfi-handle {
        display: none;
    }
}
