/* Customer Service Plugin Styles */
.csp-container {
  position: fixed;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
}

/* 包裹容器 */
.csp-wrapper {
  position: fixed;
  bottom: 20px;
  z-index: 9999;
}

.csp-wrapper.right {
  right: 20px;
}

.csp-wrapper.left {
  left: 20px;
}

/* 悬浮按钮 */
.csp-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  animation: csp-pulse 2s infinite;
}

.csp-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.csp-toggle-btn svg {
  width: 28px;
  height: 28px;
  color: white;
  transition: all 0.3s;
}

.csp-toggle-btn .csp-icon-close {
  display: none;
}

.csp-toggle-btn.active .csp-icon-chat {
  display: none;
}

.csp-toggle-btn.active .csp-icon-close {
  display: block;
}

.csp-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ef4444;
  color: white;
  font-size: 12px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  animation: csp-bounce 0.5s ease-out;
}

@keyframes csp-pulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
  50% {
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
  }
}

@keyframes csp-bounce {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

/* 聊天窗口 */
.csp-window {
  position: absolute;
  bottom: 80px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.csp-wrapper.right .csp-window {
  right: 0;
}

.csp-wrapper.left .csp-window {
  left: 0;
}

.csp-window.csp-window-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* 头部 */
.csp-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  flex-shrink: 0;
  width: 100%;
}

.csp-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.csp-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
}

.csp-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.csp-title {
  font-size: 16px;
  font-weight: 600;
}

.csp-subtitle {
  font-size: 13px;
  opacity: 0.9;
}

.csp-close-btn {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.csp-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.csp-close-btn svg {
  width: 18px;
  height: 18px;
}

/* 消息列表 */
.csp-message-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8fafc;
  min-height: 200px;
}

/* 消息项 */
.csp-message {
  display: flex;
  margin-bottom: 16px;
  animation: csp-slideIn 0.3s ease-out;
}

.csp-message-agent {
  justify-content: flex-start;
}

.csp-message-user {
  justify-content: flex-end;
}

@keyframes csp-slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.csp-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
}

