/* ==========================================================================
   ORDER-DETAIL-SHOPIFY-1 — Order / POS sale details rebuilt to the Shopify order page.
   Reference: a 125% display screenshot of a Shopify draft order, so 1 CSS px = 1.25 screenshot px.
   Every size below is the screenshot measurement divided by 1.25.
   Scope: #view-order-detail only. Markup comes from renderOrderDetail() in js/chunk-orders.js
   (classes .odx-*). Load AFTER page-unify.css / shopify-shell.css.
   Roll back: delete this file's <link> and restore chunk-orders.js from the previous zip.
   ========================================================================== */

#view-order-detail [hidden] { display: none !important; }

/* The old "Back to orders" text link is replaced by the round back button in the header row. */
#view-order-detail > .back-link { display: none; }

/* Canvas: the reference page is plain white; the desktop shell paints #FBFBFB. */
@media (min-width: 861px) {
  .main:has(#view-order-detail.active),
  body:has(#view-order-detail.active) .main { background: #fff; }
  /* run edge to edge so the header row sits at the panel's own 16px padding, like the reference */
  #view-order-detail { margin: -22px calc(-1 * var(--shell-gutter, 24px)) -40px; }
}

#view-order-detail .odx {
  --odx-text: #303030;
  --odx-text-2: #616161;
  --odx-border: #E3E3E3;
  --odx-hair: #EBEBEB;
  --odx-link: #168A4E;
  --odx-fill: #EBEBEB;
  --odx-card-shadow: 0 1px 4px rgba(0, 0, 0, .04), 0 2px 32px rgba(0, 0, 0, .05);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px; line-height: 20px; font-weight: 450; color: var(--odx-text);
  -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11' 1;
  padding-bottom: 64px; box-sizing: border-box;
}
#view-order-detail .odx *, #view-order-detail .odx *::before, #view-order-detail .odx *::after { box-sizing: border-box; }
#view-order-detail .odx a { text-decoration: none; }
#view-order-detail .odx .odx-ico { display: block; width: 20px; height: 20px; flex: none; }

/* ------------------------------ header row ------------------------------ */
.odx-top { display: flex; align-items: center; gap: 12px; padding: 11px 16px 0; min-height: 40px; }
.odx-back {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
  color: var(--odx-text); background: #fff; border: 1px solid transparent;
  box-shadow: 0 0 0 1px var(--odx-border), 0 1px 2px rgba(0, 0, 0, .08);
}
.odx-back:hover { background: #F7F7F7; }
.odx-crumb { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; line-height: 20px; font-weight: 550; color: var(--odx-text-2); }
.odx-crumb .odx-ico { width: 20px; height: 20px; color: var(--odx-text-2); }
.odx-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* pills: top row = white with border; inside sections = grey fill; .odx-pill-dark = primary */
.odx-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 30px; padding: 0 12px; border-radius: 999px;
  font: 550 13px/20px 'Inter', sans-serif; color: var(--odx-text); white-space: nowrap; cursor: pointer;
  background: #fff; border: 1px solid transparent; box-shadow: 0 0 0 1px var(--odx-border), 0 1px 2px rgba(0, 0, 0, .06);
  transition: background .12s ease;
}
.odx-pill:hover { background: #F7F7F7; }
.odx-pill:active { background: #F1F1F1; }
.odx-pill:focus-visible, .odx-icon-btn:focus-visible, .odx-back:focus-visible { outline: 2px solid #168A4E; outline-offset: 1px; }
.odx-sec-actions .odx-pill:not(.odx-pill-dark), .odx-form-actions .odx-pill:not(.odx-pill-dark) { background: var(--odx-fill); box-shadow: none; }
.odx-sec-actions .odx-pill:not(.odx-pill-dark):hover, .odx-form-actions .odx-pill:not(.odx-pill-dark):hover { background: #E3E3E3; }
.odx-pill-dark {
  color: #fff; background: linear-gradient(180deg, #3B3B3B 0%, #1A1A1A 100%); border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 -1px 0 rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .25);
}
.odx-pill-dark:hover { background: linear-gradient(180deg, #454545 0%, #242424 100%); }
.odx-pill-dark:active { background: #1A1A1A; }
.odx-pill-dark[disabled] { opacity: .5; cursor: not-allowed; }
.odx-sec-actions .odx-pill, .odx-form-actions .odx-pill, .odx-block { height: 28px; }
.odx-pill-full { width: 100%; height: 28px; background: var(--odx-fill); box-shadow: none; }
.odx-pill-full:hover { background: #E3E3E3; }
.odx-pill-danger { color: #8E1F0B; background: #FFF; box-shadow: inset 0 0 0 1px #E0B3B2; }
.odx-pill-danger:hover { background: #FFF4F4; }
.odx-pad .hint, .odx-pad .odx-hint { margin: 8px 0 0; font-size: 12px; line-height: 16px; color: var(--odx-text-2); }
.odx-pad .alert-banner { margin: 0; font-size: 13px; line-height: 20px; }
.odx-pad .odx-ro { color: var(--odx-text-2); }
.odx-pill-sm { height: 24px; padding: 0 10px; font-size: 12px; line-height: 16px; }
.odx-block { width: 100%; margin-top: 8px; }
.odx-chev { width: 16px !important; height: 16px !important; color: var(--odx-text-2); margin-right: -4px; }
.odx-pill-group { display: inline-flex; border-radius: 999px; background: #fff; box-shadow: 0 0 0 1px var(--odx-border), 0 1px 2px rgba(0, 0, 0, .06); }
.odx-pill-group .odx-pill-nav { width: 36px; padding: 0; box-shadow: none; background: transparent; }
.odx-pill-group .odx-pill-nav:hover { background: #F1F1F1; }
.odx-pill-nav .odx-ico { width: 16px; height: 16px; }
.odx-pill-nav.is-disabled { color: #B5B5B5; cursor: default; pointer-events: none; }
.odx-icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--odx-text-2); cursor: pointer;
}
.odx-icon-btn:hover { background: #F1F1F1; color: var(--odx-text); }

/* dropdown menus */
.odx-menu-wrap { position: relative; }
.odx-menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; min-width: 220px; padding: 4px;
  background: #fff; border-radius: 12px; box-shadow: 0 0 0 1px var(--odx-border), 0 8px 24px -4px rgba(0, 0, 0, .18);
}
.odx-menu a, .odx-menu button {
  display: block; width: 100%; padding: 6px 8px; border: 0; border-radius: 8px; background: none; text-align: left;
  font: 450 13px/20px 'Inter', sans-serif; color: var(--odx-text); cursor: pointer;
}
.odx-menu a:hover, .odx-menu button:hover { background: #F1F1F1; }

/* ------------------------------ title block ------------------------------ */
.odx-page { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.odx-titlebar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 0; }
.odx-title { margin: 0; font: 650 24px/32px 'Inter', sans-serif; letter-spacing: -.01em; color: #1A1A1A; }
.odx-titlebar .badge {
  height: 24px; padding: 0 8px; border-radius: 8px; display: inline-flex; align-items: center; font: 450 12px/16px 'Inter', sans-serif;
}
.odx-sub { margin: 2px 0 0; font-size: 13px; line-height: 20px; color: var(--odx-text-2); }

/* ------------------------------ two columns ------------------------------ */
.odx-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; column-gap: 48px; align-items: start; margin-top: 17.5px; }
.odx-main { min-width: 0; }
.odx-sec { margin-top: 15px; }
#odItemsSec { margin-top: 29px; }
#odPaymentSec { margin-top: 30px; }
.odx-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; margin-bottom: 12px; }
/* 15px: measured 76dev for "Products" in the reference at 125% */
.odx-sec-head h2 { margin: 0; font: 500 15px/24px 'Inter', sans-serif; letter-spacing: 0; color: var(--odx-text); }
.odx-sec-actions { display: flex; align-items: center; gap: 8px; }

.odx-card {
  background: #fff; border: 1px solid var(--odx-border); border-radius: 16px; box-shadow: var(--odx-card-shadow); overflow: hidden;
}
.odx-pad { padding: 16px; overflow: visible; }
.odx-hint { margin: 8px 0 0; font-size: 12px; line-height: 16px; color: var(--odx-text-2); }
.odx-error { min-height: 0; margin-top: 8px; font-size: 12px; color: #B42318; }
.odx-error:empty { display: none; }
.odx-empty { padding: 20px 16px; text-align: center; color: var(--odx-text-2); }

/* ------------------------------ products card ------------------------------ */
.odx-item { display: flex; align-items: center; gap: 12px; padding: 16px; }
.odx-item + .odx-item { border-top: 1px solid var(--odx-hair); }
.odx-thumb { width: 40px; height: 40px; flex: none; border-radius: 8px; border: 1px solid var(--odx-border); object-fit: cover; background: #fff; }
.odx-item-info { flex: 1 1 auto; min-width: 0; margin-left: -4px; }
.odx-item-name { font-weight: 500; color: #1A1A1A; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odx-item-meta { display: flex; align-items: center; gap: 6px; margin-top: 1px; min-width: 0; }
.odx-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 6px; background: var(--odx-fill); color: var(--odx-text); font-size: 12px; line-height: 16px; font-weight: 450; white-space: nowrap; }
.odx-sku { color: var(--odx-text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odx-item-price { min-width: 84px; text-align: right; color: var(--odx-text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* quantity is read-only information, so it is plain text ("× 2"), not an input-looking box */
.odx-item-qty {
  min-width: 40px; flex: none; text-align: center; color: var(--odx-text-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.odx-item-qty span { opacity: .7; }
.odx-item-total { min-width: 88px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------ payment card ------------------------------ */
.odx-pay { padding: 12px 16px 14px; }
.odx-rows { display: block; }
.odx-row { display: grid; grid-template-columns: 31.6% minmax(0, 1fr) auto; align-items: center; min-height: 28px; column-gap: 12px; }
.odx-row-l { color: var(--odx-text); }
.odx-row-m { color: var(--odx-text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odx-row-r { text-align: right; color: var(--odx-text-2); font-variant-numeric: tabular-nums; }
.odx-row.is-total { margin-top: 0; }
.odx-row.is-total .odx-row-l, .odx-row.is-total .odx-row-r { font-weight: 650; color: #1A1A1A; }
.odx-divider { height: 1px; margin: 8px 0; background: var(--odx-hair); }
.odx-info-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 28px; }
.odx-info-row > span:first-child { color: var(--odx-text); }
.odx-info-row > span:last-child { color: var(--odx-text-2); text-align: right; min-width: 0; overflow-wrap: anywhere; }
.odx-payform { margin: 0; }
.odx-formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.odx-span { grid-column: 1 / -1; }
.odx-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* inputs (Shopify: 28px, 8px radius, hairline border + inset shade) */
.odx-field { margin: 0; }
.odx-field label { display: block; margin-bottom: 4px; font-size: 13px; line-height: 20px; font-weight: 450; color: var(--odx-text); }
.odx-field input, .odx-select select, .odx-comment textarea {
  font: 450 13px/20px 'Inter', sans-serif; color: var(--odx-text); background: #fff; outline: 0;
}
.odx-field input {
  width: 100%; height: 32px; padding: 0 12px; border: 0; border-radius: 8px; box-shadow: inset 0 0 0 1px #8A8A8A;
}
.odx-field input:focus { box-shadow: inset 0 0 0 2px #168A4E; }
.odx-field input::placeholder, .odx-comment textarea::placeholder { color: var(--odx-text-2); }
.odx-editform .odx-field + .odx-field { margin-top: 8px; }

/* ------------------------------ timeline ------------------------------ */
.odx-comment { overflow: hidden; }
.odx-comment-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; }
.odx-avatar {
  flex: none; width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  font: 550 14px/1 'Inter', sans-serif; color: #fff; background: linear-gradient(180deg, #00A3D2, #3CC3EE);
}
.odx-comment textarea { flex: 1 1 auto; min-height: 36px; max-height: 160px; padding: 8px 0; border: 0; resize: none; overflow: auto; }
.odx-comment-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 6px 16px; background: #FAFAFA; }
.odx-comment-hint { font-size: 12px; line-height: 16px; color: var(--odx-text-2); }
.odx-timeline { list-style: none; margin: 16px 0 0; padding: 0 0 0 4px; }
.odx-ev { position: relative; display: flex; gap: 14px; padding: 0 0 16px; }
.odx-ev:not(:last-child)::before { content: ''; position: absolute; left: 4px; top: 14px; bottom: -2px; width: 1px; background: var(--odx-border); }
.odx-ev-dot { flex: none; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px #8A8A8A; position: relative; z-index: 1; }
.odx-ev-body { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.odx-ev-msg { color: var(--odx-text); }
.odx-ev-time { color: var(--odx-text-2); font-size: 12px; white-space: nowrap; }
.odx-ev-note .odx-ev-body { display: block; }
.odx-note { padding: 12px 16px; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px var(--odx-border); }
.odx-note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.odx-note-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 12px; line-height: 16px; color: var(--odx-text-2); }
.odx-note-del { width: 24px; height: 24px; opacity: .6; }
.odx-note-del .odx-ico { width: 16px; height: 16px; }
.odx-note:hover .odx-note-del { opacity: 1; }

/* ------------------------------ side column ------------------------------ */
.odx-aside { margin-top: 2px; }
.odx-side-card {
  padding: 0 16px; background: #fff; border: 1px solid var(--odx-border); border-radius: 16px;
  box-shadow: var(--odx-card-shadow);
}
.odx-side-sec { padding: 16px 0; border-top: 1px solid var(--odx-hair); }
.odx-side-sec:first-child { border-top: 0; }
.odx-side-head { display: flex; align-items: center; justify-content: space-between; min-height: 28px; margin-bottom: 8px; }
.odx-side-head h3 { margin: 0; font: 550 13px/20px 'Inter', sans-serif; color: var(--odx-text-2); }
.odx-side-head .odx-icon-btn { margin-right: -6px; }
.odx-lines > div { color: var(--odx-text); }
.odx-lines .odx-strong { font-weight: 450; }
.odx-lines .odx-muted { color: var(--odx-text-2); }
.odx-lines .odx-gap { margin-top: 8px; }
.odx-link, #view-order-detail .odx a.odx-link { color: var(--odx-link); }
.odx-link:hover { text-decoration: underline !important; }
.odx-select { position: relative; }
.odx-select select {
  appearance: none; -webkit-appearance: none; width: 100%; height: 30px; padding: 0 32px 0 12px; border: 0; border-radius: 8px;
  box-shadow: inset 0 0 0 1px #CFCFCF, 0 1px 0 rgba(0, 0, 0, .04); cursor: pointer;
}
.odx-select select:focus-visible { box-shadow: inset 0 0 0 2px #168A4E; }
.odx-select .odx-select-ico { position: absolute; right: 8px; top: 5px; width: 20px; height: 20px; color: var(--odx-text-2); pointer-events: none; }

/* ------------------------------ phones ------------------------------ */
@media (max-width: 860px) {
  #view-order-detail { margin: 0 -14px; }
  .odx-grid { grid-template-columns: minmax(0, 1fr); row-gap: 24px; }
  .odx-title { font-size: 20px; line-height: 28px; }
  .odx-item { flex-wrap: wrap; row-gap: 8px; }
  .odx-item-info { flex-basis: calc(100% - 52px); }
  .odx-item-price { margin-left: auto; min-width: 0; }
  .odx-item-qty { min-width: 0; }
  .odx-item-total { min-width: 0; }
  .odx-row { grid-template-columns: minmax(0, 1fr) auto; }
  .odx-row-m { display: none; }
  .odx-formgrid { grid-template-columns: 1fr; }
  .odx-menu-right { right: 0; }
  .odx-top-actions .odx-pill-group { display: none; }
}
@media (prefers-reduced-motion: reduce) { .odx-pill { transition: none; } }

/* refund history rows inside the Void & refund card */
.odx-pad .kv-row { padding: 6px 0; font-size: 13px; line-height: 20px; border-bottom: 1px solid var(--odx-hair); }
.odx-pad .kv-row .k { color: var(--odx-text-2); }
.odx-pad .kv-row .v { font-weight: 450; color: var(--odx-text); }
.odx-pad .sub { font-size: 12px; color: var(--odx-text-2); }


/* ------------------------------ polish ------------------------------ */
/* Desktop: the page header already has a back button (.ax-back), so the in-page
   round back arrow is phone-only; the "POS Sales / Orders" crumb is now a link. */
@media (min-width: 861px) {
  .odx-back { display: none; }
  .odx-top { padding-top: 6px; }
  /* start the side card level with the first main card (title block + section heading) */
  .odx-aside { margin-top: 69px; }
}
#view-order-detail .odx a.odx-crumb { text-decoration: none; }
#view-order-detail .odx a.odx-crumb:hover { color: var(--odx-text); text-decoration: underline; }
.odx-item-name { font-weight: 550; }


/* ------------------------------ loading skeleton ------------------------------ */
/* #view-order-detail is pulled up/out with negative margins so .odx can run edge to edge
   (see top of file). The shared page skeleton (.view-skel, admin.css) lives in the same
   box, so it inherited that pull: it slid under the page header (clipping the back
   button) and touched both edges. Give it the same centred column + padding as
   .odx-page, start it below the header row, and use this page's 2-column proportions. */
#view-order-detail > .view-skel {
  max-width: 1120px; margin: 0 auto; padding: 68px 16px 40px; box-sizing: border-box;
}
#view-order-detail > .view-skel .sk-card { border-radius: 16px; }
@media (min-width: 861px) {
  #view-order-detail > .view-skel .sk-g2 { grid-template-columns: minmax(0, 1fr) 280px; column-gap: 48px; }
}
