/* ============================================================
   web-app-v1 — スタイル
   （委託先アプリ index.html のCSSを移植・拡張。フレームワーク不使用）
   ============================================================ */

/* ===== リセット & ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic', sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
  font-size: 15px;
}
button { font-family: inherit; }

/* ===== ヘッダー ===== */
.header {
  background: #1a1a2e;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-title { font-size: 15px; font-weight: 700; }
.header-sub { font-size: 12px; color: #aaa; }
.env-badge {
  background: #f59e0b;
  color: #1a1a2e;
  font-size: 10px;
  font-weight: 800;
  border-radius: 4px;
  padding: 1px 6px;
  vertical-align: middle;
}
.env-badge:empty { display: none; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}
.icon-btn.spinning { animation: spin 1s linear infinite; display: inline-block; }
.logout-btn {
  background: transparent;
  border: 1px solid #555;
  color: #aaa;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.logout-btn:hover { background: #333; }

/* ===== メインコンテナ ===== */
.container { max-width: 640px; margin: 0 auto; padding: 14px 14px 90px; }

/* ===== ログイン画面（委託先アプリと同型） ===== */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand { font-size: 22px; font-weight: 800; letter-spacing: .05em; color: #1a1a2e; }
.login-logo .sub { font-size: 12px; color: #888; margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 6px; }
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  font-size: 16px; /* 16px以上でiOSのズームを防ぐ */
  outline: none;
  background: #fff;
  transition: border-color .2s;
}
.form-input:focus { border-color: #1a1a2e; }
.login-btn {
  width: 100%;
  padding: 14px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background .2s;
}
.login-btn:hover { background: #2d2d4e; }
.login-btn:disabled { background: #aaa; cursor: not-allowed; }
.error-msg {
  background: #fff0f0;
  border: 1px solid #ffcccc;
  color: #c00;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 14px;
  display: none;
}

/* ===== 検索・フィルタ ===== */
.filter-bar { margin-bottom: 12px; }
.search-input { margin-bottom: 8px; }
.filter-row { display: flex; gap: 8px; align-items: center; }
.filter-select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  outline: none;
}
.filter-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #555;
  white-space: nowrap;
  cursor: pointer;
}

.item-count { font-size: 13px; color: #888; margin-bottom: 10px; }
.item-count strong { color: #1a1a2e; }
.sync-time { font-size: 11px; color: #bbb; margin-left: 6px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.screen-title {
  font-size: 13px;
  font-weight: 600;
  color: #888;
  letter-spacing: .05em;
}

/* ===== 商品カード（委託先アプリと同型＋在庫バッジ） ===== */
.item-card {
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  cursor: pointer;
}
.item-icon {
  width: 48px;
  height: 48px;
  background: #f0f2f5;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.item-img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f0f2f5;
}
.item-info { flex: 1; min-width: 0; }
.item-brand { font-size: 11px; color: #888; font-weight: 600; letter-spacing: .03em; }
.item-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0;
}
.item-meta { font-size: 12px; color: #aaa; }
.item-price { font-size: 13px; color: #444; font-weight: 600; margin-top: 2px; }
.item-stock { text-align: center; flex-shrink: 0; }
.stock-label { font-size: 10px; color: #aaa; margin-top: 2px; }

.stock-badge {
  display: inline-block;
  min-width: 34px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #e8f5e9;
  color: #15803d;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
}
.stock-badge.zero { background: #f0f0f0; color: #999; }
.stock-badge.negative { background: #fee2e2; color: #dc2626; }
.negative-note { font-size: 11px; color: #dc2626; margin-left: 8px; }

.more-note { text-align: center; font-size: 12px; color: #aaa; padding: 14px 0; }

/* ===== ボタン ===== */
.primary-btn {
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.primary-btn:hover { background: #2d2d4e; }
.secondary-btn {
  background: #eef1f7;
  color: #1a1a2e;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.primary-btn.small, .secondary-btn.small {
  padding: 8px 14px;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}
button:disabled { opacity: .5; cursor: not-allowed; }

/* ===== ボトムナビ ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  z-index: 100;
}
.nav-item {
  background: none;
  border: none;
  font-size: 11px;
  font-weight: 600;
  color: #999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 18px;
  border-radius: 10px;
}
.nav-item.active { color: #1a1a2e; background: #eef1f7; }
.nav-icon { font-size: 20px; }
.nav-scan {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1a1a2e;
  border: none;
  cursor: pointer;
  margin-top: -22px;
  box-shadow: 0 4px 12px rgba(26,26,46,.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-scan-icon { font-size: 24px; }

/* ===== ローディング・空状態 ===== */
.loading { text-align: center; padding: 40px 0; color: #aaa; font-size: 14px; }
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e0e0e0;
  border-top-color: #1a1a2e;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 60px 20px; color: #aaa; }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== トースト =====
   画面上部（ヘッダー下）に表示。下部だとスキャンボタンや操作を隠すため。
   pointer-events:none で表示中も下のボタンをタップできる */
.toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(-130px);
  background: #1a1a2e;
  color: #fff;
  padding: 12px 22px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  transition: transform .3s ease;
  z-index: 999;
  max-width: 92vw;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: #ef4444; }

/* ===== モーダル / ボトムシート ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  transform: translateY(40px);
  transition: transform .25s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.modal-body { font-size: 13px; color: #555; margin: 12px 0; line-height: 1.6; }
.modal-product {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions.column { flex-direction: column; }
.modal-cancel {
  flex: 1;
  padding: 12px;
  background: #f0f0f0;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.modal-cancel.full { width: 100%; margin-top: 12px; }
.modal-confirm {
  flex: 2;
  padding: 12px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.modal-confirm.blue { background: #1a1a2e; }

/* ===== 商品詳細 ===== */
.detail-stock { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.detail-table { margin-bottom: 6px; }
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}
.detail-key { color: #888; }
.detail-val { font-weight: 600; text-align: right; }

/* ===== フォーム部品 ===== */
.form-row { display: flex; gap: 10px; }
.form-group.half { flex: 1; }
.radio-row, .check-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-chip input, .check-chip input { display: none; }
.radio-chip span, .check-chip span {
  display: inline-block;
  padding: 9px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: all .15s;
}
.radio-chip input:checked + span,
.check-chip input:checked + span {
  background: #1a1a2e;
  border-color: #1a1a2e;
  color: #fff;
}
.qty-stepper { display: flex; align-items: center; gap: 6px; }
.qty-stepper button {
  width: 42px;
  height: 44px;
  border: 1.5px solid #e0e0e0;
  background: #fff;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.qty-input { text-align: center; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn .form-input { flex: 1; }
.item-preview { font-size: 12px; color: #15803d; margin-top: 6px; min-height: 16px; }

/* ===== スキャナー ===== */
.modal.scanner { border-radius: 16px; margin: 0 14px 14px; }
#scanner-video {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 12px;
  object-fit: cover;
}
.scanner-status {
  text-align: center;
  font-size: 13px;
  color: #888;
  margin-top: 10px;
  min-height: 18px;
}
.photo-btn {
  display: block;
  text-align: center;
  margin-top: 12px;
  cursor: pointer;
}

/* PCでの表示調整 */
@media (min-width: 700px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 16px; }
}
