
/* ============== 智能客服悬浮窗 ============== */
.wd-chat-fab {
  position: fixed;
  right: 24px;
  bottom: 32px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: transparent;
  color: var(--wd-white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  padding: 0;
  overflow: hidden;
}
.wd-chat-fab img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
}
.wd-chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.wd-chat-fab:active {
  transform: scale(0.95);
}
.wd-chat-fab:focus-visible {
  outline: 2px solid var(--wd-focus-ring);
  outline-offset: 4px;
}

.wd-chat-fab .tooltip {
  position: absolute;
  right: 64px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--wd-navy);
  color: var(--wd-white);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  pointer-events: none;
}
.wd-chat-fab:hover .tooltip {
  opacity: 1;
  visibility: visible;
}

.wd-chat-panel {
  position: fixed;
  right: -400px;
  bottom: 100px;
  width: 380px;
  max-height: 600px;
  background: var(--wd-white);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 1001;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--wd-border);
}
.wd-chat-panel.open {
  right: 24px;
}

.wd-chat-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--wd-chat-green-deep) 0%, var(--wd-chat-green) 40%, var(--wd-chat-red) 80%, var(--wd-chat-red-light) 100%);
  border-radius: 20px 20px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--wd-white);
}
.wd-chat-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wd-chat-title .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 4px;
}
.wd-chat-title .avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.wd-chat-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: var(--wd-white);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.wd-chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.wd-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wd-chat-body::-webkit-scrollbar {
  width: 4px;
}
.wd-chat-body::-webkit-scrollbar-track {
  background: transparent;
}
.wd-chat-body::-webkit-scrollbar-thumb {
  background: var(--wd-border);
  border-radius: 2px;
}

.wd-chat-message {
  display: flex;
  gap: 10px;
  max-width: 100%;
}
.wd-chat-message.user {
  flex-direction: row-reverse;
}
.wd-chat-message.user .bubble {
  background: linear-gradient(135deg, var(--wd-chat-green), var(--wd-chat-green-light));
  color: var(--wd-white);
  border-radius: 16px 4px 16px 16px;
}
.wd-chat-message.ai {
  flex-direction: row;
}
.wd-chat-message.ai .bubble {
  background: var(--wd-border-light);
  color: var(--wd-navy);
  border-radius: 4px 16px 16px 16px;
}

.wd-chat-message .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.wd-chat-message.user .avatar {
  background: var(--wd-accent);
  color: var(--wd-white);
}
.wd-chat-message.ai .avatar {
  background: linear-gradient(135deg, var(--wd-chat-green-deep), var(--wd-chat-red));
  color: var(--wd-white);
}

.wd-chat-message .bubble {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.65;
  max-width: 75%;
  word-break: break-word;
}

.wd-chat-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--wd-border);
}
.wd-chat-source-item {
  font-size: 12px;
  color: var(--wd-slate-light);
  margin-bottom: 4px;
}
.wd-chat-source-item:last-child {
  margin-bottom: 0;
}

.wd-chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--wd-border-light);
  border-radius: 12px;
}
.wd-chat-typing .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--wd-slate-light);
  animation: wd-chat-typing-dot 1.4s infinite ease-in-out;
}
.wd-chat-typing .dot:nth-child(1) { animation-delay: 0s; }
.wd-chat-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.wd-chat-typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes wd-chat-typing-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.wd-chat-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--wd-border);
  display: flex;
  gap: 10px;
  background: var(--wd-white);
  border-radius: 0 0 20px 20px;
}
.wd-chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--wd-border);
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--wd-light);
  transition: border-color 0.2s, background 0.2s;
}
.wd-chat-input:focus {
  outline: none;
  border-color: var(--wd-chat-green);
  background: var(--wd-white);
}
.wd-chat-input::placeholder {
  color: var(--wd-slate-light);
}
.wd-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--wd-chat-green), var(--wd-chat-red));
  border: none;
  color: var(--wd-white);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.wd-chat-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(232, 80, 91, 0.3);
}
.wd-chat-send:active {
  transform: translateY(0);
}
.wd-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.wd-chat-product-selector {
  padding: 8px 20px;
  background: var(--wd-light);
  border-bottom: 1px solid var(--wd-border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.wd-chat-product-tag {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.wd-chat-product-tag.active {
  background: var(--wd-accent);
  color: var(--wd-white);
}
.wd-chat-product-tag:not(.active) {
  background: var(--wd-white);
  color: var(--wd-slate);
  border-color: var(--wd-border);
}
.wd-chat-product-tag:not(.active):hover {
  border-color: var(--wd-accent);
  color: var(--wd-accent);
}
.wd-chat-product-tag.locked {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--wd-border-light);
  color: var(--wd-slate-light);
  border-color: var(--wd-border);
}
.wd-chat-product-tag.locked:hover {
  border-color: var(--wd-border);
  color: var(--wd-slate-light);
}
.wd-chat-product-tag.locked small {
  font-size: 10px;
  margin-left: 2px;
}

@media (max-width: 480px) {
  .wd-chat-fab {
    width: 48px;
    height: 48px;
    right: 16px;
    bottom: 24px;
    font-size: 20px;
  }
  .wd-chat-panel {
    width: calc(100vw - 32px);
    max-height: 70vh;
    right: -100vw;
    bottom: 88px;
  }
  .wd-chat-panel.open {
    right: 16px;
  }
  .wd-chat-message .bubble {
    max-width: 85%;
  }
}
