/* The Purchase Orders page. A plain stylesheet rather than scoped CSS because the page is five
   components (the tabs, each tab's body and the detail dialog) and scoped styles stop at a
   component's edge. Builds on estimating.css: .po-page sits inside .est-page, so tables, badges,
   form rows and panels come from there. */

/* ------------------------------------------------------------------- tabs */

.po-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 2px solid var(--vml-gray-light);
    margin: 1rem 0 1.25rem;
}

.po-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
    color: var(--vml-gray-dark);
    cursor: pointer;
}

    .po-tab:hover {
        color: var(--vml-black);
    }

    .po-tab.active {
        color: var(--vml-black);
        font-weight: 600;
        border-bottom-color: var(--vml-blue);
    }

.po-tab-count {
    display: inline-block;
    min-width: 1.4rem;
    margin-left: 0.35rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background-color: rgba(0, 142, 194, 0.12);
    color: var(--vml-blue);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

/* ------------------------------------------------------------------- shared */

.po-toolbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

    /* The hint gives way so Reload stays on its own line's right, rather than wrapping under it. */
    .po-toolbar > .est-hint {
        flex: 1 1 24rem;
        margin: 0;
    }

    .po-toolbar > .po-reload {
        white-space: nowrap;
    }

/* Something waiting on Oodles or on Steph. Amber, as elsewhere for "not this app's fault". */
.po-notice {
    background: #fff8e6;
    border: 1px solid #f3dca4;
    border-radius: 6px;
    padding: 0.6rem 0.9rem;
    margin: 0.5rem 0 1rem;
    font-size: 0.88rem;
}

    .po-notice .est-toggle,
    .po-notice .est-hint {
        margin: 0.4rem 0 0;
    }

.po-clickable {
    cursor: pointer;
}

    tr.po-clickable:hover td,
    td.po-clickable:hover {
        background-color: #f5fbfe;
    }

/* The sortable header's button looks like the header text it replaces. */
.po-sort {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    white-space: nowrap;
}

    .po-sort:hover {
        color: var(--vml-blue);
    }

    .po-sort:focus-visible {
        outline: 2px solid var(--vml-blue);
        outline-offset: 2px;
    }

.po-sort-arrow {
    font-size: 0.75em;
    color: var(--vml-blue);
}

th.num .po-sort {
    text-align: right;
}

.po-page .po-grid td.row-actions {
    text-align: right;
    white-space: nowrap;
}

.po-page .po-badge-late {
    background-color: rgba(192, 57, 43, 0.12);
    color: #a93226;
}

.po-qty {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

    .po-qty input {
        max-width: 7rem;
    }

    .po-qty span {
        color: var(--vml-gray-dark);
        font-size: 0.85rem;
        white-space: nowrap;
    }

/* ------------------------------------------------------------------- create */

.po-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.po-type {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--vml-gray-light);
    border-radius: 6px;
    background-color: var(--vml-white);
    cursor: pointer;
}

    .po-type input {
        /* The whole card is the control; the radio stays for keyboard and screen readers. */
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    .po-type:focus-within {
        box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--vml-blue);
    }

    .po-type.active {
        border-color: var(--vml-blue);
        box-shadow: inset 0 3px 0 var(--vml-blue);
    }

.po-type-name {
    font-weight: 600;
}

.po-type-blurb {
    font-size: 0.82rem;
    color: var(--vml-gray-dark);
}

.po-coming-soon h2 .badge {
    margin-left: 0.4rem;
}

.po-picker-row .form-row,
.po-line-entry .form-row,
.po-draft-fields .form-row {
    /* estimating.css caps form rows at 380px for single-column forms; these sit in grids. */
    max-width: none;
}

.po-picker-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0 1rem;
}

.po-offers {
    margin-bottom: 1rem;
}

    .po-offers td:first-child {
        width: 2rem;
    }

    .po-offers tr.po-selected td {
        background-color: #eaf6fb;
    }

.po-star {
    color: #e0a100;
    margin-right: 0.2rem;
}

