/* OMS redesign — FACTORY product workspace (public/js/oms-rdf-product.js).
 *
 * The admin portal's product workspace (prws, oms-rd-admin.css) drawn for the
 * factory: a full-window record with a fixed header, a tab strip and
 * collapsible cards. oms-rd-admin.css is NOT loaded on the factory page, so
 * the shell classes it would supply (.ow-head, .ow-col …) are defined here,
 * scoped to #rdf-prod-ws. Everything is id-scoped so it beats the page's
 * inline <style> and oms-mobile.css (which loads after this) without
 * !important. No remote assets.
 */

/* ---------- overlay + shell ------------------------------------------------ */
#rdf-prod-ov.modal-overlay {
    z-index: 1005; background: rgba(15, 23, 42, .55);
    align-items: stretch; justify-content: flex-end; padding: 0;
}
/* The PO-product notes popup opens FROM the workspace (Orders tab). It is an
   ordinary .modal-overlay (z 1000) and would open behind it. Only that one is
   lifted: a record the workspace was opened FROM must stay underneath. */
body.rdf-prod-open #product-notes-popup.show { z-index: 1010; }

#rdf-prod-ov #rdf-prod-ws {
    width: 100%; max-width: 1440px; height: 100%;
    background: var(--bg); font-size: 14px;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: -4px 0 24px rgba(11, 22, 58, .18);
}
#rdf-prod-ws .ow-head {
    flex: none; position: relative; z-index: 20; background: var(--surface);
    border-bottom: 1px solid var(--line); padding: 14px 28px 12px;
    display: flex; flex-direction: column; gap: 10px;
}
#rdf-prod-ws .ow-head-r1, #rdf-prod-ws .ow-head-r2 { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }
#rdf-prod-ws .ow-head-r1 > div:first-child { min-width: 0; flex: 1; }
#rdf-prod-ws .crumb { margin-bottom: 4px; flex-wrap: wrap; }
#rdf-prod-ws .crumb a { cursor: pointer; }
#rdf-prod-ws .crumb .mono { font-size: 12px; font-weight: 700; color: var(--ink-2); }
#rdf-prod-ws .ws-head { gap: 10px; }
#rdf-prod-ws .ws-head h1 { font-size: 22px; line-height: 1.2; color: var(--ink); }
#rdf-prod-ws .ws-head h1.sub { color: var(--muted); font-weight: 700; }
#rdf-prod-ws .rdf-code { font-size: 22px; cursor: copy; border-radius: 6px; word-break: break-all; }
#rdf-prod-ws .rdf-desc { margin-top: 4px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
#rdf-prod-ws .rdf-pos { font-size: 12.5px; font-weight: 700; min-width: 48px; text-align: center; }
#rdf-prod-ws .iconbtn { cursor: pointer; }
#rdf-prod-ws .iconbtn:disabled { opacity: .4; cursor: default; }
#rdf-prod-ws .rdf-badges { flex-wrap: wrap; min-width: 0; gap: 8px; }
#rdf-prod-ws .rdf-when { font-size: 12.5px; font-weight: 600; }
#rdf-prod-ws .btn svg { width: 14px; height: 14px; }
#rdf-prod-ws .menu { top: 42px; width: 240px; }
#rdf-prod-ws .menu[hidden] { display: none; }

