/* ==========================================================================
   Taha Auto admin: Scan a shelf (js/inventory-scan.js). A sheet on the phone,
   a dialog on a computer, built on admin.css's .modal: photos and a note, the
   reading state, then the review (one card per product it counted, what it'll
   do to inventory, Apply). Tokens only, so every look (navy, glass, classic)
   and a custom accent carry through; the navy tweaks sit at the bottom.
   ========================================================================== */
#scan-modal .iscan__box { display: flex; flex-direction: column; gap: 12px; max-height: min(90dvh, 940px); overflow: hidden; }
#scan-modal .iscan__box:focus { outline: none; }
#scan-modal .iscan__box.is-drop { border-color: var(--accent-ui); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .25); }
.iscan__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; align-content: start; gap: 14px; margin: 0 -4px; padding: 2px 4px 8px; }
.iscan__foot { flex: none; align-items: center; margin: 0; padding-top: 10px; border-top: 1px solid var(--line); }
.iscan__foot .btn svg { width: 16px; height: 16px; }
.iscan [hidden] { display: none !important; }
.iscan p { margin: 0; }
.iscan__intro { line-height: 1.45; }

/* ---------- 1. photos ---------- */
.iscan__drop { position: relative; display: grid; justify-items: center; align-content: center; gap: 6px; min-height: 168px; padding: 20px 16px; border: 1.5px dashed var(--line-3); border-radius: 18px; background: var(--panel); color: var(--text); text-align: center; cursor: pointer; }
.iscan__drop b { font-size: 16px; font-weight: 700; }
.iscan__drop small { font-size: 13px; color: var(--text-2); }
.iscan__drop-ic { width: 52px; height: 52px; padding: 13px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 22px rgba(var(--accent-rgb), .28); }
.iscan__drop:hover { border-color: var(--accent-ui); }
.iscan__drop:focus-within, .iscan__shot--add:focus-within, .iscan__pick:focus-within { outline: 2px solid var(--accent-ui); outline-offset: 2px; }
.iscan__drop input, .iscan__shot--add input, .iscan__pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.iscan__shots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.iscan__shot { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; }
.iscan__shot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.iscan__shot--add { gap: 2px; align-content: center; border: 1.5px dashed var(--line-3); background: var(--panel); color: var(--accent-text); cursor: pointer; overflow: visible; }
.iscan__shot--add svg { width: 22px; height: 22px; }
.iscan__shot--add small { font-size: 12.5px; font-weight: 650; }
/* remove: a 44px target in the corner, drawn as a small dark circle */
.iscan__rm { position: absolute; top: 0; right: 0; width: 44px; height: 44px; display: grid; place-items: start end; padding: 5px; background: none; border: 0; cursor: pointer; }
.iscan__rm span { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, .66); color: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); }
.iscan__rm svg { width: 14px; height: 14px; }
.iscan__rm:focus-visible { outline: none; }
.iscan__rm:focus-visible span { box-shadow: 0 0 0 2px var(--accent-ui); }
.iscan__spin { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent-ui); animation: iscan-spin .8s linear infinite; }
@keyframes iscan-spin { to { transform: rotate(360deg); } }
.iscan__shotwrap { display: grid; gap: 10px; min-width: 0; }   /* the tiles, From library and the count, spaced like the rest of the body */
.iscan__adds { display: flex; flex-wrap: wrap; gap: 8px; }
.iscan__pick { position: relative; overflow: hidden; min-height: 44px; padding: 10px 16px; }
.iscan__note textarea { min-height: 64px; resize: vertical; }
.iscan__note label small { color: var(--text-3); font-weight: 500; }
.iscan__tips { display: grid; gap: 4px; margin: 0; padding-left: 18px; line-height: 1.4; }

