/*!
 * AWMS – Item Scan (PICK / PACK / PickFlow) and its popups.
 * Loaded after awm-theme.css. Uses the theme tokens (--t-*).
 */

/* ---------- One popup at a time on scanner pages ---------- */
/* Toasts never stack on top of each other while scanning: only the newest is shown. */
:root body.awm-scanner-page #toast .toast:not(:last-child){display:none!important}
:root body #awmPickVerifyLoader.gs-verify-progress{position:static!important;width:auto!important;margin:8px 0 0;padding:10px 12px!important;border:1px solid var(--t-line)!important;border-radius:var(--t-r)!important;background:var(--t-surface-2)!important;box-shadow:none!important;font-size:13px}
:root body #awmPickVerifyLoader.gs-verify-progress b{font-size:13px;color:var(--t-text)}
/* The global loader always sits above an open popup instead of behind/beside it. */
:root body #awmGlobalLoader{z-index:100000!important}

/* ---------- Shared bits ---------- */
:root body .gs-copy{display:inline-grid;place-items:center;flex:0 0 auto;width:28px;height:28px;margin-left:4px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--t-muted);cursor:pointer;vertical-align:middle}
:root body .gs-copy:hover{background:var(--t-surface-3);color:var(--t-brand-700)}
:root body .gs-copy:focus-visible,:root body .gs-info-btn:focus-visible{outline:0;box-shadow:var(--t-ring)}
:root body .gs-copy svg,:root body .gs-copy i{width:14px;height:14px;font-size:13px}
:root body .count-pop{animation:gs-pop .35s var(--t-ease)}
@keyframes gs-pop{0%{transform:scale(1)}40%{transform:scale(1.18)}100%{transform:scale(1)}}

/* Missing reason: dropdown + "Other" text */
:root body .awm-reason-field{display:flex;flex-direction:column;gap:6px;min-width:0}
:root body .awm-reason-field .input{width:100%;min-height:42px}
:root body .awm-reason-other[hidden]{display:none!important}

