/* =======================================================
   ui.css — 탭 화면 공용 스타일 (탭바 / 리스트 카드 / 칩 / 버튼 / 폼 / 토스트)
   기존 창고네비 화면(style.css) 요소는 건드리지 않는다.
   ======================================================= */

/* ---------- Views ---------- */
.view[hidden]{ display: none !important; }
/* html,body{height:100%}라 body의 padding-bottom은 넘친 내용 뒤에 적용되지 않는다 → 탭 화면 자체에 탭바 높이만큼 여백을 둔다 */
.view:not(#view-map){ padding-bottom: var(--footer-h, 56px); }

.view-head{
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: nowrap; gap: 8px 12px;
  min-height: 36px;
  margin-bottom: 10px;
}
.view-head h2{ flex: 0 1 auto; min-width: 0; }
.view-head > :not(h2){ flex: 0 0 auto; }
.view-head h2{
  margin: 0;
  font-size: 18px; font-weight: 700; line-height: 1.3; color: #0f172a;
}
.view-toolbar{
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-bottom: 10px;
}
.view-toolbar input[type="text"],
.view-toolbar input[type="search"],
.view-toolbar input[type="number"],
.view-toolbar input[type="date"],
.view-toolbar select{
  flex: 1 1 140px; min-width: 0;
  height: 40px; padding: 0 10px;
  border: 1px solid #cbd5e1; border-radius: 10px;
  background: #fff; color: #0f172a;
  font: inherit; font-size: 16px;
}
.view-toolbar input[type="date"],
.view-toolbar select{ flex: 0 1 auto; }
.view-toolbar input:focus,
.view-toolbar select:focus{
  outline: none; border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56,189,248,.25);
}
.view-body{ min-width: 0; }

