/* ===========================
   客服聊天系统 v2.0 样式
   =========================== */

/* 浮动按钮 */
.cs-float-btn {
  position: fixed;
  width: 62px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #0062e9;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  transition: left 0.2s ease, top 0.2s ease, transform 0.15s ease;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cs-float-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 28px rgba(0, 98, 233, 0.4);
}

.cs-float-btn:active {
  transform: scale(0.95);
}

.cs-float-btn.cs-dragging {
  transition: none;
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(0, 98, 233, 0.5);
}

.cs-float-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

/* 聊天弹窗 */
.cs-chat-dialog {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  height: 70vh;
  max-height: 600px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.cs-chat-dialog.cs-hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

/* 聊天头部 */
.cs-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0062e9 0%, #0052c7 100%);
  color: #ffffff;
  flex-shrink: 0;
}

.cs-chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.cs-header-icon {
  color: #ffd700;
  flex-shrink: 0;
}

.cs-chat-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  padding: 0;
}

.cs-chat-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* 消息区域 */
.cs-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.cs-chat-loading {
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  padding: 40px 0;
}

.cs-chat-empty {
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  padding: 40px 0;
}

.cs-hidden {
  display: none !important;
}

/* 消息气泡 */
.cs-message-item {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

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

.cs-message-admin {
  align-self: flex-start;
  align-items: flex-start;
}

.cs-message-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.cs-message-user .cs-message-bubble {
  background: #0062e9;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.cs-message-admin .cs-message-bubble {
  background: #f3f4f6;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}

.cs-message-time {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
  padding: 0 6px;
}

.cs-message-failed .cs-message-bubble {
  background: #fee2e2 !important;
  color: #991b1b !important;
}

.cs-message-image {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
}

/* 输入区域 */
.cs-chat-input-area {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
  flex-shrink: 0;
}

.cs-chat-tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.cs-chat-tool-btn:hover {
  background: #f3f4f6;
  color: #0062e9;
}

.cs-chat-input {
  flex: 1;
  height: 38px;
  border: 1px solid #e5e7eb;
  border-radius: 19px;
  padding: 0 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.cs-chat-input:focus {
  border-color: #0062e9;
}

.cs-chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #0062e9;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
  padding: 0;
}

.cs-chat-send-btn:hover {
  background: #0052c7;
  transform: scale(1.05);
}

.cs-chat-send-btn:active {
  transform: scale(0.95);
}

/* 表情面板 */
.cs-emoji-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  max-height: 120px;
  overflow-y: auto;
}

.cs-emoji-item {
  width: 36px;
  height: 36px;
  border: none;
  background: #ffffff;
  border-radius: 8px;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.cs-emoji-item:hover {
  background: #e5e7eb;
  transform: scale(1.1);
}

/* 滚动条美化 */
.cs-chat-messages::-webkit-scrollbar,
.cs-emoji-panel::-webkit-scrollbar {
  width: 4px;
}

.cs-chat-messages::-webkit-scrollbar-track,
.cs-emoji-panel::-webkit-scrollbar-track {
  background: transparent;
}

.cs-chat-messages::-webkit-scrollbar-thumb,
.cs-emoji-panel::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 2px;
}

@media (min-width: 481px) {
  .cs-chat-dialog {
    bottom: 20px;
    right: 20px;
    left: auto;
    height: 500px;
    border-radius: 16px;
    max-height: 80vh;
  }
}
