@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

body {
  background-image: url("/static/img/SanreyIndexBackground.png");
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.chatbot {
  position: fixed;
  right: 40px;
  bottom: 100px;
  width: 420px;
  transform: scale(0.5);
  opacity: 0;
  pointer-events: none;
  background-color: #fff;
  overflow: hidden;
  border-radius: 15px;
  transform-origin: bottom right;
  box-shadow: 0 0 128px 0 rgba(0, 0, 0, 0.1),
    0 32px 64px -48px rgba(0, 0, 0, 0.5);
  transition: all 0.1s ease;
  z-index: 50;
}

.show-chatbot .chatbot {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.show-chatbot .chatbot-toggler span:first-child,
.chatbot-toggler span:last-child {
  opacity: 0;
}

.show-chatbot .chatbot-toggler span:last-child {
  opacity: 1;
}

.chatbot header {
  background: #fff;
  /* border: 3px solid #E1E1E1; */
  border-radius: 16px 16px 0 0;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); /* 陰影 */
  padding: 10px 0;
  text-align: center;
  position: relative;
}

.chatbot header h2 {
  color: #59697a;
  font-size: 1.2rem;
}

.chatbot header span {
  position: absolute;
  right: 20px;
  top: 50%;
  color: #fcfaf2;
  cursor: pointer;
  display: none;
  transform: translateY(-50%);
}

.chatbot .chatbot-content {
  height: 500px;
  overflow-y: auto;
  padding: 30px 20px 100px;
  background: radial-gradient(
      circle at center left,
      rgba(86, 145, 255, 0.2) 10%,
      /* 左上角的淡紫色 */ rgba(255, 255, 255, 0.9) 40%
    ),
    radial-gradient(
      circle at bottom right,
      rgba(86, 145, 255, 0.2) 10%,
      /* 右下角的淡紫色 */ rgba(255, 255, 255, 0.9) 50%
    );
  background-blend-mode: multiply;
  border-radius: 10px;
}

.chatbot .chat {
  display: flex;
}

.chatbot .outgoing {
  margin: 20px 0;
  justify-content: flex-end;
}

.chatbot .chat p {
  color: #003366;
  max-width: 75%;
  white-space: pre-line;
  word-wrap: break-word; /* 長單詞換行 */
  overflow-wrap: break-word; /* 增強兼容性 */
  font-size: 0.9rem;
  padding: 12px 16px;
  border-radius: 10px 10px 0 10px;
  background: rgba(217, 217, 238, 0.7);
}

.chatbot .chat p.error {
  color: #721c24;
  background: #f8d7da;
}

.chatbot .incoming p {
  color: #003366;
  border: 1px solid #bac8df; /* 主邊框顏色 */
  background: white;
  border-radius: 10px;
  word-wrap: break-word; /* 換行 */
  overflow-wrap: break-word;
}

.chatbot .incoming span {
  width: 40px;
  height: 40px;

  align-self: flex-end;

  text-align: center;
  line-height: 32px;
  border-radius: 4px;
  margin: 0 10px 1px 0;
}

.chatbot .chat-input {
  position: absolute;
  bottom: 0;
  width: 100%;
  display: flex;
  gap: 5px;
  background: #ffffff;
  padding: 5px 20px;
  border-top: 1px solid #ccc;
  border-radius: 10px;
  flex-shrink: 0;
  height: 65px;
}

.robot-icon {
  width: 40px;
  height: 40px;
  object-fit: cover;
  padding-left: 10px;
  padding-bottom: 5px;
  flex-shrink: 0;
}

.chat-input span {
  align-self: flex-end;
  height: 55px;
  line-height: 55px;
  color: #0f2540;
  font-size: 1.8rem;
  cursor: pointer;
  visibility: hidden;
}

.chat-input textarea {
  height: 55px;
  width: 100%;
  border: none;
  outline: none;
  font-size: 0.95rem;
  resize: none;
  padding: 16px 15px 16px 0;
  color: #0f2540;
  border-radius: 10px;
  overflow: hidden;
}

.chat-input textarea:valid ~ span {
  visibility: visible;
}

.chatbot-toggler {
  position: fixed;
  right: 45px;
  bottom: 45px;
  height: 50px;
  width: 50px;
  color: #fcfaf2;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  cursor: pointer;
  background: rgba(0,0,0,0.4);
  border-radius: 50%;
  transition: all 0.2s ease;
}

.show-chatbot .chatbot-toggler {
  transform: rotate(90deg);
}

.chatbot-toggler span {
  position: absolute;
}

/* 隱藏手機版以外的關閉按鈕 */
.mobile-close-icon {
  display: none; /* 預設隱藏 */
}

/* 僅在手機版顯示這個圖示 */
@media (max-width: 490px) {
  /* 顯示手機版的關閉圖示 */
  .mobile-close-icon {
    display: inline-block;
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
  }

  /* 調整聊天機器人為全螢幕 */
  .chatbot {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  /* 修正內容區域的高度 */
  .chatbot .chatbot-content {
    height: calc(100% - 65px);
  }

  .chatbot header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .chatbot header span {
    display: block;
    width: 28px;
    height: 28px;
  }

  .chatbot header h2 {
    font-size: 1.2rem;
    margin-top: 15px;
  }

  .chat.incoming p {
    font-size: 16px;
  }
  .preset-questions button {
    font-size: 16px !important;
  }
  .chat-input textarea {
    font-size: 16px;
  }
}

.preset-questions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
  margin-left: 65px;
}

.preset-questions button {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #004680;
  border: 1px solid #e1e1e1;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  width: 80%;
  max-width: 200px;
  transition: background 0.3s ease, transform 0.2s ease;
}

.preset-questions button:hover {
  background: #f0f8ff;
  transform: translateY(-2px);
}

.preset-questions span.material-symbols-outlined {
  font-size: 1rem;
  margin-right: 6px;
  color: #004680;
}

.waiting-indicator {
  font-size: 24px;
  font-weight: bold;
  color: #0f2540;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
}
