/* ============================================================
   TIAI Chatbot Widget — 浮動對話視窗
   引入方式：<link rel="stylesheet" href="css/chatbot.css">
   ============================================================ */

/* CSS 變數 — 想換色直接改這裡 */
:root {
  --tiai-bot-primary:  #2b7cff;
  --tiai-bot-accent:   #00CCFF;
  --tiai-bot-gradient: linear-gradient(135deg, #00CCFF 0%, #2b7cff 100%);
  --tiai-bot-glow:     0 8px 24px rgba(43, 124, 255, 0.35);
  --tiai-bot-bubble:   #F0F7FF;
  --tiai-bot-text:     #1A1A2E;
}

/* === Launcher（浮動圓鈕） === */
.tiai-bot-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--tiai-bot-gradient);
  cursor: pointer;
  box-shadow: var(--tiai-bot-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: tiai-bot-pulse 2.4s infinite;
  transition: transform 0.2s;
  font-family: inherit;
}
.tiai-bot-launcher:hover     { transform: scale(1.06); }
.tiai-bot-launcher.is-open   { animation: none; }
.tiai-bot-launcher svg       { width: 26px; height: 26px; }
.tiai-bot-launcher .badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  background: #ff3b5c;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

@keyframes tiai-bot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(43,124,255,0.5); }
  70%  { box-shadow: 0 0 0 14px rgba(43,124,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(43,124,255,0); }
}

/* === Panel（對話視窗） === */
.tiai-bot-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 9997;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #ECEEF5;
  font-family: "Microsoft JhengHei", "Heiti TC", sans-serif;
}
.tiai-bot-panel.is-open {
  display: flex;
  animation: tiai-bot-pop 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes tiai-bot-pop {
  from { opacity: 0; transform: translateY(20px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* === Header === */
.tiai-bot-header {
  background: var(--tiai-bot-gradient);
  padding: 16px 18px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}
.tiai-bot-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tiai-bot-avatar svg { width: 22px; height: 22px; }
.tiai-bot-title    { flex: 1; min-width: 0; }
.tiai-bot-name     { font-size: 15px; font-weight: 700; line-height: 1.2; }
.tiai-bot-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.tiai-bot-status::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #3fe39a;
  box-shadow: 0 0 0 2px rgba(63,227,154,0.3);
}
.tiai-bot-close {
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tiai-bot-close svg { width: 14px; height: 14px; }

/* === Messages === */
.tiai-bot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #FAFBFC;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tiai-bot-messages::-webkit-scrollbar       { width: 6px; }
.tiai-bot-messages::-webkit-scrollbar-thumb { background: rgba(43,124,255,0.2); border-radius: 3px; }

.tiai-bot-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.tiai-bot-row.is-user { flex-direction: row-reverse; }
.tiai-bot-row .mini-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--tiai-bot-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tiai-bot-row .mini-avatar svg { width: 16px; height: 16px; }

.tiai-bot-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 4px 16px 16px 16px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--tiai-bot-bubble);
  color: var(--tiai-bot-text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.tiai-bot-row.is-user .tiai-bot-bubble {
  border-radius: 16px 4px 16px 16px;
  background: var(--tiai-bot-gradient);
  color: #fff;
  box-shadow: 0 2px 8px rgba(43,124,255,0.25);
}

/* Typing indicator */
.tiai-bot-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--tiai-bot-bubble);
  border-radius: 4px 16px 16px 16px;
}
.tiai-bot-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--tiai-bot-primary);
  opacity: 0.5;
  animation: tiai-bot-bounce 1.2s infinite;
}
.tiai-bot-typing span:nth-child(2) { animation-delay: 0.18s; }
.tiai-bot-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes tiai-bot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* Quick reply chips */
.tiai-bot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 36px;
  margin-top: 4px;
}
.tiai-bot-chip {
  background: #fff;
  border: 1.5px solid rgba(43,124,255,0.27);
  color: var(--tiai-bot-primary);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  white-space: nowrap;
}
.tiai-bot-chip:hover {
  background: var(--tiai-bot-gradient);
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
}

/* Bot message links */
.tiai-bot-link {
  color: var(--tiai-bot-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tiai-bot-link:hover { opacity: 0.8; }

/* === Input bar === */
.tiai-bot-input-bar {
  padding: 12px 14px;
  border-top: 1px solid #ECEEF5;
  background: #fff;
  display: flex;
  gap: 8px;
  align-items: center;
}
.tiai-bot-input {
  flex: 1;
  border: 1px solid #E5E8F0;
  background: #F5F7FB;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  color: #1A1A2E;
}
.tiai-bot-input:focus {
  border-color: var(--tiai-bot-primary);
  box-shadow: 0 0 0 3px rgba(43,124,255,0.15);
}
.tiai-bot-input::placeholder { color: #9aa1b5; }
.tiai-bot-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--tiai-bot-gradient);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.tiai-bot-send:hover:not(:disabled) { transform: scale(1.06); }
.tiai-bot-send:disabled {
  background: #E5E8F0;
  cursor: not-allowed;
}
.tiai-bot-send svg { width: 18px; height: 18px; }

.tiai-bot-footer {
  padding: 6px 14px 8px;
  font-size: 11px;
  text-align: center;
  color: #9aa1b5;
  background: #fff;
  border-top: 1px solid #F2F4F9;
}

/* === Mobile === */
@media (max-width: 480px) {
  .tiai-bot-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 90px;
  }
  .tiai-bot-launcher {
    right: 16px;
    bottom: 16px;
  }
}
