/* Detail drawer anatomy (US-926) -- one spec for every detail / document drawer.

   Shell: a MudDialog with Class="lw-modal lw-modal--sheet lw-modal--scroll
   lw-modal--flush" (bottom sheet at 100dvh - 48px, 12px top radius; app.css /
   mudblazor-overrides.css), LwModalHeader in TitleContent (status chips in the
   header's second row, a figure such as an amount in Actions via
   .lw-drawer-amount), LwModalFooter in DialogActions.

   Body: .lw-drawer-split holds a details column and an optional document pane.
     .lw-drawer-details  muted, scrolls, 32px inset (16px phone)
       .lw-drawer-switch  phone-only LwPaneSwitch wrapper (Details | Document)
       .lw-drawer-content 760px ControlCard column, 20px between cards;
                          read-only rows inside cards use .lw-field-rows (app.css)
     .lw-drawer-pane     white document pane (40%, or the wide variant)
       .lw-drawer-pane-toolbar  file name + ghost icon tools
       .lw-drawer-pane-body     > .lw-drawer-pane-stage (dot grid) > .lw-drawer-pane-page
                                  | .lw-drawer-pane-img | .lw-drawer-pane-state | .lw-drawer-pane-loading
   Phone: the columns stack and .lw-drawer-split--doc swaps the details column
   for the pane (the switch stays as the way back).

   Promoted from ViewInvoiceModal (US-798) when the RFP detail drawer and the
   document drawers had drifted to four different sizes (Cody, 2026-09-24).
   Global because MudDialog teleports its content out of scoped-CSS reach and
   the pieces are shared across components. Consumers: ViewInvoiceModal,
   ContractorRfpDetailModal, HomeownerDocumentDrawer, DocumentViewerModal. */

/* ---------- Header figure ---------- */
.lw-drawer-amount {
    font-size: 18px;
    font-weight: var(--lw-font-bold);
    font-variant-numeric: tabular-nums;
    color: var(--lw-text-primary);
    white-space: nowrap;
}

/* Drawer headers align to the top: title, figure and close share the first
   line and the status chips wrap underneath, instead of the figure and close
   floating to the middle of a two-row chip stack (Cody, 2026-09-06, on the
   invoice sheet). Out-specifies LwModalHeader's scoped align-items: center. */
.mud-dialog.lw-modal--sheet .lw-modal-header,
.mud-dialog.irm-sheet .lw-modal-header,
.mud-dialog.prm-sheet .lw-modal-header,
.mud-dialog.aim-dialog:has(.aim-take) .lw-modal-header {
    align-items: flex-start;
}

.mud-dialog.lw-modal--sheet .lw-modal-title-row,
.mud-dialog.irm-sheet .lw-modal-title-row,
.mud-dialog.prm-sheet .lw-modal-title-row,
.mud-dialog.aim-dialog:has(.aim-take) .lw-modal-title-row {
    min-height: 32px;
}

/* A sheet with nothing on the title's line (no figure, no header actions -- the supplier
   W-9 review, US-1191): the subtitle sits right under the title, the dialog header's 2px. */
.mud-dialog.lw-modal--sheet.lw-modal--plain-head .lw-modal-title-row {
    min-height: 0;
}

.mud-dialog.lw-modal--sheet .lw-modal-header-actions,
.mud-dialog.irm-sheet .lw-modal-header-actions,
.mud-dialog.prm-sheet .lw-modal-header-actions,
.mud-dialog.aim-dialog:has(.aim-take) .lw-modal-header-actions {
    min-height: 32px;
    display: flex;
    align-items: center;
}

/* The review takeovers (InvoiceReviewModal, ProposalReviewModal, the
   AddInvoiceModal review step) keep their own full-height frames in
   mudblazor-overrides.css but share this header anatomy since US-1043. */

/* Status chips row under the header title (LwModalHeader ChildContent). */
.lw-drawer-chips {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

/* ---------- Split body ---------- */
.lw-drawer-split {
    display: flex;
    height: 100%;
    min-height: 0;
    background: var(--lw-bg-muted);
}

.lw-drawer-details {
    flex: 1 1 60%;
    min-width: 0;
    overflow-y: auto;
    padding: 32px;
    background: var(--lw-bg-muted);
}

.lw-drawer-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}

.lw-drawer-content--table { max-width: 1120px; }
.lw-drawer-content--wide { max-width: 1320px; }

.lw-drawer-content--fade {
    animation: lw-drawer-fade-in 0.35s ease-out;
}

@keyframes lw-drawer-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.lw-drawer-switch {
    display: none;
}

/* ---------- Document pane ---------- */
.lw-drawer-pane {
    flex: 0 0 40%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--lw-white);
    border-left: 1px solid var(--lw-border);
}

/* Document-first drawers (a file with a few facts): the pane takes the space
   and the details column narrows to a 360px sidebar. */
.lw-drawer-split--wide-pane .lw-drawer-details {
    flex: 0 0 360px;
    padding: 24px;
}

.lw-drawer-split--wide-pane .lw-drawer-pane {
    flex: 1 1 auto;
}

/* Pane only (no details column), e.g. a plain document viewer. */
.lw-drawer-split--pane-only .lw-drawer-pane {
    flex: 1 1 auto;
    border-left: 0;
}