.po-other-vendor {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

    .po-other-vendor input {
        max-width: 26rem;
    }

.po-line-entry {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0 1rem;
    align-items: start;
}

    /* Lines the button up with the inputs, under the labels the other columns have. */
    .po-line-entry .po-add {
        padding-top: 1.55rem;
    }

.po-disabled {
    color: var(--vml-gray-dark);
    cursor: not-allowed;
}

.po-inline-date {
    display: inline-block;
    width: auto;
    padding: 0.1rem 0.35rem;
    font-size: 0.85rem;
}

.po-draft {
    margin-bottom: 1rem;
}

.po-draft-head {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}

    .po-draft-head h3 {
        margin: 0;
        flex: 1 1 auto;
    }

.po-draft-total {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.po-draft-lines {
    margin: 0.75rem 0 1rem;
}

    .po-draft-lines input.form-control {
        min-width: 5rem;
    }

    .po-draft-lines input.po-sku {
        min-width: 9rem;
    }

    .po-page .po-draft-lines .po-qty input {
        min-width: 4.5rem;
        max-width: 7rem;
    }

.po-draft-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 0 1.25rem;
}

    .po-draft-fields textarea {
        min-height: 4.6rem;
    }

    .po-draft-fields .po-wide,
    .po-ship-to {
        grid-column: 1 / -1;
    }

.po-ship-to {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

    .po-ship-to .po-wide {
        grid-column: 1 / -1;
    }

.po-needs {
    color: #a86a12;
}

.po-submitted {
    border-top-color: #26b050;
}

/* ------------------------------------------------------------------- detail dialog */

.vml-modal.po-detail {
    max-width: 62rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.po-notes {
    white-space: pre-wrap;
    font-size: 0.9rem;
}

/* ------------------------------------------------------------------- goods in */

/* Three inputs per row on a table that has to fit beside the nav: sized to what they hold. */
.po-page .po-goods-in input.form-control {
    min-width: 6.5rem;
}

.po-page .po-goods-in input[type="date"] {
    min-width: 8.5rem;
}

.po-page .po-goods-in .po-qty input {
    min-width: 4.5rem;
    max-width: 5.5rem;
}

.po-detail h2 .badge {
    margin-left: 0.5rem;
}

/* One delivery against one PO: the header fields in a row, the Receive button at the end. */
.po-receive-head {
    display: grid;
    grid-template-columns: minmax(10rem, 2fr) minmax(6rem, 1fr) minmax(9rem, 1fr) minmax(9rem, 1.5fr) auto;
    gap: 0 1rem;
    align-items: start;
    margin-bottom: 0.75rem;
}

    .po-page .po-receive-head .form-row {
        max-width: none;
    }

/* Read-only header values, set on the input baseline so the row lines up. */
.po-receive-value {
    padding: 0.375rem 0;
    font-weight: 600;
}

    .po-receive-value .btn-linklike {
        padding: 0;
    }

.po-receive-action {
    padding-top: 1.55rem;
}

@media (max-width: 900px) {
    .po-receive-head {
        grid-template-columns: 1fr 1fr;
    }
}

/* ------------------------------------------------------------------- invoices */

.po-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

    .po-page .po-filters .form-row {
        min-width: 12rem;
    }

/* A long material name wraps rather than pushing the amounts off the edge. */
.po-page .po-grid td.po-wrap {
    min-width: 10rem;
    max-width: 16rem;
    white-space: normal;
}

.po-detail tfoot td {
    border-top: 1px solid var(--vml-gray-light);
}

@media (max-width: 640.98px) {
    .po-ship-to {
        grid-template-columns: 1fr;
    }
}

/* ------------------------------------------------------------------- purchase units + acknowledging */

/* A price-list vendor Business Central no longer has: shown, so the gap is visible, but not choosable. */
.po-offers tr.po-unavailable td {
    color: var(--vml-gray-dark);
    cursor: not-allowed;
}

.po-offers .badge {
    margin-left: 0.3rem;
}

/* A line the vendor's confirmation changed. */
.po-ack-lines tr.po-changed td {
    background-color: #fff8e6;
}

.po-ack-lines .po-qty input {
    max-width: 7rem;
}

/* ------------------------------------------------------------------- email dialog */

.po-page .form-row.po-wide-row {
    max-width: none;
}

.po-gap {
    margin-left: 0.75rem;
}

/* ------------------------------------------------------------------- outsourced POs */

.po-out-kind {
    display: flex;
    gap: 1.5rem;
}

.po-out-line {
    display: grid;
    grid-template-columns: minmax(14rem, 3fr) minmax(6rem, 1fr) minmax(6rem, 1fr) minmax(7rem, 1fr) auto;
    gap: 0 1rem;
    align-items: start;
}

    .po-page .po-out-line .form-row {
        max-width: none;
    }

    .po-out-line .po-out-details {
        grid-column: 1 / -2;
    }

.po-draft-fields .po-span-2 {
    grid-column: span 2;
}

.po-details {
    white-space: pre-wrap;
}

@media (max-width: 900px) {
    .po-out-line {
        grid-template-columns: 1fr 1fr;
    }

        .po-out-line .po-out-desc,
        .po-out-line .po-out-details {
            grid-column: 1 / -1;
        }
}
