/* #588: the layout of the computer scan page (scan.html since 23 Nov 2026; tried as scan_beta.html from 19 Nov).
   Every rule is scoped to body.scan-layout; scan_classic.html (the previous layout, kept for a week) does not load
   this file. Some rules need !important: the shared scripts write inline sizes, margins and displays meant for the
   previous layout (adaptToWebcamSize, responsiveConfig, startPage). A display that a script switches on and off is never
   forced here, so the scripts keep deciding what shows. */

/* ---- the panel ---------------------------------------------------------------------------------------------- */
body.scan-layout #mainContainer.sb-shell {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 0 !important;
  box-sizing: border-box;
  margin: 2px 16px 12px !important;
  padding: 12px 16px 14px !important;
  height: calc(100vh - var(--gestic-topbar-h, 60px) - 14px);
  min-height: 520px;
  background: #fff;
  color: #1a1a1a;
  border-radius: 12px;
  box-shadow: 0 4px 22px rgba(0, 0, 0, 0.35);
  font-size: 15px;
  /* product.css centres #mainContainer's text and clips it below 1200 px (its narrow-window block) */
  text-align: left !important;
  overflow: visible !important;
}
body.scan-layout .sb-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e6e6e6;
  padding-bottom: 9px;
  margin-bottom: 12px;
}
body.scan-layout .sb-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
body.scan-layout h1.sb-h1 { margin: 0 !important; font-size: 1.3em !important; line-height: 1.2 !important; font-weight: 700; }
body.scan-layout .sb-mode { color: #444; }
body.scan-layout .sb-other { color: #8f5f32; font-size: 0.9em; text-decoration: underline; }
body.scan-layout .sb-other[hidden] { display: none; }
body.scan-layout .sb-tools { display: flex; align-items: center; gap: 8px; }

/* Buttons keep today's icon and Text-view word (scan_ui.js switches them), hidden here: the layout shows words. */
body.scan-layout #settingsText, body.scan-layout #guideText,
body.scan-layout #newListIcon, body.scan-layout #newListText, body.scan-layout #cleanDisplayIcon, body.scan-layout #cleanDisplayText,
body.scan-layout #capturePhotoIcon, body.scan-layout #capturePhotoText, body.scan-layout #captureScanIcon, body.scan-layout #captureScanText,
body.scan-layout #uploadIcon, body.scan-layout #uploadText, body.scan-layout #folderWatchText, body.scan-layout #rotateText {
  display: none !important;
}
body.scan-layout #rotateIcon, body.scan-layout #folderWatchIcon { display: inline-block !important; }
/* Settings and Help: the icon next to the word (as on the approved design). Also what the website's Selenium suite
   waits for before it opens Settings (ViewsAndImportTests: #settingsIcon clickable). */
body.scan-layout #settingBtn > #settingsIcon, body.scan-layout #guideBtn > #guideIcon {
  display: inline-block !important; width: 18px !important; height: 18px !important; flex: 0 0 18px;
}

body.scan-layout .sb-btn,
body.scan-layout .sb-tools > #settingBtn,
body.scan-layout .sb-tools > #guideBtn,
body.scan-layout #folderWatchButton,
body.scan-layout #galleryReviewButton {
  align-items: center; gap: 7px; box-sizing: border-box;
  width: auto !important; height: auto !important; min-height: 36px; margin: 0 !important;
  padding: 6px 12px !important; border: 1px solid #cfcfcf; border-radius: 8px !important;
  background: #f3f3f3 !important; color: #1a1a1a !important; box-shadow: none !important;
  font: inherit; font-size: 0.92em !important; font-weight: 400; white-space: nowrap; cursor: pointer;
}
body.scan-layout .sb-btn, body.scan-layout .sb-tools > #settingBtn, body.scan-layout .sb-tools > #guideBtn { display: inline-flex; }
body.scan-layout #folderWatchButton { display: inline-flex; }
body.scan-layout #folderWatchIcon { height: 18px !important; }
body.scan-layout .sb-btn:hover, body.scan-layout .sb-tools > button:hover, body.scan-layout #folderWatchButton:hover,
body.scan-layout #galleryReviewButton:hover { background: #ebebeb !important; }

