/* ============================================================
   Search Map Screen — フルスクリーンオーバーレイ
   gubook AIサポーター（メガネさん検索）
   カラーパレット: ダークブラウン #3c2415, プライマリブラウン #5a3e28,
                  古紙ベージュ #f5eed8, 背景 #f0e6d3,
                  カード背景 #faf5eb, ボーダー #c4b59a
   フォント: 'Noto Serif JP', serif
   タップ領域: 最低44px
   ============================================================ */

/* ============================================================
   1. フルスクリーンオーバーレイ
   ============================================================ */
.search-map-screen {
  position: fixed;
  top: var(--header-height, 48px);
  left: 0;
  right: 0;
  bottom: calc(var(--nav-height, 64px) + var(--safe-area-bottom, 0px));
  z-index: 105;
  display: flex;
  flex-direction: column;
  background: #f0e6d3;
  font-family: 'Noto Serif JP', serif;
}

/* ============================================================
   2. 上部バー（メガネさん + 検索バー）
   ============================================================ */
.sms-top-bar {
  display: flex;
  align-items: center;
  padding: 12px 12px 8px;
  gap: 10px;
  background: #f0e6d3;
  flex-shrink: 0;
  z-index: 2;
}

/* ============================================================
   3. メガネさんアイコン
   ============================================================ */
.sms-megane-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sms-megane-icon.animating {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   4. 検索バー
   ============================================================ */
.sms-search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  background: #faf5eb;
  border: 1px solid #c4b59a;
  border-radius: 24px;
  padding: 4px 8px;
  gap: 4px;
  overflow: hidden;
  min-width: 0;
}

.sms-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 15px;
  padding: 8px 8px;
  color: #2c1810;
  font-family: 'Noto Serif JP', serif;
  outline: none;
}

.sms-search-input::placeholder {
  color: #8b7355;
}

/* ============================================================
   5. アイコンボタン（マイク・検索・閉じる）
   ============================================================ */
.sms-voice-btn,
.sms-search-btn {
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.sms-voice-btn:hover,
.sms-voice-btn:focus,
.sms-search-btn:hover,
.sms-search-btn:focus {
  background: rgba(90, 62, 40, 0.1);
}

.sms-close-btn {
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #5a3e28;
  flex-shrink: 0;
  transition: background-color 0.2s;
}

.sms-close-btn:hover,
.sms-close-btn:focus {
  background: rgba(90, 62, 40, 0.1);
}

.sms-voice-btn.recording {
  background: #8b2500;
  border-radius: 50%;
}

.sms-voice-btn.recording svg {
  stroke: #f0e6d3;
}

/* ============================================================
   6. サジェストチップエリア
   ============================================================ */
.sms-suggest-area {
  padding: 0 12px 8px;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sms-suggest-chips {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.sms-suggest-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  min-height: 32px;
  border: 1px solid #c4b59a;
  border-radius: 16px;
  background: #faf5eb;
  color: #5a3e28;
  font-size: 13px;
  font-family: 'Noto Serif JP', serif;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.sms-suggest-chip:hover,
.sms-suggest-chip:focus {
  background: #f0e6d3;
  border-color: #8b6914;
}

.sms-suggest-chip:active {
  transform: scale(0.97);
}

.sms-suggest-chip-edit {
  /* 編集チップ（✏️）は常に末尾 */
}

/* ============================================================
   7. マップ領域（80%以上）
   ============================================================ */
.sms-map-container {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #e8dcc8;
}

.sms-map {
  width: 100%;
  height: 100%;
}

/* ============================================================
   8. フィルタドロップダウン（左下）
   ============================================================ */
.sms-filter-dropdown {
  position: absolute;
  bottom: 16px;
  left: 12px;
  z-index: 1;
  padding: 6px 10px;
  min-height: 36px;
  border: 1px solid #c4b59a;
  border-radius: 6px;
  background: #faf5eb;
  color: #2c1810;
  font-size: 13px;
  font-family: 'Noto Serif JP', serif;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(44, 24, 16, 0.15);
  white-space: nowrap;
}

.sms-filter-dropdown:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ID セレクタ互換（chatSearch.js _buildDOM() で使用） */
#chat-map-filter {
  position: absolute;
  bottom: 16px;
  left: 12px;
  z-index: 1;
  padding: 6px 10px;
  min-height: 36px;
  border: 1px solid #c4b59a;
  border-radius: 6px;
  background: #faf5eb;
  color: #2c1810;
  font-size: 13px;
  font-family: 'Noto Serif JP', serif;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(44, 24, 16, 0.15);
  white-space: nowrap;
}

#chat-map-filter:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   9. 現在地ボタン（右下）
   ============================================================ */
.sms-location-btn {
  position: absolute;
  bottom: 100px;
  right: 12px;
  z-index: 1;
  width: clamp(40px, 11vw, 48px);
  height: clamp(40px, 11vw, 48px);
  min-width: var(--tap-target-min, 44px);
  min-height: var(--tap-target-min, 44px);
  border: 1px solid #c4b59a;
  border-radius: 50%;
  background: #faf5eb;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(44, 24, 16, 0.15);
  transition: background-color 0.2s;
}

.sms-location-btn svg {
  transform: none;
}

.sms-location-btn:hover,
.sms-location-btn:focus {
  background: #f0e6d3;
  outline: 2px solid #8b6914;
  outline-offset: 2px;
}

/* ID セレクタ互換（chatSearch.js _buildDOM() で使用） */
#chat-map-location-btn {
  position: absolute;
  bottom: 100px;
  right: 12px;
  z-index: 1;
  width: clamp(40px, 11vw, 48px);
  height: clamp(40px, 11vw, 48px);
  min-width: var(--tap-target-min, 44px);
  min-height: var(--tap-target-min, 44px);
  border: 1px solid #c4b59a;
  border-radius: 50%;
  background: #faf5eb;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(44, 24, 16, 0.15);
  transition: background-color 0.2s;
}

#chat-map-location-btn svg {
  transform: none;
}

