/* FAQ Chatbot Floating UI Styles (Flicker-Free & Color-Aligned Version) */

:root {
  --faq-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --faq-border-radius: 12px;
}

/* フローティングコンテナ */
.faq-bot-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* フローティング起動ボタン */
.faq-bot-trigger {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ink);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease;
  margin-top: 12px;
}

.faq-bot-trigger:hover {
  transform: scale(1.05);
  background: var(--accent);
}

.faq-bot-trigger svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* チャットウィンドウ本体 (デフォルト非表示、container.open時に表示) */
.faq-chat-window {
  width: 380px;
  height: 500px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--faq-border-radius);
  box-shadow: var(--faq-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: faqFadeUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-bot-container.open .faq-chat-window {
  display: flex;
}

@keyframes faqFadeUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ヘッダー */
.faq-header {
  background: var(--ink);
  color: #ffffff;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.faq-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.faq-header-title svg {
  width: 18px;
  height: 18px;
  stroke: var(--accent);
}

/* ヘッダー右上の閉じるボタン(表示する) */
.faq-close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.faq-close-btn:hover {
  color: #ffffff;
}

.faq-close-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
}

/* メッセージ表示エリア */
.faq-messages-area {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

/* メッセージバブル */
.faq-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

/* ユーザー吹き出し（AIアナリスト風） */
.faq-message.user {
  align-self: flex-end;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: var(--ink);
  border-bottom-right-radius: 2px;
}

/* ボット吹き出し */
.faq-message.bot {
  align-self: flex-start;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-bottom-left-radius: 2px;
}

.faq-message.bot p {
  margin: 0 0 8px 0;
}
.faq-message.bot p:last-child {
  margin-bottom: 0;
}
.faq-message.bot ul, .faq-message.bot ol {
  margin: 4px 0;
  padding-left: 20px;
}
.faq-message.bot li {
  margin-bottom: 4px;
}

.faq-message.bot strong {
  font-weight: 700;
  color: var(--ink);
}

/* 予測質問（サジェスト）コンテナ */
.faq-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 4px;
}

/* サジェスト質問（AIアナリスト風） */
.faq-suggestion-btn {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  color: #475569;
  font-size: 11.5px;
  font-weight: 400;
  padding: 6px 12px;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.faq-suggestion-btn:hover {
  background: #f1f5f9;
  color: var(--ink);
}

/* ローディング表示 */
.faq-loading-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
}

.faq-loading-dot {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: faqDotPulse 1.2s infinite ease-in-out;
}

.faq-loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.faq-loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes faqDotPulse {
  0%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* 入力エリア */
.faq-input-area {
  padding: 12px;
  border-top: 1px solid var(--line-strong);
  background: var(--surface);
  display: flex;
  gap: 8px;
  align-items: center;
}

.faq-input {
  flex: 1;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.2s;
}

.faq-input:focus {
  border-color: var(--accent);
}

/* 送信ボタン（AIアナリスト風） */
.faq-send-btn {
  background: #0f172a;
  color: #ffffff;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.faq-send-btn:hover {
  background: #334155;
}

.faq-send-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* スマホ対応 */
@media (max-width: 480px) {
  .faq-chat-window {
    width: calc(100vw - 32px);
    height: 450px;
    right: 16px;
  }
  .faq-bot-container {
    bottom: 16px;
    right: 16px;
  }
}
