/* ============================================================
 * css/style.css
 * 内部移動スキャンの見た目。
 * ★元の作り（odoo-upload-system の BarcodeScanner.tsx / Tailwind）を
 *   ★素のCSSに置き直したもの。★寸法・色の考え方はそのまま。
 * ★現場は手袋・明るい屋内。★押すところは大きく、文字は太く。
 * ============================================================ */

:root {
  --ink: #0f172a;          /* slate-900 */
  --ink-2: #334155;        /* slate-700 */
  --note: #64748b;         /* slate-500 */
  --line: #e2e8f0;         /* slate-200 */
  --bg: #f1f5f9;           /* slate-100 */
  --card: #ffffff;
  --primary: #1d4ed8;      /* blue-700 */
  --ok: #15803d;           /* green-700 */
  --ok-bg: #f0fdf4;
  --warn-bg: #fffbeb;      /* amber-50 */
  --warn-line: #fde68a;
  --warn-ink: #92400e;
  --err: #b91c1c;          /* red-700 */
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

/* ── 上のバー ───────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--ink);
  color: #fff;
}
.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
.icon-btn {
  margin-left: auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255, 255, 255, .3); }

/* ── 本文 ───────────────────────────────── */
.page {
  padding: 16px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.h2 { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.label { font-size: 12px; font-weight: 700; color: var(--note); }
.value { font-size: 18px; font-weight: 700; }
.note { font-size: 12px; color: var(--note); margin: 0; line-height: 1.6; }
.note.center { text-align: center; }
.foot { font-size: 12px; color: var(--note); text-align: center; margin: 4px 0 0; }

.field { display: flex; flex-direction: column; gap: 4px; }
.inline { display: flex; gap: 8px; align-items: stretch; }
.inline .input { flex: 1; min-width: 0; }

.warn {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-ink);
  font-size: 13px;
  font-weight: 700;
}

/* ── 入力 ───────────────────────────────── */
.input, .select {
  width: 100%;
  padding: 12px;
  font-size: 16px;              /* ★16px 未満だと iOS が拡大する */
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
}
.select { appearance: none; background-image: none; font-weight: 700; }
.input:focus, .select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ── ボタン ─────────────────────────────── */
.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: #e2e8f0;
  color: var(--ink);
}
.btn.w-full { width: 100%; }
.btn.xl { padding: 18px; font-size: 18px; border-radius: 14px; }
.btn.sm { padding: 8px 12px; font-size: 13px; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: #1e40af; }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:active { background: var(--ink-2); }
.btn.white { background: #fff; color: var(--ink); }
.btn.white:active { background: #e2e8f0; }
.btn.ghost { background: #fff; color: var(--ink-2); border: 1px solid #cbd5e1; }
.btn.translucent { background: rgba(255, 255, 255, .15); color: #fff; }
.btn.translucent:active { background: rgba(255, 255, 255, .3); }
.btn.tool { background: rgba(255, 255, 255, .15); color: #fff; }
.btn.tool.on { background: #fbbf24; color: var(--ink); }
.btn:disabled { opacity: .5; }
.ico { font-size: 20px; }

/* ── 未送信キュー ───────────────────────── */
.queue {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  background: var(--warn-bg);
  border-color: var(--warn-line);
}
.queue-text { margin: 0; font-size: 13px; color: var(--warn-ink); flex: 1; }
.queue-text strong { font-size: 16px; }

/* ── 記録の一覧 ─────────────────────────── */
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
}
.history .cn { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.history .dest { color: var(--ink-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .when { color: var(--note); font-size: 11px; }
.history .state { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
.history .state.sent { background: var(--ok-bg); color: var(--ok); }
.history .state.queued { background: var(--warn-bg); color: var(--warn-ink); }

/* ── 移動先リスト（設定）─────────────────── */
.dest-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dest-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.dest-row.fixed { background: var(--bg); }
.dest-row.none { background: var(--bg); }
.dest-fixed-name { font-weight: 700; }
.dest-row .input { flex: 1; padding: 10px; min-width: 0; }

/* ★どれを「開いたときの初期値」にするか（1つだけ・付けなくてもよい） */
.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 6px 2px;
  cursor: pointer;
}
.radio {
  width: 22px;
  height: 22px;
  flex: none;
  margin: 0;
  accent-color: var(--primary);
}
.mini-btn {
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-2);
}
.mini-btn:active { background: var(--bg); }
.mini-btn.del { color: var(--err); border-color: #fecaca; }
.mini-btn:disabled { opacity: .35; }

/* ── 設定シート ─────────────────────────── */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg);
  overflow-y: auto;
}

/* ══ スキャナー（全画面）══════════════════════
   ★元の作り: fixed inset-0 / 映像は object-cover（黒帯を出さない）
   ★ガイド枠の大きさは JS が SCAN_TUNING.roi*Ratio を入れる      */
.scanner {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #000;
  overflow: hidden;
}
.video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 12px;
  padding-top: calc(16px + env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(0, 0, 0, .7), transparent);
}
.scanner-title { margin: 0; color: #fff; font-size: 14px; font-weight: 700; }
.round-btn {
  margin-left: auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.round-btn:active { background: rgba(255, 255, 255, .3); }

.guide-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.guide {
  position: relative;
  border-radius: 16px;
  transition: background-color .15s;
}
.guide.flash { background: rgba(74, 222, 128, .2); }
.corner {
  position: absolute;
  width: 40px;
  height: 40px;
  border-color: rgba(255, 255, 255, .9);
}
.guide.flash .corner { border-color: #4ade80; }
.corner.tl { top: 0; left: 0; border-top: 4px solid; border-left: 4px solid; border-top-left-radius: 16px; }
.corner.tr { top: 0; right: 0; border-top: 4px solid; border-right: 4px solid; border-top-right-radius: 16px; }
.corner.bl { bottom: 0; left: 0; border-bottom: 4px solid; border-left: 4px solid; border-bottom-left-radius: 16px; }
.corner.br { bottom: 0; right: 0; border-bottom: 4px solid; border-right: 4px solid; border-bottom-right-radius: 16px; }
.guide-line {
  position: absolute;
  left: 24px;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  height: 2px;
  background: rgba(248, 113, 113, .7);
}
.guide.flash .guide-line { background: #86efac; }

.scanner-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 16px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, .8), transparent);
}

.banner { max-height: 38vh; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
}
.chip.sent { background: #dcfce7; color: var(--ok); }
.chip.queued { background: #fef3c7; color: var(--warn-ink); }
.chip.ng { background: #fee2e2; color: var(--err); }

.instruction {
  margin: 0;
  color: #fff;
  font-size: 14px;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.notice {
  margin: 0;
  color: #fde68a;
  font-size: 12px;
  text-align: center;
  background: rgba(0, 0, 0, .4);
  border-radius: 6px;
  padding: 4px 8px;
}
.hint {
  margin: 0;
  color: rgba(255, 255, 255, .8);
  font-size: 12px;
  text-align: center;
  background: rgba(0, 0, 0, .4);
  border-radius: 6px;
  padding: 6px 8px;
}
.cont-note { margin: 0; color: rgba(255, 255, 255, .6); font-size: 11px; text-align: center; }

.scan-dest { display: flex; align-items: center; gap: 8px; }
.scan-dest-label { color: rgba(255, 255, 255, .85); font-size: 12px; font-weight: 700; flex: none; }
.dark-select {
  background: rgba(255, 255, 255, .92);
  border-color: transparent;
  padding: 10px 12px;
}

.panel {
  background: rgba(255, 255, 255, .95);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-title { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.panel-title.err { color: var(--err); }
.panel-note { margin: 0; font-size: 11px; color: var(--ink-2); line-height: 1.6; }

.tools { display: flex; align-items: center; gap: 12px; }
.zoom { flex: 1; display: flex; align-items: center; gap: 8px; }
.zoom-label { color: rgba(255, 255, 255, .8); font-size: 12px; }
.range { flex: 1; accent-color: #fff; }
