/**
 * Galaxia AI 相談ウィジェット
 * 全ページ右下に常時表示するフローティングチャット
 * ブランドカラー: グラデーション #3aa0ff → #2bd4d4 / ダーク #0e0e14
 */

:root {
  --gxai-grad: linear-gradient(135deg, #3aa0ff, #2bd4d4);
  --gxai-dark: #0e0e14;
}

/* ===== フローティング起動ボタン（AI相談とわかるピル型） ===== */
.gxai-launcher {
  position: fixed;
  right: 24px;
  bottom: 76px; /* 右下の「トップへ戻る」ボタンのすぐ上に重ねる */
  z-index: 99998;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 22px 0 16px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: var(--gxai-grad);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  box-shadow: 0 8px 24px rgba(58, 160, 255, .42), 0 2px 6px rgba(0, 0, 0, .2);
  transition: transform .2s ease, box-shadow .2s ease, padding .2s ease, width .2s ease, bottom .25s ease;
  -webkit-tap-highlight-color: transparent;
}

/* 最下部付近ではフッターのお問い合わせリンクと重ならないよう持ち上げる */
.gxai-lifted .gxai-launcher { bottom: 168px; }
.gxai-lifted .gxai-panel { bottom: 236px; }
.gxai-launcher:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(58, 160, 255, .52); }
.gxai-launcher:active { transform: translateY(-1px) scale(.99); }

/* アイコン部 */
.gxai-launcher__icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gxai-launcher__icon svg { width: 21px; height: 21px; display: block; }
.gxai-icon-chat { animation: gxai-twinkle 2.6s ease-in-out infinite; }
@keyframes gxai-twinkle { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .75; transform: scale(.9); } }

/* テキストラベル（AI相談） */
.gxai-launcher__label { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.gxai-launcher__label b { font-size: 15px; font-weight: 800; letter-spacing: .03em; }
.gxai-launcher__label small { font-size: 10px; font-weight: 600; opacity: .92; letter-spacing: .02em; }

/* 開いている間はアイコン（キラキラ）だけの円形に収まる */
.gxai-launcher.is-open { width: 60px; padding: 0; justify-content: center; }
.gxai-launcher.is-open .gxai-launcher__label { display: none; }
.gxai-launcher.is-open .gxai-launcher__icon { background: transparent; }
.gxai-launcher.is-open .gxai-launcher__icon svg { width: 26px; height: 26px; }

/* 初回の注目アニメーション */
.gxai-launcher.gxai-attract { animation: gxai-attract 1s ease-in-out 3; }
@keyframes gxai-attract {
  0%, 100% { transform: translateY(0); box-shadow: 0 8px 24px rgba(58, 160, 255, .42), 0 0 0 0 rgba(58, 160, 255, .5); }
  50% { transform: translateY(-4px); box-shadow: 0 14px 34px rgba(58, 160, 255, .55), 0 0 0 10px rgba(58, 160, 255, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .gxai-icon-chat, .gxai-launcher.gxai-attract { animation: none; }
}

/* ===== チャットパネル ===== */
.gxai-panel {
  position: fixed;
  right: 24px;
  bottom: 144px;
  z-index: 99999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 190px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(14, 14, 20, .28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.98);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease, bottom .25s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
}
.gxai-panel.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* ヘッダー */
.gxai-head {
  background: var(--gxai-grad);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.gxai-head__avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.gxai-head__avatar svg { width: 22px; height: 22px; }
.gxai-head__title { font-size: 15px; font-weight: 800; line-height: 1.3; margin: 0; }
.gxai-head__sub { font-size: 11px; opacity: .85; margin: 2px 0 0; display: flex; align-items: center; gap: 5px; }
.gxai-head__dot { width: 7px; height: 7px; border-radius: 50%; background: #5dffa0; box-shadow: 0 0 0 0 rgba(93,255,160,.6); animation: gxai-pulse 2s infinite; }
@keyframes gxai-pulse { 0% { box-shadow: 0 0 0 0 rgba(93,255,160,.6); } 70% { box-shadow: 0 0 0 6px rgba(93,255,160,0); } 100% { box-shadow: 0 0 0 0 rgba(93,255,160,0); } }

/* メッセージ領域 */
.gxai-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: #f5f7fb;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.gxai-msg { display: flex; max-width: 84%; }
.gxai-msg__bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}
.gxai-msg--bot { align-self: flex-start; }
.gxai-msg--bot .gxai-msg__bubble {
  background: #fff;
  color: #1c1c28;
  border: 1px solid #e6eaf2;
  border-bottom-left-radius: 5px;
}
.gxai-msg--user { align-self: flex-end; }
.gxai-msg--user .gxai-msg__bubble {
  background: var(--gxai-dark);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.gxai-msg__bubble a { color: #2b8fe0; text-decoration: underline; }
.gxai-msg--user .gxai-msg__bubble a { color: #7ec9ff; }

/* クイック返信 */
.gxai-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 14px; background: #f5f7fb; }
.gxai-quick__btn {
  font-size: 12.5px; font-weight: 700;
  color: #2b8fe0; background: #fff;
  border: 1px solid #cfe2fb; border-radius: 999px;
  padding: 7px 13px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.gxai-quick__btn:hover { background: var(--gxai-grad); color: #fff; border-color: transparent; }

/* タイピングインジケータ */
.gxai-typing .gxai-msg__bubble { display: flex; gap: 4px; align-items: center; }
.gxai-typing span { width: 7px; height: 7px; border-radius: 50%; background: #b6c0d4; animation: gxai-bounce 1.2s infinite; }
.gxai-typing span:nth-child(2) { animation-delay: .2s; }
.gxai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes gxai-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* 入力フォーム */
.gxai-foot { border-top: 1px solid #e6eaf2; background: #fff; padding: 10px 12px; }
.gxai-form { display: flex; align-items: flex-end; gap: 8px; }
.gxai-form textarea {
  flex: 1;
  border: 1px solid #d8deea;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 110px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease;
}
.gxai-form textarea:focus { border-color: #3aa0ff; }
.gxai-send {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border: none; border-radius: 12px;
  background: var(--gxai-grad);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s ease, transform .15s ease;
}
.gxai-send:hover { transform: scale(1.05); }
.gxai-send:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.gxai-send svg { width: 20px; height: 20px; }
.gxai-foot__note { text-align: center; font-size: 10px; color: #9aa3b5; margin: 7px 0 2px; }

@media screen and (max-width: 480px) {
  .gxai-panel { right: 8px; bottom: 130px; width: calc(100vw - 16px); height: calc(100vh - 158px); }
  .gxai-launcher { right: 14px; bottom: 62px; height: 54px; padding: 0 18px 0 14px; gap: 8px; }
  .gxai-launcher__icon { width: 30px; height: 30px; }
  .gxai-launcher__icon svg { width: 19px; height: 19px; }
  .gxai-launcher__label b { font-size: 14px; }
  .gxai-launcher__label small { font-size: 9.5px; }
  .gxai-launcher.is-open { width: 54px; }
  .gxai-lifted .gxai-launcher { bottom: 150px; }
  .gxai-lifted .gxai-panel { bottom: 210px; }
}
