/* --- ウィジェット全体の配置 --- */
#chatbot-widget {
  position: fixed;
  bottom: 10px;
  right: 0;
  z-index: 9999;
  font-family: 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  width: 100%;
  /* ★ここをCocoonの実際の最大幅（例えば1280pxなど）より少し大きくします */
  max-width: 1300px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, bottom 0.4s ease;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  /* 右端（サイドバー側）に寄せる */
}

#chatbot-widget.visible {
  opacity: 1;
  pointer-events: auto;
}

#chatbot-toggle,
#chatbot-box {
  width: 336px;
  margin-right: 0;
  pointer-events: auto;
}

#chatbot-widget {
  align-items: center;
}
/* --- ボタン（トグル）のデザイン --- */
#chatbot-toggle {
  background: #1e3a5f;
  color: #fff;
  padding: 14px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  /* テキストを中央へ */
  gap: 12px;
  box-sizing: border-box;
  border: 2px solid #1e3a5f;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  position: relative;
  order: 1;
}

#chatbot-toggle:hover {
  background: #264a7a;
  border-color: #264a7a;
}

#chatbot-widget.open #chatbot-toggle {
  border-radius: 8px 8px 0 0;
  box-shadow: none;
}

#chatbot-toggle::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

#chatbot-toggle::after {
  content: '✕';
  position: absolute;
  right: 18px;
  font-size: 18px;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s ease;
}

#chatbot-widget.open #chatbot-toggle::after {
  opacity: 0.8;
  transform: scale(1);
}

/* --- チャットボックス（ウィンドウ） --- */
#chatbot-box {
  order: 2;
  height: 480px;
  background: #fff !important;
  border-radius: 0 0 8px 8px;
  border: 2px solid #1e3a5f;
  border-top: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

#chatbot-box.hidden {
  display: none !important;
}

/* メッセージエリア */
#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  font-size: 15px;
  line-height: 1.7;
  background: #f7fbfe;
  display: flex;
  flex-direction: column;
}

/* 注意事項 */
#chatbot-notice {
  background: #fff8e6;
  color: #7a6000;
  font-size: 13px;
  line-height: 1.6;
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  flex-shrink: 0;
  border: 1px solid #f0e0b0;
}

/* 入力エリア */
#chatbot-input-area {
  display: flex;
  border-top: 1px solid #d0dde8;
  background: #fff;
  padding: 12px 10px;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

.bot-msg,
.user-msg {
  border-radius: 4px;
  padding: 12px 16px;
  margin-bottom: 12px;
  word-wrap: break-word;
}

.bot-msg {
  background: #fff;
}

.user-msg { 
  background: #1e3a5f; 
  color: #fff; 
  margin-left: auto; 
}

/* ローディング */
.bot-msg.loading {
  display: flex !important;
  align-items: center;
  gap: 6px;
  padding: 15px 20px;
  background: #fff;
  border-left: 3px solid #1e3a5f;
  min-height: 46px;
}

.bot-msg.loading span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1e3a5f;
  display: inline-block;
  animation: bounce 1.4s infinite ease-in-out both;
}

.bot-msg.loading span:nth-child(1) {
  animation-delay: -0.32s;
}

.bot-msg.loading span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.3;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

#chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid #b0c4d8;
  border-radius: 20px;
  outline: none;
  font-size: 16px;
}

#chatbot-send {
  padding: 10px 18px;
  background: #1e3a5f;
  color: #fff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

/* リンク */
.chat-link {
  color: #1e3a5f;
  text-decoration: underline;
  word-break: break-all;
}

/* --- スマホ向けレスポンシブ（センター配置） --- */
@media (max-width: 600px) {
  #chatbot-widget {
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    align-items: center;
    /* 中央に寄せる */
    bottom: 20px;
  }

  #chatbot-toggle,
  #chatbot-box {
    width: 90%;
    max-width: 340px;
    margin-right: 0;
    /* スマホでは右余白をリセット */
  }

  #chatbot-toggle {
    border-radius: 30px;
  }

  #chatbot-widget.open #chatbot-toggle {
    border-radius: 20px 20px 0 0;
  }
}

/* 思考プロセス演出用のスタイル */
.loading-text {
  font-size: 0.85em;
  color: #888;
  margin-bottom: 8px;
  font-style: italic;
  transition: opacity 0.3s ease;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background: #ccc;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  animation: dots 1.4s infinite ease-in-out both;
}

/* 点滅アニメーション（既存のものがあれば不要です） */
@keyframes dots {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1.0);
  }
}