#chat-map-location-btn:hover,
#chat-map-location-btn:focus {
  background: #f0e6d3;
  outline: 2px solid #8b6914;
  outline-offset: 2px;
}

/* ============================================================
   10. 凡例
   ============================================================ */
.sms-legend {
  position: absolute;
  bottom: 56px;
  right: 12px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 5px 8px;
  background: rgba(250, 245, 235, 0.92);
  border-radius: 6px;
  font-size: 11px;
  color: #5a3e28;
  box-shadow: 0 1px 4px rgba(44, 24, 16, 0.12);
}

/* ID セレクタ互換（chatSearch.js _buildDOM() で使用） */
#chat-map-legend {
  position: absolute;
  bottom: 56px;
  right: 12px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 5px 8px;
  background: rgba(250, 245, 235, 0.92);
  border-radius: 6px;
  font-size: 11px;
  color: #5a3e28;
  box-shadow: 0 1px 4px rgba(44, 24, 16, 0.12);
}

.legend-pin {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
}

.legend-pin.published {
  background: #e74c3c;
}

.legend-pin.draft {
  background: #3498db;
}

/* ============================================================
   11. 吹き出し表示エリア（Result Bubble）
   ============================================================ */
.sms-result-bubble-area {
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  z-index: 3;
  pointer-events: none;
}

/* メガネさん + 吹き出しの横並びレイアウト */
.sms-result-bubble-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
}

.sms-result-megane {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-top: 4px;
}

.sms-result-bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  padding-right: 32px;
  background: #faf5eb;
  border: 1px solid #d4c5a9;
  border-radius: 0 12px 12px 12px;
  box-shadow: 0 2px 8px rgba(44, 24, 16, 0.15);
  font-size: 11px;
  line-height: 1.5;
  color: #2c1810;
  pointer-events: auto;
  max-height: 20vh;
  overflow-y: auto;
}

.sms-result-bubble .result-bubble-text {
  font-size: 11px;
  line-height: 1.5;
}

.sms-result-bubble .result-bubble-text p {
  margin: 0 0 3px;
  font-size: 11px;
}

.sms-result-bubble .result-bubble-text h1,
.sms-result-bubble .result-bubble-text h2,
.sms-result-bubble .result-bubble-text h3,
.sms-result-bubble .result-bubble-text h4,
.sms-result-bubble .result-bubble-text h5,
.sms-result-bubble .result-bubble-text h6 {
  font-size: 12px;
  font-weight: bold;
  margin: 4px 0 2px;
}

.sms-result-bubble .result-bubble-text ul,
.sms-result-bubble .result-bubble-text ol {
  margin: 3px 0;
  padding-left: 14px;
  font-size: 11px;
}

.sms-result-bubble .result-bubble-spots {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
}

.sms-result-bubble .result-bubble-spots li {
  margin: 2px 0;
}

/* 吹き出しの三角形（左上角、メガネさん側を向く） */
.sms-result-bubble::before {
  content: '';
  position: absolute;
  top: 10px;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid #faf5eb;
}

