/* Сканер ценников: камера, штрихкод и история сканов.
   Шрифт, тема и компоненты — в /shared/styles.css. */

/* Приложение занимает экран целиком: камера тянется на всю высоту, страница
   не прокручивается и не «оттягивается» при свайпе. */
html, body { overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* в поле ввода EAN выделение и правка остаются */
.input { -webkit-user-select: text; user-select: text; }

/* колонка сканера уже прочих — шапка равняется по ней */
:root { --content-w: 480px; }

#scan { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
#input, #history, #result { display: flex; flex-direction: column; gap: 12px; }
#history { flex: 1; min-height: 0; }

/* ── Камера ────────────────────────────────────────────────────────────── */
#scanWrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: #000;
  overflow: hidden;
}
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
/* Прицел: декодируем только то, что попало в рамку (см. CROP в app.js) */
#scanWrap .frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 70%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 2px solid color-mix(in oklch, var(--foreground) 90%, transparent);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 0 0 9999px rgb(0 0 0 / .3);
  pointer-events: none;
}

/* Нижняя панель камеры: фонарик и зум */
#camCtl {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
}
.torch { width: 40px; height: 40px; font-size: 20px; }
.torch.on { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.torch.on:active { background: color-mix(in oklch, var(--primary) 90%, black); }
@media (hover: hover) { .torch.on:hover { background: color-mix(in oklch, var(--primary) 90%, black); } }

/* Slider (shadcn): дорожка h-2 rounded-full, заполнение primary,
   бегунок size-5 с обводкой primary */
#zoom {
  flex: 1;
  height: 40px;
  margin: 0;
  background: transparent;
  touch-action: none;
  -webkit-appearance: none;
  appearance: none;
}
#zoom::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--primary) var(--p, 0%), var(--secondary) var(--p, 0%));
}
#zoom::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -6px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  background: var(--background);
}
#zoom::-moz-range-track { height: 8px; border-radius: 999px; background: var(--secondary); }
#zoom::-moz-range-progress { height: 8px; border-radius: 999px; background: var(--primary); }
#zoom::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  background: var(--background);
}

/* ── История ───────────────────────────────────────────────────────────── */
.hist { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.hist-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex: none;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-xs);
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.hist-item:active { background: var(--accent); }
@media (hover: hover) { .hist-item:hover { background: var(--accent); } }
.hist-ean { font-variant-numeric: tabular-nums; }
.hist-sub { color: var(--muted-foreground); font-size: 13px; font-weight: 400; white-space: nowrap; }
.hist-empty { padding: 24px 0; color: var(--muted-foreground); text-align: center; }

/* ── Результат ─────────────────────────────────────────────────────────── */
/* Штрихкод — чёрным по белому: тёмная подложка сбивает сканер кассы */
.barcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: #fff;
  color: #000;
  box-shadow: var(--shadow-xs);
}
.barcard svg { width: 100%; height: auto; }

.meta {
  padding: 4px 16px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-xs);
}
.meta div { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.meta div:last-child { border-bottom: none; }
.meta .k { color: var(--muted-foreground); }