/* ---- More ------------------------------------------------------------------------------------------------------ */
body.scan-layout .sb-more-wrap { position: relative; }
body.scan-layout .sb-more {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 60; min-width: 250px;
  display: flex; flex-direction: column; padding: 6px 0;
  background: #fff; border: 1px solid #cfcfcf; border-radius: 10px; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
}
body.scan-layout .sb-more[hidden] { display: none; }
body.scan-layout .sb-more hr { border: 0; border-top: 1px solid #e6e6e6; margin: 4px 0; }
body.scan-layout .sb-more #sorterdiv { margin: 0; padding: 0; }
body.scan-layout .sb-more .sb-item,
body.scan-layout .sb-more #newListBtn,
body.scan-layout .sb-more #cleanDisplayBtn,
body.scan-layout .sb-more #sortingbutton {
  width: 100% !important; height: auto !important; margin: 0 !important; padding: 8px 14px !important;
  justify-content: flex-start; text-align: left; box-sizing: border-box;
  background: none !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  font: inherit; font-size: 0.95em !important; color: #1a1a1a !important; text-decoration: none; cursor: pointer;
}
body.scan-layout .sb-more .sb-item, body.scan-layout .sb-more #sortingbutton { display: block; }
body.scan-layout .sb-more #newListBtn, body.scan-layout .sb-more #cleanDisplayBtn { display: flex; }
body.scan-layout .sb-more .sb-item:hover, body.scan-layout .sb-more #newListBtn:hover,
body.scan-layout .sb-more #cleanDisplayBtn:hover, body.scan-layout .sb-more #sortingbutton:hover { background: #f4f4f4 !important; }

/* ---- the two (or three) columns ---------------------------------------------------------------------------- */
body.scan-layout .sb-body {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: minmax(340px, 1fr) minmax(440px, 1.05fr); gap: 18px;
}
/* Settings > Show last scan comparison: a third column between the picture and the list, at every width */
body.scan-layout .sb-body.sb-compare { grid-template-columns: minmax(220px, 1fr) minmax(200px, 0.75fr) minmax(340px, 1.05fr); }
body.scan-layout .sb-body > #lastScanPanel { margin: 0 !important; min-height: 0; overflow: auto; }
body.scan-layout .sb-stage, body.scan-layout .sb-way { min-height: 0; display: flex; flex-direction: column; }
body.scan-layout .sb-way { flex: 1 1 auto; }
body.scan-layout .sb-way[hidden], body.scan-layout .sb-choose[hidden] { display: none; }
body.scan-layout .sb-hidden { display: none !important; }