/* ---------- body + tabs ---------------------------------------------------- */
#rdf-prod-ws .rdf-body {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 18px 28px 48px; display: flex; flex-direction: column; gap: 16px;
}
#rdf-prod-ws .wtabs { flex: none; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; gap: 2px; }
#rdf-prod-ws .wtabs::-webkit-scrollbar { display: none; }
#rdf-prod-ws .wtab { padding: 11px 14px; white-space: nowrap; }
#rdf-prod-ws .wtab:hover { color: var(--ink); }
#rdf-prod-ws .wtab.on .c { background: var(--accent); border-color: var(--accent); color: #fff; }
#rdf-prod-ws #rdf-prod-pane { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---------- layout pieces -------------------------------------------------- */
#rdf-prod-ws .rdf-stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
#rdf-prod-ws .dgrid.rdf-dgrid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
#rdf-prod-ws .dgrid.rdf-notesgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; }
#rdf-prod-ws .ow-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#rdf-prod-ws .rdf-side { position: sticky; top: 0; }
#rdf-prod-ws .col-card[hidden], #rdf-prod-ws .col-b[hidden] { display: none; }
#rdf-prod-ws .col-h { user-select: none; }
#rdf-prod-ws .col-h:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#rdf-prod-ws .col-h .sum:empty { display: none; }
#rdf-prod-ws .col-h .rdf-ectl { margin-left: auto; display: inline-flex; gap: 6px; flex: none; }
#rdf-prod-ws .col-h .sum + .rdf-ectl { margin-left: 10px; }
#rdf-prod-ws .rdf-g2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
#rdf-prod-ws .rdf-g3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
#rdf-prod-ws .rdf-g4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; }
#rdf-prod-ws .rdf-span { grid-column: 1 / -1; }
#rdf-prod-ws .f .v { overflow-wrap: anywhere; line-height: 1.4; }
#rdf-prod-ws .input { height: 36px; font-size: 13.5px; }
#rdf-prod-ws textarea.input { height: auto; resize: vertical; }
#rdf-prod-ws .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#rdf-prod-ws .input.changed, #rdf-prod-ws .edit-input.changed { background: #FFF8E1; border-color: #F5C77A; }
#rdf-prod-ws .rdf-help { font-size: 12px; color: var(--muted); font-weight: 500; line-height: 1.45; margin: 4px 0 0; }
#rdf-prod-ws .rdf-link { font-size: 12.5px; font-weight: 700; cursor: pointer; align-self: flex-start; margin-top: 6px; }
#rdf-prod-ws a[onclick] { cursor: pointer; }
#rdf-prod-ws .rdf-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; font-weight: 600; }
#rdf-prod-ws .rdf-err { padding: 14px; color: var(--bad); font-size: 13px; font-weight: 600; }
#rdf-prod-ws .rdf-note { text-transform: none; letter-spacing: 0; font-weight: 600; }
#rdf-prod-ws .chip.rdf-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

/* Read-only / how-to-edit bar */
#rdf-prod-ws .rdf-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    padding: 11px 16px; border-radius: 12px; border: 1px solid #C9CEFB; background: var(--accent-soft);
    color: #2A37B8; font-size: 13px; font-weight: 600; line-height: 1.45;
}
#rdf-prod-ws .rdf-bar.warn { background: var(--warn-soft); border-color: #F5C77A; color: var(--warn); }

/* fieldCell() output while a section is being edited */
#rdf-prod-ws .rdf-editcell .detail-item { display: flex; flex-direction: column; gap: 4px; margin: 0; }
#rdf-prod-ws .rdf-editcell .detail-item label {
    font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 0;
}
#rdf-prod-ws .rdf-editcell .edit-input {
    height: 34px; border: 1px solid var(--line-2); border-radius: 9px; padding: 0 10px;
    font-family: inherit; font-size: 13.5px; color: var(--ink); background: #fff; width: 100%;
}
#rdf-prod-ws .rdf-editcell .edit-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#rdf-prod-ws .rdf-editcell .edit-input.changed { background: #FFF8E1; border-color: #F5C77A; }

