/**
 * 客服组件样式
 */

:root {
  color-scheme: light;
  font-family: "SF Pro Display", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, rgba(109, 141, 255, 0.18), transparent 45%),
    radial-gradient(circle at bottom left, rgba(135, 214, 255, 0.2), transparent 50%),
    linear-gradient(180deg, #f5f7ff 0%, #eef2ff 100%);
  font-size: 14px;
  color: #1f2430;
}

/* ========== 客服启动按钮 ========== */
.cs-launcher {
  position: fixed;
  right: 28px;
  bottom: 28px;
  height: 56px;
  padding: 0 20px;
  border-radius: 28px;
  background: linear-gradient(135deg, #5674ff 0%, #7b92ff 50%, #8da8ff 100%);
  box-shadow: 0 8px 24px rgba(86, 116, 255, 0.4), 0 0 0 0 rgba(86, 116, 255, 0.7);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 998;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 8px 24px rgba(86, 116, 255, 0.4), 0 0 0 0 rgba(86, 116, 255, 0.7);
  }
  50% {
    box-shadow: 0 8px 24px rgba(86, 116, 255, 0.4), 0 0 0 10px rgba(86, 116, 255, 0);
  }
  100% {
    box-shadow: 0 8px 24px rgba(86, 116, 255, 0.4), 0 0 0 0 rgba(86, 116, 255, 0);
  }
}

.cs-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(86, 116, 255, 0.5);
  animation: none;
}

.cs-launcher:active {
  transform: translateY(0);
}

.cs-launcher-icon {
  font-size: 24px;
  animation: swing 1.5s ease-in-out infinite;
}

@keyframes swing {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(15deg);
  }
  75% {
    transform: rotate(-15deg);
  }
}

.cs-launcher:hover .cs-launcher-icon {
  animation: none;
  transform: scale(1.1);
}

.cs-launcher-text {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ========== 客服窗口容器 ========== */
.cs-widget-wrapper {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 520px;
  height: 560px;
  z-index: 999;
  user-select: none;
  opacity: 0;
  transform: scale(0.94) translateY(18px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  display: none;
}

.cs-widget-wrapper.is-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.cs-widget {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 26px;
  box-shadow: 0 26px 54px rgba(38, 61, 128, 0.22);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(241, 246, 255, 0.92) 100%);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(149, 176, 255, 0.24);
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 480px;
}

.cs-widget::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 20% 10%, rgba(131, 172, 255, 0.3), transparent 55%),
    radial-gradient(circle at 80% 0%, rgba(255, 255, 255, 0.35), transparent 60%);
  mix-blend-mode: screen;
}

/* ========== 头部 ========== */
.cs-header {
  background: linear-gradient(135deg, #5674ff 0%, #8da8ff 48%, #9cd7ff 100%);
  padding: 12px 18px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  cursor: grab;
}

.cs-header::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.cs-avatar {
  width: 42px;
  height: 42px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.36);
  flex-shrink: 0;
  overflow: hidden;
}

.cs-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cs-header-info {
  flex: 1;
  min-width: 0;
}

.cs-title {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.cs-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 11px;
  line-height: 1;
}

.cs-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2fd067;
  box-shadow: 0 0 0 5px rgba(47, 208, 103, 0.24);
}

.cs-toolbar {
  display: flex;
  gap: 6px;
}

.cs-toolbar-button {
  width: 28px;
  height: 28px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 300;
  transition: background 0.2s ease;
}

