/* ============================================================
   民泊自動応答チャットボット - スタイルシート
   モバイルファースト設計 / iPhone・Android対応
   ============================================================ */

/* ─── リセット & 基本設定 ─────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --blue-dark:    #0f4c75;
  --blue-mid:     #1b6ca8;
  --teal:         #1a9b8a;
  --teal-dark:    #0e7a6c;
  --teal-light:   #e6f7f5;
  --bot-bubble:   #f0f2f5;
  --user-bubble:  #1a9b8a;
  --text-main:    #222;
  --text-sub:     #666;
  --border:       #e5e7eb;
  --shadow:       rgba(0, 0, 0, 0.10);
  --radius-lg:    18px;
  --radius-sm:    10px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family:
    -apple-system, BlinkMacSystemFont,
    'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
    'Noto Sans JP', 'Yu Gothic UI', 'Meiryo',
    sans-serif;
  background: #e2e8f0;
  color: var(--text-main);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* ─── アプリ全体のレイアウト ──────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* iOS Safari のアドレスバー対応 */
  max-width: 640px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 40px var(--shadow);
}

/* ─── ヘッダー ────────────────────────────────────────────── */
#header {
  flex-shrink: 0;
  background: linear-gradient(145deg, var(--blue-dark) 0%, var(--teal) 100%);
  color: #fff;
  padding: 14px 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  position: relative;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.h-icon {
  font-size: 32px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  flex-shrink: 0;
}

.h-text h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.3;
}

.h-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.85;
  margin-top: 3px;
}

/* 生きているドット（オンライン表示） */
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  flex-shrink: 0;
  animation: liveBlink 2s ease-in-out infinite;
}

@keyframes liveBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(0.8); }
}

/* ─── メッセージエリア ────────────────────────────────────── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar { width: 3px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* ─── メッセージ行 ──────────────────────────────────────── */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msgIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}

.msg.bot  { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }

/* アバター */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--blue-dark), var(--teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

/* バブル */
.bubble {
  max-width: 82%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  border-radius: var(--radius-lg);
}

.bot  .bubble {
  background: var(--bot-bubble);
  color: var(--text-main);
  border-bottom-left-radius: 5px;
}

.user .bubble {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 5px;
}

/* バブル内のリッチコンテンツ */
.bubble h3 {
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.bubble p {
  margin-bottom: 6px;
}
.bubble p:last-child { margin-bottom: 0; }

.bubble ul {
  padding-left: 18px;
  margin: 6px 0;
}
.bubble li { margin-bottom: 4px; }

.bubble strong { font-weight: 700; }

/* インフォボックス（青緑） */
.bubble .info-box {
  background: rgba(26, 155, 138, 0.10);
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 9px 11px;
  margin-top: 9px;
  font-size: 13px;
  line-height: 1.65;
}

/* 警告ボックス（オレンジ） */
.bubble .warn-box {
  background: rgba(245, 158, 11, 0.10);
  border-left: 3px solid #f59e0b;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 9px 11px;
  margin-top: 9px;
  font-size: 13px;
  line-height: 1.65;
}

/* カテゴリグリッド（バブル内） */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-main);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: left;
  line-height: 1.3;
}

.cat-btn:hover {
  background: var(--teal-light);
  border-color: var(--teal);
}

.cat-btn:active {
  background: var(--teal-light);
  border-color: var(--teal);
  transform: scale(0.96);
}

.cat-btn .ci {
  font-size: 19px;
  line-height: 1;
  flex-shrink: 0;
}

/* ─── タイピングインジケーター ───────────────────────────── */
.typing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: msgIn 0.2s ease both;
}

.typing-bubble {
  background: var(--bot-bubble);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 5px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.30s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%            { transform: translateY(-7px); opacity: 1;   }
}

/* ─── クイックアクションバー ─────────────────────────────── */
#quick-wrap {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 9px 0;
}

#quick-bar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#quick-bar::-webkit-scrollbar { display: none; }

.q-btn {
  flex-shrink: 0;
  padding: 7px 13px;
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1.5px solid rgba(26, 155, 138, 0.3);
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.q-btn:hover {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.q-btn:active {
  background: var(--teal-dark);
  color: #fff;
  transform: scale(0.95);
}

/* ─── 入力エリア ────────────────────────────────────────── */
#footer {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  /* iPhone のホームインジケーター対応 */
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f5f6f7;
  border-radius: 26px;
  padding: 5px 5px 5px 15px;
  border: 1.5px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-row:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26, 155, 138, 0.12);
  background: #fff;
}

#msg-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-main);
  outline: none;
  padding: 6px 0;
  min-width: 0;
}

#msg-input::placeholder {
  color: #adb5bd;
  font-size: 13px;
}

#send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

#send-btn:hover  { background: var(--teal-dark); }
#send-btn:active { background: var(--teal-dark); transform: scale(0.92); }

/* ─── デスクトップ向け微調整 ──────────────────────────────── */
@media (min-width: 641px) {
  #app {
    border-radius: 16px;
    margin-top: 20px;
    margin-bottom: 20px;
    height: calc(100vh - 40px);
  }
  body { display: flex; align-items: flex-start; justify-content: center; }
}

/* ─── 言語選択スクリーン ─────────────────────────────────── */
#lang-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(145deg, var(--blue-dark) 0%, var(--teal) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
  transition: opacity 0.38s ease, transform 0.38s ease;
}

#lang-screen.fade-out {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.lang-card {
  background: #fff;
  border-radius: 24px;
  padding: 28px 22px 24px;
  max-width: 420px;
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  -webkit-overflow-scrolling: touch;
}

.lang-title {
  text-align: center;
  margin-bottom: 20px;
}

.lang-logo {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 10px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

.lang-title h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--blue-dark);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.lang-subtitle {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.6;
}

.lang-sub-mini {
  font-size: 11px;
  opacity: 0.7;
  letter-spacing: 0.2px;
}

.lang-property-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 14px;
  background: var(--teal-light);
  color: var(--teal-dark);
  border-radius: 20px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

#lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fafbff;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  font-family: inherit;
  transition: all 0.15s ease;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.lang-btn:hover {
  border-color: var(--teal);
  background: var(--teal-light);
  color: var(--teal-dark);
}

.lang-btn:active {
  transform: scale(0.95);
  background: var(--teal-light);
  border-color: var(--teal);
}

.lang-flag {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

/* デスクトップ：言語スクリーンも中央に */
@media (min-width: 641px) {
  .lang-card {
    max-width: 460px;
  }
}

/* ─── メディア（画像・動画）表示 ────────────────────────── */
.media-wrap {
  margin: 8px 0 4px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 100%;
}

.media-wrap img {
  width: 100%;
  display: block;
  border-radius: 10px;
  cursor: pointer;
}

.media-wrap iframe {
  width: 100%;
  height: 200px;
  border: none;
  display: block;
  border-radius: 10px;
}

.step-item {
  margin: 8px 0;
}

.step-num {
  font-size: 11px;
  font-weight: bold;
  color: #1a9b8a;
  background: #e8f8f5;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}
