/* ============================================================
   藍 AIアシスタント チャットボットウィジェット
   LP改修時はchatbot.jsのCHATBOT_KNOWLEDGEを更新してください
   ============================================================ */

/* --- チャットボット専用CSS変数 --- */
:root {
  --cb-koiai:      #1A1F2E;
  --cb-ai-blue:    #2D4A7A;
  --cb-yamabuki:   #E8A511;
  --cb-panel:      #ffffff;
  --cb-border:     rgba(26,31,46,.10);
  --cb-bot-bubble: #e6ebf4;
  --cb-bot-text:   #1f2637;
  --cb-text:       #1A1F2E;
  --cb-muted:      #6b7690;
  --cb-chip-c:     #2D4A7A;
  --cb-input-bg:   #f3f5fa;
  --cb-input-bd:   rgba(26,31,46,.14);
  --cb-footer:     #ffffff;
  --cb-card:       #ffffff;
  --cb-time:       #9aa4bb;
  --cb-shadow:     0 18px 50px rgba(26,31,46,.22);
  --cb-scroll:     rgba(45,74,122,.25);
  --cb-page-bg:    #f3f5fa; /* fab-dot border用 */
}

@media (prefers-color-scheme: dark) {
  :root {
    --cb-panel:      #171c2b;
    --cb-border:     rgba(120,150,200,.12);
    --cb-bot-bubble: #242d45;
    --cb-bot-text:   #d8dff0;
    --cb-text:       #d8dff0;
    --cb-muted:      #7a87a8;
    --cb-chip-c:     #7ea8e0;
    --cb-input-bg:   #1e2538;
    --cb-input-bd:   rgba(120,150,200,.18);
    --cb-footer:     #171c2b;
    --cb-card:       #1e2538;
    --cb-time:       #5a6480;
    --cb-shadow:     0 18px 50px rgba(0,0,0,.45);
    --cb-scroll:     rgba(120,150,200,.2);
    --cb-page-bg:    #171c2b;
  }
}
:root[data-theme="light"] {
  --cb-panel:      #ffffff;
  --cb-border:     rgba(26,31,46,.10);
  --cb-bot-bubble: #e6ebf4;
  --cb-bot-text:   #1f2637;
  --cb-text:       #1A1F2E;
  --cb-muted:      #6b7690;
  --cb-chip-c:     #2D4A7A;
  --cb-input-bg:   #f3f5fa;
  --cb-input-bd:   rgba(26,31,46,.14);
  --cb-footer:     #ffffff;
  --cb-card:       #ffffff;
  --cb-time:       #9aa4bb;
  --cb-page-bg:    #f3f5fa;
}
:root[data-theme="dark"] {
  --cb-panel:      #171c2b;
  --cb-border:     rgba(120,150,200,.12);
  --cb-bot-bubble: #242d45;
  --cb-bot-text:   #d8dff0;
  --cb-text:       #d8dff0;
  --cb-muted:      #7a87a8;
  --cb-chip-c:     #7ea8e0;
  --cb-input-bg:   #1e2538;
  --cb-input-bd:   rgba(120,150,200,.18);
  --cb-footer:     #171c2b;
  --cb-card:       #1e2538;
  --cb-time:       #5a6480;
  --cb-page-bg:    #171c2b;
}

/* ============ フローティングボタン ============ */
.chat-fab {
  position: fixed;
  right: 24px; bottom: 24px;
  width: 62px; height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--cb-ai-blue), var(--cb-koiai));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 30px rgba(26,31,46,.45);
  z-index: 1000;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .25s, visibility .25s;
}
.chat-fab svg { width: 28px; height: 28px; }

