/* ============================================
   chat-widget.css — AI 客服 widget
   共用 xunc.css 的 CSS variables（需先載入 xunc.css）
   ============================================ */

#xc-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  width: 56px;
  height: 56px;
  border-radius: 2px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(57, 197, 187, 0.35);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s;
  cursor: none;
}
#xc-chat-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(57,197,187,.45); }
#xc-chat-btn svg { width: 26px; height: 26px; }

#xc-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 2px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px);
  animation: xcPanelIn 0.28s var(--ease-out) forwards;
}
@keyframes xcPanelIn { to { opacity: 1; transform: translateY(0); } }

#xc-chat-panel[hidden] { display: none; }

.xc-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  flex-shrink: 0;
}
.xc-chat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: xcPulse 1.6s ease-in-out infinite;
}
@keyframes xcPulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.xc-chat-title-wrap { flex: 1; min-width: 0; }
.xc-chat-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  color: var(--fg1);
}
.xc-chat-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg2);
  letter-spacing: .04em;
  margin-top: 2px;
}
#xc-chat-close {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: none;
  opacity: .85;
  transition: opacity .2s;
}
#xc-chat-close:hover { opacity: 1; }
#xc-chat-close svg { width: 16px; height: 16px; }

.xc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.xc-msg {
  max-width: 85%;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  border-radius: 2px;
}
.xc-msg--user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--bg);
}
.xc-msg--bot {
  align-self: flex-start;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--fg1);
}
.xc-typing {
  align-self: flex-start;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
}
.xc-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: xcBounce 1.1s ease-in-out infinite;
}
.xc-typing span:nth-child(2) { animation-delay: .15s; }
.xc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes xcBounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

.xc-chat-inputrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#xc-chat-input {
  flex: 1;
  min-width: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px 14px;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--fg1);
  outline: none;
  cursor: text !important;
  transition: border-color .2s;
}
#xc-chat-input::placeholder { color: var(--fg3); }
#xc-chat-input:focus { border-color: var(--accent); }
#xc-chat-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 2px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: none;
  transition: opacity .2s, transform .2s;
}
#xc-chat-send:disabled { opacity: .35; }
#xc-chat-send:not(:disabled):hover { transform: scale(1.06); }
#xc-chat-send svg { width: 17px; height: 17px; }

@media (pointer: coarse) {
  #xc-chat-btn, #xc-chat-close, #xc-chat-send { cursor: auto; }
}

@media (max-width: 480px) {
  #xc-chat-btn { bottom: 16px; right: 16px; }
  #xc-chat-panel { bottom: 16px; right: 16px; }
}
