/* 聊天視窗主體外框 */
.chat-container {
  width: 100%;
  max-width: 500px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 600px;
  border: 1px solid #e0e0e0;
}

/* 聊天室標題列 */
.chat-header {
  background-color: #007bff;
  color: #ffffff;
  padding: 15px;
  font-size: 1.1em;
  font-weight: bold;
  text-align: center;
}

/* 對話訊息歷史展示區 */
.chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background-color: #fafafa;
}

/* 單條訊息共同樣式 */
.message-bubble {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
}

/* 訊息文字泡泡 */
.message-text {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95em;
  line-height: 1.4;
  word-wrap: break-word;
}

/* 顧客提問樣式 (靠右、藍底白字) */
.message-user {
  align-items: flex-end;
}
.message-user .message-text {
  background-color: #007bff;
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

/* AI 回覆樣式 (靠左、灰底黑字) */
.message-ai {
  align-items: flex-start;
}
.message-ai .message-text {
  background-color: #e9ecef;
  color: #333333;
  border-bottom-left-radius: 2px;
}

/* AI 參考來源說明區 (灰色細字) */
.source-info {
  font-size: 0.8em;
  color: #888888;
  margin-top: 4px;
  padding-left: 5px;
}

/* 底部輸入區域 */
.chat-input-area {
  border-top: 1px solid #eeeeee;
  padding: 10px;
  display: flex;
  background-color: #ffffff;
}

/* 輸入框 */
.chat-input {
  flex: 1;
  border: 1px solid #cccccc;
  border-radius: 4px;
  padding: 10px;
  font-size: 0.95em;
  outline: none;
}
.chat-input:focus {
  border-color: #007bff;
}

/* 發送按鈕 */
.btn-send {
  background-color: #007bff;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  margin-left: 8px;
  padding: 0 18px;
  font-size: 0.95em;
  cursor: pointer;
  transition: background-color 0.2s;
}
.btn-send:hover {
  background-color: #0056b3;
}
.btn-send:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

/* 💡 新增：常見引導問題提示區樣式 */
.guide-questions-container {
  padding: 10px 15px;
  background-color: #fafafa;
  border-top: 1px dashed #e5e5e5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  box-sizing: border-box;
}

.guide-question-btn {
  background-color: #f0f7ff;
  color: #007bff;
  border: 1px solid #cce4ff;
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 0.88em;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
  white-space: nowrap;
  outline: none;
}

.guide-question-btn:hover {
  background-color: #007bff;
  color: #ffffff;
  border-color: #007bff;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 123, 255, 0.15);
}

.guide-question-btn:active {
  transform: translateY(0);
}

/*==================客製新增======================================*/

/* ===== 新增：右下角固定開關按鈕 ===== */
#chatToggleBtn {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  background-color: #007bff;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition:
    transform 0.2s ease,
    background-color 0.2s ease;
}
#chatToggleBtn:hover {
  background-color: #0056b3;
  transform: scale(1.06);
}
#chatToggleBtn svg {
  width: 26px;
  height: 26px;
  fill: #ffffff;
}

/* ===== 聊天視窗主體外框：原本樣式 + 固定定位/開關動畫 ===== */
.chat-container {
  /* 原本樣式 */
  width: 100%;
  max-width: 500px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 600px;
  border: 1px solid #e0e0e0;

  /* 新增：固定在右下角、預設隱藏 */
  position: fixed;
  right: 24px;
  bottom: 96px;
  max-height: calc(100vh - 140px);
  z-index: 9999;

  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}
.chat-container.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ===== 聊天視窗主體外框：原本樣式 + 固定定位/開關動畫 ===== */
.chat-container {
  /* 原本樣式 */
  width: 100%;
  max-width: 500px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 600px;
  border: 1px solid #e0e0e0;

  /* 新增：固定在右下角、預設隱藏 */
  position: fixed;
  right: 24px;
  bottom: 96px;
  max-height: calc(100vh - 140px);
  z-index: 9999;

  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}
.chat-container.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* 聊天室標題列：原本樣式 + 關閉按鈕排版 */
.chat-header {
  background-color: #007bff;
  color: #ffffff;
  padding: 15px;
  font-size: 1.1em;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-header .chat-header-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}
.chat-header .chat-header-close svg {
  width: 18px;
  height: 18px;
  fill: #ffffff;
}

/* 手機版寬度調整（視窗貼齊螢幕邊緣） */
@media (max-width: 540px) {
  .chat-container {
    right: 12px;
    left: 12px;
    max-width: none;
    width: auto;
  }
  #chatToggleBtn {
    right: 16px;
  }
}