#rdf-prod-ws .rdf-fid { display: flex; flex-direction: column; gap: 5px; padding-top: 12px; border-top: 1px solid var(--line); max-width: 360px; }
#rdf-prod-ws .rdf-colrow { display: flex; flex-direction: column; gap: 6px; }
#rdf-prod-ws .rdf-colrow > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- gallery -------------------------------------------------------- */
#rdf-prod-ws .rdf-hero { display: flex; flex-direction: column; gap: 10px; }
#rdf-prod-ws .rdf-gmain {
    position: relative; aspect-ratio: 1 / 1; border-radius: 12px; border: 1px solid var(--line);
    background: #F1F2F7; display: grid; place-items: center; overflow: hidden; cursor: zoom-in;
}
#rdf-prod-ws .rdf-gmain.empty { cursor: default; aspect-ratio: 4 / 3; }
#rdf-prod-ws .rdf-gmain img { width: 100%; height: 100%; object-fit: contain; display: block; }
#rdf-prod-ws .rdf-gmain em, #rdf-prod-ws .rdf-awimg em, #rdf-prod-ws .rdf-logo-img em, #rdf-prod-ws .rdf-subimg em {
    font-style: normal; font-size: 12.5px; color: var(--muted); font-weight: 600;
}
#rdf-prod-ws .rdf-glab { position: absolute; left: 10px; top: 10px; background: #fff; height: 22px; font-size: 11.5px; }
#rdf-prod-ws .rdf-gstrip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
#rdf-prod-ws .rdf-gthumb {
    flex: none; width: 64px; height: 64px; padding: 0; border-radius: 9px; overflow: hidden;
    border: 1px solid var(--line); background: #F1F2F7; cursor: pointer;
}
#rdf-prod-ws .rdf-gthumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
#rdf-prod-ws .rdf-gthumb.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
#rdf-prod-ws .kvl > div > span:last-child { min-width: 0; overflow-wrap: anywhere; text-align: right; }

/* ---------- pricing / tables ---------------------------------------------- */
#rdf-prod-ws .rdf-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
#rdf-prod-ws .rdf-kpis .kpi { gap: 6px; }
#rdf-prod-ws .rdf-kpis .kpi i { font-size: 11.5px; font-weight: 600; }
#rdf-prod-ws .rdf-currow { gap: 10px; }
#rdf-prod-ws .rdf-cur { width: 120px; }
#rdf-prod-ws .rdf-tblwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
#rdf-prod-ws .rdf-tbl td, #rdf-prod-ws .rdf-tbl th { white-space: nowrap; }
#rdf-prod-ws .rdf-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
#rdf-prod-ws .rdf-tbl td .input { height: 32px; min-width: 80px; }
#rdf-prod-ws .rdf-tbl .rdf-ref { width: 160px; }
#rdf-prod-ws .rdf-sc th, #rdf-prod-ws .rdf-sc td { text-align: center; }
#rdf-prod-ws .rdf-sc th:first-child, #rdf-prod-ws .rdf-sc tbody th { text-align: left; }
#rdf-prod-ws .rdf-sc tbody th { font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--ink); background: var(--surface); font-weight: 700; }
#rdf-prod-ws .rdf-sc td .input { text-align: center; padding: 0 6px; min-width: 56px; }

/* ---------- artwork -------------------------------------------------------- */
#rdf-prod-ws .rdf-awgrid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
#rdf-prod-ws .rdf-awpair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#rdf-prod-ws .rdf-awimg {
    position: relative; aspect-ratio: 1 / 1; border-radius: 12px; border: 1px solid var(--line);
    background: #F1F2F7; display: grid; place-items: center; overflow: hidden;
}
#rdf-prod-ws .rdf-awimg.empty { border-style: dashed; }
#rdf-prod-ws .rdf-awimg img { width: 100%; height: 100%; object-fit: contain; display: block; }
#rdf-prod-ws .rdf-awimg .chip { position: absolute; left: 8px; top: 8px; background: #fff; height: 22px; font-size: 11.5px; }
#rdf-prod-ws .rdf-pdf { color: var(--bad); border-color: #F0BCC4; background: var(--bad-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#rdf-prod-ws .rdf-logos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
#rdf-prod-ws .rdf-logo { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
#rdf-prod-ws .rdf-logo-img { height: 170px; background: var(--sunk); display: grid; place-items: center; padding: 8px; }
#rdf-prod-ws .rdf-logo-img img { max-width: 100%; max-height: 154px; object-fit: contain; display: block; }
#rdf-prod-ws .rdf-logo-b { padding: 9px 11px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
#rdf-prod-ws .rdf-logo-b b { font-size: 13px; }
#rdf-prod-ws .rdf-dets .omsdt-grid { margin: 0; }