/* ---- the start: the home page's first-cards rows (home.css .fc-btn) ----------------------------------------- */
body.scan-layout .sb-choose { max-width: 560px; margin-top: 4px; }
body.scan-layout .sb-q { font-size: 1.15em; font-weight: 700; margin: 0 0 4px; }
body.scan-layout .fc-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; box-sizing: border-box; min-height: 56px;
  padding: 12px 14px; margin: 9px 0; border-radius: 10px; background: #e9e9e9; color: #000;
  border: 1px solid #cfcfcf; font: inherit; text-align: left; cursor: pointer;
}
body.scan-layout .fc-btn:hover { background: #e2e2e2; }
body.scan-layout .fc-btn b { display: block; font-size: 1.05em; }
body.scan-layout .fc-btn small { display: block; font-size: 0.85em; color: #333; margin-top: 2px; line-height: 1.3; }
body.scan-layout .fc-btn.fc-primary { background: #e0a83a; color: #1a1a1a; border-color: #c8902c; }
body.scan-layout .fc-btn.fc-primary small { color: #1a1a1a; }
body.scan-layout .fc-ico { flex: 0 0 34px; width: 34px; height: 34px; }
body.scan-layout .sb-tag {
  margin-left: auto; align-self: flex-start; white-space: nowrap; font-size: 0.75em; font-weight: 700;
  background: rgba(0, 0, 0, 0.12); border-radius: 8px; padding: 1px 7px;
}
body.scan-layout .sb-foot { font-size: 0.88em; color: #555; margin-top: 8px; }
body.scan-layout .sb-linkbtn {
  background: none; border: 0; padding: 0; font: inherit; color: #8f5f32; text-decoration: underline; cursor: pointer;
}

/* ---- the picture box (webcam, document scanner) ----------------------------------------------------------- */
body.scan-layout .sb-cam {
  position: relative; flex: 1 1 auto; min-height: 220px; overflow: hidden;
  background: #1c1c1e; border-radius: 10px;
}
/* scan_camera.js sizes the camera for the previous layout (80vh boxes, margins, a turn). In this box the
   picture is centred and sized by scan_layout.js through --sb-* (it reads the camera's own proportions). */
body.scan-layout #sbCam #display,
body.scan-layout #sbCam #subContainer,
body.scan-layout #sbCam #videoContainer,
body.scan-layout #sbCam .videoWrapper {
  position: absolute !important; inset: 0 !important; margin: 0 !important; top: 0 !important;
  width: auto !important; height: auto !important; max-width: none !important;
}
body.scan-layout #sbCam #videoElement {
  position: absolute !important; left: 50% !important; top: 50% !important; margin: 0 !important;
  width: var(--sb-vw, 0px) !important; height: var(--sb-vh, 0px) !important; aspect-ratio: auto !important;
  object-fit: contain; transform: translate(-50%, -50%) rotate(var(--sb-rot, 0deg)) !important;
}
body.scan-layout #sbCam #frame {
  position: absolute !important; left: 50% !important; top: 50% !important; margin: 0 !important;
  width: var(--sb-fw, 0px) !important; height: var(--sb-fh, 0px) !important; aspect-ratio: auto !important;
  transform: translate(-50%, -50%) !important; border-width: 3px; box-sizing: border-box;
}
body.scan-layout .sb-over { position: absolute; z-index: 3; display: flex; align-items: center; gap: 8px; }
body.scan-layout .sb-over-tl { top: 10px; left: 10px; }
body.scan-layout .sb-over-tr { top: 10px; right: 10px; }
body.scan-layout .sb-over-bl { left: 10px; bottom: 10px; }
body.scan-layout .sb-over .rotate-div { margin: 0 !important; }
body.scan-layout .sb-over #select {
  height: auto !important; max-width: 15rem; padding: 4px 8px; font-size: 0.82em; border-radius: 16px;
  background: rgba(20, 20, 20, 0.62); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35);
}
body.scan-layout .sb-over #select option { color: #1a1a1a; background: #fff; }
body.scan-layout #rotate {
  width: 40px !important; height: 40px !important; padding: 0 !important; margin: 0 !important; border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.92) !important; border: 1px solid rgba(0, 0, 0, 0.2) !important; cursor: pointer;
}
body.scan-layout #rotateIcon { width: 22px; height: 22px; }
body.scan-layout #focusdiv {
  display: flex; align-items: center; gap: 6px; color: #eee; font-size: 0.8em;
  background: rgba(20, 20, 20, 0.55); padding: 4px 8px; border-radius: 12px;
}
body.scan-layout #focusdiv > span { margin: 0 !important; }
/* product.css draws the meter's colours from --w, its width: change that, not the width */
body.scan-layout #myProgressBar { --w: 7rem; }