/* ---------- 2. reading ---------- */
.iscan__work { position: relative; display: grid; justify-items: center; gap: 12px; padding: 18px 0 8px; text-align: center; }
.iscan__strip { position: relative; display: flex; justify-content: center; gap: 8px; }
.iscan__mini { width: 72px; height: 72px; flex: none; border-radius: 12px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); }
.iscan__mini img { display: block; width: 100%; height: 100%; object-fit: cover; }
.iscan__strip--work .iscan__mini { width: 84px; height: 84px; }
.iscan__strip--sm { justify-content: flex-start; }
.iscan__strip--sm .iscan__mini { width: 44px; height: 44px; border-radius: 9px; }
/* the light that runs down the photos while it reads (transform only; still with Reduce Motion) */
.iscan__beam { position: absolute; top: 0; left: -8px; right: -8px; height: 3px; border-radius: 3px; background: var(--accent-ui); box-shadow: 0 0 14px 3px rgba(var(--accent-rgb), .55); animation: iscan-beam 1.6s cubic-bezier(.45, 0, .55, 1) infinite alternate; pointer-events: none; }
@keyframes iscan-beam { from { transform: translateY(0); } to { transform: translateY(81px); } }
.iscan__state { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; }
.iscan__state svg { width: 18px; height: 18px; color: var(--accent-text); }

/* ---------- 3a. errors ---------- */
.iscan__err { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px; border-radius: 14px; border: 1px solid var(--danger); background: rgba(229, 72, 77, .08); }
.iscan__err-ic { width: 36px; height: 36px; padding: 9px; border-radius: 10px; background: rgba(229, 72, 77, .16); color: var(--danger-text); }
.iscan__err b { display: block; font-size: 15.5px; line-height: 1.35; }
.iscan__err p { margin-top: 4px; font-size: 14px; line-height: 1.45; color: var(--text-2); }
.iscan [data-scan-login] .ai__msg { max-width: none; }