.chat-fab::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--cb-yamabuki);
  animation: cbFabPulse 2.8s ease-out infinite;
  pointer-events: none;
}
@keyframes cbFabPulse {
  0%   { transform: scale(1);    opacity: .7; }
  65%  { transform: scale(1.38); opacity: 0; }
  100% { transform: scale(1.38); opacity: 0; }
}
@keyframes cbFabFloat {
  0%   { transform: translateY(0px)  rotate(0deg); }
  30%  { transform: translateY(-7px) rotate(-1.5deg); }
  60%  { transform: translateY(-4px) rotate(1deg); }
  100% { transform: translateY(0px)  rotate(0deg); }
}
@keyframes cbStatusGlow {
  0%, 100% { box-shadow: 0 0 4px #00c896; opacity: 1; }
  50%       { box-shadow: 0 0 9px #00c896, 0 0 3px #00c896; opacity: .85; }
}

.chat-fab:not(.cb-hidden) {
  animation: cbFabFloat 3.8s cubic-bezier(.45,.05,.55,.95) infinite;
}
.chat-fab:not(.cb-hidden):hover {
  animation: none;
  transform: scale(1.1) translateY(-3px);
  box-shadow: 0 16px 40px rgba(26,31,46,.55), 0 0 0 3px var(--cb-yamabuki);
}

.chat-fab .fab-dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--cb-yamabuki);
  border: 2px solid var(--cb-page-bg);
}

.chat-fab.cb-hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(.6) translateY(20px);
  pointer-events: none;
}

/* ============ チャットウィジェット ============ */
.chat-widget {
  position: fixed;
  right: 24px; bottom: 24px;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--cb-panel);
  border: 1px solid var(--cb-border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--cb-shadow);
  z-index: 1001;
  transform-origin: bottom right;
  opacity: 0;
  visibility: hidden;
  transform: translateY(28px) scale(.92);
  transition: transform .32s cubic-bezier(.34,1.4,.64,1), opacity .28s ease, visibility .32s;
}
.chat-widget.cb-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

@media (max-width: 480px) {
  .chat-widget { right: 12px; bottom: 12px; }
  .chat-fab    { right: 16px; bottom: 16px; }
}

/* --- ヘッダー --- */
.cb-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: linear-gradient(135deg, #1A1F2E 0%, #2D4A7A 100%);
  color: #fff;
}
.cb-avatar {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-yamabuki), #f5c34f);
  color: var(--cb-koiai);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 19px;
  box-shadow: 0 3px 10px rgba(0,0,0,.3), inset 0 0 0 1px rgba(255,255,255,.35);
}
.cb-header-info { flex: 1; min-width: 0; }
.cb-header-info .cb-name {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: .03em;
}
.cb-header-info .cb-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 11px;
  color: rgba(255,255,255,.72);
}
.cb-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #00c896;
  animation: cbStatusGlow 2.4s ease-in-out infinite;
}
.cb-min {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s;
}
.cb-min:hover { background: rgba(255,255,255,.24); }

/* --- メッセージエリア --- */
.cb-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.cb-body::-webkit-scrollbar { width: 6px; }
.cb-body::-webkit-scrollbar-thumb { background: var(--cb-scroll); border-radius: 3px; }
.cb-body::-webkit-scrollbar-track { background: transparent; }

/* --- メッセージ --- */
.cb-msg { display: flex; flex-direction: column; max-width: 100%; animation: cbMsgIn .32s ease both; }
@keyframes cbMsgIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cb-msg.bot  { align-items: flex-start; }
.cb-msg.user { align-items: flex-end; }

.cb-bubble {
  max-width: 82%;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
.cb-msg.bot  .cb-bubble { background: var(--cb-bot-bubble); color: var(--cb-bot-text); border-radius: 6px 18px 18px 18px; }
.cb-msg.user .cb-bubble { background: linear-gradient(135deg, #c98d0a 0%, #a87308 100%); color: var(--cb-koiai); font-weight: 600; border-radius: 18px 6px 18px 18px; }
.cb-time { font-size: 10px; color: var(--cb-time); margin-top: 4px; padding: 0 4px; }

/* --- タイピング --- */
.cb-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--cb-bot-bubble);
  border-radius: 6px 18px 18px 18px;
  padding: 13px 16px;
  animation: cbMsgIn .25s ease both;
}
.cb-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--cb-muted); animation: cbTyping 1.15s ease-in-out infinite; }
.cb-typing i:nth-child(2) { animation-delay: .15s; }
.cb-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes cbTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* --- チップ --- */
.cb-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 4px; animation: cbMsgIn .35s ease both; }
.cb-chip {
  border: 1.5px solid var(--cb-chip-c);
  background: transparent;
  color: var(--cb-chip-c);
  border-radius: 999px;
  padding: 9px 19px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s, transform .15s;
}
.cb-chip:hover  { background: var(--cb-yamabuki); border-color: var(--cb-yamabuki); color: var(--cb-koiai); transform: translateY(-1px); }
.cb-chip:active { transform: translateY(0) scale(.97); }

