/* ===========================================================
   Pâtisserie 結 -YUI- チャットボットUI
   フローティングボタン＋スライドアップで開くチャットパネル
   =========================================================== */

/* チャット内のテキストは、画面で読みやすいシステムサンセリフを使用 */
:root {
  --chat-font: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
               "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo",
               "Noto Sans JP", sans-serif;
}

/* ===== フローティングボタン ===== */
.chat-fab {
  position: fixed;
  right: 24px; bottom: 24px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--color-ink, #1F1A14);
  color: var(--color-bg, #FBF8F3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 6px 24px rgba(0,0,0,0.22);
  transition: transform .25s ease, background .25s ease;
  border: none;
}
.chat-fab:hover {
  transform: scale(1.06);
  background: var(--color-accent-dk, #5A3F1F);
}
.chat-fab svg {
  width: 26px; height: 26px;
  fill: currentColor;
}
.chat-fab .icon-close { display: none; }
.chat-fab.is-open .icon-chat { display: none; }
.chat-fab.is-open .icon-close { display: block; }

/* ===== チャットパネル ===== */
.chat-panel {
  position: fixed;
  right: 24px; bottom: 96px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: var(--color-bg, #FBF8F3);
  border: 1px solid var(--color-line, #DCD3C4);
  box-shadow: 0 20px 60px rgba(0,0,0,0.22);
  display: flex;
  flex-direction: column;
  z-index: 200;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  overflow: hidden;
}
.chat-panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* ===== ヘッダー ===== */
.chat-header {
  padding: 18px 20px;
  background: var(--color-ink, #1F1A14);
  color: var(--color-bg, #FBF8F3);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-header .avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--color-accent, #8B6B3C);
  display: flex; align-items: center; justify-content: center;
  font-family: "Cormorant Garamond", serif;
  font-size: 13px;
  letter-spacing: 0.18em;
  flex-shrink: 0;
}
.chat-header .title { flex: 1; min-width: 0; }
.chat-header h3 {
  font-family: var(--chat-font);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.06em;
  margin: 0 0 2px;
  line-height: 1.4;
}
.chat-header small {
  font-family: "Cormorant Garamond", serif;
  font-size: 10px;
  letter-spacing: 0.22em;
  opacity: 0.7;
}

/* ===== メッセージ表示エリア ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--color-bg-alt, #F4EFE6);
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--color-line, #DCD3C4); border-radius: 3px; }

.chat-msg {
  max-width: 86%;
  padding: 12px 16px;
  border-radius: 14px;
  font-family: var(--chat-font);
  font-size: 14.5px;
  line-height: 1.75;
  letter-spacing: 0.02em;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: msgFadeIn .3s ease;
}
@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.assistant {
  background: var(--color-white, #FFFFFF);
  color: var(--color-ink, #1F1A14);
  align-self: flex-start;
  border: 1px solid var(--color-line, #DCD3C4);
  border-bottom-left-radius: 4px;
}
.chat-msg.user {
  background: var(--color-ink, #1F1A14);
  color: var(--color-bg, #FBF8F3);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* 入力中インジケータ */
.chat-msg.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 14px 16px;
}
.chat-msg.typing span {
  width: 6px; height: 6px;
  background: var(--color-ink-soft, #5A4F42);
  border-radius: 50%;
  animation: typing 1.2s infinite ease-in-out;
}
.chat-msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1; transform: translateY(-3px); }
}

/* ===== サジェスト質問チップ ===== */
.chat-suggestions {
  padding: 0 18px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--color-bg-alt, #F4EFE6);
  flex-shrink: 0;
  /* スターター質問が多くてもメッセージ表示を圧迫しないよう抑制 */
  max-height: 22vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.chat-suggestions::-webkit-scrollbar { width: 4px; }
.chat-suggestions::-webkit-scrollbar-thumb { background: var(--color-line, #DCD3C4); border-radius: 2px; }
.chat-suggest {
  font-size: 12.5px;
  padding: 8px 14px;
  border: 1px solid var(--color-line, #DCD3C4);
  background: var(--color-bg, #FBF8F3);
  cursor: pointer;
  font-family: var(--chat-font);
  letter-spacing: 0.02em;
  color: var(--color-ink, #1F1A14);
  border-radius: 100px;
  transition: border-color .2s ease, background .2s ease;
  line-height: 1.4;
}
.chat-suggest:hover {
  border-color: var(--color-accent, #8B6B3C);
  background: var(--color-white, #FFFFFF);
}

/* ===== 入力欄 ===== */
.chat-input-area {
  padding: 12px 14px;
  background: var(--color-bg, #FBF8F3);
  border-top: 1px solid var(--color-line, #DCD3C4);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--color-line, #DCD3C4);
  background: var(--color-bg-alt, #F4EFE6);
  padding: 11px 14px;
  font-family: var(--chat-font);
  font-size: 14.5px;
  line-height: 1.55;
  border-radius: 4px;
  max-height: 80px;
  color: var(--color-ink, #1F1A14);
  letter-spacing: 0.02em;
}
.chat-input:focus {
  outline: none;
  border-color: var(--color-accent, #8B6B3C);
  background: var(--color-white, #FFFFFF);
}
.chat-send {
  background: var(--color-ink, #1F1A14);
  color: var(--color-bg, #FBF8F3);
  border: none;
  padding: 0 18px;
  height: 38px;
  cursor: pointer;
  font-family: "Cormorant Garamond", serif;
  font-size: 12px;
  letter-spacing: 0.25em;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background .25s ease;
}
.chat-send:hover { background: var(--color-accent-dk, #5A3F1F); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== スマホ対応 ===== */
@media (max-width: 560px) {
  .chat-panel {
    right: 12px; bottom: 80px;
    width: calc(100vw - 24px);
    height: calc(100vh - 110px);
  }
  .chat-fab {
    right: 16px; bottom: 16px;
    width: 54px; height: 54px;
  }
  .chat-fab svg { width: 22px; height: 22px; }
}
