/* ======================================================================
   AI案内係（猫のキャラクター）チャットウィジェット
   右下のボタンと、その上に開くパネル。LP本体のCSSに依存しない。
   ====================================================================== */

.ai-chat {
  --ai-blue: #226db3;
  --ai-blue-deep: #0f3f6e;
  --ai-line: #dbe5ef;
  --ai-bg: #ffffff;
  --ai-user: #226db3;
  --ai-bot: #f2f6fa;
  --ai-ink: #1f2933;
  /* 左下に置く。右下はLPのフローティングメニュー（#houjin-floating-menu）と
     ページトップボタンが使っているため */
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 9000;
  font-family: "Zen Maru Gothic", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ai-ink);
}

/* --- 起動ボタン: 猫のイラストそのもの（透過・背景なし） --- */
.ai-chat__launcher {
  position: relative;
  display: block;
  margin-right: auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ai-chat__launcher-img {
  display: block;
  width: 140px;
  height: auto;
  filter: drop-shadow(0 8px 14px rgba(15, 63, 110, 0.28));
  transition: transform 0.2s ease;
  transform-origin: 60% 90%;
}
.ai-chat__launcher:hover .ai-chat__launcher-img {
  transform: translateY(-4px) rotate(-4deg);
}
.ai-chat__launcher:focus-visible .ai-chat__launcher-img {
  outline: 3px solid rgba(34, 109, 179, 0.5);
  outline-offset: 4px;
  border-radius: 12px;
}
/* 吹き出しの「質問する」 */
.ai-chat__launcher-label {
  position: absolute;
  left: 130px;
  top: 18px;
  padding: 7px 12px;
  border-radius: 12px;
  background: var(--ai-bg);
  color: var(--ai-blue-deep);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(15, 63, 110, 0.18);
}
.ai-chat__launcher-label::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 12px;
  border-width: 6px 7px 6px 0;
  border-style: solid;
  border-color: transparent var(--ai-bg) transparent transparent;
}
.ai-chat.is-open .ai-chat__launcher-label {
  display: none;
}
.ai-chat.is-open .ai-chat__launcher-img {
  width: 72px;
}
.ai-chat.is-open .ai-chat__panel {
  bottom: 84px;
}
.ai-chat__debug {
  margin: -4px 0 0 40px;
  font-size: 10.5px;
  color: #a0522d;
  word-break: break-all;
}

/* --- パネル --- */
/* LP側のCSSが section を display:block にしているため、hidden 属性を確実に効かせる */
.ai-chat__panel[hidden] {
  display: none !important;
}
.ai-chat__panel {
  position: absolute;
  left: 0;
  bottom: 150px;
  width: min(380px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: var(--ai-bg);
  border: 1px solid var(--ai-line);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(15, 63, 110, 0.25);
  overflow: hidden;
}

.ai-chat__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: linear-gradient(135deg, #0f3f6e, #226db3);
  color: #fff;
}
.ai-chat__head-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
  padding: 3px;
  box-sizing: border-box;
  flex: 0 0 auto;
}
.ai-chat__head-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}
.ai-chat__head-name {
  font-size: 14px;
  font-weight: 700;
}
.ai-chat__head-sub {
  font-size: 11px;
  opacity: 0.85;
}
.ai-chat__close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.ai-chat__close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.ai-chat__log {
  flex: 1 1 auto;
  min-height: 180px;
  overflow-y: auto;
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.ai-chat__msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}
.ai-chat__msg--user {
  justify-content: flex-end;
}
.ai-chat__msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e9f3fb;
  object-fit: contain;
  padding: 2px;
  box-sizing: border-box;
  flex: 0 0 auto;
}
.ai-chat__bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--ai-bot);
  color: var(--ai-ink);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.ai-chat__msg--assistant .ai-chat__bubble {
  border-bottom-left-radius: 4px;
}
.ai-chat__msg--user .ai-chat__bubble {
  background: var(--ai-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* 入力中のドット */
.ai-chat__msg--typing .ai-chat__bubble {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
}
.ai-chat__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9db4c9;
  animation: ai-chat-bounce 1.2s infinite ease-in-out;
}
.ai-chat__dot:nth-child(2) {
  animation-delay: 0.15s;
}
.ai-chat__dot:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes ai-chat-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* 質問例 */
.ai-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px 8px;
}
.ai-chat__chip {
  padding: 6px 12px;
  border: 1px solid #c9d8e6;
  border-radius: 999px;
  background: #fff;
  color: var(--ai-blue-deep);
  font-size: 12px;
  cursor: pointer;
}
.ai-chat__chip:hover {
  background: #eef5fb;
  border-color: #9dbad6;
}
.ai-chat__chip:disabled {
  opacity: 0.5;
  cursor: default;
}

/* 入力欄 */
.ai-chat__form {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--ai-line);
  background: #fff;
}
.ai-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #c9d8e6;
  border-radius: 10px;
  font-size: 16px; /* iOS の自動ズームを防ぐ */
  font-family: inherit;
}
.ai-chat__input:focus {
  outline: none;
  border-color: var(--ai-blue);
  box-shadow: 0 0 0 3px rgba(34, 109, 179, 0.18);
}
.ai-chat__send {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--ai-blue);
  color: #fff;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.ai-chat__send:disabled {
  opacity: 0.6;
  cursor: default;
}
.ai-chat__note {
  margin: 0;
  padding: 0 12px 10px;
  font-size: 10.5px;
  line-height: 1.5;
  color: #6b7785;
}

/* スマホ: パネルを画面幅いっぱいに */
@media (max-width: 600px) {
  .ai-chat {
    left: 12px;
    bottom: 12px;
  }
  .ai-chat__panel {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 150px);
    bottom: 104px;
  }
  .ai-chat.is-open .ai-chat__panel {
    bottom: 70px;
    max-height: calc(100vh - 110px);
  }
  .ai-chat__launcher-img {
    width: 112px;
  }
  .ai-chat__launcher-label {
    left: 104px;
    top: 10px;
  }
  .ai-chat.is-open .ai-chat__launcher-img {
    width: 60px;
  }
}

/* 印刷時は出さない */
@media print {
  .ai-chat {
    display: none;
  }
}
