/* ============================================================
   chat.css — 遺品整理業者選び方ガイド チャット風申し込みUI

   配色は参考にした空き家買取チャット(aki-lucky)と完全に同じ緑を使用
   （2026-08-19オーナー指示：オレンジ統一から差し戻し、akiボットと同一トンマナに）。
     --chat-green-1: #3ecb5e / --chat-green-2: #1caf41（ヘッダー・タイル・ボタンのグラデ）
     --chat-green-ink: #1caf41（強調テキスト・検索演出・フォーカスリング）
     必須タグ=赤(#d32f2f)・エラー=赤(#c62828)は元のaki-luckyと同じ意味色として維持。
   ============================================================ */

.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;

  height: 100%;
  height: 100dvh;

  background: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Meiryo", sans-serif;

  --chat-green-1: #3ecb5e;
  --chat-green-2: #1caf41;
  --chat-green-ink: #1caf41;
  --chat-green-glow: rgba(28, 175, 65, 0.32);
}

.chat-overlay[hidden] {
  display: none;
}

.chat-frame {
  width: 100%;
  max-width: 480px;
  min-height: 100%;
  margin: 0 auto;
  background: #eef1f4;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, var(--chat-green-1) 0%, var(--chat-green-2) 100%);
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}

.chat-header-title {
  flex: 1 1 auto;
  min-width: 0;
  padding-left: 2px;
}

.chat-header-name {
  display: block;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.3;
}

.chat-header-sub {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  opacity: 0.92;
}

.chat-iconbtn {
  flex: 0 0 auto;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 0;
  border-radius: 22px;
  color: #ffffff;
  font-family: inherit;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chat-iconbtn:active {
  background: rgba(255, 255, 255, 0.32);
}

.chat-remain {
  display: block;
  padding: 7px 14px;
  background: #ffffff;
  border-bottom: 1px solid #e2e6e9;
  color: var(--chat-green-ink);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.02em;
}

/* ── 建物の種類タイル ─────────────────────────────────── */
.chat-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin: 4px 0 16px;
}

.chat-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 108px;
  padding: 16px 8px;
  background: linear-gradient(180deg, var(--chat-green-1) 0%, var(--chat-green-2) 100%);
  border: 0;
  border-bottom: 4px solid rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  color: #ffffff;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--chat-green-glow);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, border-bottom-width 0.1s ease;
}

.chat-tile:active {
  transform: translateY(3px);
  border-bottom-width: 1px;
}

.chat-tile-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.chat-tile-icon svg {
  width: 25px;
  height: 25px;
  fill: var(--chat-green-2);
}

.chat-tile span {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.26);
}

.chat-tiles.is-decided .chat-tile span {
  text-shadow: none;
}
.chat-tiles.is-decided .chat-tile.is-selected span {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.26);
}

.chat-tiles.is-decided .chat-tile {
  background: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.1);
  color: #46544b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.chat-tiles.is-decided .chat-tile-icon {
  background: #eaf9ee;
}
.chat-tiles.is-decided .chat-tile-icon svg {
  fill: #a6b8ac;
}
.chat-tiles.is-decided .chat-tile.is-selected {
  background: linear-gradient(180deg, var(--chat-green-1) 0%, var(--chat-green-2) 100%);
  border-bottom-color: rgba(0, 0, 0, 0.18);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--chat-green-glow);
}
.chat-tiles.is-decided .chat-tile.is-selected .chat-tile-icon svg {
  fill: var(--chat-green-2);
}

/* ── 日本列島＝地方選択（②-a・2026-08-25追加）──────────────
   ★選択パネルそのものが列島になっている★
   地図と選択を分けると「別れちゃうと意味がない」ため、パネルを列島の位置関係に
   並べ、大きさも地方の実サイズに合わせている（北海道・東北が最大／四国が最小）。
   配色はチャット既存の緑トンマナ（--chat-green-*）に揃えている。 */
.chat-map {
  margin: 4px 0 16px;
  padding: 12px 10px;
  background: #f2faf4;
  border: 1px solid #d8ecdd;
  border-radius: 14px;
}

/* パネル自体が列島。各地方が押せるボタンになっている */
.chat-jp {
  display: block;
  width: 100%;
  height: auto;
}

.chat-jp-rg {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chat-jp-rg:focus {
  outline: none;
}

.chat-jp-rg rect {
  stroke: #f2faf4;
  stroke-width: 2.4;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.16));
  transition: filter 0.1s ease;
}
.chat-jp-rg text {
  fill: #ffffff;
  font-family: inherit;
  font-weight: 900;
  text-anchor: middle;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.26);
  pointer-events: none; /* 文字を貫通させてパネル側でクリックを拾う */
}