/* ---- under the picture: the one gold button and the way's own options ------------------------------------- */
body.scan-layout .sb-strip { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 10px; }
body.scan-layout #captureButton,
body.scan-layout #captureScanButton,
body.scan-layout .sb-drop label[for="filenames"] {
  align-items: center; justify-content: center; gap: 10px; box-sizing: border-box;
  width: auto !important; height: auto !important; min-height: 44px; margin: 0 !important; padding: 9px 22px !important;
  border: 1px solid #c8902c !important; border-radius: 10px !important; background: #e0a83a !important;
  color: #1a1a1a !important; font: inherit; font-size: 1.02em !important; font-weight: 700; cursor: pointer; box-shadow: none !important;
}
body.scan-layout #captureButton { flex: 1 1 auto !important; }
body.scan-layout #captureScanButton, body.scan-layout #captureButton { display: inline-flex; }
body.scan-layout .sb-drop label[for="filenames"] { display: inline-flex !important; }
body.scan-layout #captureButton:hover, body.scan-layout #captureScanButton:hover, body.scan-layout .sb-drop label[for="filenames"]:hover { background: #d89d2c !important; }
body.scan-layout .sb-kbd { font-weight: 400; font-size: 0.78em; border: 1px solid #b07d22; border-radius: 4px; padding: 0 5px; }
body.scan-layout #autotriggerdiv { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
/* Auto capture as a switch; still the #autotrigger check box the scripts (and the X1PRO extension) read. */
body.scan-layout #autotrigger {
  appearance: none; -webkit-appearance: none; position: relative; flex: 0 0 auto; width: 34px; height: 20px; margin: 0 8px 0 0;
  border-radius: 10px; background: #c9c9c9; cursor: pointer; vertical-align: middle; transition: background 0.15s;
}
body.scan-layout #autotrigger::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: left 0.15s;
}
body.scan-layout #autotrigger:checked { background: #e0a83a; }
body.scan-layout #autotrigger:checked::after { left: 16px; }
body.scan-layout #autotrigger:focus-visible { outline: 2px solid #8f5f32; outline-offset: 2px; }
body.scan-layout .sb-lines:empty { display: none; }
body.scan-layout .sb-lines > * { margin-top: 6px; }

