/*
 * Warehouse forms and modals, iOS 26 style. Every Warehouse modal posts a form whose id starts
 * with "wh-", and every record card (unit, tank, service order, trip, PO, job, item, EDI message)
 * is a ".modal-body.wh-card", so the skin follows both wherever the app's modal shows them. The admin's
 * Settings → Appearance writes the variables (accent, density, corners) in a <style> next to
 * this file; switching the style off there simply stops loading it.
 */
:root {
    --whf-accent: #0a84ff;
    --whf-field-h: 44px;
    --whf-radius: 12px;
    --whf-card-radius: 22px;
    --whf-gap: 14px;
    --whf-sheet: #ffffff;
    --whf-fill: #f2f2f7;
    --whf-fill-hover: #e9e9ef;
    --whf-text: #1c1c1e;
    --whf-label: #6c6c70;
    --whf-hair: rgba(60, 60, 67, .14);
}
body.color-1E202D {
    --whf-sheet: #1c1c1e;
    --whf-fill: #2c2c2e;
    --whf-fill-hover: #353538;
    --whf-text: #f2f2f7;
    --whf-label: #a1a1a8;
    --whf-hair: rgba(235, 235, 245, .12);
}

.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) {
    border: 0;
    border-radius: var(--whf-card-radius);
    background: var(--whf-sheet);
    color: var(--whf-text);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
    overflow: hidden;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .modal-body {
    padding: 8px 22px 6px;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .form-group {
    margin-bottom: var(--whf-gap);
}
/* the label is a small caption above its field, like an iOS grouped list header */
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .form-group > label,
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) label.wh-label {
    display: block;
    margin: 0 0 6px 4px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--whf-label);
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .form-control,
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .select2-container .select2-choice,
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .select2-container-multi .select2-choices,
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .select2-container--default .select2-selection {
    min-height: var(--whf-field-h);
    border: 1px solid transparent;
    border-radius: var(--whf-radius);
    background: var(--whf-fill);
    color: var(--whf-text);
    box-shadow: none;
    transition: background .15s, border-color .15s, box-shadow .15s;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) input.form-control,
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) select.form-control {
    height: var(--whf-field-h);
    padding: 0 14px;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) textarea.form-control {
    padding: 11px 14px;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .select2-container .select2-choice {
    line-height: calc(var(--whf-field-h) - 2px);
    padding-left: 14px;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .select2-container .select2-choice .select2-arrow {
    background: transparent;
    border-left: 0;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .select2-container .select2-choice .select2-arrow b {
    background-position-y: calc((var(--whf-field-h) - 26px) / 2);
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .form-control:hover,
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .select2-container:hover .select2-choice {
    background: var(--whf-fill-hover);
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .form-control:focus,
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .select2-container-active .select2-choice {
    background: var(--whf-sheet);
    border-color: var(--whf-accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--whf-accent) 22%, transparent);
    outline: 0;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .form-control::placeholder {
    color: var(--whf-label);
    opacity: .75;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .form-text {
    margin: 5px 0 0 4px;
    font-size: 12px;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .form-check-input:checked {
    background-color: var(--whf-accent);
    border-color: var(--whf-accent);
}
/* a validation message reads as a line under the field, not a red box */
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) label.error {
    margin: 5px 0 0 4px;
    font-size: 12px;
    font-weight: 500;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .modal-footer {
    border-top: 0;
    padding: 10px 22px 20px;
    gap: 8px;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .modal-footer .btn,
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .modal-body .btn {
    border-radius: 999px;
    padding: 9px 18px;
    font-weight: 600;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .modal-footer .btn-primary {
    background: var(--whf-accent);
    border-color: var(--whf-accent);
    min-width: 140px;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .modal-footer .btn-default {
    background: var(--whf-fill);
    border-color: transparent;
    color: var(--whf-text);
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) hr {
    border-color: var(--whf-hair);
    opacity: 1;
}

/* on a phone the modal is a sheet that rises from the bottom */
@media (max-width: 767.98px) {
    .modal .modal-dialog:has(form[id^="wh-"], .modal-body.wh-card) {
        margin: 0;
        min-height: 100%;
        display: flex;
        align-items: flex-end;
    }
    .modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) {
        border-radius: var(--whf-card-radius) var(--whf-card-radius) 0 0;
        width: 100%;
    }
    .modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .modal-footer .btn-primary {
        flex: 1 1 auto;
    }
    .modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) input.form-control {
        font-size: 16px; /* no zoom-in on iOS */
    }
}

/* density: compact */
:root.wh-density-compact {
    --whf-field-h: 36px;
    --whf-gap: 9px;
}

/* damaged sides at the gate: a row of pill toggles */
.wh-side-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.wh-side-toggles .btn {
    border-radius: 999px;
    padding: 6px 14px;
}
.wh-side-toggles .btn-check:checked + .btn {
    background: #ff3b30;
    border-color: #ff3b30;
    color: #fff;
}

/* the gate appointment hint under the truck plate */
.wh-appt-hint-ok {
    color: #1f7a3a;
    font-weight: 600;
}
.wh-appt-hint-late {
    color: #b8460b;
    font-weight: 600;
}
body.color-1E202D .wh-appt-hint-ok {
    color: #7ee29b;
}
body.color-1E202D .wh-appt-hint-late {
    color: #ffb27a;
}

/* help lines under fields: the sheet's own label colour, ≥ 5:1 in light and dark */
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .form-text,
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .form-text.text-off {
    color: var(--whf-label) !important;
}

/* "More details": the optional part of a short gate form, folded */
.wh-more {
    margin: 4px 0 10px;
}
.wh-more > summary {
    cursor: pointer;
    list-style: none;
    padding: 10px 14px;
    border-radius: var(--whf-radius);
    background: var(--whf-fill);
    color: var(--whf-accent);
    font-weight: 600;
}
.wh-more > summary::-webkit-details-marker {
    display: none;
}
.wh-more > summary::after {
    content: "›";
    float: right;
    transition: transform .15s;
}
.wh-more[open] > summary {
    margin-bottom: 12px;
}
.wh-more[open] > summary::after {
    transform: rotate(90deg);
}
body.color-1E202D .wh-more > summary {
    color: #7ab8ff;
}

/* lines of a document built from Warehouse work: tick · what · quantity · price · line total */
.wh-doc-lines {
    max-height: 46vh;
    overflow: auto;
    margin-bottom: 10px;
}
.wh-doc-group {
    margin: 12px 4px 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--whf-label);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.wh-doc-line {
    display: grid;
    grid-template-columns: 22px 1fr 76px 96px 96px;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--whf-radius);
    background: var(--whf-fill);
    margin-bottom: 6px;
}
.wh-doc-line.off {
    opacity: .55;
}
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .wh-doc-line input.form-control {
    height: 36px;
    min-height: 36px;
    padding: 0 8px;
    background: var(--whf-sheet);
    text-align: right;
}
.wh-doc-what small {
    display: block;
    color: var(--whf-label);
}
.wh-doc-sum {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.wh-doc-total {
    text-align: right;
    margin: 4px 4px 14px;
    font-size: 16px;
}
@media (max-width: 575.98px) {
    .wh-doc-line {
        grid-template-columns: 22px 1fr 1fr;
    }
    .wh-doc-what {
        grid-column: 2 / 4;
    }
    .wh-doc-sum {
        grid-column: 2 / 4;
    }
}

/* the chain of documents around a piece of work: work → estimate → proposal → invoice */
.wh-chain {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 4px 0 12px;
}
.wh-chain-step {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(118, 118, 128, .12);
    color: inherit;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}
a.wh-chain-step:hover {
    background: rgba(10, 132, 255, .14);
}
.wh-chain-step .st {
    font-weight: 500;
    opacity: .8;
}
.wh-chain-arrow {
    opacity: .5;
}

/* estimate or proposal: a two-way switch at the top of the sheet */
.wh-doc-type {
    display: inline-flex;
    gap: 4px;
    padding: 3px;
    margin: 0 0 12px;
    border-radius: 12px;
    background: var(--whf-fill);
}
.wh-doc-type .btn {
    border: 0;
    border-radius: 9px;
    padding: 7px 16px;
    background: transparent;
    color: var(--whf-text);
}
.wh-doc-type .btn-check:checked + .btn {
    background: var(--whf-sheet);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}

/* the theme's muted grey (#898fa9, !important in 1E202D.css) is 4.43:1 on the dark sheet:
   on a sheet, muted text takes the sheet's own label grey */
body.color-1E202D .modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .text-off {
    color: var(--whf-label) !important;
}

/* PerfectScrollbar measures the body before the sheet's padding lands and keeps a sideways rail
   for content that fits (scrollWidth = clientWidth): a sheet scrolls down only */
.modal .modal-content:has(form[id^="wh-"], .modal-body.wh-card) .modal-body > .ps__rail-x {
    display: none !important;
}
