/* =========================================================
   チャットボットウィジェット
   ========================================================= */

.chatbot {
  --cb-primary: #1f5f9c;
  --cb-primary-dark: #164a7a;
  --cb-accent: #f0a93b;
  --cb-text: #2a3340;
  --cb-text-sub: #4f5a68;
  --cb-bg: #ffffff;
  --cb-bg-alt: #f4f9fd;
  --cb-border: #dde7f0;
  --cb-shadow: 0 14px 36px rgba(31, 95, 156, 0.18);
  --cb-radius: 12px;

  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  color: var(--cb-text);
  font-size: 14px;
  line-height: 1.7;
}

/* ---------- 起動ボタン ---------- */
.chatbot__launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--cb-primary);
  color: #fff;
  border: none;
  box-shadow: var(--cb-shadow);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, background .2s ease;
}
.chatbot__launcher:hover {
  background: var(--cb-primary-dark);
  transform: translateY(-2px);
}
.chatbot__launcher svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chatbot__launcher-label {
  position: absolute;
  right: 74px;
  top: 50%;
  transform: translateY(-50%);
  background: #fff;
  color: var(--cb-text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.chatbot__launcher:hover .chatbot__launcher-label { opacity: 1; }

/* ---------- パネル ---------- */
.chatbot__panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--cb-bg);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
}
.chatbot.is-open .chatbot__panel {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* ---------- ヘッダー ---------- */
.chatbot__header {
  background: var(--cb-primary);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chatbot__header-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}
.chatbot__header-sub {
  font-size: 11px;
  opacity: .85;
  margin-top: 2px;
}
.chatbot__close {
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.chatbot__close:hover { background: rgba(255,255,255,.28); }

/* ---------- メッセージエリア ---------- */
.chatbot__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--cb-bg-alt);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.chatbot__messages::-webkit-scrollbar { width: 6px; }
.chatbot__messages::-webkit-scrollbar-thumb {
  background: #c6d4e1;
  border-radius: 3px;
}

.cb-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 10px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: cb-fade-in .25s ease;
}
.cb-msg--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--cb-border);
  border-bottom-left-radius: 2px;
}
.cb-msg--user {
  align-self: flex-end;
  background: var(--cb-primary);
  color: #fff;
  border-bottom-right-radius: 2px;
}

@keyframes cb-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 候補ボタン ---------- */
.cb-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-start;
  max-width: 100%;
  width: 100%;
}
.cb-option {
  text-align: left;
  background: #fff;
  border: 1px solid var(--cb-border);
  color: var(--cb-primary);
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  font-family: inherit;
}
.cb-option:hover {
  background: var(--cb-primary);
  border-color: var(--cb-primary);
  color: #fff;
}
.cb-option--cat {
  font-weight: 500;
}
.cb-option--back {
  color: var(--cb-text-sub);
  font-size: 12px;
  padding: 6px 10px;
}

/* ---------- 回答下のアクション ---------- */
.cb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  align-self: flex-start;
}
.cb-action {
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--cb-border);
  color: var(--cb-primary);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.cb-action:hover { background: var(--cb-bg-alt); }
.cb-action--cta {
  background: var(--cb-accent);
  border-color: var(--cb-accent);
  color: #fff;
}
.cb-action--cta:hover { background: #d68f1e; border-color: #d68f1e; }

/* ---------- 入力欄 ---------- */
.chatbot__input {
  border-top: 1px solid var(--cb-border);
  padding: 10px 12px;
  background: #fff;
  display: flex;
  gap: 8px;
}
.chatbot__input input {
  flex: 1;
  border: 1px solid var(--cb-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--cb-bg-alt);
  color: var(--cb-text);
}
.chatbot__input input:focus {
  border-color: var(--cb-primary);
  background: #fff;
}
.chatbot__input button {
  border: none;
  background: var(--cb-primary);
  color: #fff;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}
.chatbot__input button:hover { background: var(--cb-primary-dark); }
.chatbot__input button:disabled { background: #b8c5d3; cursor: not-allowed; }

/* ---------- フッター注記 ---------- */
.chatbot__note {
  font-size: 10.5px;
  color: var(--cb-text-sub);
  text-align: center;
  padding: 4px 12px 8px;
  background: #fff;
}

/* ---------- スマホ最適化 ---------- */
@media (max-width: 480px) {
  .chatbot__panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 88px;
    height: calc(100vh - 110px);
  }
  .chatbot__launcher {
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
  }
  .chatbot__launcher-label { display: none; }
}