.view:not(#view-map) .empty,
dialog :not(.suggest) > .empty{
  margin: 0; padding: 28px 12px;
  text-align: center; font-size: 14px; line-height: 1.5; color: #64748b;
}

/* ---------- Work list (card rows) ---------- */
.wl-list{
  display: grid; gap: 8px;
  margin: 0; padding: 0; list-style: none;
}
.wl-row{
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px;
  padding: 12px;
  border: 1px solid #e2e8f0; border-radius: 12px;
  background: #fff;
}
.wl-main{ flex: 1 1 0; min-width: 0; }
.wl-side{
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  text-align: right;
}
.wl-actions{
  flex: 1 0 100%;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.wl-code{
  font-size: 12px; line-height: 1.3; color: #64748b;
  word-break: break-all;
}
.wl-name{
  font-size: 15px; font-weight: 600; line-height: 1.35; color: #0f172a;
  word-break: break-word;
}
.wl-meta{
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
  margin-top: 4px;
  font-size: 12px; line-height: 1.4; color: #64748b;
}
.wl-row.is-done{
  background: #f8fafc;
  opacity: .55;
}

/* ---------- Chips ---------- */
.chip{
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border: 1px solid transparent; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
  white-space: nowrap;
}
.chip--ok{ background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.chip--warn{ background: #fef3c7; border-color: #fde68a; color: #92400e; }
.chip--danger{ background: #fee2e2; border-color: #fecaca; color: #b91c1c; }
.chip--info{ background: #e0f2fe; border-color: #bae6fd; color: #075985; }
.chip--muted{ background: #f1f5f9; border-color: #e2e8f0; color: #64748b; }
.rack-chips{ display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Buttons ---------- */
.btn-sm, .btn-primary, .btn-ghost, .btn-danger{
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; height: auto; padding: 0 14px;
  /* 창고네비의 .toolbar button / .detail-actions button 과 같은 서식 */
  border: 1px solid #e2e8f0; border-radius: 10px;
  background: #f8fafc; color: #0f172a;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  white-space: nowrap;
  cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: filter .15s ease, transform .05s ease, background-color .15s ease, border-color .15s ease;
}
.btn-sm{ padding: 0 10px; font-size: 13px; }
.btn-primary{ background: #0ea5e9; border-color: #0284c7; color: #fff; }
.btn-ghost{ background: #fff; border-color: #e2e8f0; color: #0f172a; }
.btn-danger{ background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.btn-sm:hover, .btn-primary:hover, .btn-ghost:hover, .btn-danger:hover{ filter: brightness(.98); }
.btn-sm:active, .btn-primary:active, .btn-ghost:active, .btn-danger:active{ transform: translateY(1px); }
.btn-sm:focus-visible, .btn-primary:focus-visible, .btn-ghost:focus-visible, .btn-danger:focus-visible,
.seg > button:focus-visible, .tabbar__tab:focus-visible{
  outline: 2px solid #38bdf8; outline-offset: 2px;
}
.btn-sm:disabled, .btn-primary:disabled, .btn-ghost:disabled, .btn-danger:disabled{
  opacity: .5; cursor: not-allowed; filter: none; transform: none;
}

/* ---------- Forms ---------- */
.form-grid{
  display: grid; grid-template-columns: 1fr; gap: 12px;
}
.field{
  display: grid; gap: 6px; min-width: 0;
  font-size: 13px; font-weight: 600; color: #334155;
}
.field > label, .field > span{ font-size: 13px; font-weight: 600; color: #334155; }
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea,
dialog .field input[type="text"],
dialog .field input[type="number"]{
  width: 100%; min-width: 0;
  height: 40px; padding: 0 10px;
  border: 1px solid #cbd5e1; border-radius: 10px;
  background: #fff; color: #0f172a;
  font: inherit; font-size: 16px; font-weight: 400;
}
.field textarea{ height: auto; min-height: 72px; padding: 8px 10px; line-height: 1.4; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus{
  outline: none; border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56,189,248,.25);
}
.field input:disabled, .field select:disabled, .field textarea:disabled,
.field input[readonly]{ background: #f1f5f9; color: #64748b; }

/* ---------- Segmented buttons ---------- */
.seg{
  display: inline-flex; max-width: 100%;
  border: 1px solid #e2e8f0; border-radius: 10px;
  background: #fff; overflow: hidden;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
}
.seg > button{
  appearance: none;
  flex: 1 1 auto;
  min-height: 40px; height: auto; padding: 0 12px;
  border: 0; border-left: 1px solid #e2e8f0; border-radius: 0;
  background: #f8fafc; color: #0f172a;
  font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.seg > button:first-child{ border-left: 0; }
.seg > button.is-active{ background: #0ea5e9; color: #fff; }
.seg > button:disabled{ opacity: .5; cursor: not-allowed; }

/* ---------- Date bar (UI.dateBar) ---------- */
.date-bar{ display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.date-bar .date-bar__today{ min-height: 34px; padding: 0 10px; }
.date-bar .date-bar__today[hidden]{ display: none; }
.date-bar .date-bar__all{ min-height: 34px; padding: 0 12px; }
.date-bar .date-bar__all.is-active{ background: #0ea5e9; border-color: #0ea5e9; color: #fff; }
.date-bar .date-bar__input,
.view-head input[type="date"]{
  flex: 0 0 auto; width: 136px; min-width: 0;
  height: 34px; padding: 0 6px;
  border: 1px solid #cbd5e1; border-radius: 10px;
  background: #fff; color: #0f172a;
  font: inherit; font-size: 16px;   /* 16px 미만이면 iOS가 화면을 확대한다 */
}
.date-bar .date-bar__input:focus,
.view-head input[type="date"]:focus{
  outline: none; border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56,189,248,.25);
}

/* ---------- Bottom tab bar (#footerActions) ---------- */
.footer-actions.tabbar{
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex; align-items: stretch; gap: 0;
  padding: 0 4px env(safe-area-inset-bottom, 0px);
  border-top: 1px solid #e2e8f0;
  background: rgba(255,255,255,.96);
  -webkit-backdrop-filter: saturate(120%) blur(6px);
  backdrop-filter: saturate(120%) blur(6px);
  overflow-x: auto; overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.footer-actions.tabbar::-webkit-scrollbar{ display: none; }
.tabbar__tab{
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  min-width: 72px; min-height: 52px; padding: 6px 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 0; border-top: 3px solid transparent; border-radius: 0;
  background: transparent; color: #64748b;
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* 넓은 화면에서는 가운데 정렬, 좁으면 왼쪽부터 스크롤 */
.tabbar__tab:first-child{ margin-left: auto; }
.tabbar__tab:last-child{ margin-right: auto; }
.tabbar__tab:hover{ color: #0f172a; }
.tabbar__tab.is-active{
  color: #0ea5e9; border-top-color: #0ea5e9; font-weight: 700;
  background: linear-gradient(180deg, rgba(14,165,233,.10), rgba(14,165,233,0));
}
.tabbar__badge{
  flex: 0 0 auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  pointer-events: none;
}
.tabbar__badge[hidden]{ display: none; }

/* ---------- Toast ---------- */
.toast-host{
  position: fixed;
  left: 12px; right: 12px; top: auto;
  bottom: calc(var(--footer-h, 56px) + 12px);
  z-index: 1500;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  /* popover 기본 스타일 초기화 */
  inset-inline: 12px;
  width: auto; height: auto; margin: 0; padding: 0;
  border: 0; background: transparent; color: inherit; overflow: visible;
  pointer-events: none;
}
.toast-host:not(:has(.toast)){ display: none; }
.toast{
  max-width: min(480px, 100%);
  padding: 10px 14px;
  border-radius: 12px;
  background: #0f172a; color: #fff;
  font-size: 14px; font-weight: 500; line-height: 1.4;
  word-break: break-word;
  box-shadow: 0 8px 24px rgba(2,8,23,.22);
  pointer-events: auto;
  animation: ui-toast-in .18s ease-out;
  transition: opacity .2s ease, transform .2s ease;
}
.toast--ok{ background: #15803d; }
.toast--error{ background: #b91c1c; }
.toast.is-leaving{ opacity: 0; transform: translateY(6px); }
@keyframes ui-toast-in{
  from{ opacity: 0; transform: translateY(8px); }
  to{ opacity: 1; transform: none; }
}

/* ---------- Confirm dialog (UI.confirm) ---------- */
dialog.ui-confirm{
  width: min(360px, calc(100vw - 32px));
  padding: 0;
}
.ui-confirm__body{
  padding: 20px 18px 12px;
  font-size: 15px; line-height: 1.5; color: #0f172a;
  white-space: pre-line; word-break: break-word;
}
.ui-confirm__actions{
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 8px 18px 18px;
}
dialog.ui-confirm .ui-confirm__actions button{ min-height: 44px; font-size: 15px; }

@media (min-width: 640px){
  .form-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabbar__tab{ min-width: 96px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce){
  .toast{ animation: none; transition: none; }
}

/* ---------- 신규입고 탭 (목록은 app.js가 그린다) ---------- */
#view-newinbound .new-inbound-toolbar{ align-items: center; }
#view-newinbound .view-head .new-inbound-date-field{ font-size: 0; gap: 0; }   /* '날짜' 글자는 숨기고 칸만 */
#view-newinbound .view-head .new-inbound-date-field input[type="date"]{ min-width: 0; }
#view-newinbound .new-inbound-toolbar #newInboundSource{ flex: 1 1 100%; font-size: 12px; }
#view-newinbound .new-inbound-toolbar .new-inbound-query{ flex: 1 1 160px; }
#view-newinbound .new-inbound-table-wrap{ padding: 0; overflow-x: auto; }
#view-newinbound #tblNewInbound tbody tr{ cursor: pointer; }
#view-newinbound .new-inbound-actions{
  bottom: var(--footer-h, 56px);
  gap: 8px; margin-top: 8px; padding: 10px 0;
}
#view-newinbound .new-inbound-actions button{ flex: 1 1 0; min-height: 48px; font-size: 16px; }

/* ---------- 사진으로 코드 읽기 (scan.js) ---------- */
[data-scan-for]{ flex: 0 0 auto; min-width: 40px; padding: 0 8px; font-size: 17px; line-height: 1; }
dialog.scan-choose{ width: min(360px, calc(100vw - 32px)); }
.scan-choose__list{ display: grid; gap: 8px; padding: 12px 16px; max-height: 50vh; overflow: auto; }
.scan-choose__list button{
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  height: auto; min-height: 44px; padding: 6px 12px;
  font-size: 16px; text-align: left; word-break: break-all;
}
.scan-choose__list button small{ font-size: 12px; font-weight: 500; color: #64748b; }

/* 화면 내 카메라: 화면 전체를 덮고, 보이는 장면이 그대로 찍히도록 영상은 잘라내지 않는다 */
dialog.scan-cam{
  width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh;
  margin: 0; padding: 0; border: 0; border-radius: 0;
  background: #000; color: #fff; overflow: hidden;
}
dialog.scan-cam[open]{ display: flex; flex-direction: column; }
dialog.scan-cam::backdrop{ background: #000; }
.scan-cam__video{ flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.scan-cam__hint{ margin: 0; padding: 8px 12px; text-align: center; font-size: 13px; color: #e2e8f0; }
.scan-cam__bar{
  flex: 0 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
dialog.scan-cam .scan-cam__side{
  justify-self: center; height: 44px; padding: 0 14px;
  border: 1px solid rgba(255,255,255,.35); border-radius: 10px;
  background: rgba(255,255,255,.12); color: #fff; font-size: 14px; font-weight: 600;
}
dialog.scan-cam .scan-cam__shutter{
  width: 76px; height: 76px; padding: 0; border-radius: 50%;
  border: 5px solid rgba(255,255,255,.55); background: #fff; background-clip: padding-box;
}
dialog.scan-cam .scan-cam__shutter:disabled{ opacity: .4; }
dialog.scan-cam .scan-cam__shutter:active{ transform: scale(.94); }

