/*
 * Shared stock supplier modal styles.
 * These are used by several stock pages (Suppliers, Supplier groups, Master suppliers),
 * so they live in a global (non-scoped) stylesheet rather than a single page's
 * scoped .razor.css — otherwise the Blazor scope attribute only matches one page and
 * the modals on the others render inline in the page flow instead of as overlays.
 */

/* The neutral stock-modal-* names are aliases for the supplier family below, so new modals (or pages
   migrating off a bespoke scoped copy) can use a page-agnostic name without minting another family. */
.stock-supplier-modal-backdrop,
.stock-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1060;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(10, 22, 30, 0.42);
    backdrop-filter: blur(5px);
}

.stock-modal-panel,
.stock-supplier-modal-panel {
    width: min(680px, 100%);
    overflow: hidden;
    border: 1px solid rgba(22, 135, 95, 0.16);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 28px 90px rgba(10, 22, 30, 0.28);
}

.stock-supplier-modal-header,
.stock-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem 0.85rem;
    border-bottom: 1px solid rgba(42, 54, 66, 0.08);
    background: #fbfcfd;
}

.stock-modal-header h2,
.stock-supplier-modal-header h2 {
    margin: 0.2rem 0 0;
    color: #142936;
    font-size: 1.35rem;
    font-weight: 850;
    letter-spacing: 0;
}

.stock-modal-header p,
.stock-supplier-modal-header p {
    max-width: 500px;
    margin: 0.2rem 0 0;
    color: #53636d;
    font-size: 0.86rem;
    line-height: 1.4;
}

.stock-modal-close,
.stock-supplier-modal-close {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid rgba(42, 54, 66, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.82);
    color: #53636d;
}

.stock-modal-content,
.stock-supplier-modal-content {
    display: grid;
    gap: 1rem;
    padding: 1.1rem;
}

.stock-supplier-modal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.75fr);
    gap: 1rem;
}

.stock-supplier-modal-safety {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    border: 1px solid rgba(22, 135, 95, 0.14);
    border-radius: 10px;
    padding: 0.75rem;
    background: #f4fbf7;
    color: #2b4555;
    font-size: 0.83rem;
    line-height: 1.4;
}

.stock-supplier-modal-safety i {
    margin-top: 0.15rem;
    color: #16875f;
}

.stock-supplier-modal-actions,
.stock-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.85rem 1.1rem 1rem;
    border-top: 1px solid rgba(42, 54, 66, 0.08);
    background: #fbfcfd;
}

/* Wide, scrollable per-supplier product catalogue modal. */
.stock-supplier-products-modal-panel {
    display: flex;
    flex-direction: column;
    width: min(1080px, 100%);
    max-height: 88vh;
}

.stock-supplier-products-modal-panel .stock-supplier-modal-header {
    flex: 0 0 auto;
}

.stock-products-modal-head-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.stock-products-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
}

.stock-products-add-form {
    border: 1px solid rgba(42, 54, 66, 0.12);
    border-radius: 10px;
    padding: 1rem;
    background: #fbfcfd;
}

.stock-products-modal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    min-height: 34px;
}

/* The price-edit dialog opens on top of the products modal. */
.stock-price-edit-backdrop {
    z-index: 1070;
}

/*
 * Catalogue picker — a multi-column grid of click-anywhere-to-select product cards.
 * Replaces the single-column table so a couple of thousand catalogue products take far
 * fewer pages to work through, and a whole page can be added in one go.
 */
.stock-catalogue-picker {
    display: grid;
    gap: 0.85rem;
}

.stock-catalogue-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.stock-catalogue-search {
    position: relative;
    flex: 1 1 16rem;
    min-width: 12rem;
}

.stock-catalogue-search > i {
    position: absolute;
    top: 50%;
    left: 0.6rem;
    transform: translateY(-50%);
    color: #879790;
    font-size: 0.8rem;
    pointer-events: none;
}

.stock-catalogue-search .form-control {
    padding-left: 1.9rem;
}

.stock-catalogue-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.stock-catalogue-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.85rem;
    color: #53636d;
    font-size: 0.82rem;
}

.stock-catalogue-meta strong {
    color: #142936;
}

.stock-catalogue-selected {
    color: #16875f;
    font-weight: 650;
}

.stock-catalogue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 0.5rem;
}

.stock-catalogue-card {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid rgba(42, 54, 66, 0.14);
    border-radius: 9px;
    background: #fff;
    color: #23323c;
    font-size: 0.85rem;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}