.chat-jp-rg:focus-visible rect {
  stroke: #0f7f2e;
}
.chat-jp-rg:active rect {
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.16));
}

/* 決定後：選んだ地方だけ緑で残し、他は白に落とす（タイルと同じ作法）。
   ★押し間違えても選び直せるよう、決定後もクリック可のまま（cursorも変えない）★ */
.chat-jp.is-decided .chat-jp-rg rect {
  fill: #ffffff !important;
  stroke: #e2ece5;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.06));
}
.chat-jp.is-decided .chat-jp-rg text {
  fill: #a6b8ac;
  text-shadow: none;
}
.chat-jp.is-decided .chat-jp-rg.is-selected rect {
  fill: url(#chatJpGrad) !important;
  stroke: #f2faf4;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.16));
}
.chat-jp.is-decided .chat-jp-rg.is-selected text {
  fill: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.26);
}

/* ── 都道府県タイル（②-b・2026-08-25追加）───────────────────
   建物の種類タイルと同じ .chat-tile / .is-selected / .is-decided を流用し、
   サイズだけ詰める。アイコンが無く1行なので文字はボタン直下に置いている
   （＝.chat-tile span のルールは効かないので、ここで指定する）。 */
.chat-tiles--pref {
  gap: 9px;
  margin-bottom: 10px;
}

.chat-tile--pref {
  min-height: 0;
  padding: 13px 6px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.26);
}

.chat-tiles.is-decided .chat-tile--pref {
  text-shadow: none;
}
.chat-tiles.is-decided .chat-tile--pref.is-selected {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.26);
}

/* 地方を選び直す（選択が3段になるので戻り道を用意する） */
.chat-relink {
  display: block;
  margin: -4px 0 16px;
  padding: 6px 2px;
  background: none;
  border: 0;
  color: var(--chat-green-ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* ── 吹き出し ─────────────────────────────────────────── */
.chat-messages {
  padding: 16px 12px 4px;
}

.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  animation: chat-in 0.26s ease both;
}

@keyframes chat-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-row {
    animation: none;
  }
}

/* 笑顔のコールセンター風オペレーター写真（baked_images/chat-avatar.webp、
   akiボットと同一の画像・同一のトリミング設定）。 */
.chat-avatar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background-color: #d9f0e1;
  background-image: url("baked_images/chat-avatar.webp");
  background-repeat: no-repeat;
  background-position: center 29%;
  background-size: 160%;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

/* 写真を使うのでSVGは非表示にする（画像差し替え時の保険として残す） */
.chat-avatar svg {
  display: none;
  width: 22px;
  height: 22px;
  fill: var(--chat-green-2);
}

.chat-bubble {
  max-width: 84%;
  padding: 13px 15px;
  border-radius: 13px;
  background: #dcefe1;
  border-top-left-radius: 4px;
  color: #26332a;
  font-size: 16px;
  line-height: 1.65;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}

.chat-bubble strong {
  color: #0f7a2c;
  font-weight: 900;
}

.chat-bubble-note {
  display: block;
  margin-top: 6px;
  color: #4a5a4e;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.chat-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--chat-green-ink);
  font-weight: 800;
}

.chat-search-dots {
  display: inline-flex;
  gap: 5px;
}

.chat-search-dots i {
  width: 7px;
  height: 7px;
  background: var(--chat-green-ink);
  border-radius: 50%;
  animation: chat-dot 1s ease-in-out infinite;
}

.chat-search-dots i:nth-child(2) {
  animation-delay: 0.15s;
}
.chat-search-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

