/* 客服悬浮球样式 */
.chat-float {
  position: fixed;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  cursor: grab;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  user-select: none;
  touch-action: none;
}

.chat-float:hover {
  transform: scale(1.1);
}

.chat-float:active {
  cursor: grabbing;
  transform: scale(1.05);
}

.chat-float svg {
  width: 26px;
  height: 26px;
  fill: white;
}

.chat-float .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #ff4757;
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: bold;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

.chat-float .badge.show {
  display: flex;
}

/* 客服聊天窗口 */
.chat-widget {
  position: fixed;
  width: 340px;
  height: 480px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-widget.show {
  display: flex;
}

.chat-widget-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
}

.chat-widget-header .title {
  font-weight: 600;
  font-size: 15px;
}

.chat-widget-header .status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-widget-header .status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #2ed573;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.chat-widget-close {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.chat-widget-close:hover {
  opacity: 0.8;
}

.chat-widget-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-message.user {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-message.admin,
.chat-message.system {
  background: white;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-message.system {
  background: #e8f5e9;
  color: #2e7d32;
  font-style: italic;
  font-size: 13px;
}

.chat-message img {
  max-width: 100%;
  border-radius: 8px;
  cursor: pointer;
}

.chat-message-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
}

.chat-message.user .chat-message-time {
  text-align: right;
}

.chat-widget-input {
  padding: 12px;
  background: white;
  border-top: 1px solid #eee;
}

.chat-widget-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.chat-toolbar-btn {
  background: #f0f2f5;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-toolbar-btn:hover {
  background: #e4e6eb;
}

.chat-toolbar-btn svg {
  width: 18px;
  height: 18px;
  fill: #666;
}

.chat-toolbar-btn input {
  display: none;
}

.chat-message img,
.chat-msg-image {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
  object-fit: cover;
}

.chat-widget-input-row {
  display: flex;
  gap: 8px;
}

.chat-widget-input textarea {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 8px 12px;
  resize: none;
  height: 40px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.chat-widget-input textarea:focus {
  border-color: #667eea;
}

.chat-send-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s;
}

.chat-send-btn:hover {
  opacity: 0.9;
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-widget-empty {
  text-align: center;
  color: #999;
  font-size: 13px;
  padding: 20px;
}

.chat-widget-loading {
  text-align: center;
  color: #999;
  font-size: 13px;
  padding: 10px;
}

.chat-widget-loading::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* 图片预览 */
.chat-image-preview {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 90vw;
  max-height: 90vh;
  z-index: 10000;
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.chat-image-preview-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