/* --- CTAボタン --- */
.cb-ctas { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 4px; animation: cbMsgIn .35s ease both; }
.cb-cta {
  border: none;
  background: var(--cb-yamabuki);
  color: var(--cb-koiai);
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 13.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(232,165,17,.35);
  transition: transform .15s, box-shadow .2s, background .2s;
}
.cb-cta:hover  { background: #f0b32a; transform: translateY(-1px); box-shadow: 0 7px 18px rgba(232,165,17,.45); }
.cb-cta:active { transform: scale(.98); }
.cb-cta.big    { width: 100%; padding: 14px 20px; font-size: 14.5px; border-radius: 12px; }
.cb-cta.ghost  { background: transparent; color: var(--cb-chip-c); border: 1.5px solid var(--cb-chip-c); box-shadow: none; }
.cb-cta.ghost:hover { background: var(--cb-yamabuki); border-color: var(--cb-yamabuki); color: var(--cb-koiai); }

/* --- 戻るリンク --- */
.cb-restart {
  align-self: flex-start;
  background: none; border: none;
  font-family: inherit;
  font-size: 12px;
  color: var(--cb-muted);
  cursor: pointer;
  padding: 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
  animation: cbMsgIn .35s ease both;
  transition: color .2s;
}
.cb-restart:hover { color: var(--cb-yamabuki); }

/* --- フォーム --- */
.cb-form {
  width: 88%;
  background: var(--cb-card);
  border: 1px solid var(--cb-border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  animation: cbMsgIn .35s ease both;
}
.cb-form label { font-size: 11px; font-weight: 700; color: var(--cb-muted); letter-spacing: .04em; }
.cb-form input {
  width: 100%;
  border: 1px solid var(--cb-input-bd);
  background: var(--cb-input-bg);
  color: var(--cb-text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
}
.cb-form input:focus { border-color: var(--cb-yamabuki); box-shadow: 0 0 0 3px rgba(232,165,17,.18); }
.cb-form .cb-err { font-size: 11px; color: #e05252; display: none; }
.cb-form.err .cb-err { display: block; }

/* --- 戻るバー --- */
.cb-backbar { padding: 6px 16px; background: var(--cb-footer); border-top: 1px solid var(--cb-input-bd); }
.cb-backbar button { background: none; border: none; font-size: 12px; color: var(--cb-ai-blue); cursor: pointer; padding: 2px 0; opacity: .75; transition: opacity .2s; }
.cb-backbar button:hover { opacity: 1; }

/* --- フッター --- */
.cb-footer {
  position: relative;
  flex-shrink: 0;
  border-top: 1px solid var(--cb-border);
  background: var(--cb-footer);
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.cb-footer::before {
  content: "";
  position: absolute;
  top: -28px; left: 0; right: 0;
  height: 28px;
  background: linear-gradient(transparent, var(--cb-footer));
  pointer-events: none;
  z-index: 1;
}
.cb-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--cb-input-bd);
  background: var(--cb-input-bg);
  color: var(--cb-text);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.5;
  max-height: 96px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.cb-input:focus { border-color: var(--cb-yamabuki); box-shadow: 0 0 0 3px rgba(232,165,17,.16); }
.cb-input::placeholder { color: var(--cb-muted); }

.cb-send {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--cb-yamabuki);
  color: var(--cb-koiai);
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform .15s, background .2s;
}
.cb-send:hover  { background: #f0b32a; transform: translateY(-1px); }
.cb-send:active { transform: scale(.94); }
.cb-send svg { width: 18px; height: 18px; }

.cb-powered {
  flex-shrink: 0;
  text-align: center;
  font-size: 10px;
  color: var(--cb-muted);
  padding: 5px 12px 8px;
  background: var(--cb-footer);
  letter-spacing: .03em;
}