.csp-message-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.csp-message-content {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.csp-message-name {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.csp-message-text {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
}

.csp-message-content-agent .csp-message-text {
  background: white;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  color: #1e293b;
}

.csp-message-content-user .csp-message-text {
  background: #7c3aed;
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.csp-message-text a {
  color: inherit;
  text-decoration: underline;
}

.csp-message-time {
  font-size: 11px;
  color: #94a3b8;
}

.csp-message-content-agent .csp-message-time {
  text-align: left;
}

.csp-message-content-user .csp-message-time {
  text-align: right;
}

/* 输入指示器 */
.csp-typing-indicator {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  animation: csp-slideIn 0.3s ease-out;
}

.csp-typing-dots {
  padding: 10px 14px;
  background: white;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: flex;
  gap: 4px;
}

.csp-typing-dots span {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: csp-typing 1.4s infinite;
  opacity: 0.3;
}

.csp-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.csp-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes csp-typing {
  0%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

/* 快捷回复 */
.csp-quick-replies {
  padding: 16px 20px 12px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.csp-quick-title {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 8px;
  font-weight: 600;
}

.csp-quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.csp-quick-reply {
  padding: 6px 12px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.csp-quick-reply:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 输入区域 */
.csp-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #e2e8f0;
  align-items: flex-end;
}

.csp-upload-btn {
  width: 36px;
  height: 36px;
  background: #f1f5f9;
  border: none;
  border-radius: 8px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.csp-upload-btn:hover {
  background: #e2e8f0;
  color: #475569;
}

.csp-upload-btn svg {
  width: 18px;
  height: 18px;
}

.csp-input-field {
  flex: 1;
  min-height: 36px;
  max-height: 80px;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
  transition: all 0.2s;
}

.csp-input-field:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.csp-input-field::placeholder {
  color: #94a3b8;
}

.csp-send-btn {
  width: 36px;
  height: 36px;
  background: #7c3aed;
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.csp-send-btn:hover:not(:disabled) {
  background: #6d28d9;
  transform: scale(1.05);
}

.csp-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  opacity: 0.6;
}

.csp-send-btn svg {
  width: 16px;
  height: 16px;
}

/* 主聊天区域（用于侧边栏布局） */
.csp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 内容区域容器（左右布局） */
.csp-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 窗口带有侧边栏的样式 - 左右布局 */
.csp-window.csp-window-with-sidebar {
  display: flex;
  flex-direction: column;
}

/* 没有侧边栏时的样式 */
.csp-window:not(.csp-window-with-sidebar) {
  display: flex;
  flex-direction: column;
}

/* 公司介绍侧边栏 - 改为在右侧 */
.csp-sidebar {
  width: 280px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-left: 1px solid #e2e8f0;
  overflow-y: auto;
  display: flex;
  flex-direction: column; /* 侧边栏内部纵向排列 */
  flex-shrink: 0;
  order: 2; /* 侧边栏在右边 */
  min-width: 280px;
}

.csp-main {
  order: 1; /* 主聊天区域在左边 */
  min-width: 0;
}

/* 侧边栏内容恢复为纵向布局 */
.csp-sidebar-content {
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.csp-company-logo {
  width: 100px;
  height: 100px;
  margin-bottom: 20px;
  border-radius: 16px;
  overflow: hidden;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.csp-company-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.csp-company-logo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
}

.csp-company-logo-placeholder svg {
  width: 50px;
  height: 50px;
}

.csp-company-name {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 12px;
}

.csp-company-desc {
  font-size: 13px;
  color: #64748b;
  line-height: 1.8;
  margin-bottom: 24px;
}

.csp-company-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-bottom: 24px;
}

.csp-feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: white;
  border-radius: 10px;
  transition: all 0.2s;
  border: 1px solid #e2e8f0;
}

.csp-feature-item:hover {
  border-color: #7c3aed;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
}

.csp-feature-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #7c3aed;
}

.csp-feature-item span {
  font-size: 13px;
  color: #475569;
  font-weight: 500;
}

.csp-company-contact {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-bottom: 20px;
}

.csp-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: white;
  border-radius: 10px;
  color: #475569;
  text-decoration: none;
  transition: all 0.2s;
  border: 1px solid #e2e8f0;
  font-size: 13px;
  font-weight: 500;
}

.csp-contact-item:hover {
  border-color: #7c3aed;
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
}

.csp-contact-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #64748b;
}

.csp-sidebar-divider {
  display: block;
  width: 100%;
  height: 1px;
  background: #e2e8f0;
  margin: 20px 0;
}

.csp-service-hours {
  text-align: center;
  padding: 16px;
  background: white;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.csp-service-title {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
  font-weight: 600;
}

.csp-service-time {
  font-size: 14px;
  color: #22c55e;
  font-weight: 700;
}

.csp-sidebar-content {
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.csp-company-logo {
  width: 100px;
  height: 100px;
  margin-bottom: 20px;
  border-radius: 16px;
  overflow: hidden;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.csp-company-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.csp-company-logo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
}

.csp-company-logo-placeholder svg {
  width: 50px;
  height: 50px;
}

.csp-company-name {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 12px;
}

.csp-company-desc {
  font-size: 13px;
  color: #64748b;
  line-height: 1.8;
  margin-bottom: 24px;
}

.csp-company-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-bottom: 24px;
}

.csp-feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: white;
  border-radius: 10px;
  transition: all 0.2s;
  border: 1px solid #e2e8f0;
}

.csp-feature-item:hover {
  border-color: #7c3aed;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
}

.csp-feature-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #7c3aed;
}

.csp-feature-item span {
  font-size: 13px;
  color: #475569;
  font-weight: 500;
}

.csp-company-contact {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-bottom: 20px;
}

.csp-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: white;
  border-radius: 10px;
  color: #475569;
  text-decoration: none;
  transition: all 0.2s;
  border: 1px solid #e2e8f0;
  font-size: 13px;
  font-weight: 500;
}

.csp-contact-item:hover {
  border-color: #7c3aed;
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
}

.csp-contact-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #64748b;
}

.csp-sidebar-divider {
  width: 100%;
  height: 1px;
  background: #e2e8f0;
  margin: 20px 0;
}

.csp-service-hours {
  text-align: center;
  padding: 16px;
  background: white;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.csp-service-title {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
  font-weight: 600;
}

.csp-service-time {
  font-size: 14px;
  color: #22c55e;
  font-weight: 700;
}

/* 侧边栏滚动条样式 */
.csp-sidebar::-webkit-scrollbar {
  width: 4px;
}

.csp-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.csp-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.csp-sidebar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 滚动条样式 */
.csp-message-list::-webkit-scrollbar {
  width: 6px;
}

.csp-message-list::-webkit-scrollbar-track {
  background: transparent;
}

.csp-message-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.csp-message-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 响应式设计 */
@media (max-width: 768px) {
  /* 隐藏侧边栏 */
  .csp-sidebar {
    display: none;
  }

  .csp-window.csp-window-with-sidebar {
    display: flex;
  }

  .csp-window {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
  }

  .csp-toggle-btn {
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
  }

  .csp-toggle-btn svg {
    width: 24px;
    height: 24px;
  }

  .csp-message-content {
    max-width: 85%;
  }

  .csp-quick-replies {
    padding: 12px 16px;
  }

  .csp-quick-reply {
    padding: 6px 10px;
    font-size: 11px;
  }

  .csp-input-area {
    padding: 10px 12px;
  }

  .csp-upload-btn,
  .csp-send-btn {
    width: 32px;
    height: 32px;
  }
}

@media (max-width: 480px) {
  .csp-header {
    padding: 12px 16px;
  }

  .csp-title {
    font-size: 14px;
  }

  .csp-subtitle {
    font-size: 12px;
  }

  .csp-message-list {
    padding: 16px;
  }

  .csp-message-text {
    font-size: 13px;
  }
}
