/* Skaner kodów kreskowych w wyszukiwarce (2.0.48) - web/assets/js/skaner.js */

/* przycisk aparatu: w polu wyszukiwania nagłówka i obok pola w Wyszukiwarce */
.scan-btn {
  flex: 0 0 auto; display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--r-8);
  background: transparent; color: var(--navy-title); cursor: pointer;
}
.scan-btn:hover { background: var(--blue-50); }
.scan-btn:focus-visible { outline: 3px solid var(--cyan); outline-offset: 1px; }
.scan-btn[hidden] { display: none; }
.scan-btn svg { width: 22px; height: 22px; }
.scan-btn-lg { width: 44px; height: 44px; border: 1px solid var(--border-2); background: #fff; }
.s-q-row { display: flex; gap: 8px; align-items: center; }
.s-q-row .input { flex: 1 1 auto; min-width: 0; }

/* nakładka pełnoekranowa */
html.scan-open, html.scan-open body { overflow: hidden; }
.scan-ov {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; flex-direction: column;
  background: #000; color: #fff;
}
.scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.scan-aim { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.scan-frame {
  position: relative; width: min(86vw, 560px); aspect-ratio: 2.2 / 1;
  border: 2px solid rgb(255 255 255 / .9); border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgb(0 4 40 / .5);
}
.scan-laser {
  position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; margin-top: -1px;
  background: #EF4444; box-shadow: 0 0 8px 1px rgb(239 68 68 / .8);
  animation: scanLaser 1.6s ease-in-out infinite;
}
@keyframes scanLaser { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.scan-off .scan-aim, .scan-off .scan-video { visibility: hidden; }

.scan-top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(rgb(0 0 0 / .65), transparent);
}
.scan-top h2 { color: #fff; font-size: 17px; font-weight: 600; margin: 0; }
.scan-x {
  width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgb(255 255 255 / .16); color: #fff; cursor: pointer;
}
.scan-x:hover { background: rgb(255 255 255 / .28); }

.scan-bottom {
  position: relative; z-index: 2; margin-top: auto; align-self: center;
  width: 100%; max-width: 600px; display: grid; gap: 12px;
  padding: 28px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgb(0 0 0 / .78) 26%);
}
.scan-hint { margin: 0; text-align: center; font-size: 15px; line-height: 1.4; color: #fff; text-shadow: 0 1px 3px rgb(0 0 0 / .8); }
.scan-err { background: #FEF2F2; color: #7F1D1D; border-radius: var(--r-8); padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.scan-tools { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.scan-tools:not(:has(> :not([hidden]))) { display: none; }
.scan-tool {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px;
  border: 1px solid rgb(255 255 255 / .35); border-radius: 22px;
  background: rgb(255 255 255 / .14); color: #fff; font: inherit; font-size: 14px; cursor: pointer;
}
.scan-tool[hidden] { display: none; }
.scan-tool[aria-pressed="true"] { background: var(--cyan); border-color: var(--cyan); color: var(--navy-title); }
.scan-manual { display: grid; gap: 6px; }
.scan-manual label { font-size: 13px; color: #D1D5DB; }
.scan-manual-row { display: flex; gap: 8px; }
.scan-manual-row input {
  flex: 1 1 auto; min-width: 0; height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--r-8); background: #fff; color: var(--text);
  font-size: 16px; font-family: var(--mono, inherit); letter-spacing: .04em;   /* 16px: iOS nie powiększa */
}
.scan-manual-row .btn { height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.scan-ov button:focus-visible, .scan-ov input:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

@media (max-width: 420px) { .scan-manual-row .btn span { display: none; } }
/* 2.0.67: tryby „Wyszukaj” / „Do koszyka” (aplikacja na telefon) */
.scan-mode {
  position: relative; z-index: 2; align-self: center; display: inline-flex; gap: 4px; padding: 4px; margin-top: 2px;
  border-radius: 24px; background: rgb(0 0 0 / .45); border: 1px solid rgb(255 255 255 / .25);
}
.scan-mode button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 0; border-radius: 20px;
  background: transparent; color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.scan-mode button[aria-pressed="true"] { background: #fff; color: var(--navy-title); }
.scan-frame.scan-busy { border-color: var(--cyan); }
.scan-frame.scan-ok { border-color: #22C55E; box-shadow: 0 0 0 100vmax rgb(0 4 40 / .5), inset 0 0 0 4px #22C55E; }
.scan-frame.scan-bad { border-color: #F87171; box-shadow: 0 0 0 100vmax rgb(0 4 40 / .5), inset 0 0 0 4px #F87171; }
/* w trybie koszyka ramka wyżej (pod nią lista skanów), niższa */
.scan-koszyk .scan-aim { align-items: flex-start; padding-top: calc(max(12px, env(safe-area-inset-top)) + 130px); }
.scan-koszyk .scan-frame { aspect-ratio: 3 / 1; width: min(80vw, 480px); }
.scan-koszyk .scan-bottom { padding-top: 16px; }
.scan-cart { display: grid; gap: 8px; min-height: 0; }
.scan-cart[hidden] { display: none; }
.scan-cart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.scan-cart-sum { font-size: 13px; color: #E5E7EB; }
.scan-cart-head .btn { min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.scan-list {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 6px;
  max-height: min(34vh, 300px); overflow-y: auto; overscroll-behavior: contain;
}
.scan-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-8);
  background: #fff; color: var(--text); border-left: 4px solid #22C55E; font-size: 14px;
}
.scan-row.warn { border-left-color: #F59E0B; }
.scan-row.err { border-left-color: #EF4444; }
.scan-row.usun { border-left-color: var(--border-2); opacity: .75; }
.scan-row.empty { border-left-color: transparent; background: rgb(255 255 255 / .12); color: #E5E7EB; font-size: 13px; }
.scan-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.scan-row-main .code { font-weight: 700; }
.scan-row-name { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-row-n { color: var(--muted); font-size: 12px; font-weight: 400; }
.scan-row-uw { font-size: 12.5px; color: #92400E; }
.scan-row.err .scan-row-uw { color: #991B1B; }
.scan-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.scan-qty { flex: 0 0 auto; display: inline-flex; align-items: center; border: 1px solid var(--border-2); border-radius: var(--r-8); overflow: hidden; }
.scan-qty button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: #F3F4F6; color: var(--navy-title); cursor: pointer; }
.scan-qty input { width: 52px; height: 40px; border: 0; text-align: center; font-size: 16px; font-weight: 700; color: var(--text); -moz-appearance: textfield; }
.scan-qty input::-webkit-outer-spin-button, .scan-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* przycisk „Skanuj do koszyka” — tylko na urządzeniu z aparatem (skaner.js ustawia html.ma-aparat) */
.skan-koszyk-btn { display: none; align-items: center; gap: 6px; }
html.ma-aparat .skan-koszyk-btn { display: inline-flex; }
.skan-koszyk-btn svg { width: 18px; height: 18px; }
@media (max-width: 700px) {
  html.ma-aparat .page-head .skan-koszyk-btn { width: 100%; min-height: 48px; justify-content: center; font-size: 16px; order: -1; }
  .scan-list { max-height: 30vh; }
}
@media (max-height: 640px) { .scan-koszyk .scan-aim { padding-top: calc(max(12px, env(safe-area-inset-top)) + 104px); } .scan-list { max-height: 22vh; } }

@media (prefers-reduced-motion: reduce) { .scan-laser { animation: none; opacity: 1; } }
@media print { .scan-ov, .scan-btn { display: none !important; } }
