/* ============================================================
   革製品オーダーメイド受付アプリ スタイル
   iPadでの操作(大きめのタップ領域・見やすい文字サイズ)を意識
   ============================================================ */

:root {
  --color-bg: #f7f2ea;
  --color-surface: #ffffff;
  --color-primary: #8a5a3b;
  --color-primary-dark: #6e4429;
  --color-accent: #c98a4b;
  --color-text: #3a2b20;
  --color-text-muted: #8a7d70;
  --color-border: #e4d8c8;
  --color-danger: #b5482f;
  --color-success: #4b7a4f;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(58, 43, 32, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Hiragino Sans", "Yu Gothic", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh; /* dvh未対応の古いiPadOS向けフォールバック */
  height: 100dvh;
}

/* ---------- ヘッダー ---------- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--color-primary);
  color: #fff;
  flex: 0 0 auto;
  padding-top: max(14px, env(safe-area-inset-top));
}
.app-header__title { font-size: 1.15rem; font-weight: 700; }
.app-header__status { font-size: 0.8rem; opacity: 0.9; }
.app-header__status.is-offline { color: #ffd9c2; }

/* ---------- メインエリア ---------- */
.app-main {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 100px;
}

.view { display: none; }
.view.is-active { display: block; }

h2 { font-size: 1.3rem; margin: 0 0 16px; color: var(--color-primary-dark); }
h3 { font-size: 1rem; margin: 20px 0 8px; color: var(--color-primary-dark); }

/* ---------- 下部タブバー ---------- */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.72rem;
  cursor: pointer;
}
.tabbar__btn.is-active { color: var(--color-primary); font-weight: 700; }
.tabbar__icon { font-size: 1.3rem; }

/* ---------- ボタン共通 ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
}
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:active { background: var(--color-primary-dark); }
.btn--ghost { background: transparent; color: var(--color-primary); border: 1px solid var(--color-border); }
.btn--confirm { background: var(--color-success); color: #fff; }
.btn:disabled { opacity: 0.5; }

/* ---------- ウィザード ---------- */
.wizard { max-width: 900px; margin: 0 auto; }

.wizard__progress {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}
.progress-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--color-border);
}
.progress-dot.is-done { background: var(--color-accent); }
.progress-dot.is-current { background: var(--color-primary); transform: scale(1.3); }

.wizard__step { display: none; }
.wizard__step.is-active { display: block; }

.wizard__nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}
.wizard__nav .btn--primary,
.wizard__nav .btn--confirm { margin-left: auto; }

/* ---------- 選択グリッド(革/ステッチ/ファスナー) ---------- */
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.picker-grid.is-disabled { opacity: 0.4; pointer-events: none; }

.picker-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow);
}
.picker-card.is-selected { border-color: var(--color-primary); background: #fbf3ea; }
.picker-card img {
  width: 100%; height: 100px; object-fit: cover; border-radius: 8px; display: block;
}
.picker-card__noimg {
  width: 100%; height: 100px; border-radius: 8px;
  background: var(--color-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted); font-size: 0.8rem;
}
.picker-card__name { margin-top: 8px; font-size: 0.85rem; font-weight: 600; }

.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 16px; font-size: 0.95rem;
}
.checkbox-row input { width: 20px; height: 20px; }

/* ---------- フォーム ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label,
.settings-block label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted);
}
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="search"], textarea {
  font-size: 1rem;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
}
textarea { resize: vertical; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- 確認画面 ---------- */
.confirm-summary { background: var(--color-surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--color-border); font-size: 0.92rem; }
.summary-row:last-child { border-bottom: none; }
.summary-row__label { color: var(--color-text-muted); flex: 0 0 40%; }
.summary-row__value { flex: 1; text-align: right; word-break: break-all; }
.confirm-note { margin-top: 14px; color: var(--color-text-muted); font-size: 0.85rem; }

/* ---------- 完了画面 ---------- */
.done-screen { text-align: center; padding: 40px 20px; }
.done-screen__icon {
  width: 64px; height: 64px; margin: 0 auto 16px;
  border-radius: 50%; background: var(--color-success); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 2rem;
}
.done-screen p { color: var(--color-text-muted); }
.done-screen .btn { margin-top: 20px; }

/* ---------- 履歴 ---------- */
.search-box { width: 100%; margin-bottom: 16px; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-card {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--color-surface); border: none; border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; text-align: left;
}
.history-card__title { font-weight: 700; margin-bottom: 4px; }
.history-card__sub { font-size: 0.8rem; color: var(--color-text-muted); }
.mail-badge { font-size: 0.75rem; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.mail-badge--sent { background: #e3f0e4; color: var(--color-success); }
.mail-badge--failed { background: #fbe4df; color: var(--color-danger); }
.mail-badge--not_configured { background: #f0ece3; color: var(--color-text-muted); }
.mail-badge--pending { background: #fdf1de; color: var(--color-accent); }

/* ---------- カタログ管理 ---------- */
.subtabs { display: flex; gap: 8px; margin-bottom: 16px; }
.subtab {
  flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text-muted); font-weight: 600; cursor: pointer;
}
.subtab.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.catalog-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.catalog-card {
  display: flex; gap: 10px; align-items: center; text-align: left;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 10px; cursor: pointer; box-shadow: var(--shadow);
}
.catalog-card img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.catalog-card .picker-card__noimg { width: 56px; height: 56px; flex: 0 0 auto; font-size: 0.65rem; }
.catalog-card__name { font-weight: 700; font-size: 0.9rem; }
.catalog-card__memo { font-size: 0.78rem; color: var(--color-text-muted); }

/* ---------- 設定 ---------- */
.settings-block {
  background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px;
}
.settings-help { font-size: 0.82rem; color: var(--color-text-muted); line-height: 1.5; }
.saved-msg { color: var(--color-success); font-weight: 600; margin-top: 10px; }

/* ---------- 空状態 ---------- */
.empty-state { color: var(--color-text-muted); text-align: center; padding: 30px 0; grid-column: 1 / -1; }

/* ---------- モーダル ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(58, 43, 32, 0.5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal[hidden] { display: none; }
.modal__box {
  background: var(--color-surface); border-radius: var(--radius); padding: 20px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.modal__box--wide { max-width: 640px; }
.modal__box label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.88rem; color: var(--color-text-muted); }
.modal__actions { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.modal__actions-right { display: flex; gap: 10px; }

.photo-input { display: flex; flex-direction: column; gap: 8px; }
.photo-input__preview { width: 100%; max-height: 160px; object-fit: cover; border-radius: 8px; }

/* ---------- 商品のパーツ編集 ---------- */
.parts-editor { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--color-border); padding-top: 14px; }
.parts-editor h4 { margin: 0; font-size: 0.95rem; color: var(--color-primary-dark); }
.parts-editor__list { display: flex; flex-direction: column; gap: 10px; }

.part-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  align-items: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px;
}
.part-row__label, .part-row__type {
  font-size: 0.9rem;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}
.part-row__required {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.78rem; color: var(--color-text-muted); white-space: nowrap;
}
.part-row__remove {
  background: none; border: none; color: var(--color-danger);
  font-size: 0.8rem; cursor: pointer; white-space: nowrap; padding: 6px;
}
.parts-empty-hint { color: var(--color-text-muted); font-size: 0.85rem; }

@media (max-width: 640px) {
  .part-row { grid-template-columns: 1fr; }
}

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--color-text); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 0.85rem; z-index: 100; box-shadow: var(--shadow);
}
