/* ============================================================
 * 康医汇在线客服组件样式
 * ============================================================ */

/* ---------- 悬浮按钮 ---------- */
.cs-float-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
  z-index: 9998;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  user-select: none;
}

.cs-float-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.5);
}

/* 脉冲呼吸动画 */
.cs-float-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.4);
  z-index: -1;
  animation: cs-pulse 2s ease-in-out infinite;
}

@keyframes cs-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.3);
    opacity: 0;
  }
}

/* Tooltip 文字 */
.cs-float-btn .cs-tooltip {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 0.8125rem;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cs-float-btn .cs-tooltip::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: #1e293b;
}

.cs-float-btn:hover .cs-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(-4px);
}

/* 未读消息红点 */
.cs-float-btn .cs-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  background: #ef4444;
  color: #fff;
  font-size: 0.6875rem;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-weight: 600;
  border: 2px solid #fff;
}

/* ---------- 聊天窗口 ---------- */
.cs-chat-window {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 340px;
  height: 500px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cs-chat-window.open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* 顶部标题栏 */
.cs-chat-header {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cs-chat-header .cs-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cs-chat-header .cs-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.cs-chat-header .cs-title {
  font-weight: 600;
  font-size: 0.9375rem;
}

.cs-chat-header .cs-status {
  font-size: 0.75rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.cs-chat-header .cs-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.cs-chat-header .cs-header-actions {
  display: flex;
  gap: 4px;
}

.cs-chat-header .cs-header-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.cs-chat-header .cs-header-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* 快捷问题区 */
.cs-quick-questions {
  padding: 12px 12px 8px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.cs-quick-questions .cs-quick-title {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 8px;
  font-weight: 500;
}

.cs-quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.cs-quick-btn {
  padding: 6px 10px;
  background: #f1f5f9;
  border: none;
  border-radius: 8px;
  font-size: 0.75rem;
  color: #334155;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, color 0.2s;
  line-height: 1.4;
}

.cs-quick-btn:hover {
  background: #dbeafe;
  color: #2563eb;
}

/* 聊天消息区 */
.cs-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #f8fafc;
}

.cs-chat-body::-webkit-scrollbar {
  width: 4px;
}

.cs-chat-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.cs-message {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  animation: cs-msg-in 0.3s ease;
}

@keyframes cs-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cs-message.cs-message-user {
  flex-direction: row-reverse;
}

.cs-message .cs-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.cs-message.cs-message-bot .cs-msg-avatar {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
}

.cs-message.cs-message-user .cs-msg-avatar {
  background: #e2e8f0;
  color: #475569;
}

.cs-message .cs-msg-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.8125rem;
  line-height: 1.5;
  word-break: break-word;
}

.cs-message.cs-message-bot .cs-msg-bubble {
  background: #fff;
  color: #1e293b;
  border-top-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cs-message.cs-message-user .cs-msg-bubble {
  background: #2563eb;
  color: #fff;
  border-top-right-radius: 4px;
}

.cs-message .cs-msg-time {
  font-size: 0.625rem;
  color: #94a3b8;
  margin-top: 4px;
  text-align: center;
}

/* 转人工按钮 */
.cs-transfer-btn {
  display: block;
  width: 100%;
  padding: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  color: #16a34a;
  font-size: 0.8125rem;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s;
  text-align: center;
}

.cs-transfer-btn:hover {
  background: #dcfce7;
}

/* 底部输入区 */
.cs-chat-footer {
  padding: 10px 12px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  background: #fff;
}

.cs-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 0.8125rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.cs-input:focus {
  border-color: #2563eb;
}

.cs-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.cs-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.cs-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---------- 转人工表单 ---------- */
.cs-form-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: none;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.cs-form-overlay.open {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.cs-form-overlay h4 {
  text-align: center;
  color: #1e293b;
  margin-bottom: 4px;
  font-size: 1rem;
}

.cs-form-overlay .cs-form-subtitle {
  text-align: center;
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 20px;
}

.cs-form-group {
  margin-bottom: 14px;
}

.cs-form-group label {
  display: block;
  font-size: 0.8125rem;
  color: #475569;
  margin-bottom: 6px;
  font-weight: 500;
}

.cs-form-group input,
.cs-form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.8125rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  box-sizing: border-box;
}

.cs-form-group input:focus,
.cs-form-group textarea:focus {
  border-color: #2563eb;
}

.cs-form-group textarea {
  resize: none;
  min-height: 72px;
}

.cs-form-submit {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  font-weight: 500;
  transition: transform 0.2s, box-shadow 0.2s;
}

.cs-form-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.cs-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.cs-form-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.cs-form-close:hover {
  background: #e2e8f0;
}

.cs-form-success {
  text-align: center;
  padding: 20px 0;
}

.cs-form-success .cs-success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #dcfce7;
  color: #22c55e;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.cs-form-success h4 {
  color: #1e293b;
  margin-bottom: 8px;
}

.cs-form-success p {
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.6;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 480px) {
  .cs-float-btn {
    right: 16px;
    bottom: 16px;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .cs-chat-window {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 85vh;
    border-radius: 16px 16px 0 0;
  }

  .cs-quick-grid {
    grid-template-columns: 1fr 1fr;
  }

  .cs-message .cs-msg-bubble {
    max-width: 70%;
  }
}

/* ============================================================
 * v2.0 新增：AI 打字指示器 / 企业微信转人工面板
 * ============================================================ */

/* ---------- AI 正在输入指示器 ---------- */
.cs-message.cs-typing-wrap .cs-msg-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.cs-typing .cs-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: cs-blink 1.2s infinite ease-in-out;
}

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

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

@keyframes cs-blink {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------- 转人工面板（企业微信） ---------- */
.cs-transfer-panel {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow-y: auto;
}

.cs-transfer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.cs-transfer-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.cs-transfer-head h4 {
  text-align: left;
  margin-bottom: 2px;
  font-size: 1rem;
}

.cs-transfer-subtitle {
  font-size: 0.75rem;
  color: #64748b;
}

/* 企业微信信息区 */
.cs-transfer-wechat {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}

.cs-wechat-qr img {
  width: 140px;
  height: 140px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  object-fit: contain;
}

.cs-wechat-qr .cs-wechat-link {
  display: inline-block;
  padding: 10px 20px;
  background: #07c160;
  color: #fff;
  border-radius: 8px;
  font-size: 0.875rem;
  text-decoration: none;
  font-weight: 500;
}

.cs-wechat-qr .cs-wechat-placeholder {
  padding: 32px 12px;
  color: #94a3b8;
  font-size: 0.8125rem;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
}

.cs-wechat-info {
  margin-top: 10px;
}

.cs-wechat-name {
  font-weight: 600;
  color: #1e293b;
  font-size: 0.9375rem;
  margin-bottom: 4px;
}

.cs-wechat-tip {
  font-size: 0.75rem;
  color: #64748b;
}

/* 成功状态中的企业微信卡片 */
.cs-success-wechat {
  margin-top: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.cs-success-wechat img {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  object-fit: contain;
}

.cs-success-wechat .cs-wechat-link {
  display: inline-block;
  padding: 10px 20px;
  background: #07c160;
  color: #fff;
  border-radius: 8px;
  font-size: 0.875rem;
  text-decoration: none;
  font-weight: 500;
}

.cs-success-wechat .cs-wechat-name {
  margin-top: 10px;
  font-weight: 600;
  color: #1e293b;
}

.cs-success-wechat .cs-wechat-tip {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 4px;
}

/* 转人工表单区 */
.cs-transfer-form {
  margin-top: 4px;
}