/* ---------- Item Scan step ---------- */
:root body .gs .gs-head{display:flex;align-items:center;gap:10px}
:root body .gs .gs-head .guided-skip-btn{margin-left:auto}
:root body .gs .location-step .gs-loc-meta{display:block;margin-top:4px;font-style:normal;font-size:12.5px;opacity:.85}
:root body .gs .gs-loc{display:flex!important;align-items:center;justify-content:space-between;gap:10px;flex-wrap:nowrap!important}
:root body .gs .gs-loc-text{display:flex;align-items:baseline;gap:10px;min-width:0;flex-wrap:wrap}
:root body .gs .gs-loc-text strong{overflow-wrap:anywhere}
:root body .gs .gs-item{display:grid!important;grid-template-columns:120px minmax(0,1fr)!important;gap:16px!important;align-items:start}
:root body .gs .gs-img .item-with-img{width:120px;height:120px}
:root body .gs .gs-img img{width:100%;height:100%;object-fit:contain}
:root body .gs .gs-info{min-width:0}
:root body .gs .gs-name{display:flex;align-items:flex-start;gap:2px;margin-bottom:8px}
:root body .gs .gs-name h2{margin:0!important;font-size:18px!important;line-height:1.3!important;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
:root body .gs .gs-codes{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 16px;margin:0}
:root body .gs .gs-code{min-width:0;margin:0}
:root body .gs .gs-code dt{font-size:10.5px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--t-muted);margin:0}
:root body .gs .gs-code dd{display:flex;align-items:center;min-width:0;margin:0;min-height:28px}
:root body .gs .gs-code dd b,:root body .gs .gs-code dd code{font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
:root body .gs .gs-code dd code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:none;padding:0;color:var(--t-text)}
:root body .gs .gs-avail{position:relative}
:root body .gs .gs-avail .guided-available-value{display:inline-flex;align-items:center;min-width:36px;padding:2px 10px;border-radius:999px;background:#ecfdf5;color:#067647;font-weight:700}
:root body .gs-info-btn{display:inline-grid;place-items:center;width:30px;height:30px;margin-left:6px;padding:0;border:1px solid var(--t-brand-100);border-radius:50%;background:var(--t-brand-50);color:var(--t-brand-700);cursor:pointer}
:root body .gs-info-btn svg,:root body .gs-info-btn i{width:16px;height:16px;font-size:15px}
:root body .gs-info-btn[aria-expanded="true"]{background:var(--t-brand);color:#fff;border-color:var(--t-brand)}

/* Availability popover (tooltip under the info icon) */
:root body .gs-pop{position:absolute;z-index:60;left:0;top:calc(100% + 6px);width:min(320px,calc(100vw - 32px));border:1px solid var(--t-line);border-radius:var(--t-r-lg);background:#fff;box-shadow:var(--t-sh-lg);overflow:hidden}
:root body .gs-pop-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 12px;border-bottom:1px solid var(--t-line);font-size:13px}
:root body .gs-pop-x{width:28px;height:28px;border:0;border-radius:8px;background:transparent;color:var(--t-muted);font-size:18px;cursor:pointer}
:root body .gs-pop-x:hover{background:var(--t-surface-3)}
:root body .gs-pop-body{max-height:260px;overflow:auto}
:root body .gs-pop-loading,:root body .gs-pop-empty{display:flex;align-items:center;gap:8px;padding:14px 12px;font-size:13px;color:var(--t-muted)}
:root body .gs-pop-empty.bad{color:#b42318}
:root body .gs-pop-list{list-style:none;margin:0;padding:4px 0}
:root body .gs-pop-list li{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:7px 12px;font-size:13.5px}
:root body .gs-pop-list li + li{border-top:1px solid var(--t-surface-3)}
:root body .gs-pop-list li.is-current{background:#ecfdf5}
:root body .gs-pop-list li em{font-style:normal;font-size:11px;font-weight:700;color:#067647;margin-left:6px}
:root body .gs-pop-list li b{font-variant-numeric:tabular-nums}
:root body .gs-pop-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 12px;border-top:1px solid var(--t-line);background:var(--t-surface-2);font-size:12px;color:var(--t-muted)}
:root body .gs-link{border:0;background:none;padding:2px 0;font-size:12.5px;font-weight:600;color:var(--t-brand-700);cursor:pointer}

/* Quantities: this item here + whole order */
:root body .gs .gs-qty{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:10px 0 2px}
:root body .gs .gs-qty-label{font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--t-muted)}
:root body .gs .gs-qty .qty-pills{margin:0!important}
:root body .gs-order{margin:10px 0 4px;padding:10px 12px;border:1px solid var(--t-line);border-radius:var(--t-r);background:var(--t-surface-2)}
:root body .gs-order-head{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:6px}
:root body .gs-order-head span{font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--t-muted)}
:root body .gs-order-head b{font-size:14px;color:var(--t-text)}
:root body .gs-order .progress{margin:0!important}
:root body .gs-order-text{margin-top:6px;font-size:12.5px;color:var(--t-text-2)}
:root body .gs-missing{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:start;margin-top:10px}
:root body .gs-missing .btn{min-height:42px;white-space:nowrap}

/* ---------- Order List / Picked List / D365 locations ---------- */
:root body .ol-tools{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:10px}
:root body .ol-tools .searchbox{flex:1 1 260px;min-width:0}
:root body .ol-filter{display:inline-flex;gap:4px;padding:3px;border-radius:999px;background:var(--t-surface-3)}
:root body .ol-filter button{border:0;background:transparent;border-radius:999px;padding:6px 12px;font-size:12.5px;font-weight:600;color:var(--t-text-2);cursor:pointer;white-space:nowrap}
:root body .ol-filter button.active{background:#fff;color:var(--t-text);box-shadow:var(--t-sh-xs)}
:root body .ol-list,:root body .pl-list,:root body .dl-list{display:flex;flex-direction:column;border:1px solid var(--t-line);border-radius:var(--t-r-lg);overflow:hidden}
:root body .ol-row{display:grid;grid-template-columns:minmax(120px,170px) minmax(0,1fr) minmax(250px,300px) 110px;gap:12px;align-items:center;padding:10px 12px;border-top:1px solid var(--t-line);background:#fff}
:root body .ol-row[hidden]{display:none}
:root body .ol-row:first-child,:root body .ol-headrow + .ol-row{border-top:0}
:root body .ol-headrow{background:var(--t-surface-2);font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--t-muted);border-bottom:1px solid var(--t-line)}
:root body .ol-row.is-current{background:var(--t-brand-50)}
:root body .ol-row[data-state="done"]{background:var(--t-surface-2)}
:root body .ol-loc{display:flex;flex-direction:column;align-items:flex-start;gap:3px;min-width:0}
:root body .ol-loc b{font-size:13.5px;overflow-wrap:anywhere}
:root body .ol-loc small{font-size:11px;color:var(--t-muted)}
:root body .ol-item{display:flex;flex-direction:column;gap:2px;min-width:0}
:root body .ol-name{font-size:13.5px;line-height:1.3;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
:root body .ol-meta{display:flex;align-items:center;flex-wrap:wrap;gap:0 4px;font-size:12px;color:var(--t-muted);min-width:0}
:root body .ol-meta code{font-size:12px;background:none;padding:0;color:var(--t-text-2)}
:root body .ol-meta .gs-copy{width:24px;height:24px;margin-left:0}
:root body .ol-qty{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;text-align:center}
:root body .ol-qty span{display:flex;flex-direction:column;align-items:center;gap:1px}
:root body .ol-qty small{display:none;font-size:10px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--t-muted)}
:root body .ol-qty b{font-size:14px;font-variant-numeric:tabular-nums}
:root body .ol-qty .is-missing b{color:#b42318}
:root body .ol-qty .ol-left b{color:var(--t-brand-700)}
:root body .ol-act{display:flex;justify-content:flex-end}
:root body .ol-empty{padding:18px 12px;color:var(--t-muted);text-align:center;font-size:13px}
:root body .pl-stats{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 10px}
:root body .pl-stats span{display:flex;flex-direction:column;gap:2px;flex:1 1 110px;padding:8px 12px;border:1px solid var(--t-line);border-radius:var(--t-r);background:var(--t-surface-2)}
:root body .pl-stats small{font-size:11px;font-weight:600;color:var(--t-muted)}
:root body .pl-stats b{font-size:18px}
:root body .pl-row{display:flex;align-items:center;gap:12px;padding:10px 12px;border-top:1px solid var(--t-line);background:#fff}
:root body .pl-row:first-child{border-top:0}
:root body .pl-main{display:flex;flex-direction:column;gap:2px;flex:1 1 auto;min-width:0}
:root body .pl-qty{display:flex;flex-direction:column;align-items:center;flex:0 0 auto;min-width:48px}
:root body .pl-qty small{font-size:10px;font-weight:700;text-transform:uppercase;color:var(--t-muted)}
:root body .pl-qty b{font-size:18px}
:root body .dl-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 12px;border-top:1px solid var(--t-line);background:#fff;font-size:13.5px}
:root body .dl-row:first-child{border-top:0}
:root body .dl-row > div{display:flex;align-items:center;flex-wrap:wrap;gap:4px 8px;min-width:0}
:root body .dl-row small{color:var(--t-muted);font-size:11.5px}
:root body .dl-row.is-current{background:#ecfdf5}
:root body .dl-headrow{background:var(--t-surface-2);font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--t-muted)}
:root body .dl-qty{font-variant-numeric:tabular-nums}
:root body .dl-qty.zero{color:var(--t-faint)}

/* PICK completion details */
:root body .completed-job-details td.cd-item{min-width:220px}
:root body .completed-job-details td.cd-item b{display:block;font-weight:600}
:root body .completed-job-details td.cd-item .muted{display:block;font-size:12px}

/* Missing quantity popup */
:root body .mm-body{display:flex;flex-direction:column;gap:6px}
:root body .mm-qty{display:flex;align-items:center;justify-content:center;gap:12px;margin:6px 0 12px}
:root body .mm-qty .btn{min-width:52px;min-height:48px;font-size:22px}
:root body .mm-qty .input{max-width:140px;text-align:center;font-size:22px;font-weight:800;min-height:48px}
:root body .mm-note{font-size:12px;margin-top:4px}
:root body .mm-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}

/* ---------- Phones ---------- */
@media (max-width:780px){
  /* Scanner pages get the whole screen: no chat button, no bottom tab bar, no org/warehouse pickers
     (switching those in the middle of a job is not wanted anyway). */
  :root body.awm-scanner-page .aw-assist{display:none!important}
  :root body.awm-scanner-page .t-tabbar{display:none!important}
  :root body.awm-scanner-page .topbar .org-switcher{display:none!important}
  :root body.awm-scanner-page #toast{top:calc(8px + env(safe-area-inset-top,0px))!important;bottom:auto!important}
  :root body.awm-scanner-page .main,:root body.awm-scanner-page #view{padding-bottom:16px!important}
  :root body.awm-scanner-page .page{padding-top:8px!important}
  :root body.awm-scanner-page .guided-topbar,:root body.awm-scanner-page .pick-top{gap:6px!important;margin-bottom:6px!important}
  :root body.awm-scanner-page .scanner-order-head h1,:root body.awm-scanner-page .guided-order-head h1{font-size:18px!important;margin:0!important}
  :root body.awm-scanner-page .scanner-order-head{margin-bottom:6px!important}
  :root body.awm-scanner-page .scanner-order-head svg{display:none}

  :root body .gs .guided-stage{padding:10px!important}
  :root body .gs .gs-loc{padding:8px 10px!important}
  :root body .gs .gs-loc-text span{font-size:10px}
  :root body .gs .gs-loc-text strong{font-size:17px!important}
  :root body .gs .gs-item{grid-template-columns:72px minmax(0,1fr)!important;gap:10px!important;padding:10px!important}
  :root body .gs .gs-img .item-with-img{width:72px;height:72px}
  :root body .gs .gs-name h2{font-size:15px!important;-webkit-line-clamp:2}
  :root body .gs .gs-codes{grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:4px 10px}
  :root body .gs .gs-code dd b,:root body .gs .gs-code dd code{font-size:13px}
  :root body .gs .gs-avail{grid-column:1/-1}
  :root body .gs .gs-qty{margin-top:8px}
  :root body .gs .gs-qty .qty-pills{display:grid!important;grid-template-columns:repeat(3,1fr);width:100%}
  :root body .gs .gs-qty .qty-pills em{width:auto!important;height:auto!important;border-radius:12px!important;padding:6px 4px!important}
  :root body .gs .scan-search input.scan-big{font-size:16px!important;min-height:48px!important}
  :root body .gs-missing{grid-template-columns:1fr}
  :root body .gs-missing .btn{width:100%}
  :root body .gs-pop{position:fixed;left:12px;right:12px;top:auto;bottom:12px;width:auto}

  /* Lists in popups become compact cards */
  :root body .ol-headrow,:root body .dl-headrow{display:none!important}
  :root body .ol-row{grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"loc act" "item item" "qty qty";gap:6px 10px;padding:10px}
  :root body .ol-loc{grid-area:loc;flex-direction:row;align-items:center;flex-wrap:wrap;gap:6px}
  :root body .ol-item{grid-area:item}
  :root body .ol-qty{grid-area:qty;gap:4px}
  :root body .ol-qty span{padding:4px 2px;border-radius:8px;background:var(--t-surface-2)}
  :root body .ol-qty small{display:block}
  :root body .ol-act{grid-area:act}
  :root body .ol-tools .searchbox{flex-basis:100%}
  :root body .ol-filter{flex:1 1 auto}
  :root body .ol-filter button{flex:1 1 0;padding:6px 8px}
  :root body .scanner-row-count{display:none}
  :root body .mm-actions{display:grid;grid-template-columns:1fr 1fr}

  /* Keep the words on scanner buttons – icons alone (back arrow, shuffle, list) were guesswork. */
  :root body.awm-scanner-page .pick-top .ux-has-text > ux-t,
  :root body .mm-actions .ux-has-text > ux-t,
  :root body .gs-missing .ux-has-text > ux-t,
  :root body .ol-act .ux-has-text > ux-t,
  :root body .gs .guided-switch-another .ux-has-text > ux-t{display:inline!important}
  :root body.awm-scanner-page .pick-top .ux-has-text,
  :root body .mm-actions .ux-has-text,
  :root body .gs-missing .ux-has-text,
  :root body .ol-act .ux-has-text{gap:6px!important;padding-left:10px!important;padding-right:10px!important}
  :root body.awm-scanner-page .pick-top{display:grid!important;grid-template-columns:auto 1.25fr 1fr;align-items:stretch}
  :root body.awm-scanner-page .pick-top .btn{min-height:40px!important;font-size:12.5px!important;white-space:normal!important;line-height:1.15!important;text-align:center}
  :root body.awm-scanner-page .pick-top .btn ux-t{white-space:normal!important}
  :root body.awm-scanner-page .pick-last-suggested{font-size:11px!important;margin-top:2px}
  :root body.awm-scanner-page .pick-last-suggested .badge{display:none!important}
  /* PACK: readable buttons, less explanation text, box sizes two per row */
  :root body.awm-scanner-page .box-create .ux-has-text > ux-t,
  :root body.awm-scanner-page .close-box-text-btn > ux-t,
  :root body.awm-scanner-page .pack-complete-panel .ux-has-text > ux-t{display:inline!important}
  :root body.awm-scanner-page .box-create .btn,:root body.awm-scanner-page .close-box-text-btn{width:100%;gap:6px!important}
  :root body.awm-scanner-page .guided-pack-open-scan .guided-pack-open-icon,:root body.awm-scanner-page .guided-pack-open-scan p{display:none!important}
  :root body.awm-scanner-page .guided-pack-open-scan{padding:10px!important}
  :root body.awm-scanner-page .guided-pack-open-scan h2{font-size:15px!important;margin:0 0 8px!important}
  :root body.awm-scanner-page .guided-pack-viewport .grid2,:root body.awm-scanner-page .guided-completion .grid2{display:grid!important;grid-template-columns:1fr 1fr!important;gap:8px!important}
  :root body.awm-scanner-page .guided-pack-viewport .grid2 label,:root body.awm-scanner-page .guided-completion .grid2 label{font-size:12px}
  :root body .gs .gs-codes{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
  :root body .gs .gs-code:nth-child(3),:root body .gs .gs-code:nth-child(4){grid-column:1/-1}
  :root body .gs .gs-code dd{min-height:24px}
}

/* ---------- Read-only users (AWS_ALL_Viewer): show everything, hide what changes data ---------- */
:root body.awm-viewer .card:has(> form[onsubmit^="createTJ"]),
:root body.awm-viewer section:has(> form[onsubmit^="createPF"]),
:root body.awm-viewer .tj-page .guided-scanner .scan-search,
:root body.awm-viewer .tj-page .guided-scanner .scan-actions,
:root body.awm-viewer .tj-page .guided-scanner .gs-missing,
:root body.awm-viewer .tj-page .guided-scanner .guided-actions,
:root body.awm-viewer button[onclick^="deletePF"],
:root body.awm-viewer button[onclick^="deleteTJ"],
:root body.awm-viewer button[onclick^="startPF"],
:root body.awm-viewer button[onclick^="createTJ"]{display:none!important}
:root body.awm-viewer .tj-page .guided-scanner::before{content:"Read-only view – scanning and changes are disabled for your role.";display:block;margin:0 0 10px;padding:8px 12px;border-radius:var(--t-r);background:var(--t-surface-2);border:1px solid var(--t-line);font-size:12.5px;color:var(--t-text-2)}