/* ---------- files ---------------------------------------------------------- */
#rdf-prod-ws .rdf-drop {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 12px 14px; border: 1.5px dashed var(--line-2); border-radius: 12px; background: var(--sunk);
    font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
#rdf-prod-ws .rdf-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
#rdf-prod-ws a.ftile { display: block; color: var(--ink); }
#rdf-prod-ws a.ftile:hover { border-color: var(--accent); }
#rdf-prod-ws .ftile .fi { overflow: hidden; }
#rdf-prod-ws .ftile .fi img { width: 100%; height: 100%; object-fit: contain; display: block; }
#rdf-prod-ws .rdf-ficon { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#rdf-prod-ws .rdf-ficon svg { width: 34px; height: 34px; color: var(--muted); }
#rdf-prod-ws .rdf-ficon span { font-size: 11.5px; font-weight: 800; color: var(--muted); text-transform: uppercase; }
#rdf-prod-ws .rdf-fm { padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#rdf-prod-ws .rdf-fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }

/* ---------- orders / customer history ------------------------------------- */
#rdf-prod-ws .rdf-subs { display: flex; flex-direction: column; gap: 10px; }
#rdf-prod-ws .rdf-subitem { display: flex; gap: 14px; align-items: flex-start; border: 1px solid var(--line); border-radius: 11px; padding: 12px; background: #fff; }
#rdf-prod-ws .rdf-subitem > img, #rdf-prod-ws .rdf-subimg {
    width: 76px; height: 76px; flex: none; border-radius: 9px; border: 1px solid var(--line);
    object-fit: contain; background: #F1F2F7; display: grid; place-items: center;
}
#rdf-prod-ws .rdf-subb { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }

/* ---------- notes ---------------------------------------------------------- */
#rdf-prod-ws .rdf-notes { min-height: 180px; }
#rdf-prod-ws .tl .r b { font-weight: 700; }
#rdf-prod-ws .rdf-tlmeta { font-size: 11.5px; margin-top: 2px; }
#rdf-prod-ws .card .ch .muted { font-size: 12px; }

/* ---------- responsive ----------------------------------------------------- */
@media (max-width: 1100px) {
    #rdf-prod-ws .dgrid.rdf-dgrid, #rdf-prod-ws .dgrid.rdf-notesgrid { grid-template-columns: minmax(0, 1fr); }
    #rdf-prod-ws .rdf-side { position: static; order: -1; }
    #rdf-prod-ws .rdf-gmain { aspect-ratio: 16 / 10; }
}
@media (max-width: 900px) {
    #rdf-prod-ov #rdf-prod-ws { max-width: 100%; box-shadow: none; }
    #rdf-prod-ws .ow-head { padding: 12px 16px; }
    #rdf-prod-ws .ow-head-r1, #rdf-prod-ws .ow-head-r2 { flex-wrap: wrap; }
    #rdf-prod-ws .rdf-body { padding: 14px 16px 40px; }
    #rdf-prod-ws .rdf-g3, #rdf-prod-ws .rdf-g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #rdf-prod-ws .rdf-g2, #rdf-prod-ws .rdf-awgrid { grid-template-columns: minmax(0, 1fr); }
    #rdf-prod-ws .rdf-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    #rdf-prod-ws .input, #rdf-prod-ws .rdf-editcell .edit-input { font-size: 16px; }   /* no iOS focus-zoom */
    #rdf-prod-ws .col-h { flex-wrap: wrap; }
}
@media (max-width: 600px) {
    #rdf-prod-ws .rdf-g3, #rdf-prod-ws .rdf-g4 { grid-template-columns: minmax(0, 1fr); }
    #rdf-prod-ws .rdf-kpis { grid-template-columns: minmax(0, 1fr); }
    #rdf-prod-ws .ws-head h1, #rdf-prod-ws .rdf-code { font-size: 18px; }
}
