/* チャットボット - フローティングボタン */
.oac-chatbot-button {
  position: fixed;
  bottom: 30px;
  right: 110px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0494a3 0%, #036f7a 100%);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(4, 148, 163, 0.4), 0 0 0 0 rgba(4, 148, 163, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  z-index: 9999;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 6px 20px rgba(4, 148, 163, 0.4), 0 0 0 0 rgba(4, 148, 163, 0.7);
  }
  50% {
    box-shadow: 0 6px 20px rgba(4, 148, 163, 0.4), 0 0 0 15px rgba(4, 148, 163, 0);
  }
  100% {
    box-shadow: 0 6px 20px rgba(4, 148, 163, 0.4), 0 0 0 0 rgba(4, 148, 163, 0);
  }
}

.oac-chatbot-button:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 28px rgba(4, 148, 163, 0.5);
  animation: none; /* ホバー時はパルス停止 */
}

/* チャットボタンのツールチップ */
.oac-chatbot-tooltip {
  position: absolute;
  right: 85px;
  top: 50%;
  transform: translateY(-50%);
  background: white;
  color: #333;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0.3; /* 常時表示（薄く） */
  visibility: visible; /* 常に表示 */
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* 矢印（右向き） */
.oac-chatbot-tooltip::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 0 8px 8px;
  border-color: transparent transparent transparent white;
}

/* ホバー時にツールチップを濃く表示 */
.oac-chatbot-button:hover .oac-chatbot-tooltip {
  opacity: 1; /* ホバーで完全に表示 */
}