.lw-drawer-pane-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    flex-shrink: 0;
    padding: 8px 12px;
    background: var(--lw-white);
    border-bottom: 1px solid var(--lw-border);
}

.lw-drawer-pane-file {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: var(--lw-font-medium);
    color: var(--lw-text-primary);
}

.lw-drawer-pane-tools {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.lw-drawer-pane-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--lw-radius-control);
    background: transparent;
    color: var(--lw-gray-graphite);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.lw-drawer-pane-icon:hover {
    color: var(--lw-text-primary);
    background: var(--lw-accent);
}

.lw-drawer-pane-icon .mud-icon-root {
    width: 16px;
    height: 16px;
    font-size: 16px;
}

.lw-drawer-pane-count {
    min-width: 40px;
    text-align: center;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--lw-gray-graphite);
}

.lw-drawer-pane-divider {
    width: 1px;
    height: 16px;
    margin: 0 4px;
    background: var(--lw-border);
}

.lw-drawer-pane-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Drafting-table stage: white with a 16px dot grid; the document floats as a
   shadowed page sheet (reference document-preview viewer). */
.lw-drawer-pane-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    padding: 24px;
    background-color: var(--lw-white);
    background-image: radial-gradient(color-mix(in srgb, var(--lw-text-primary) 5%, transparent) 1.5px, transparent 1.5px);
    background-size: 16px 16px;
}

.lw-drawer-pane-page {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
    margin: auto;
    overflow: hidden;
    background: var(--lw-white);
    border: 1px solid var(--lw-border);
    border-radius: var(--lw-radius-control);
    box-shadow: var(--lw-shadow-card);
}

.lw-drawer-pane-page iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
}

.lw-drawer-pane-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 16px;
}

.lw-drawer-pane-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: var(--lw-white);
    border: 1px solid var(--lw-border);
    border-radius: var(--lw-radius-control);
    box-shadow: var(--lw-shadow-card);
}

/* Empty / error / not-previewable: LwDocEmpty or LwCardNote centred. */
.lw-drawer-pane-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
}

.lw-drawer-pane-loading {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 8px;
    padding: 16px;
}

.lw-drawer-pane-loading .lw-skeleton {
    flex: 1 1 auto;
    border-radius: var(--lw-radius-card);
}

.lw-drawer-pane-caption {
    font-size: 13px;
    color: var(--lw-gray-graphite);
}

/* ---------- Phone ---------- */
@media (max-width: 767.98px) {
    /* Sheet titles wrap to two lines instead of ellipsizing beside the figure,
       pager and close ("Budget Adjustme..." on the adjustment sheet, US-1043).
       Short titles (invoice numbers) are unaffected. */
    .mud-dialog.lw-modal--sheet .lw-modal-title,
    .mud-dialog.lw-modal--takeover .lw-modal-title,
    .mud-dialog.irm-sheet .lw-modal-title,
    .mud-dialog.prm-sheet .lw-modal-title,
    .mud-dialog.aim-dialog:has(.aim-take) .lw-modal-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-height: 20px;
    }

    /* O8 re-flow for headers that carry a pager (adjustment sheet, document
       drawer): title + close on the first row, number and chips beneath, then
       the figure and the prev/next pager on a row of their own. Squeezing all
       of it onto the title line left the title ~160px wide (Cody, 2026-10-11). */
    .mud-dialog.lw-modal .lw-modal-header:has(.lw-drawer-pane-tools, .lw-drawer-header-row) {
        flex-wrap: wrap;
        row-gap: 10px;
    }

    .mud-dialog.lw-modal .lw-modal-header:has(.lw-drawer-pane-tools, .lw-drawer-header-row) .lw-modal-header-text {
        order: 0;
        flex: 1 1 0;
    }

    .mud-dialog.lw-modal .lw-modal-header:has(.lw-drawer-pane-tools, .lw-drawer-header-row) .lw-modal-close {
        order: 1;
    }

    .mud-dialog.lw-modal .lw-modal-header:has(.lw-drawer-pane-tools, .lw-drawer-header-row) .lw-modal-header-actions {
        order: 2;
        flex: 1 1 100%;
        justify-content: space-between;
        min-height: 0;
    }

    .lw-drawer-split {
        flex-direction: column;
    }

    .lw-drawer-details,
    .lw-drawer-split--wide-pane .lw-drawer-details {
        flex: 1 1 auto;
        padding: 16px;
    }

    .lw-drawer-switch {
        display: block;
        margin: 0 0 12px;
    }

    .lw-drawer-pane {
        display: none;
        border-left: 0;
    }

    .lw-drawer-pane-stage {
        padding: 12px;
    }

    /* Document view: the details column collapses to the switch and the pane
       takes the rest of the sheet. */
    .lw-drawer-split--doc .lw-drawer-details {
        flex: 0 0 auto;
        overflow: visible;
        padding-bottom: 0;
    }

    .lw-drawer-split--doc .lw-drawer-content {
        display: none;
    }

    .lw-drawer-split--doc .lw-drawer-pane,
    .lw-drawer-split--pane-only .lw-drawer-pane {
        display: flex;
        flex: 1 1 auto;
        min-height: 0;
    }
}
