/* ========= 橙电AI智能客服聊天组件样式 ========= */
/* 浮动按钮 */
.cd-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--c-brand, #FF6B35);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(255,107,53,0.35);
  z-index: 9998;
  transition: all 0.3s ease;
}
.cd-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(255,107,53,0.45);
}
.cd-chat-toggle.active {
  background: var(--c-dark, #0B1120);
}

/* 未读角标 */
.cd-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e53e3e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
}

/* 聊天窗口 */
.cd-chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
  z-index: 9999;
}
.cd-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* 头部 */
.cd-chat-header {
  background: var(--c-brand, #FF6B35);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.cd-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cd-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cd-chat-title {
  font-size: 15px;
  font-weight: 700;
}
.cd-chat-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cd-chat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}
.cd-chat-minimize {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.cd-chat-minimize:hover { opacity: 1; }

/* 消息区域 */
.cd-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f8fa;
  scroll-behavior: smooth;
}
.cd-chat-messages::-webkit-scrollbar { width: 4px; }
.cd-chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* 消息气泡 */
.cd-chat-msg {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  animation: cdChatFadeIn 0.3s ease;
}
@keyframes cdChatFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.cd-chat-msg-bot {
  align-self: flex-start;
}
.cd-chat-msg-bot .cd-chat-msg-content {
  background: #fff;
  color: #1a1a2e;
  border: 1px solid #e8e8e8;
  border-radius: 4px 16px 16px 16px;
}
.cd-chat-msg-user {
  align-self: flex-end;
}
.cd-chat-msg-user .cd-chat-msg-content {
  background: var(--c-brand, #FF6B35);
  color: #fff;
  border-radius: 16px 4px 16px 16px;
}
.cd-chat-msg-content {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

/* 快捷按钮 */
.cd-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}
.cd-chat-quick-btn {
  background: #fff;
  border: 1px solid var(--c-brand, #FF6B35);
  color: var(--c-brand, #FF6B35);
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.cd-chat-quick-btn:hover {
  background: var(--c-brand, #FF6B35);
  color: #fff;
}

/* 产品卡片 */
.cd-chat-products {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.cd-chat-product-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.cd-chat-product-card:hover {
  border-color: var(--c-brand, #FF6B35);
}
.cd-chat-product-name {
  font-weight: 600;
  color: #1a1a2e;
}
.cd-chat-product-brand {
  color: #666;
  font-size: 12px;
  margin-top: 2px;
}
.cd-chat-product-price {
  color: var(--c-brand, #FF6B35);
  font-weight: 600;
  font-size: 13px;
  margin-top: 2px;
}

/* 打字指示器 */
.cd-chat-typing {
  display: flex;
  gap: 4px;
  padding: 8px 14px;
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 16px;
}
.cd-chat-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aaa;
  animation: cdChatTyping 1.4s infinite;
}
.cd-chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.cd-chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes cdChatTyping {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* 输入区域 */
.cd-chat-input-area {
  flex-shrink: 0;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  background: #fff;
}
.cd-chat-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cd-chat-input {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 9px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.cd-chat-input:focus {
  border-color: var(--c-brand, #FF6B35);
}
.cd-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--c-brand, #FF6B35);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.cd-chat-send:hover {
  background: var(--c-brand-dark, #E55A2B);
  transform: scale(1.05);
}
.cd-chat-footer {
  font-size: 11px;
  color: #999;
  text-align: center;
  margin-top: 6px;
}
.cd-chat-footer a {
  color: var(--c-brand, #FF6B35);
  text-decoration: none;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .cd-chat-window {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .cd-chat-toggle {
    bottom: 16px;
    right: 16px;
  }
}