.cs-toolbar-button:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ========== 热门问题 ========== */
.cs-hot-questions {
  padding: 8px 20px 10px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(156, 170, 210, 0.12);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.4s ease 0.1s,
              padding 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.cs-hot-questions.is-visible {
  max-height: 100px;
  opacity: 1;
  padding: 8px 20px 10px;
}

.cs-hot-questions-title {
  font-size: 12px;
  color: #7f8fbc;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.hot-icon {
  font-size: 13px;
}

.cs-hot-questions-list {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(119, 145, 216, 0.45) rgba(142, 162, 219, 0.12);
}

.cs-hot-questions-list::-webkit-scrollbar {
  height: 5px;
  background: rgba(142, 162, 219, 0.14);
  border-radius: 999px;
}

.cs-hot-questions-list::-webkit-scrollbar-thumb {
  background: rgba(119, 145, 216, 0.55);
  border-radius: 999px;
}

.cs-hot-question-item {
  padding: 6px 12px;
  background: rgba(240, 244, 255, 0.92);
  border-radius: 16px;
  font-size: 12.5px;
  color: #5a6896;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  flex: 0 0 auto;
  opacity: 0;
  transform: translateX(-20px);
  animation: slideInItem 0.4s ease forwards;
}

@keyframes slideInItem {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 为每个项添加延迟，创建连续滑入效果 */
.cs-hot-question-item:nth-child(1) { animation-delay: 0.1s; }
.cs-hot-question-item:nth-child(2) { animation-delay: 0.15s; }
.cs-hot-question-item:nth-child(3) { animation-delay: 0.2s; }
.cs-hot-question-item:nth-child(4) { animation-delay: 0.25s; }
.cs-hot-question-item:nth-child(5) { animation-delay: 0.3s; }
.cs-hot-question-item:nth-child(6) { animation-delay: 0.35s; }

.cs-hot-question-item:hover {
  background: rgba(86, 116, 255, 0.12);
  transform: translateY(-1px);
}

/* ========== 消息列表 ========== */
.cs-message-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.cs-message-list {
  height: 100%;
  padding: 24px 22px 18px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(119, 145, 216, 0.35) transparent;
}

.cs-message-list::-webkit-scrollbar {
  width: 6px;
}

.cs-message-list::-webkit-scrollbar-track {
  background: transparent;
}

.cs-message-list::-webkit-scrollbar-thumb {
  background: rgba(119, 145, 216, 0.35);
  border-radius: 999px;
}

.cs-empty {
  margin-top: 72px;
  text-align: center;
  color: #a0a9c4;
}

.cs-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.cs-empty-text {
  font-size: 13px;
  line-height: 1.7;
}

/* ========== 消息项 ========== */
.cs-message {
  margin-bottom: 16px;
  max-width: 86%;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transform: translateY(10px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.cs-message.self {
  margin-left: auto;
  flex-direction: row-reverse;
}

.cs-message.cs-message--enter {
  transform: translateY(0);
  opacity: 1;
}

.cs-message-tip {
  max-width: 90%;
  margin: 16px auto;
  padding: 8px 16px;
  border-radius: 16px;
  background: #dfe6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: #6374a6;
  text-align: center;
}

.cs-message-avatar {
  width: 38px;
  height: 38px;
  border-radius: 16px;
  background: #dfe6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: #6374a6;
  overflow: hidden;
  margin-bottom: 25px;
}

.cs-message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex-shrink: 0;
}

.cs-bubble-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.cs-message-name {
  font-size: 12px;
  color: #7f8fbc;
  padding-left: 4px;
  margin-bottom: 2px;
}

.cs-bubble {
  padding: 12px 18px;
  border-radius: 20px 20px 20px 10px;
  background: #fff;
  color: #1b1d21;
  box-shadow: 0 16px 34px rgba(62, 82, 126, 0.1);
  line-height: 1.6;
  word-break: break-word;
  font-size: 14px;
  letter-spacing: 0.12px;
}

.cs-message.self .cs-bubble {
  background: linear-gradient(135deg, #6284ff, #8ea7ff);
  color: #fff;
  border-radius: 20px 20px 10px 20px;
  box-shadow: 0 18px 36px rgba(96, 133, 255, 0.28);
}

.cs-message.self .cs-bubble-wrapper {
  align-items: flex-end;
}

.cs-meta {
  font-size: 12px;
  color: rgba(23, 26, 29, 0.4);
  margin-top: 4px;
  text-align: right;
  line-height: 1;
}

.cs-meta .cs-message-status {
  margin-left: 4px;
}
.cs-meta .is-unread {
  color: #3370ff;
}
.cs-meta .is-read {
  color: #999999;
}

.cs-message.self .cs-meta {
  align-self: flex-end;
}

/* ========== 输入区域 ========== */
.cs-input-panel {
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(156, 170, 210, 0.16);
  background: rgba(255, 255, 255, 0.96);
}

.cs-textarea-wrapper {
  position: relative;
  flex: 1;
  background: rgba(240, 244, 255, 0.92);
  border-radius: 18px;
  padding: 6px 14px 6px 16px;
  box-shadow: inset 0 0 0 1px rgba(133, 157, 224, 0.18);
  transition: box-shadow 0.2s ease, background 0.2s ease, padding 0.2s ease;
}

.cs-textarea-wrapper:focus-within {
  box-shadow: inset 0 0 0 1px rgba(98, 132, 255, 0.48), 0 8px 18px rgba(107, 137, 255, 0.18);
  background: rgba(235, 240, 255, 0.96);
  padding-right: 70px;
}

.cs-textarea {
  border: none;
  resize: none;
  min-height: 46px;
  max-height: 140px;
  padding: 6px 0 20px;
  width: 100%;
  background: transparent;
  font-size: 14px;
  line-height: 1.58;
  font-family: inherit;
  outline: none;
  overflow: hidden;
  color: #1f2430;
}

.cs-textarea::placeholder {
  color: #99a7c8;
}

.cs-hint {
  position: absolute;
  bottom: 12px;
  left: 17px;
  font-size: 11.5px;
  color: #9aa7ca;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.cs-send-btn {
  position: absolute;
  right: 12px;
  bottom: 10px;
  border: none;
  border-radius: 16px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #4f71ff, #51d1ff);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 14px 24px rgba(87, 143, 255, 0.26);
  pointer-events: auto;
  opacity: 0;
}

.cs-textarea-wrapper:focus-within .cs-send-btn {
  opacity: 1;
}

.cs-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(87, 143, 255, 0.36);
}

.cs-send-btn:active {
  transform: translateY(0);
}

/* ========== Toast 提示 ========== */
.cs-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  padding: 12px 24px;
  background: rgba(31, 36, 48, 0.92);
  color: #fff;
  border-radius: 12px;
  font-size: 14px;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

.cs-toast.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ========== 加载遮罩 ========== */
.cs-mask {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  border-radius: 16px;
}

.cs-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.cs-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(86, 116, 255, 0.2);
  border-top-color: #5674ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== 调整大小手柄 ========== */
.cs-resize-handle {
  position: absolute;
  z-index: 10;
}

.cs-resize-handle[data-dir="n"],
.cs-resize-handle[data-dir="s"] {
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
}

.cs-resize-handle[data-dir="e"],
.cs-resize-handle[data-dir="w"] {
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
}

.cs-resize-handle[data-dir="n"] {
  top: 0;
}

.cs-resize-handle[data-dir="s"] {
  bottom: 0;
}

.cs-resize-handle[data-dir="e"] {
  right: 0;
}

.cs-resize-handle[data-dir="w"] {
  left: 0;
}

.cs-resize-handle[data-dir="ne"],
.cs-resize-handle[data-dir="nw"],
.cs-resize-handle[data-dir="se"],
.cs-resize-handle[data-dir="sw"] {
  width: 16px;
  height: 16px;
}

.cs-resize-handle[data-dir="ne"] {
  top: 0;
  right: 0;
  cursor: nesw-resize;
}

.cs-resize-handle[data-dir="nw"] {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}

.cs-resize-handle[data-dir="se"] {
  bottom: 0;
  right: 0;
  cursor: nwse-resize;
}

.cs-resize-handle[data-dir="sw"] {
  bottom: 0;
  left: 0;
  cursor: nesw-resize;
}

