/* AI客服小部件样式 - 蓝色主题 */

/* 页面背景 */
body {
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #2196F3 0%, #0D47A1 100%);
  min-height: 100vh;
}

/* 对话框容器 - 全屏模式 */
.ai-chat-window {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
}

/* 对话框头部 */
.ai-chat-header {
  background: linear-gradient(135deg, #2196F3 0%, #0D47A1 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ai-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chat-avatar {
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ai-chat-avatar svg {
  width: 24px;
  height: 24px;
  fill: #2196F3;
}

.ai-chat-title {
  font-size: 18px;
  font-weight: 600;
}

.ai-chat-status {
  font-size: 12px;
  opacity: 0.9;
  margin-top: 2px;
}

/* 消息区域 */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
  background: #f0f0f0;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: #2196F3;
  border-radius: 3px;
}

/* 欢迎消息 */
.ai-chat-welcome {
  background: white;
  padding: 24px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ai-chat-welcome-title {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
}

.ai-chat-welcome div {
  color: #666;
  line-height: 1.6;
}

/* 消息气泡 */
.ai-chat-message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-chat-message.user {
  flex-direction: row-reverse;
}

/* 消息头像 */
.ai-chat-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ai-chat-message.bot .ai-chat-msg-avatar {
  background: linear-gradient(135deg, #2196F3 0%, #0D47A1 100%);
}

.ai-chat-message.bot .ai-chat-msg-avatar svg {
  width: 20px;
  height: 20px;
  fill: white;
}

.ai-chat-message.user .ai-chat-msg-avatar {
  background: linear-gradient(135deg, #4FC3F7 0%, #2196F3 100%);
}

.ai-chat-message.user .ai-chat-msg-avatar svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* 消息内容 */
.ai-chat-msg-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-chat-msg-text {
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.6;
  word-wrap: break-word;
  max-width: 70%;
}

.ai-chat-message.bot .ai-chat-msg-text {
  background: white;
  color: #333;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  border-bottom-left-radius: 4px;
}

.ai-chat-message.user .ai-chat-msg-text {
  background: linear-gradient(135deg, #2196F3 0%, #0D47A1 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Markdown 渲染 */
.ai-chat-msg-text h1,
.ai-chat-msg-text h2,
.ai-chat-msg-text h3 {
  margin: 0.5em 0;
}

.ai-chat-msg-text p {
  margin: 0.5em 0;
}

.ai-chat-msg-text ul,
.ai-chat-msg-text ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.ai-chat-msg-text code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.ai-chat-message.user .ai-chat-msg-text code {
  background: rgba(255, 255, 255, 0.2);
}

.ai-chat-msg-text pre {
  background: #f5f5f5;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.5em 0;
}

.ai-chat-message.user .ai-chat-msg-text pre {
  background: rgba(255, 255, 255, 0.1);
}

.ai-chat-msg-text pre code {
  background: none;
  padding: 0;
}

/* 加载动画 */
.ai-chat-loading {
  display: flex;
  gap: 4px;
  padding: 16px;
}

.ai-chat-loading span {
  width: 8px;
  height: 8px;
  background: #2196F3;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.ai-chat-loading span:nth-child(1) {
  animation-delay: -0.32s;
}

.ai-chat-loading span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* 附件区域 */
.ai-chat-attachments {
  padding: 16px 20px 16px 26px;  /* 增加左侧和右侧padding，给删除按钮留空间 */
  background: white;
  border-top: 1px solid #e0e0e0;
  display: none;
}

.ai-chat-attachments.show {
  display: block;
}

.ai-chat-attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;  /* 增加间距 */
}

.ai-chat-attachment {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: visible;  /* 改为visible，让删除按钮完整显示 */
  border: 2px solid #e0e0e0;
  background: #f5f5f5;
  margin: 6px;  /* 添加margin，给删除按钮留空间 */
}

.ai-chat-attachment img,
.ai-chat-attachment video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.ai-chat-attachment.file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.ai-chat-attachment.file svg {
  width: 28px;
  height: 28px;
}

.ai-chat-attachment-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.ai-chat-attachment-name {
  font-size: 10px;
  color: #666;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  margin-top: 4px;
}

.ai-chat-attachment-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: #ff4757;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.ai-chat-attachment-remove svg {
  width: 12px;
  height: 12px;
  fill: white;
}

/* 输入区域 */
.ai-chat-input-area {
  background: white;
  border-top: 1px solid #e0e0e0;
  padding: 16px 20px;
  flex-shrink: 0;
}

.ai-chat-input-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.ai-chat-attach {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: none;
  border: 2px solid #e0e0e0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-chat-attach:hover {
  border-color: #2196F3;
  background: #E3F2FD;
}

.ai-chat-attach svg {
  width: 20px;
  height: 20px;
  fill: #666;
}

.ai-chat-attach:hover svg {
  fill: #2196F3;
}

.ai-chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.4;
}

.ai-chat-input:focus {
  border-color: #2196F3;
}

.ai-chat-input::placeholder {
  color: #999;
}

.ai-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2196F3 0%, #0D47A1 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-chat-send:hover {
  background: linear-gradient(135deg, #4FC3F7 0%, #2196F3 100%);
  transform: scale(1.05);
}

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

.ai-chat-send svg {
  width: 20px;
  height: 20px;
  fill: white;
}

.ai-chat-send:disabled {
  background: #e0e0e0;
  cursor: not-allowed;
}

/* 拖拽提示 */
.ai-chat-drop-hint {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(33, 150, 243, 0.95);
  color: white;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

.ai-chat-drop-hint.show {
  display: flex;
}

.ai-chat-drop-hint svg {
  width: 64px;
  height: 64px;
  fill: white;
}

.ai-chat-drop-hint span {
  font-size: 18px;
  font-weight: 600;
}

/* 隐藏浮动按钮 */
.ai-chat-trigger {
  display: none !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .ai-chat-msg-text {
    max-width: 85%;
  }
}

/* 文档下载卡片 */
.document-download-card {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 2px solid #2196F3;
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
  max-width: 400px;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.15);
}

.doc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.doc-icon {
  font-size: 40px;
  flex-shrink: 0;
}

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

.doc-filename {
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
  font-size: 14px;
  word-break: break-all;
}

.doc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #666;
  flex-wrap: wrap;
}

.doc-type {
  background: #2196F3;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
}

.doc-separator {
  color: #ddd;
}

.doc-expires {
  color: #ff9800;
  font-weight: 500;
}

.doc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding-top: 12px;
  border-top: 1px solid #dee2e6;
}

.doc-countdown {
  font-size: 13px;
  color: #666;
  font-weight: 500;
}

.doc-countdown.expired {
  color: #f44336;
  font-weight: 600;
}

.doc-download-btn {
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-size: 14px;
}

.doc-download-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.doc-download-btn:active {
  transform: scale(0.95);
}

.doc-notice {
  padding-top: 8px;
  border-top: 1px solid #dee2e6;
  color: #6c757d;
  font-size: 11px;
  text-align: center;
}

.doc-notice small {
  display: block;
  line-height: 1.5;
}