body.scan-layout .sb-cam-scanner { display: flex; align-items: center; justify-content: center; background: #2a2a2d; }
body.scan-layout .sb-cam-scanner #default {
  width: 100% !important; height: 100% !important; margin: 0 !important; background: transparent !important;
}
body.scan-layout .sb-cam-note { position: absolute; color: #bbb; font-size: 0.9em; pointer-events: none; }
body.scan-layout .sb-cam-scanner #default:not(:empty) + .sb-cam-note { display: none; }
body.scan-layout .scanSource-div { flex-direction: row !important; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 !important; }
body.scan-layout #sourceDriverNote { flex-basis: 100%; }
body.scan-layout #source { max-width: 16rem; }
body.scan-layout .sb-scanopts { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; font-size: 0.93em; }
body.scan-layout .sb-scanopts label { white-space: normal; }
body.scan-layout .sb-scanopts br { display: none; }
body.scan-layout .sb-scanopts #stopAtPriceNote { max-width: none !important; }
/* Storage format... belongs to chaos sorting: shown once it is ticked */
body.scan-layout #chaossortingdiv:not(:has(#useChaosSorting:checked)) #storageFormatBtn { display: none; }

body.scan-layout .sb-drop {
  flex: 1 1 auto; min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 16px; text-align: center; color: #444; background: #fafafa;
  border: 2px dashed #c9c9c9; border-radius: 12px;
}
body.scan-layout .sb-drop.sb-dragover { border-color: #e0a83a; background: #fdf7ea; }
body.scan-layout .sb-drop .fc-ico { width: 42px; height: 42px; color: #8f5f32; }
body.scan-layout #autocropdiv { display: flex; align-items: center; gap: 6px; }
body.scan-layout #autocropdiv br { display: none; }
body.scan-layout .sb-hint { color: #555; font-size: 0.9em; }

/* ---- the list column -------------------------------------------------------------------------------------- */
body.scan-layout .sb-side.control-view {
  display: flex !important; flex-direction: column !important; min-height: 0; min-width: 0;
  width: auto !important; margin: 0 !important; padding: 0 !important;
  /* product.css centres .control-view below 1200 px */
  align-items: stretch !important; justify-content: flex-start !important; text-align: left;
}
body.scan-layout .sb-side #controls { display: flex !important; flex-direction: column; flex: 0 0 auto; }
body.scan-layout #listSelection {
  width: auto !important; margin: 0 0 6px !important; padding: 0 !important;
  background: none !important; border: 0 !important; box-shadow: none !important;
}
body.scan-layout #listSelection .importLabelView { margin: 0 0 3px !important; font-size: 0.85em; color: #555; }
body.scan-layout #listSelection .select2-container { width: 100% !important; }
body.scan-layout #listSelection .select2-selection {
  min-height: 36px; border: 1px solid #cfcfcf !important; border-radius: 8px !important; background: #fff !important;
}
body.scan-layout #sorterTraysBox { margin-top: 8px; }
body.scan-layout .sb-newlist {
  display: block; width: 100%; padding: 8px 10px; text-align: left; cursor: pointer;
  background: #fff; border: 0; border-bottom: 1px solid #e6e6e6; font: inherit; font-weight: 700; color: #8f5f32;
}
body.scan-layout .sb-newlist:hover { background: #fbf6ea; }
body.scan-layout .sb-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 10px; font-size: 0.88em; color: #555; }
body.scan-layout .sb-chips[hidden] { display: none; }
body.scan-layout .sb-chip {
  min-height: 30px; padding: 3px 11px; border: 1px solid #d5d5d5; border-radius: 15px; background: #f6f6f6;
  font: inherit; font-size: 0.95em; color: #1a1a1a; cursor: pointer; max-width: 15rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body.scan-layout .sb-chip b { font-weight: 600; }
body.scan-layout .sb-chip.sb-on { background: #fbefd6; border-color: #e0a83a; }
body.scan-layout .sb-listhead {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px;
  border-top: 1px solid #e6e6e6; padding-top: 8px; margin-bottom: 6px;
}
body.scan-layout .sb-count { color: #333; }
body.scan-layout #galleryReviewButton { flex: 0 0 auto !important; display: inline-flex; }
body.scan-layout .sb-side #scrollScans {
  flex: 1 1 auto; min-height: 120px; max-height: none !important; margin: 0 !important;
  border: 1px solid #e6e6e6; border-radius: 8px; background: #fff; box-shadow: none;
}
/* Plain rows white; the price-alert, game-changer and failed-scan rows keep their own colours (they are !important). */
body.scan-layout #scanned tr:nth-child(odd), body.scan-layout #scanned tr:nth-child(even) { background-color: #fff; }
body.scan-layout #scanned td { border-bottom: 1px solid #eee; }

/* ---- windows ---------------------------------------------------------------------------------------------- */
body.scan-layout .fieldsetSetting:has(#buttonViewCustomization) { display: none; }
body.scan-layout .sb-onebyone {
  margin-left: 10px; padding: 4px 10px; border: 1px solid #cfcfcf; border-radius: 8px; background: #fff;
  font: inherit; font-size: 0.8em; cursor: pointer; vertical-align: middle;
}

/* The version badge sits bottom-right in white; over the white panel it could not be read: next to the account picture */
body.scan-layout .versionBadge { top: 16px; bottom: auto; right: 72px; background: rgba(20, 20, 20, 0.55); color: #fff; z-index: 10; }

/* ---- narrow windows: one column, the page scrolls ------------------------------------------------------- */
@media (max-width: 1150px) {
  body.scan-layout #mainContainer.sb-shell { height: auto; min-height: calc(100vh - var(--gestic-topbar-h, 60px) - 14px); }
  body.scan-layout .sb-body { grid-template-columns: 1fr !important; }
  /* Keep the opening choices compact on tall screens; the list takes the spare height.
     Active scan modes keep their existing preview space. */
  body.scan-layout .sb-body:has(.sb-choose:not([hidden])) { grid-template-rows: auto minmax(0, 1fr); }
  body.scan-layout .sb-cam { min-height: 380px; }
  body.scan-layout .sb-side #scrollScans { max-height: 70vh !important; }
}
