/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   국방 스캐너 — 스타일시트 (QR + 바코드)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* 탭 바 */
.tab-bar {
  display: flex;
  background: #162435;
  border-bottom: 1px solid #2b4a70;
  flex-shrink: 0;
}
.tab-bar .tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: none; border: none;
  color: #7a9ab8;
  font-family: inherit; font-size: 13px; font-weight: bold;
  padding: 12px 8px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab-bar .tab:active { background: rgba(255,255,255,0.04); }
.tab-bar .tab.active {
  color: #c8a96e;
  border-bottom-color: #c8a96e;
  background: #1e3248;
}

/* 1D 바코드 모드일 때 스캔 박스를 가로로 길쭉하게 */
.scan-box.barcode-mode {
  width: 320px !important;
  height: 140px !important;
}

/* 바코드 결과 카드 */
.result-scroll {
  flex: 1; overflow-y: auto; padding: 16px;
  background: #0d1b2a;
}
.bc-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  color: #111;
}
.bc-format-badge {
  display: inline-block;
  background: #1b3a6b;
  color: #c8a96e;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 4px 14px;
  border-radius: 12px;
  margin-bottom: 18px;
}
.bc-value {
  font-size: 22px;
  font-weight: bold;
  color: #111;
  word-break: break-all;
  padding: 14px;
  background: #f5f5f5;
  border-radius: 8px;
  border: 2px solid #1b3a6b;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}
.bc-meta {
  border-top: 1px solid #ddd;
  padding-top: 14px;
  text-align: left;
}
.bc-meta-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.bc-meta-lbl { color: #666; font-weight: bold; }
.bc-meta-val { color: #111; }

:root {
  --primary:      #1b3a6b;
  --primary-dk:   #132c54;
  --primary-lt:   #2a5298;
  --gold:         #c8a96e;
  --gold-lt:      #e0c88a;
  --bg:           #0d1b2a;
  --surface:      #162435;
  --surface2:     #1e3248;
  --border:       #2b4a70;
  --text:         #e8ecf1;
  --text-dim:     #7a9ab8;
  --success:      #27ae60;
  --danger:       #c0392b;
  --radius:       10px;
  --font:         'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%; width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  overflow: hidden;
  overscroll-behavior: none;
}

/* ── 화면 전환 ── */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 1;
}
.screen.active { opacity: 1; pointer-events: all; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━
   공통 헤더
━━━━━━━━━━━━━━━━━━━━━━━━ */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  height: 54px;
  background: var(--primary-dk);
  border-bottom: 2px solid var(--gold);
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
}

.logo { display: flex; align-items: center; gap: 8px; }
.logo-star { color: var(--gold); font-size: 20px; line-height: 1; }
.logo-text  { font-size: 16px; font-weight: bold; letter-spacing: 0.5px; color: var(--text); }

.header-title { font-size: 15px; font-weight: bold; }

.header-right { display: flex; gap: 6px; }

.btn-icon-header {
  background: none; border: none; color: var(--gold);
  padding: 8px; cursor: pointer; border-radius: 6px;
  display: flex; align-items: center;
}
.btn-icon-header:active { background: rgba(255,255,255,0.08); }

.btn-back {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none;
  color: var(--gold); font-size: 14px;
  font-family: var(--font); cursor: pointer; padding: 8px 4px;
}
.btn-back:active { opacity: 0.7; }

.btn-danger-sm {
  background: none; border: 1px solid var(--danger);
  border-radius: 6px; color: var(--danger);
  font-family: var(--font); font-size: 12px;
  padding: 5px 10px; cursor: pointer;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━
   스캔 화면
━━━━━━━━━━━━━━━━━━━━━━━━ */
.camera-wrap {
  flex: 1; position: relative; overflow: hidden; background: #000;
}

#video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* 어두운 오버레이 */
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
}
.overlay-top  { flex: 1; background: rgba(0,0,0,0.50); }
.overlay-bot  { flex: 1; background: rgba(0,0,0,0.50);
                display: flex; align-items: flex-start; justify-content: center; padding-top: 20px; }
.overlay-mid  { display: flex; height: 260px; }
.overlay-side { flex: 1; background: rgba(0,0,0,0.50); }

/* 스캔 박스 */
.scan-box {
  width: 260px; height: 260px;
  position: relative;
  border: 1.5px solid rgba(255,255,255,0.20);
}

.corner {
  position: absolute; width: 28px; height: 28px;
  border-color: var(--gold); border-style: solid;
}
.corner.tl { top:-2px; left:-2px;  border-width: 3px 0 0 3px; }
.corner.tr { top:-2px; right:-2px; border-width: 3px 3px 0 0; }
.corner.bl { bottom:-2px; left:-2px;  border-width: 0 0 3px 3px; }
.corner.br { bottom:-2px; right:-2px; border-width: 0 3px 3px 0; }

.scan-line {
  position: absolute; left: 6px; right: 6px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  box-shadow: 0 0 10px var(--gold);
  animation: scanMove 2s ease-in-out infinite;
}
@keyframes scanMove {
  0%   { top: 8px; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: calc(100% - 8px); opacity: 0; }
}

.scan-hint {
  color: rgba(255,255,255,0.85);
  font-size: 13px; letter-spacing: 0.3px;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
}

/* 스캔 바 (하단) */
.scan-bar {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  gap: 20px;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  min-height: 60px;
}

.btn-torch {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--gold);
  font-family: var(--font); font-size: 13px;
  padding: 8px 14px; cursor: pointer;
}
.btn-torch.on { background: var(--gold); color: var(--primary-dk); border-color: var(--gold); }

.scan-status {
  color: var(--text-dim); font-size: 13px; text-align: center; flex: 1;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━
   결과 화면
━━━━━━━━━━━━━━━━━━━━━━━━ */
.result-scroll {
  flex: 1; overflow-y: auto; padding: 14px;
  background: var(--bg);
}
.result-scroll::-webkit-scrollbar { width: 4px; }
.result-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* 군용 라벨 카드 */
.military-card {
  background: #fff; border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  color: #111;
}

.card-header {
  background: #fff;
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 14px 10px;
  border-bottom: 2px solid #111;
}
.mil-emblem { margin-bottom: 2px; }
.mil-title {
  font-size: 17px; font-weight: bold;
  letter-spacing: 12px; color: #111;
}

/* 정보 테이블 */
.info-table {
  width: 100%; border-collapse: collapse;
}
.info-table tr {
  border-bottom: 1px solid #ccc;
}
.info-table tr:last-child { border-bottom: none; }

.info-table th {
  background: #f0f0f0;
  font-weight: bold; font-size: 12.5px;
  padding: 10px 12px;
  width: 28%; white-space: nowrap;
  border-right: 2px solid #111;
  vertical-align: middle;
  text-align: left;
}
.info-table td {
  padding: 10px 12px;
  font-size: 14px;
  word-break: break-all;
  vertical-align: middle;
}

.mono { font-family: 'Courier New', monospace; letter-spacing: 0.5px; }

.unit-val  { font-weight: bold; font-size: 15px; }
.divider   { color: #999; margin: 0 8px; }
.sub-label { font-size: 11px; color: #777; margin-right: 4px; }
.qty-val   { font-weight: bold; font-size: 15px; }

/* 카드 하단 */
.card-footer {
  background: #f8f8f8;
  border-top: 1px solid #ddd;
  padding: 10px 12px;
}
.scan-time { font-size: 11px; color: #888; margin-bottom: 8px; }

.raw-toggle {
  background: none; border: 1px solid #ccc; border-radius: 6px;
  color: #666; font-size: 12px; font-family: var(--font);
  padding: 5px 12px; cursor: pointer; width: 100%;
}
.raw-box {
  margin-top: 10px;
  background: #eee; border-radius: 6px; padding: 10px;
}
.raw-fields {
  font-size: 11px; line-height: 1.9; color: #333;
  margin-bottom: 8px;
}
.raw-fields span.lbl { color: #666; }
.raw-fields span.val { font-family: monospace; color: #111; }

.raw-full {
  font-family: 'Courier New', monospace;
  font-size: 10px; color: #555;
  word-break: break-all; line-height: 1.6;
  border-top: 1px solid #ccc; padding-top: 8px; margin-top: 4px;
}

/* 액션 바 */
.action-bar {
  flex-shrink: 0;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.btn-primary {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary-lt); border: none; border-radius: var(--radius);
  color: #fff; font-family: var(--font); font-size: 16px; font-weight: bold;
  padding: 14px; cursor: pointer; letter-spacing: 1px;
  transition: background 0.15s;
}
.btn-primary:active { background: var(--primary); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━
   기록 화면
━━━━━━━━━━━━━━━━━━━━━━━━ */
.history-list {
  flex: 1; overflow-y: auto; padding: 12px;
  background: var(--bg);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer; transition: background 0.12s;
  position: relative;
}
.history-item:active { background: var(--surface2); }
.history-item::after {
  content: '›';
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim); font-size: 20px;
}

.hi-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.hi-name { font-size: 15px; font-weight: bold; flex: 1; }
.hi-qty  { font-size: 13px; color: var(--gold); white-space: nowrap; }

.hi-bot { display: flex; justify-content: space-between; align-items: center; }
.hi-stock { font-family: 'Courier New', monospace; font-size: 11.5px; color: var(--text-dim); }
.hi-time  { font-size: 11px; color: var(--text-dim); }

.empty-msg {
  text-align: center; color: var(--text-dim);
  padding: 60px 20px; font-size: 15px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━
   토스트
━━━━━━━━━━━━━━━━━━━━━━━━ */
.toast {
  position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 20, 35, 0.92);
  border: 1px solid var(--border);
  color: var(--text); padding: 10px 22px;
  border-radius: 24px; font-size: 13.5px;
  opacity: 0; transition: opacity 0.25s;
  z-index: 999; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.toast.show { opacity: 1; }