/* ---------- 3b. the review ---------- */
.iscan__sum { display: grid; gap: 8px; }
.iscan__found { font-size: 15px; color: var(--text-2); }
.iscan__found b { color: var(--text); font-size: 16px; }
.iscan__age { color: var(--warn-text); font-weight: 600; }
.iscan__sum .hint { line-height: 1.45; }
.iscan__warn { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--warn); background: rgba(245, 189, 81, .08); color: var(--warn-text); font-size: 14px; line-height: 1.4; }
.iscan__how { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.iscan__how legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.iscan__how .hint { line-height: 1.4; }
/* a segmented control: real radios (keyboard and screen readers), the label is the 44px target */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 2px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel); }
.seg label { position: relative; display: grid; min-width: 0; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: grid; place-items: center; min-height: 44px; padding: 4px 8px; border-radius: 10px; font-size: 14px; font-weight: 650; line-height: 1.2; text-align: center; color: var(--text-2); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.seg input:focus-visible + span { outline: 2px solid var(--accent-ui); outline-offset: 1px; }
.seg input:disabled { cursor: not-allowed; }
.seg input:disabled + span { opacity: .4; }
@media (hover: hover) { .seg input:not(:checked):not(:disabled):hover + span { color: var(--text); background: rgba(255, 255, 255, .04); } }

.iscan__rows { display: grid; gap: 10px; }
/* a card: tick and name on the first line, everything else full width under it */
.scard { position: relative; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding: 10px 12px 12px 4px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); transition: opacity var(--dur-small, 180ms) ease; }
.scard > * { flex: 1 1 100%; min-width: 0; margin: 0; }
.scard > :not(.scard__tick):not(.scard__name) { margin-left: 8px; }
.scard.is-low { border-color: var(--warn); }
.scard.is-err { border-color: var(--danger); }
.scard.is-off { opacity: .55; }
.scard.is-done { opacity: .72; }
.scard__tick { flex: 0 0 44px; height: 46px; display: grid; place-items: center; cursor: pointer; }
.scard__tick input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.scard__name { flex: 1 1 0; }
#scan-modal textarea.scard__name { min-height: 46px; height: 46px; padding: 11px 12px; resize: none; overflow: hidden; font: inherit; font-size: 16px; font-weight: 650; line-height: 1.3; }
.scard__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: -2px !important; font-size: 13px; color: var(--text-2); }
.scard__meta [data-sec] { display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-weight: 600; }
.scard__g { width: 18px; height: 18px; flex: none; color: var(--text-2); }
.scard__meta .st { font-size: 10.5px; padding: 2px 7px; }
.scard__conf { color: var(--warn-text); }
.scard__nums { display: flex; gap: 8px; }
.scard__f { display: grid; gap: 4px; min-width: 0; }
.scard__f > span { font-size: 12px; font-weight: 600; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#scan-modal .scard__f .og-input, #scan-modal .scard__to { width: 100%; min-height: 44px; font-size: 16px; }
.scard__f--n { flex: 0 0 84px; }
.scard__f--u { flex: 1 1 0; }
.scard__f--amt { flex: 0 0 100px; }
.scard__f--n .og-input, .scard__f--amt .og-input { text-align: right; font-variant-numeric: tabular-nums; }
.scard__f--amt.is-guess > span { color: var(--warn-text); }
.scard__f--amt.is-guess .og-input { border-color: var(--warn); }
.scard__how { padding: 0; border: 0; }
.scard__loose { flex: 0 1 auto !important; min-height: 44px; margin-top: -6px !important; padding: 0 2px; background: none; border: 0; color: var(--accent-text); font: inherit; font-size: 14px; font-weight: 650; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.scard__out { font-size: 14.5px; line-height: 1.4; color: var(--text); }
.scard__out b { font-variant-numeric: tabular-nums; }
.scard__out .sub { color: var(--text-2); font-size: 13px; }
.scard__need { color: var(--warn-text); font-weight: 600; }
.scard__ok { width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; color: var(--ok-text); }
.scard__note, .scard__why { margin-top: -4px !important; font-size: 13px; line-height: 1.4; color: var(--text-2); }
.scard__note { color: var(--text); }
.scard.is-low .scard__note { color: var(--warn-text); }
.scard__why::before { content: "Why: "; color: var(--text-3); }
.scard__err { font-size: 13.5px; font-weight: 600; color: var(--danger-text); }
.iscan__unread { display: grid; gap: 6px; padding: 12px 14px; border-radius: 14px; border: 1px dashed var(--line-2); }
.iscan__unread h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.iscan__unread ul { display: grid; gap: 4px; margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.4; color: var(--text-2); }
.iscan__cost { text-align: center; font-size: 12.5px; }

/* a computer: the photo row and the review side by side where there's room */
@media (min-width: 721px) {
  #scan-modal .iscan__box { width: min(760px, 100%); }
  .iscan__shots { grid-template-columns: repeat(4, minmax(0, 132px)); }
  /* count and unit beside what to do with it; the item (or the section) beside what that does */
  .scard__nums { flex: 1 1 300px; }
  .scard__how { flex: 1 1 300px; align-self: end; }
  .scard__to, .scard__f--c { flex: 1 1 300px; }
}
@media (max-width: 720px) {
  #scan-modal .iscan__box { max-height: 94dvh; }
  #scan-modal .iscan__box .sheet__head { position: static; }   /* the box doesn't scroll; its body does */
  .iscan__foot .grow, .iscan__close { display: none; }
  .iscan__work { padding-top: 26px; }
}
/* a narrow phone (320): "In qt" gets its own line so the unit it was counted in reads in full */
@media (max-width: 360px) {
  .scard__nums { flex-wrap: wrap; }
  .scard__f--amt { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .iscan__beam { animation: none; transform: translateY(41px); opacity: .7; }
  .iscan__spin { animation-duration: 2.4s; }
  .scard { transition: none; }
}

/* ---------- navy (the phone design) ---------- */
body.theme-navy .iscan__drop, body.theme-navy .iscan__shot--add { background: #0E1A26; border-color: #3A506A; }
body.theme-navy .iscan__shot, body.theme-navy .iscan__mini { background: #172838; border-color: #203346; }
body.theme-navy .scard { background: linear-gradient(135deg, #132230, #0F1B27); border-color: #203346; }
body.theme-navy .scard.is-low { border-color: #705725; }
body.theme-navy .scard.is-err { border-color: #6B2A2D; }
body.theme-navy .seg { background: #0C1721; border-color: #2A3C4F; }
body.theme-navy .iscan__warn { border-color: #705725; background: #241E12; color: #F5BD51; }
body.theme-navy .iscan__err { border-color: #6B2A2D; background: #1E1215; }
body.theme-navy .iscan__unread { border-color: #2A3C4F; }
body.theme-navy .iscan__foot { border-top-color: #203346; }