.stock-catalogue-card:hover:not(:disabled):not(.is-added):not(.stock-catalogue-card-static) {
    border-color: rgba(22, 135, 95, 0.5);
    background: #f6fbf8;
}

/* Read-only card: same multi-column layout, but no interactive affordance (used to browse a
   master supplier's shared catalogue where there is nothing to select). */
.stock-catalogue-card-static {
    cursor: default;
}

.stock-catalogue-card:focus-visible {
    outline: 2px solid #16875f;
    outline-offset: 2px;
}

.stock-catalogue-card.is-selected {
    border-color: #16875f;
    background: #edf9f2;
    box-shadow: inset 0 0 0 1px #16875f;
}

.stock-catalogue-card.is-added {
    background: #f7f9fa;
    color: #7a8892;
    cursor: default;
}

.stock-catalogue-check {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(42, 54, 66, 0.3);
    border-radius: 5px;
    background: #fff;
    color: #fff;
    font-size: 0.6rem;
}

.stock-catalogue-card.is-selected .stock-catalogue-check {
    border-color: #16875f;
    background: #16875f;
}

.stock-catalogue-card.is-added .stock-catalogue-check {
    border-color: rgba(22, 135, 95, 0.4);
    background: rgba(22, 135, 95, 0.4);
}

.stock-catalogue-name {
    flex: 1 1 auto;
    text-align: left;
    overflow-wrap: anywhere;
}

.stock-catalogue-badge {
    flex: 0 0 auto;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.stock-catalogue-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 2rem 1rem;
    text-align: center;
    color: #879790;
    font-size: 0.86rem;
    border: 1px dashed #e6ece8;
    border-radius: 11px;
    background: #f8faf9;
}

.stock-catalogue-empty > i {
    font-size: 1.4rem;
}

.stock-catalogue-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-top: 0.25rem;
}

.stock-catalogue-page-info {
    margin: 0 0.5rem;
    color: #566862;
    font-size: 0.78rem;
}

.stock-catalogue-page-info strong {
    color: #1c2622;
}

@media (max-width: 575.98px) {
    .stock-catalogue-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575.98px) {
    .stock-products-modal-head-actions {
        flex-wrap: wrap;
    }

    .stock-supplier-modal-grid {
        grid-template-columns: 1fr;
    }

    .stock-supplier-modal-actions,
    .stock-modal-actions {
        flex-direction: column-reverse;
    }

    .stock-supplier-modal-actions .btn,
    .stock-modal-actions .btn {
        width: 100%;
    }
}

/*
 * Shared page-modal chrome (the "glassy" family: blurred slate backdrop, 18px-radius translucent panel).
 * Promoted here from byte-identical scoped copies in Ordering.razor.css and StockAuditModal.razor.css —
 * scoped CSS can't style a shared component's markup, which is also why StockEmailPreviewModal (which
 * already used these class names with no scoped copy of its own) rendered without its overlay chrome.
 * Sits at z-index 1065: above the supplier family (1060), below the price-edit dialog (1070) and the
 * page-specific stacks (Products 1080, nested recipe modals 1100) — keep that ladder intact.
 */
.stock-page-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1065;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background: rgba(15, 23, 42, .36);
    backdrop-filter: blur(8px);
}

/* One stock modal opened on top of another (the PLU mapping editor over the PLU workbench). 1085 sits
 * above the base 1065 and the price-edit dialog (1070) but below the Products stack (1080)… which it
 * must NOT, so it is pinned at 1085 — above Products, below nested recipe modals (1100). No page shows
 * a Products dialog and this pair at once, so the ladder stays unambiguous. The extra blur layer is
 * removed: two stacked backdrops read as a rendering fault rather than depth. */
.stock-page-modal-backdrop-nested {
    z-index: 1085;
    background: rgba(15, 23, 42, .28);
    backdrop-filter: none;
}

.stock-page-modal-panel {
    width: min(48rem, 100%);
    max-height: min(44rem, calc(100vh - 2.5rem));
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 18px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 28px 80px rgba(15, 23, 42, .28);
}

.stock-page-modal-panel-wide {
    width: min(76rem, 100%);
}

.stock-page-modal-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid rgba(23, 34, 49, .08);
    background: rgba(255, 255, 255, .95);
}

