/* AI客服聊天插件 - 前台样式 */

/* 容器基础样式 */
#ai-cs-chat-container {
  position: fixed;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

/* 位置设置 */
#ai-cs-chat-container.ai-cs-bottom-right {
  bottom: 20px;
  right: 20px;
}

#ai-cs-chat-container.ai-cs-bottom-left {
  bottom: 20px;
  left: 20px;
}

#ai-cs-chat-container.ai-cs-top-right {
  top: 20px;
  right: 20px;
}

#ai-cs-chat-container.ai-cs-top-left {
  top: 20px;
  left: 20px;
}

/* 聊天按钮样式 */
.ai-cs-chat-button {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  position: relative;
  animation: pulse 2s infinite;
}

.ai-cs-chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.ai-cs-chat-button svg {
  width: 28px;
  height: 28px;
}

/* 脉冲动画 */
@keyframes pulse {
  0% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(102, 126, 234, 0.7);
  }

  70% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 10px rgba(102, 126, 234, 0);
  }

  100% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(102, 126, 234, 0);
  }
}

/* 通知徽章 */
.ai-cs-notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4757;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* 聊天窗口样式 */
.ai-cs-chat-window {
  position: absolute;
  width: 380px;
  height: 520px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  border: 1px solid #e0e6ed;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideInUp 0.3s ease-out;
}

/* 窗口位置调整 */
#ai-cs-chat-container.ai-cs-bottom-right .ai-cs-chat-window {
  bottom: 80px;
  right: 0;
}

#ai-cs-chat-container.ai-cs-bottom-left .ai-cs-chat-window {
  bottom: 80px;
  left: 0;
}

#ai-cs-chat-container.ai-cs-top-right .ai-cs-chat-window {
  top: 80px;
  right: 0;
}

#ai-cs-chat-container.ai-cs-top-left .ai-cs-chat-window {
  top: 80px;
  left: 0;
}

/* 滑入动画 */
@keyframes slideInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 聊天头部 */
.ai-cs-chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-cs-header-info {
  display: flex;
  align-items: center;
}

.ai-cs-avatar {
  margin-right: 12px;
}

.ai-cs-header-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.ai-cs-status {
  font-size: 12px;
  opacity: 0.9;
}

.ai-cs-header-actions {
  display: flex;
  gap: 8px;
}

.ai-cs-minimize-btn,
.ai-cs-close-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.ai-cs-minimize-btn:hover,
.ai-cs-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* 聊天主体 */
.ai-cs-chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-cs-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 滚动条样式 */
.ai-cs-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-cs-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.ai-cs-messages::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.ai-cs-messages::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 消息样式 */
.ai-cs-message {
  display: flex;
  margin-bottom: 16px;
  animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-cs-message.ai-cs-user {
  justify-content: flex-end;
}

.ai-cs-message.ai-cs-assistant {
  justify-content: flex-start;
}

.ai-cs-message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  line-height: 1.4;
}

.ai-cs-message.ai-cs-user .ai-cs-message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-cs-message.ai-cs-assistant .ai-cs-message-content {
  background: #f8f9fa;
  color: #333;
  border: 1px solid #e9ecef;
  border-bottom-left-radius: 4px;
}

.ai-cs-message-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  text-align: center;
}

/* 加载指示器 */
.ai-cs-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  color: #666;
  font-size: 13px;
}

.ai-cs-loading-dots {
  display: flex;
  gap: 4px;
}

.ai-cs-loading-dots span {
  width: 6px;
  height: 6px;
  background: #666;
  border-radius: 50%;
  animation: loading-dots 1.4s ease-in-out infinite both;
}

.ai-cs-loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.ai-cs-loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes loading-dots {

  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 聊天底部 */
.ai-cs-chat-footer {
  border-top: 1px solid #e9ecef;
  padding: 16px 20px;
}

.ai-cs-input-container {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 20px;
  padding: 8px 12px;
  transition: border-color 0.2s;
}

.ai-cs-input-container:focus-within {
  border-color: #667eea;
  background: white;
}

.ai-cs-message-input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  padding: 8px 0;
  max-height: 100px;
  overflow-y: auto;
}

.ai-cs-message-input::placeholder {
  color: #999;
}

.ai-cs-send-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  min-width: 60px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 500;
}

.ai-cs-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

.ai-cs-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.ai-cs-chat-info {
  margin-top: 8px;
  text-align: center;
}

.ai-cs-chat-info small {
  color: #999;
  font-size: 12px;
}

/* 模态框样式 */
.ai-cs-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.ai-cs-modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.ai-cs-modal-content h3 {
  margin: 0 0 12px 0;
  color: #333;
}

.ai-cs-modal-content p {
  margin: 0 0 20px 0;
  color: #666;
}

.ai-cs-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.ai-cs-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.ai-cs-btn-primary {
  background: #667eea;
  color: white;
}

.ai-cs-btn-primary:hover {
  background: #5a67d8;
}

.ai-cs-btn-secondary {
  background: #e2e8f0;
  color: #4a5568;
}

.ai-cs-btn-secondary:hover {
  background: #cbd5e0;
}

.ai-cs-btn-danger {
  background: #e53e3e;
  color: white;
}

.ai-cs-btn-danger:hover {
  background: #c53030;
}

/* 响应式设计 */
@media (max-width: 480px) {
  #ai-cs-chat-container {
    bottom: 10px !important;
    right: 10px !important;
    left: 10px !important;
    top: auto !important;
  }

  .ai-cs-chat-window {
    width: calc(100vw - 80px) !important;
    height: calc(100vh - 120px) !important;
    max-height: 600px;
    position: fixed !important;
    bottom: 80px !important;
    right: 10px !important;
    left: 10px !important;
  }

  .ai-cs-chat-button {
    width: 50px;
    height: 50px;
  }

  .ai-cs-chat-button svg {
    width: 24px;
    height: 24px;
  }

  .ai-cs-modal-content {
    width: 95%;
    padding: 20px;
  }
}

/* 主题定制变量 */
:root {
  --ai-cs-primary-color: #667eea;
  --ai-cs-secondary-color: #764ba2;
  --ai-cs-text-color: #333;
  --ai-cs-bg-color: #fff;
  --ai-cs-border-color: #e9ecef;
  --ai-cs-light-bg: #f8f9fa;
}

/* 夜间模式支持 */
@media (prefers-color-scheme: dark) {
  .ai-cs-chat-window {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
  }

  .ai-cs-message.ai-cs-assistant .ai-cs-message-content {
    background: #4a5568;
    color: #e2e8f0;
    border-color: #6b7280;
  }

  .ai-cs-input-container {
    background: #4a5568;
    border-color: #6b7280;
  }

  .ai-cs-input-container:focus-within {
    background: #374151;
  }

  .ai-cs-message-input {
    color: #e2e8f0;
  }

  .ai-cs-message-input::placeholder {
    color: #9ca3af;
  }

  .ai-cs-chat-footer {
    border-color: #4a5568;
  }
}