.sms-result-bubble-close,
.result-bubble-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: #8b7355;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 店名インラインリンク */
.result-bubble-spot-link {
  color: #8b6914;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font-weight: bold;
}

.result-bubble-spot-link:hover,
.result-bubble-spot-link:focus {
  color: #5a3e28;
}

/* ============================================================
   12. 考え中アニメーション（メガネのレンズだけキラッ）
   ============================================================ */

/* 考え中吹き出し横のメガネさん — レンズだけキラキラ */
.sms-thinking-megane .megane-lens {
  animation: megane-lens-sparkle 1.5s ease-in-out infinite;
}

@keyframes megane-lens-sparkle {
  0%, 100% { 
    stroke: #3c2415;
    fill: rgba(255, 255, 255, 0);
  }
  50% { 
    stroke: #8b6914;
    fill: rgba(255, 255, 200, 0.3);
  }
}

/* ============================================================
   12b. 考え中吹き出し（Thinking Bubble）
   ============================================================ */
.sms-thinking-bubble {
  text-align: left;
  padding: 10px 14px;
  min-height: 32px;
}

.sms-thinking-bubble .thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: #5a3e28;
  font-family: 'Noto Serif JP', serif;
}

.sms-thinking-bubble .thinking-dots .dots {
  animation: thinkingBlink 1.5s infinite;
}

@keyframes thinkingBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ============================================================
   13. 空状態オーバーレイ
   ============================================================ */
.sms-empty-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(240, 230, 211, 0.85);
  color: #8b7355;
  font-size: 14px;
  font-family: 'Noto Serif JP', serif;
  text-align: center;
  padding: 16px;
}

.sms-empty-overlay.hidden {
  display: none !important;
}

/* ID セレクタ互換（chatSearch.js _buildDOM() で使用） */
#chat-map-empty {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(240, 230, 211, 0.85);
  color: #8b7355;
  font-size: 14px;
  font-family: 'Noto Serif JP', serif;
  text-align: center;
  padding: 16px;
}

#chat-map-empty.hidden {
  display: none !important;
}

/* ============================================================
   14. 店舗名リンク（InfoWindow 内で使用）
   ============================================================ */
.chat-spot-link {
  color: #8b6914;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-weight: bold;
  padding: 2px 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.chat-spot-link:hover,
.chat-spot-link:focus {
  color: #5a3e28;
  outline: 2px solid rgba(139, 105, 20, 0.3);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ============================================================
   15. 音声入力録音中アニメーション
   ============================================================ */
@keyframes micBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   16. サジェストチップ編集モーダル
   ============================================================ */
.sms-chip-edit-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.sms-chip-edit-modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 320px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.sms-chip-edit-title {
  margin: 0 0 4px;
  font-size: 16px;
  color: #3c2415;
}

.sms-chip-edit-desc {
  margin: 0 0 16px;
  font-size: 12px;
  color: #8b7355;
}

.sms-chip-edit-input-wrap {
  margin-bottom: 10px;
}

.sms-chip-edit-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d4c5a9;
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
  color: #3c2415;
}

.sms-chip-edit-input:focus {
  outline: none;
  border-color: #5a3e28;
}

.sms-chip-edit-error {
  margin: 0 0 12px;
  font-size: 12px;
  color: #d32f2f;
  min-height: 16px;
}

.sms-chip-edit-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.sms-chip-edit-cancel {
  padding: 10px 16px;
  border: 1px solid #d4c5a9;
  border-radius: 8px;
  background: #fff;
  color: #5a3e28;
  font-size: 14px;
  cursor: pointer;
}

.sms-chip-edit-save {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: #5a3e28;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

/* ============================================================
   17. 編集チップ初回ツールチップ
   ============================================================ */
.sms-chip-tooltip {
  position: absolute;
  right: 8px;
  top: 100%;
  margin-top: 4px;
  background: #5a3e28;
  color: #fff;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 10;
  animation: tooltipFadeIn 0.3s ease;
}

.sms-chip-tooltip::before {
  content: '';
  position: absolute;
  top: -4px;
  right: 16px;
  width: 8px;
  height: 8px;
  background: #5a3e28;
  transform: rotate(45deg);
}

@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   18. ポイント残高表示
   ============================================================ */
.sms-points-display {
  flex-shrink: 0;
  font-size: 12px;
  color: #5a3e28;
  background: #faf5eb;
  border: 1px solid #c4b59a;
  border-radius: 12px;
  padding: 4px 10px;
  white-space: nowrap;
}