.stock-page-modal-header h2 {
    margin: 0;
    color: #172231;
    font-weight: 850;
}

.stock-page-modal-header p {
    max-width: 48rem;
    margin: .25rem 0 0;
    color: #607184;
}

.stock-page-modal-eyebrow {
    color: #16875f;
    font-size: .78rem;
    font-weight: 850;
    text-transform: uppercase;
}

.stock-page-modal-close {
    display: inline-grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: #f3f7f5;
}

.stock-page-modal-content {
    display: grid;
    gap: 1rem;
    padding: 1.15rem;
}

.stock-page-modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .55rem;
}

@media (max-width: 767.98px) {
    .stock-page-modal-backdrop {
        padding: .65rem;
    }
}

/*
 * Printable blank stock count sheet (Counts.razor).
 * The .stock-count-print-root fragment is always rendered off-screen for the active count session; on paper we
 * hide the rest of the app and lay this out cleanly. It lives in this global stylesheet (not a scoped .razor.css)
 * because the "hide everything but the sheet" trick relies on a plain `body *` selector, which CSS isolation would
 * rewrite to `body *[b-xxxxx]` and no longer match the app's own chrome.
 */
.stock-count-print-root,
.stock-spec-print-root,
.stock-print-region {
    display: none;
}

@media print {
    /* Hide the whole app, then reveal only the sheet and its descendants. */
    body * {
        visibility: hidden;
    }

    .stock-count-print-root,
    .stock-count-print-root *,
    .stock-spec-print-root,
    .stock-spec-print-root *,
    .stock-print-region,
    .stock-print-region * {
        visibility: visible;
    }

    /*
     * The sheet is absolutely positioned so the (still space-occupying) hidden app chrome doesn't push it down
     * the page. Absolute resolves against the nearest *positioned* ancestor, and the OneUI shell wrappers around
     * the page content are positioned (e.g. .block is position:relative), which would anchor the sheet below the
     * header instead of at the page origin. Flatten that ancestor chain to static so the containing block becomes
     * the page itself and top/left:0 lands at the top-left corner.
     */
    #page-container,
    #main-container,
    #content_data_page,
    .content,
    .stock-workspace,
    .stock-shell,
    .stock-shell-content {
        position: static !important;
    }

    .stock-count-print-root {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        padding: 0 4mm;
        color: #000;
        font-size: 11pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Printable supplier order sheet (Ordering.razor "Ready to send" — Print / PDF). The sheet's on-screen look
     * lives in Ordering.razor.css; here we only lift it to the page origin and force clean black-on-white ink. */
    .stock-print-region {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        padding: 0 6mm;
        color: #000;
        font-size: 11pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .stock-print-region .stock-send-sheet-table {
        width: 100%;
        border-collapse: collapse;
        margin: 4mm 0;
    }

    .stock-print-region .stock-send-sheet-table th,
    .stock-print-region .stock-send-sheet-table td {
        border: 0.5pt solid #000;
        padding: 1.5mm 2mm;
        color: #000;
    }

    .stock-print-region .stock-send-sheet-table thead th {
        background: #eee;
    }

    /* Printable chef spec sheet (station card) — mirrors the on-paper count-sheet approach. */
    .stock-spec-print-root {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        padding: 0 4mm;
        color: #000;
        font-size: 11pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .stock-spec-print-root .ssp-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12mm;
        padding-bottom: 3mm;
        margin-bottom: 4mm;
        border-bottom: 1.5pt solid #000;
    }

    .stock-spec-print-root h1 {
        margin: 0;
        font-size: 17pt;
        font-weight: 700;
    }

    .stock-spec-print-root .ssp-sub {
        margin: 1mm 0 0;
        font-size: 11pt;
    }

    .stock-spec-print-root .ssp-meta {
        min-width: 52mm;
        font-size: 10pt;
    }

    .stock-spec-print-root .ssp-meta > div {
        display: flex;
        justify-content: space-between;
        gap: 4mm;
        margin-bottom: 1mm;
    }

    .stock-spec-print-root .ssp-meta span {
        color: #333;
    }

    .stock-spec-print-root h2 {
        margin: 4mm 0 1.5mm;
        font-size: 12pt;
        font-weight: 700;
        border-bottom: 0.75pt solid #666;
        padding-bottom: 1mm;
        break-after: avoid;
        page-break-after: avoid;
    }

    .stock-spec-print-root ul,
    .stock-spec-print-root ol {
        margin: 0 0 3mm;
        padding-left: 6mm;
    }

    .stock-spec-print-root li {
        margin-bottom: 1.5mm;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .stock-spec-print-root .ssp-step-meta {
        color: #555;
        font-size: 9.5pt;
    }

    .stock-spec-print-root .ssp-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 3mm;
    }

    .stock-spec-print-root .ssp-table th,
    .stock-spec-print-root .ssp-table td {
        border: 0.5pt solid #999;
        padding: 1.5mm 2mm;
        text-align: left;
        vertical-align: top;
        font-size: 10pt;
    }

    .stock-spec-print-root .ssp-table thead th {
        background: #eee;
        text-transform: uppercase;
        font-size: 9pt;
        letter-spacing: 0.4pt;
    }

    .stock-spec-print-root p {
        margin: 0 0 3mm;
    }

    .stock-count-print-root .scps-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12mm;
        padding-bottom: 3mm;
        margin-bottom: 4mm;
        border-bottom: 1.5pt solid #000;
    }

    .stock-count-print-root .scps-title h1 {
        margin: 0;
        font-size: 16pt;
        font-weight: 700;
    }

    .stock-count-print-root .scps-sub {
        margin: 1mm 0 0;
        font-size: 12pt;
        font-weight: 600;
    }

    .stock-count-print-root .scps-meta {
        min-width: 62mm;
        font-size: 10pt;
    }

    .stock-count-print-root .scps-meta-row {
        display: flex;
        align-items: baseline;
        gap: 3mm;
        margin-bottom: 1.5mm;
    }

    .stock-count-print-root .scps-meta-row > span:first-child {
        flex: 0 0 22mm;
        color: #333;
    }

    .stock-count-print-root .scps-fill {
        flex: 1 1 auto;
        border-bottom: 0.75pt solid #000;
        min-height: 4mm;
    }

    .stock-count-print-root .scps-area {
        margin-bottom: 5mm;
        /* Keep an area's heading with at least the start of its table. */
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .stock-count-print-root .scps-area h2 {
        margin: 0 0 1.5mm;
        font-size: 12pt;
        font-weight: 700;
        border-bottom: 0.75pt solid #666;
        padding-bottom: 1mm;
    }

    .stock-count-print-root .scps-area-count {
        font-size: 9pt;
        font-weight: 400;
        color: #555;
        margin-left: 2mm;
    }

    .stock-count-print-root .scps-table {
        width: 100%;
        border-collapse: collapse;
    }

    .stock-count-print-root .scps-table th,
    .stock-count-print-root .scps-table td {
        border: 0.5pt solid #999;
        padding: 1.5mm 2mm;
        text-align: left;
        vertical-align: middle;
    }

    .stock-count-print-root .scps-table thead th {
        font-size: 9pt;
        text-transform: uppercase;
        letter-spacing: 0.4pt;
        background: #eee;
    }

    .stock-count-print-root .scps-col-unit {
        width: 20mm;
    }

    .stock-count-print-root .scps-col-count {
        width: 32mm;
    }

    /* Rows can break across pages, but never split a single row. */
    .stock-count-print-root .scps-table tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .stock-count-print-root .scps-product-name {
        font-weight: 600;
    }

    .stock-count-print-root .scps-product-cat {
        display: block;
        font-size: 8.5pt;
        color: #555;
    }

    .stock-count-print-root .scps-unit {
        color: #333;
    }

    /* Empty write-in box for the counted quantity. */
    .stock-count-print-root .scps-box {
        height: 8mm;
    }

    .stock-count-print-root .scps-footer {
        margin-top: 4mm;
        padding-top: 2mm;
        border-top: 0.5pt solid #999;
        font-size: 8.5pt;
        color: #333;
    }

    /* "Where my stock is" report (Counts.razor) — extra columns/sections on top of the scps- sheet styles. */
    .stock-count-print-root .scps-col-total {
        width: 30mm;
    }

    .stock-count-print-root .scps-where-uncounted {
        margin-top: 5mm;
    }

    .stock-count-print-root .scps-where-uncounted-list {
        columns: 3;
        column-gap: 8mm;
        list-style: none;
        margin: 0;
        padding: 0;
        font-size: 9pt;
    }

    .stock-count-print-root .scps-where-uncounted-list li {
        break-inside: avoid;
        padding: 0.5mm 0;
    }

    @page {
        margin: 12mm;
    }
}