.chat-typing {
  display: flex;
  gap: 5px;
  padding: 4px 2px;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  background: #b3bfc7;
  border-radius: 50%;
  animation: chat-dot 1s ease-in-out infinite;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.16s;
}
.chat-typing span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes chat-dot {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

/* ── 対応業者カード（既存フォームのvendor-cardと同じ見せ方をチャット内で再現） ── */
.chat-vendor-card {
  margin: 4px 0 16px;
  padding: 18px 14px;
  background: #ffffff;
  border: 2px solid var(--chat-green-2);
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 2px 10px var(--chat-green-glow);
}

.chat-vendor-name {
  margin: 0 0 10px;
  color: var(--chat-green-ink);
  font-size: 22px;
  font-weight: 900;
}

.chat-vendor-badge {
  display: inline-block;
  margin: 0 0 12px;
  padding: 4px 12px;
  background: #eaf9ee;
  border: 1px solid #bfe3cd;
  border-radius: 20px;
  color: var(--chat-green-ink);
  font-size: 12px;
  font-weight: 800;
}

.chat-vendor-feats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.chat-feat-chip {
  padding: 4px 10px;
  background: #f2faf4;
  border: 1px solid #bfe3cd;
  border-radius: 20px;
  color: #2f7d4a;
  font-size: 12px;
  font-weight: 800;
}

/* ── 入力カード ───────────────────────────────────────── */
.chat-card {
  margin: 4px 0 16px;
  padding: 15px 14px 14px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.chat-field {
  margin-bottom: 12px;
}

.chat-field-label {
  display: block;
  margin-bottom: 6px;
  color: #333333;
  font-size: 13px;
  font-weight: 900;
}

.chat-card-label {
  display: block;
  margin-bottom: 9px;
  color: #333333;
  font-size: 17px;
  font-weight: 900;
}

.chat-req,
.chat-opt {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 900;
  vertical-align: 1px;
}

.chat-req {
  background: #d32f2f;
  color: #ffffff;
}

.chat-opt {
  background: #eceff1;
  color: #6b7a83;
}

.chat-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  background: #fffdf0;
  border: 1px solid #b9b9b9;
  border-radius: 8px;
  color: #222222;
  font-family: inherit;
  font-size: 17px;
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
}

.chat-input::placeholder {
  color: #a9aeb2;
}

.chat-input:focus {
  background: #ffffff;
  border-color: var(--chat-green-ink);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(28, 175, 65, 0.22);
}

textarea.chat-input {
  min-height: 84px;
  resize: vertical;
}

.chat-error {
  margin: -2px 0 10px;
  color: #c62828;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.chat-error[hidden] {
  display: none;
}

/* ── 次へ／送信ボタン ─────────────────────────────────── */
.chat-next {
  display: block;
  width: 100%;
  min-height: 58px;
  margin: 14px 0 0;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--chat-green-1) 0%, var(--chat-green-2) 100%);
  border: 0;
  border-radius: 30px;
  color: #ffffff;
  font-family: inherit;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(28, 175, 65, 0.38);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.chat-next:active {
  transform: scale(0.985);
}

.chat-next:disabled {
  background: #c9cfd4;
  box-shadow: none;
  cursor: default;
}

/* ── 送信前のみなし同意注記（既存フォームと同一文言・チェックボックスなし） ──
   ★2026-08-27: CTAの【下】に移した（ユーザー指示）。ボタンと密着するので上の余白を広げる。 */
.chat-consent-note {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: #ffffff;
  border-radius: 10px;
  color: #55605c;
  font-size: 13px;
  line-height: 1.6;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ── 下部の余白（アドレスバー・ホームバー等に被らないように） ── */
.chat-tail {
  height: 40vh;
  height: 40dvh;
  min-height: 220px;
}

/* ── ローカル確認モードの帯（本番では出ない） ────────────── */
.chat-devnote {
  padding: 6px 12px;
  background: #fff3cd;
  border-bottom: 1px solid #ffe08a;
  color: #7a5b00;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

/* ── 市区町村の入力補助（2026-08-27追加）─────────────────────
   入力しながら候補を絞る方式に確定（2026-08-27）。?city_ui=text で候補を止められる
   ★市区町村はエリア判定（AREA_MAPは都道府県キー）に使われないので、
     どの方式でも最後は手入力に落とせるようにしてある。 */
.chat-city {
  margin: -6px 0 14px;
}

/* --- auto：候補リスト --- */
.chat-city-sug {
  display: flex;
  flex-direction: column;
  border: 1px solid #e3e8ef;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 6px 16px rgba(20, 30, 50, 0.08);
  max-height: 232px;
  overflow-y: auto;
}

.chat-city-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid #f0f3f7;
  background: #fff;
  font-size: 15px;
  font-weight: 700;
  color: #1a2233;
  text-align: left;
  cursor: pointer;
}
.chat-city-item:last-child {
  border-bottom: 0;
}
.chat-city-item:active {
  background: #f3faf5;
}

.chat-city-kana {
  font-size: 11px;
  font-weight: 600;
  color: #8a94a6;
  letter-spacing: 0.02em;
}

/* データ未収録・サンプル表示の注記 */
.chat-city-note {
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: #8a94a6;
}
