/* ============================================
   售后助手聊天组件样式
   可嵌入任意 HTML 页面
   ============================================ */

#asst-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  animation: asst-pulse 2.5s infinite;
}

#asst-trigger:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(37, 99, 235, 0.5);
}

#asst-trigger svg {
  width: 30px;
  height: 30px;
  fill: white;
}

#asst-trigger .asst-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid white;
  font-size: 11px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  animation: none;
}

@keyframes asst-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4); }
  50% { box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4), 0 0 0 8px rgba(37, 99, 235, 0.1); }
}

/* 聊天窗口 */
#asst-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 400px;
  height: 600px;
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  z-index: 99999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  animation: asst-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes asst-slide-up {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

#asst-window.active {
  display: flex;
}

/* 头部 */
.asst-header {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.asst-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.asst-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.asst-header-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.asst-header-text .asst-status {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.asst-status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}

.asst-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.asst-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* 消息区域 */
.asst-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.asst-messages::-webkit-scrollbar {
  width: 6px;
}

.asst-messages::-webkit-scrollbar-track {
  background: transparent;
}

.asst-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* 消息气泡 */
.asst-msg {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  max-width: 90%;
}

.asst-msg.bot {
  align-items: flex-start;
}

.asst-msg.user {
  align-items: flex-end;
  margin-left: auto;
}

.asst-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.asst-msg.bot .asst-msg-bubble {
  background: white;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.asst-msg.user .asst-msg-bubble {
  background: #2563eb;
  color: white;
  border-bottom-right-radius: 4px;
}

/* 打字动画 */
.asst-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.asst-typing-dot {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: asst-typing-bounce 1.4s infinite ease-in-out;
}

.asst-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.asst-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes asst-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* 快捷分类 */
.asst-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.asst-category-btn {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.asst-category-btn:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
}

/* 建议问题 */
.asst-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.asst-suggestion-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: #1d4ed8;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.asst-suggestion-btn:hover {
  background: #dbeafe;
  border-color: #2563eb;
}

/* 快捷问题按钮 */
.asst-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.asst-quick-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.asst-quick-btn:hover {
  background: #eff6ff;
  color: #2563eb;
  border-color: #93c5fd;
}

/* 底部输入区 */
.asst-input-area {
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.asst-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.asst-input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 80px;
  min-height: 42px;
  transition: border-color 0.2s;
  line-height: 1.4;
}

.asst-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.asst-send-btn {
  width: 42px;
  height: 42px;
  background: #2563eb;
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.asst-send-btn:hover {
  background: #1d4ed8;
}

.asst-send-btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.asst-send-btn svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* 底部信息 */
.asst-footer {
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  padding: 4px 0 2px;
}

/* 移动端适配 */
@media (max-width: 480px) {
  #asst-window {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }

  #asst-trigger {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }
}
