/*
 * QR Code Scanner (inc/qrscan-tool.inc.php). The shared layout is pt-ui.css;
 * this is the photo with its outlines, the results, the photo list, and the
 * full-screen camera. The results and the photos are also the phone
 * editor's panels (pt-app.css gives those a dark surface, so colours there
 * are currentColor and translucent).
 */
.qs-editor [hidden] { display: none !important; }

/* ── Before a photo: upload and the camera ─────────────────────────────── */
.qs-empty-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 14px; }
.qs-empty-btns .btn { margin: 0 !important; }
.qs-camera-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.qs-cam-ic { width: 20px; height: 20px; flex: none; }

/* ── The photo, its codes outlined and numbered ────────────────────────── */
#qs-viewport { display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden; }
.qs-frame { position: relative; flex: none; }
.qs-img { display: block; width: 100%; height: 100%; border-radius: 4px; user-select: none; -webkit-user-drag: none; }
.qs-marks { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.qs-mark { fill: rgba(43, 212, 107, 0.16); stroke: #2bd46b; stroke-width: 3; stroke-linejoin: round; transition: fill 0.15s; }
.qs-mark.is-on { fill: rgba(43, 212, 107, 0.36); stroke: #fff; }
.qs-badges { position: absolute; inset: 0; pointer-events: none; }
.qs-badge {
  position: absolute;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 50%;
  background: #16181d;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 24px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  cursor: pointer;
}
.qs-badge.is-on { background: #2bd46b; color: #16181d; }
.qs-busy {
  position: absolute;
  inset-block-end: 14px;
  inset-inline: 0;
  margin: 0 auto;
  width: max-content;
  max-width: calc(100% - 24px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(22, 24, 29, 0.78);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
#pt-app .qs-viewport { height: 100% !important; min-height: 0 !important; }

/* ── The photo list ─────────────────────────────────────────────────────── */
.qs-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.qs-file { position: relative; aspect-ratio: 1; border-radius: 8px; outline: none; }
.qs-thumb {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #eef1f5;
  cursor: pointer;
  border: 2px solid transparent;
}
.qs-thumb canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.qs-file.is-selected .qs-thumb { border-color: var(--bs-primary, var(--pt-accent, #0f70e6)); }
.qs-file:focus-visible .qs-thumb { box-shadow: 0 0 0 3px rgba(15, 112, 230, 0.45); }
.qs-file-n {
  position: absolute;
  inset-block-end: 4px;
  inset-inline-start: 4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #2bd46b;
  color: #16181d;
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  pointer-events: none;
}
.qs-file.is-none .qs-file-n { background: rgba(30, 34, 40, 0.72); color: #fff; }
.qs-del {
  position: absolute;
  inset-block-start: 3px;
  inset-inline-end: 3px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(30, 34, 40, 0.72);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qs-del svg { width: 12px; height: 12px; }
/* A finger-sized target round the small x, grown outwards only. */
.qs-del::before { content: ""; position: absolute; inset-block: -8px 0; inset-inline: 0 -8px; }
.qs-addbtn {
  border: 2px dashed #b8c2d1;
  background: transparent;
  color: #5a6475;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.qs-addbtn svg { width: 24px; height: 24px; }
.qs-addbtn:hover { border-color: var(--bs-primary, var(--pt-accent, #0f70e6)); color: var(--bs-primary, var(--pt-accent, #0f70e6)); }

/* ── The results ────────────────────────────────────────────────────────── */
.qs-results-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.qs-results-title { font-size: 1rem; font-weight: 700; margin: 0; }
.qs-results { display: grid; gap: 10px; }
.qs-res {
  border: 1px solid rgba(127, 127, 127, 0.24);
  border-radius: 14px;
  padding: 12px 14px;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.qs-res.is-on { border-color: #2bd46b; box-shadow: 0 0 0 1px #2bd46b; }
.qs-res-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.qs-num {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #16181d;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 24px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.qs-kind { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.qs-kind svg { width: 18px; height: 18px; flex: none; opacity: 0.8; }
.qs-fmt {
  margin-inline-start: auto;
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.14);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.qs-res-body { min-width: 0; font-size: 14px; }
.qs-res-body p { margin: 0 0 6px; }
.qs-host { font-size: 15px; overflow-wrap: anywhere; }
.qs-lbl { opacity: 0.7; }
.qs-url, .qs-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.qs-url { font-size: 13px; opacity: 0.85; }
.qs-code { font-size: 20px; font-weight: 700; letter-spacing: 0.04em; }
.qs-hint { font-size: 12.5px; opacity: 0.7; }
.qs-title { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.qs-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 10.5em;
  overflow-y: auto;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.08);
}
.qs-fields { display: grid; grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr); gap: 4px 12px; margin: 0 0 6px; }
.qs-fields dt { font-weight: 600; opacity: 0.75; margin: 0; overflow-wrap: anywhere; }
.qs-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
.qs-raw { margin-top: 4px; font-size: 12.5px; }
.qs-raw summary { cursor: pointer; opacity: 0.75; width: max-content; max-width: 100%; }
.qs-raw pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.08);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 12em;
  overflow-y: auto;
  font-size: 12px;
  text-align: left;
}
.qs-res-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.qs-res-acts .btn { min-height: 34px; display: inline-flex; align-items: center; }
.qs-none { padding: 12px 14px; border-radius: 12px; background: rgba(217, 72, 15, 0.08); }
.qs-none-title { margin: 0 0 6px; font-weight: 700; color: #b23c0c; }
.qs-tips { margin: 0; padding-inline-start: 1.2em; font-size: 14px; }
.qs-tips li { margin: 2px 0; }
[dir="rtl"] .qs-tips { padding-left: 0; padding-right: 1.2em; }

/* ── Phone editor panels ────────────────────────────────────────────────── */
.pt-app-panels #qs-results-box { max-height: 42vh; overflow-y: auto; overscroll-behavior: contain; padding: 2px 10px 8px; }
.pt-app-panels .qs-res { border-color: var(--pt-app-line-strong, rgba(127, 127, 127, 0.3)); }
.pt-app-panels .qs-num { background: #fff; color: #16181d; }
.pt-app-panels .qs-none-title { color: #b54708; }
.pt-app-panels #qs-files { display: flex; gap: 8px; overflow-x: auto; padding: 2px 8px 4px; }
.pt-app-panels #qs-files .qs-file { flex: 0 0 64px; width: 64px; height: 64px; }
.pt-app-panels .qs-addbtn { border-color: var(--pt-app-line-strong); color: inherit; }

@media (max-width: 767px) {
  .qs-fields { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .qs-fields dd { margin-bottom: 6px; }
}

/* ── The camera ─────────────────────────────────────────────────────────── */
.qs-cam {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: contain;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.qs-cam button { touch-action: manipulation; font-family: inherit; cursor: pointer; }
.qs-cam button:focus-visible { outline: 3px solid #6fb1ff; outline-offset: 2px; }
.qs-cam-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 10px calc(12px + env(safe-area-inset-left));
}
.qs-cam-btn {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.qs-cam-btn svg { width: 22px; height: 22px; }
.qs-cam-btn.qs-off { visibility: hidden; }
.qs-cam-torch[aria-pressed="true"] { background: #ffd23f; color: #16181d; }
.qs-cam-status { flex: 1; min-width: 0; text-align: center; font-size: 15px; font-weight: 600; line-height: 1.3; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); overflow-wrap: anywhere; }
.qs-cam-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.qs-cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
/* The aim: corners in the middle, the rest a little darker. Centred with
   inset and auto margins, not left 50% and a transform (RTL). */
.qs-cam-aim {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(68vw, 52vh, 400px);
  height: min(68vw, 52vh, 400px);
  border-radius: 22px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.34);
  pointer-events: none;
}
.qs-cam-aim svg { width: 100%; height: 100%; overflow: visible; }
.qs-cam-aim path { fill: none; stroke: #fff; stroke-width: 4px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.qs-cam-marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.qs-cam-marks polygon { fill: rgba(43, 212, 107, 0.22); stroke: #2bd46b; stroke-width: 4; stroke-linejoin: round; }
.qs-cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity 0.3s ease-out; }
.qs-cam-flash.qs-on { opacity: 0.7; transition: none; }
.qs-cam-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  background: rgba(0, 0, 0, 0.8);
}
.qs-cam-msg[hidden] { display: none; }
.qs-cam-msg-text { margin: 0; max-width: 28em; font-size: 16px; line-height: 1.45; color: #fff; }
.qs-cam-msg-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.qs-cam-msg-btns button { min-height: 44px; padding: 0 20px; border-radius: 999px; font-size: 15px; font-weight: 700; border: 1.5px solid rgba(255, 255, 255, 0.55); background: transparent; color: #fff; }
.qs-cam-msg-btns .qs-cam-retry { background: #0f70e6; border-color: #0f70e6; }
.qs-cam-foot {
  display: flex;
  justify-content: center;
  padding: 14px calc(16px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.qs-cam-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  padding: 0 18px;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}
.qs-cam-pill svg { width: 20px; height: 20px; flex: none; }
@media (orientation: landscape) and (max-height: 540px) {
  .qs-cam-top { min-height: 0; padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; }
  .qs-cam-foot { padding-top: 6px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}
