/**
 * 全站常驻悬浮「人工客服」按钮与实时通话/对话浮窗样式表
 * - 悬浮按钮严格采用 position: fixed 固定于视口右下角（z-index: 150），
 *   高于正文卡片与吸顶导航（100），低于灯箱/模态弹窗（200）；
 * - 按钮正下方清晰标注「人工客服」四个字，适配浅色/深色背景与移动端窄屏；
 * - 无永久关闭/隐藏按钮功能，任何页面与交互态下始终可见、始终可点。
 */

.cs-widget-root {
  position: fixed;
  right: 22px;
  bottom: 24px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  font-family: var(--font-sans, Inter, system-ui, sans-serif);
  transition: opacity 0.2s ease;
}

/* 全屏视频/灯箱弹窗打开时自动退避隐藏，退出弹窗后自动恢复，避免遮挡播放器与控制条 */
body.modal-open .cs-widget-root {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  z-index: 10;
}

@media (max-width: 640px) {
  .cs-widget-root {
    right: 14px;
    bottom: 16px;
  }
}

/* ================= 常驻悬浮按钮（图标 + 正下方「人工客服」四字） ================= */
.cs-fab-wrap {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  user-select: none;
  outline: none;
}

.cs-fab-avatar-shell {
  position: relative;
  width: 58px;
  height: 58px;
}

.cs-fab-circle {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #3a7ff8 0%, #1d4ed8 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.42), 0 0 0 3px rgba(255, 255, 255, 0.92);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease;
}

/* 本地化悬浮按钮头像图片（object-fit: cover 铺满圆形容器） */
.cs-fab-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.cs-fab-fallback-icon {
  display: none;
  width: 28px;
  height: 28px;
}

.cs-fab-circle.is-img-fallback .cs-fab-img {
  display: none;
}

.cs-fab-circle.is-img-fallback .cs-fab-fallback-icon {
  display: block;
}

.cs-fab-wrap:hover .cs-fab-circle {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.52), 0 0 0 3px #ffffff;
}

.cs-fab-wrap:active .cs-fab-circle {
  transform: scale(0.96);
}

.cs-fab-icon {
  width: 28px;
  height: 28px;
  display: block;
}

/* 响铃或通话中的呼吸光环提示 */
.cs-fab-wrap.is-ringing .cs-fab-circle {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  animation: csPulseRing 1.3s ease-out infinite;
}

.cs-fab-wrap.is-active .cs-fab-circle {
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  animation: csPulseActive 2.2s ease-out infinite;
}

.cs-fab-status-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #ffffff;
}

.cs-fab-wrap.is-ringing .cs-fab-status-dot {
  background: #fde047;
}

/* 按钮正下方「人工客服」四个字：高对比度白底深字胶囊，浅色/深色背景均清晰可读 */
.cs-fab-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24), 0 0 0 1px rgba(255, 255, 255, 0.24);
}

@media (max-width: 640px) {
  .cs-fab-avatar-shell {
    width: 52px;
    height: 52px;
  }
  .cs-fab-label {
    font-size: 12px;
    padding: 2px 9px;
  }
}

@keyframes csPulseRing {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.65), 0 10px 26px rgba(217, 119, 6, 0.45);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(245, 158, 11, 0), 0 10px 26px rgba(217, 119, 6, 0.45);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0), 0 10px 26px rgba(217, 119, 6, 0.45);
  }
}

@keyframes csPulseActive {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5), 0 10px 26px rgba(4, 120, 87, 0.4);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(16, 185, 129, 0), 0 10px 26px rgba(4, 120, 87, 0.4);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0), 0 10px 26px rgba(4, 120, 87, 0.4);
  }
}

/* ================= 实时人工客服呼叫与对话浮窗 ================= */
.cs-panel {
  pointer-events: auto;
  width: 376px;
  max-width: calc(100vw - 28px);
  max-height: min(560px, calc(100vh - 140px));
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.24);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: csPanelIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.cs-panel.is-hidden {
  display: none;
}

@keyframes csPanelIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.cs-panel-header {
  background: linear-gradient(135deg, #0d1629 0%, #1a3566 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cs-panel-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cs-panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.cs-panel-sub {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.78);
}

.cs-panel-min-btn {
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.cs-panel-min-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* 客户端精简通话操作栏（工号与播报区已在界面隐藏，仅保留取消呼叫/挂断操作） */
.cs-call-action-bar {
  background: #f0f6ff;
  border-bottom: 1px solid #d6e6ff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cs-call-action-bar.is-active {
  background: #ecfdf5;
  border-bottom-color: #bbf7d0;
}

.cs-call-state-text {
  font-size: 12.5px;
  font-weight: 600;
  color: #1e3a8a;
}

.cs-call-action-bar.is-active .cs-call-state-text {
  color: #047857;
}

/* 隐藏客户端指定的工号展示与播报提示元素（仅隐藏 UI，不影响后台语音播报与响铃调度） */
.cs-hidden-ui {
  display: none !important;
}

.cs-staff-code-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cs-staff-code-label {
  font-size: 11.5px;
  color: #475569;
}

.cs-staff-code-num {
  font-family: var(--font-mono, monospace);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #1d4ed8;
}

.cs-voice-banner.is-active .cs-staff-code-num {
  color: #047857;
}

.cs-voice-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cs-mini-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cs-mini-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.cs-mini-btn--danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.cs-mini-btn--danger:hover {
  background: #fee2e2;
}

.cs-mini-btn--primary {
  border-color: #3a7ff8;
  background: #3a7ff8;
  color: #ffffff;
}

.cs-mini-btn--primary:hover {
  background: #2563eb;
}

/* 消息流区域 */
.cs-messages {
  flex: 1;
  min-height: 220px;
  max-height: 310px;
  overflow-y: auto;
  padding: 14px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cs-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.cs-msg-row.is-user {
  align-self: flex-end;
  align-items: flex-end;
}

.cs-msg-row.is-agent {
  align-self: flex-start;
  align-items: flex-start;
}

.cs-msg-row.is-system {
  align-self: center;
  align-items: center;
  max-width: 96%;
}

.cs-msg-meta {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 3px;
}

.cs-msg-bubble {
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.cs-msg-row.is-user .cs-msg-bubble {
  background: #3a7ff8;
  color: #ffffff;
  border-bottom-right-radius: 3px;
}

.cs-msg-row.is-agent .cs-msg-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 3px;
}

.cs-msg-row.is-system .cs-msg-bubble {
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  text-align: center;
}

.cs-input-bar {
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  display: flex;
  gap: 8px;
}

.cs-input-bar input {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 13.5px;
  outline: none;
}

.cs-input-bar input:focus {
  border-color: #3a7ff8;
}

.cs-quick-chips {
  padding: 8px 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #ffffff;
}

.cs-chip {
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11.5px;
  cursor: pointer;
}

.cs-chip:hover {
  background: #dbeafe;
}
