.media-download-preview {
  border: 1px solid var(--chat-border, #dbe3ff);
  border-radius: 8px;
  padding: 12px;
  background: var(--chat-surface, #fafafa);
  margin: 4px 0;
  max-width: 300px;
  width: 100%;
  overflow: hidden; /* 确保内容不会溢出容器 */
  box-sizing: border-box; /* 包含padding在内的总宽度 */
}

/* 紧凑模式样式 */
.media-download-preview.compact {
  padding: 8px;
  margin: 2px 0;
  max-width: none;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.media-download-preview.compact .media-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}

.media-download-preview.compact .media-details {
  margin-top: 4px;
}

.media-download-preview.compact .media-filename {
  font-size: 12px;
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.media-download-preview.compact .media-meta {
  font-size: 11px;
  margin-top: 2px;
}

/* 下载进度条样式增强 */
.download-progress .ant-card-body {
  padding: 12px !important;
}

.download-progress .ant-progress {
  margin-bottom: 8px !important;
}

.download-progress .ant-progress-line {
  position: relative;
}

.download-progress .ant-progress-bg {
  background: linear-gradient(90deg, var(--chat-primary, #4c6fff) 0%, var(--chat-primary-hover, #6885ff) 100%) !important;
  transition: all 0.3s ease !important;
}

.download-progress .ant-progress-text {
  color: var(--chat-primary, #4c6fff) !important;
  font-weight: 500 !important;
}

/* 下载状态动画效果 */
@keyframes downloadPulse {
  0% { opacity: 0.8; }
  50% { opacity: 1; }
  100% { opacity: 0.8; }
}

.download-progress .ant-spin-dot {
  animation: downloadPulse 1.4s linear infinite;
}

/* 下载信息文本样式 */
.download-progress .download-info {
  font-size: 11px;
  color: var(--chat-muted-soft, #8c8c8c);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.download-cancel-actions {
  margin-top: 8px;
  text-align: center;
}

.download-cancel-button {
  font-size: 11px !important;
}

.download-progress .download-speed {
  color: var(--chat-primary, #4c6fff);
  font-weight: 500;
}

.download-progress .remaining-time {
  color: var(--chat-primary-hover, #6885ff);
  text-align: center;
  margin-top: 4px;
  font-size: 11px;
}

.media-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  width: 100%;
  overflow: hidden; /* 防止flex项目溢出 */
}

.media-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  background: var(--chat-accent-soft, #f5f5f5);
  border-radius: 6px;
}

.media-thumbnail {
  position: relative;
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.media-thumbnail:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.media-audio-player {
  width: 100%;
}

.media-preview-modal-placeholder {
  text-align: center;
  padding: 20px;
}

.media-preview-placeholder-icon {
  font-size: 64px;
  color: var(--chat-muted-soft, #8c8c8c);
}

.media-preview-placeholder-action {
  margin-top: 16px;
}

.media-download-preview-modal {
  width: 90% !important;
  max-width: 800px;
}

.media-download-preview-modal .ant-modal-body {
  text-align: center;
  padding: 16px;
}

.media-preview-modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.media-preview-modal-image,
.media-preview-modal-video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
}

.media-preview-modal-video {
  width: 100%;
}

.media-preview-modal-audio {
  width: 100%;
}

.download-progress-card {
  width: 100%;
}

.download-progress-header {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.download-progress-icon {
  font-size: 16px;
  color: var(--chat-primary, #4c6fff);
}

.download-progress-text {
  font-weight: 500;
}

.download-progress-bar {
  margin-bottom: 8px;
}

.media-placeholder {
  text-align: center;
  padding: 20px;
}

.media-placeholder .media-preview-placeholder-icon {
  font-size: 48px;
  color: var(--chat-muted-soft, #d9d9d9);
}
.media-icon-large {
  font-size: 48px;
}

.media-icon-photo { color: var(--chat-primary, #4c6fff); }
.media-icon-video { color: var(--chat-primary, #4c6fff); }
.media-icon-document { color: var(--chat-warning, #f59e0b); }
.media-icon-audio { color: var(--chat-success, #16a34a); }
.media-icon-default { color: var(--chat-muted-soft, #8c8c8c); }

.thumbnail-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: 6px;
}

.thumbnail-overlay-icon {
  color: #ffffff;
  font-size: 16px;
}

.thumbnail-overlay-icon-large {
  font-size: 20px;
}

.media-thumbnail:hover .thumbnail-overlay {
  opacity: 1;
}

.media-details {
  flex: 1;
  min-width: 0; /* 允许flex项目收缩到比内容更小 */
  overflow: hidden; /* 防止内容溢出 */
  width: 100%; /* 确保占满可用空间 */
}

.media-filename {
  font-weight: 500;
  font-size: 14px;
  color: var(--chat-muted, #262626);
  margin-bottom: 4px;
  /* 文件名文本处理 - 使用ellipsis而不是break-all避免换行 */
  white-space: nowrap; /* 强制单行显示 */
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  max-width: 100%; /* 确保不超出父容器 */
  /* 移除多行相关样式，改为单行省略 */
  /* word-break: break-all; */
  /* display: -webkit-box; */
  /* -webkit-line-clamp: 2; */
  /* -webkit-box-orient: vertical; */
}

.media-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--chat-muted-soft, #8c8c8c);
  flex-wrap: wrap; /* 允许标签换行 */
  overflow: hidden; /* 防止溢出 */
  width: 100%;
}

.media-size {
  background: var(--chat-primary-soft, #eef1ff);
  color: var(--chat-primary, #4c6fff);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap; /* 防止标签内文字换行 */
  flex-shrink: 0; /* 标签不收缩 */
}

.media-type {
  background: var(--chat-accent-soft, #eef1ff);
  color: var(--chat-primary, #4c6fff);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap; /* 防止标签内文字换行 */
  flex-shrink: 0; /* 标签不收缩 */
}

.media-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 32px;
}

.download-progress {
  margin: 8px 0;
}

.download-progress .ant-card {
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.download-progress-content {
  text-align: center;
}

.download-progress .ant-spin {
  width: 100%;
}

.download-progress .ant-spin-text {
  font-size: 12px;
  color: var(--chat-primary, #4c6fff);
  margin-top: 8px;
}

.download-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 8px 0;
}

.download-actions .ant-btn {
  font-size: 12px;
  height: 28px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.download-preview-button {
  background: linear-gradient(135deg, var(--chat-primary, #4c6fff) 0%, var(--chat-primary-hover, #6885ff) 100%);
  border: none;
}

.download-preview-button:hover {
  background: linear-gradient(135deg, var(--chat-primary-hover, #6885ff) 0%, var(--chat-primary, #4c6fff) 100%);
}

.download-save-button {
  border-color: var(--chat-primary, #4c6fff) !important;
  color: var(--chat-primary, #4c6fff) !important;
}

.download-save-button:hover {
  border-color: var(--chat-primary-hover, #6885ff) !important;
  color: var(--chat-primary-hover, #6885ff) !important;
}

.download-actions .ant-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76, 111, 255, 0.3);
}

.download-placeholder {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

.download-placeholder .ant-btn {
  font-size: 12px;
  height: 32px;
  padding: 0 16px;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.download-primary-button {
  background: linear-gradient(135deg, var(--chat-primary, #4c6fff) 0%, var(--chat-primary-hover, #6885ff) 100%);
  border: none;
  box-shadow: 0 2px 4px rgba(76, 111, 255, 0.2);
}

.download-primary-button:hover {
  background: linear-gradient(135deg, var(--chat-primary-hover, #6885ff) 0%, var(--chat-primary, #4c6fff) 100%);
  box-shadow: 0 6px 16px rgba(76, 111, 255, 0.32);
}

.download-placeholder .ant-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(76, 111, 255, 0.32);
}

.download-error {
  margin: 8px 0;
}

.download-error .ant-card {
  border-radius: 8px;
  border: 1px solid var(--chat-danger, #ef4444);
}

.download-error-card {
  background-color: var(--chat-danger-soft, #fee2e2);
}

.download-error-message {
  color: var(--chat-danger, #ef4444);
  margin-bottom: 8px;
  font-size: 12px;
  text-align: center;
}

.download-error-actions {
  text-align: center;
}

.download-error-retry {
  font-size: 11px !important;
}

.download-error .ant-btn {
  font-size: 11px;
  height: 24px;
  border-radius: 4px;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .media-download-preview {
    max-width: 100%;
    padding: 8px;
  }
  
  .media-icon {
    width: 48px;
    height: 48px;
  }
  
  .media-icon .anticon {
    font-size: 36px !important;
  }
  
  .media-filename {
    font-size: 13px;
  }
  
  .media-meta {
    font-size: 11px;
  }
  
  .download-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }
  
  .download-actions .ant-btn {
    font-size: 11px;
  }
}

/* 加载动画 */
@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

.download-progress .ant-spin {
  animation: pulse 1.5s ease-in-out infinite;
}

/* 悬浮效果 */
.media-download-preview:hover {
  border-color: var(--chat-border, #dbe3ff);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
}

.download-actions .ant-btn:hover {
  transform: translateY(-1px);
  transition: transform 0.2s ease;
}

/* 进度条自定义样式 */
.download-progress .ant-progress-circle .ant-progress-text {
  color: var(--chat-primary, #4c6fff);
  font-size: 12px;
}

/* 成功状态指示 */
.download-actions .ant-btn-primary {
  background: linear-gradient(135deg, var(--chat-primary, #4c6fff) 0%, var(--chat-primary-hover, #6885ff) 100%);
  border: none;
}

.download-actions .ant-btn-primary:hover {
  background: linear-gradient(135deg, var(--chat-primary-hover, #6885ff) 0%, var(--chat-primary, #4c6fff) 100%);
}

/* 已下载媒体样式 */
.media-thumbnail.downloaded-media {
  border: 2px solid var(--chat-primary, #4c6fff);
  box-shadow: 0 2px 12px rgba(76, 111, 255, 0.2);
}

.media-thumbnail.downloaded-media:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(76, 111, 255, 0.28);
}

.downloaded-indicator {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--chat-primary, #4c6fff);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 500;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* 缩略图错误回退样式 - 优化后更加柔和 */
.media-icon.error-fallback {
  position: relative;
  border: 1px dashed var(--chat-border, #dbe3ff);
  background: var(--chat-accent-soft, #f5f5f5);
  cursor: pointer;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.media-icon.error-fallback:hover {
  border-color: var(--chat-border, #cbd5ff);
  background: var(--chat-accent-soft, #f0f0f0);
  transform: scale(1.02);
  transition: all 0.2s ease;
}

.error-overlay {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  text-align: center;
  border-radius: 12px;
  padding: 3px 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  max-width: 90%;
  backdrop-filter: blur(2px);
}

.error-overlay small {
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* 已下载操作区样式 */
.downloaded-actions {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.downloaded-actions .ant-btn {
  transition: all 0.3s ease;
}

.downloaded-actions .ant-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(82, 196, 26, 0.3);
}

.download-status-indicator {
  font-size: 12px;
  color: var(--chat-primary, #4c6fff);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--chat-accent-soft, #eef1ff);
  border-radius: 12px;
  border: 1px solid var(--chat-success, #16a34a);
  margin-left: 4px;
}