/* チャットウィンドウ */
.oac-chatbot-window {
  position: fixed;
  bottom: 110px;
  right: 110px;
  width: 450px;
  max-width: calc(100vw - 60px);
  height: 650px;
  max-height: calc(100vh - 200px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.oac-chatbot-window.active {
  display: flex;
}

/* チャットウィンドウが開いているときはボタンを非表示 */
.oac-chatbot-window.active ~ .oac-chatbot-button {
  display: none;
}

/* ヘッダー */
.oac-chatbot-header {
  background: linear-gradient(135deg, #0494a3 0%, #036f7a 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.oac-chatbot-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.oac-chatbot-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.oac-chatbot-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.oac-chatbot-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

.oac-chatbot-header-subtitle {
  font-size: 12px;
  opacity: 0.9;
  font-weight: 400;
}

.oac-chatbot-header-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.oac-chatbot-toggle-special {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0.8;
  transition: all 0.2s;
  flex-shrink: 0;
}

.oac-chatbot-toggle-special:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.3);
}

.oac-chatbot-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.oac-chatbot-close:hover {
  opacity: 1;
}

/* メッセージエリア */
.oac-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.oac-chat-message {
  display: flex;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.oac-chat-message.user {
  flex-direction: row-reverse;
}

.oac-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  overflow: hidden;
}

.oac-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.oac-chat-message.ai .oac-chat-avatar {
  background: linear-gradient(135deg, #0494a3 0%, #036f7a 100%);
  color: white;
}

.oac-chat-message.user .oac-chat-avatar {
  background: #e9ecef;
  color: #495057;
}

.oac-chat-bubble {
  width: fit-content;
  min-width: 80px;
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 14px;
  word-break: keep-all;
}

.oac-chat-message.ai .oac-chat-bubble {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.oac-chat-message.user .oac-chat-bubble {
  background: linear-gradient(135deg, #0494a3 0%, #036f7a 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

/* ソース（関連リンク） */
.oac-chat-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e9ecef;
  display: block;
}

.oac-chat-sources-title {
  font-size: 12px;
  color: #6c757d;
  margin-bottom: 6px;
}

.oac-chat-source-link {
  display: inline-block;
  font-size: 12px;
  color: #0494a3;
  text-decoration: none;
  padding: 4px 8px;
  background: #ebf6f8;
  border-radius: 4px;
  margin: 2px;
  transition: background 0.2s;
}

.oac-chat-source-link:hover {
  background: #d0e9ed;
}

/* ローディング */
.oac-chat-loading {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.oac-chat-loading span {
  width: 8px;
  height: 8px;
  background: #0494a3;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

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

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

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* 入力エリア */
.oac-chatbot-input-area {
  padding: 16px;
  background: white;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 8px;
}

.oac-chatbot-input-area input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #dee2e6;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.oac-chatbot-input-area input:focus {
  border-color: #0494a3;
}

.oac-chatbot-input-area button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0494a3 0%, #036f7a 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: transform 0.2s;
}

.oac-chatbot-input-area button:hover {
  transform: scale(1.05);
}

.oac-chatbot-input-area button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* モバイル対応 */
@media (max-width: 768px) {
  .oac-chatbot-window {
    bottom: 100px;
    right: 20px;
    width: calc(100vw - 40px);
    height: calc(100vh - 180px);
  }

  .oac-chatbot-button {
    bottom: 20px;
    right: 20px;
  }
}

/* よくある質問ボタン */
.oac-quick-questions {
  margin-top: 16px;
  padding: 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.oac-quick-questions-title {
  font-size: 13px;
  font-weight: 600;
  color: #495057;
  margin-bottom: 12px;
  text-align: center;
}

.oac-quick-question-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid #dee2e6;
  border-radius: 8px;
  color: #333;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.oac-quick-question-btn:hover {
  background: linear-gradient(135deg, #0494a3 0%, #036f7a 100%);
  color: white;
  border-color: #0494a3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(4, 148, 163, 0.3);
}

.oac-quick-question-btn.oac-quick-other {
  background: linear-gradient(135deg, #fff9e6 0%, #fff3cc 100%);
  border-color: #ffd966;
  margin-bottom: 0;
}

.oac-quick-question-btn.oac-quick-other:hover {
  background: linear-gradient(135deg, #ffeb99 0%, #ffe066 100%);
  color: #333;
  border-color: #ffc300;
}

/* 最後のボタンのマージンを削除 */
.oac-quick-question-btn:last-child {
  margin-bottom: 0;
}

/* AI回答内の選択肢ボタン */
.oac-choice-buttons {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.oac-choice-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid #dee2e6;
  border-radius: 8px;
  color: #333;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.oac-choice-btn:hover {
  background: linear-gradient(135deg, #0494a3 0%, #036f7a 100%);
  color: white;
  border-color: #0494a3;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(4, 148, 163, 0.3);
}

.oac-choice-btn.oac-choice-other {
  background: linear-gradient(135deg, #fff9e6 0%, #fff3cc 100%);
  border-color: #ffd966;
  margin-top: 4px;
}

.oac-choice-btn.oac-choice-other:hover {
  background: linear-gradient(135deg, #ffeb99 0%, #ffe066 100%);
  color: #333;
  border-color: #ffc300;
}

/* ================================
   スマホ対応（767px以下）
   ================================ */
@media (max-width: 767px) {
  /* チャットボタン */
  .oac-chatbot-button {
    bottom: 15px;
    right: 15px;
    width: 56px;
    height: 56px;
    font-size: 26px;
  }
  
  /* チャットウィンドウがアクティブな時はボタンを非表示（スマホ） */
  .oac-chatbot-window.active ~ .oac-chatbot-button {
    display: none !important;
  }
  
  /* ツールチップを非表示（スマホでは不要） */
  .oac-chatbot-tooltip {
    display: none;
  }
  
  /* チャットウィンドウ */
  .oac-chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  
  /* ヘッダー */
  .oac-chatbot-header {
    padding: 12px 15px;
    min-height: 56px;
  }
  
  .oac-chatbot-header-title {
    font-size: 15px;
  }
  
  .oac-chatbot-header-subtitle {
    font-size: 11px;
  }
  
  .oac-chatbot-close {
    font-size: 20px;
  }
  
  /* メッセージエリア */
  .oac-chatbot-messages {
    flex: 1 1 auto;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    min-height: 0; /* flexboxで必須 */
    max-height: calc(100vh - 56px - 70px); /* ヘッダー - 入力エリアの高さ */
  }
  
  /* メッセージバブル */
  .oac-chat-bubble {
    font-size: 14px;
    padding: 10px 12px;
    max-width: 80%;
  }
  
  /* アバター */
  .oac-chat-avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  
  .oac-chat-avatar img {
    width: 32px;
    height: 32px;
  }
  
  /* よくある質問ボタン */
  .oac-quick-question-btn {
    font-size: 13px;
    padding: 10px 14px;
  }
  
  /* 選択肢ボタン */
  .oac-choice-btn {
    font-size: 13px;
    padding: 10px 12px;
  }
  
  /* 入力エリア */
  .oac-chatbot-input-area {
    padding: 10px 12px;
    gap: 8px;
    /* キーボード表示時も固定 */
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0; /* 縮小しない */
    min-height: 62px; /* 最小高さ確保 */
    z-index: 10; /* 他の要素より上に */
  }
  
  #oac-chatbot-input {
    font-size: 16px; /* iOSのズーム防止 */
    padding: 10px 12px;
  }
  
  #oac-chatbot-send {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }
  
  /* ローディング */
  .oac-loading-dots span {
    width: 7px;
    height: 7px;
  }
  
  /* ソースリンク */
  .oac-chat-sources {
    font-size: 11px;
    margin-top: 8px;
  }
  
  .oac-chat-source-link {
    font-size: 11px;
    padding: 4px 8px;
  }
}
