.media-preview {
  max-width: 280px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  margin: 8px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
}

.media-preview:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

/* 加载状态 */
.media-preview.loading {
  background: var(--chat-accent-soft, #f5f5f5);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
}

.media-preview.loading::after {
  content: '加载中...';
  color: var(--chat-muted-soft, #999);
  font-size: 14px;
}

/* 错误状态 */
.media-preview.error {
  background: var(--chat-danger-soft, #fee2e2);
  border: 1px solid var(--chat-danger, #ef4444);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  flex-direction: column;
}

.media-preview.error::after {
  content: '加载失败';
  color: var(--chat-danger, #ef4444);
  font-size: 14px;
  margin-top: 8px;
}

.media-preview.error .anticon {
  color: var(--chat-danger, #ef4444);
  font-size: 32px;
}

.media-thumbnail,
.video-thumbnail {
  position: relative;
  cursor: default;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
}

.media-thumbnail.is-clickable,
.video-thumbnail.is-clickable {
  cursor: pointer;
}

.media-preview.image-preview .media-thumbnail,
.media-preview.video-preview .video-thumbnail {
  border-radius: 12px;
}

.media-preview:has(.media-info) .media-thumbnail,
.media-preview:has(.media-info) .video-thumbnail {
  border-radius: 12px 12px 0 0;
}

.media-thumbnail img,
.video-thumbnail video {
  width: 100%;
  height: auto;
  max-width: 200px;
  max-height: 150px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.media-thumbnail:hover img,
.video-thumbnail:hover video {
  transform: scale(1.05);
}

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

.media-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 12px;
  backdrop-filter: blur(2px);
}

.video-preview .media-overlay {
  background: rgba(0, 0, 0, 0.6);
}

.media-overlay .anticon {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.media-loading-indicator {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.media-loading-text {
  color: #fff;
  font-size: 12px;
}

.media-overlay-icon {
  font-size: 24px;
  color: #fff;
}

.media-retry-button {
  color: var(--chat-muted-soft, #8c8c8c);
}

.media-error-indicator {
  position: absolute;
  inset: 0;
  background: rgba(255, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px dashed var(--chat-danger, #ef4444);
}

.media-error-icon {
  font-size: 24px;
  color: var(--chat-danger, #ef4444);
  margin-bottom: 4px;
}

.media-error-text {
  color: var(--chat-danger, #ef4444);
  font-size: 12px;
}

.media-placeholder {
  width: 200px;
  height: 150px;
  border-radius: 8px;
  background: var(--chat-accent-soft, #f5f5f5);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.media-preview-modal-content {
  text-align: center;
}

.media-preview-modal-image {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.media-preview-modal-tip {
  margin-top: 16px;
  color: var(--chat-muted-soft, #8c8c8c);
  font-size: 12px;
}

.media-preview-modal-filename {
  margin-bottom: 4px;
}

.media-preview-modal-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--chat-muted-soft, #8c8c8c);
}

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

/* 增强媒体类型和大小的显示样式 */
.media-type-icon {
  position: absolute;
  top: 8px;
  left: 8px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 2;
  backdrop-filter: blur(2px);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.media-type-text {
  margin-left: 2px;
}

.media-size-indicator {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  z-index: 2;
  backdrop-filter: blur(2px);
  font-weight: 500;
}

/* 新增视频时长显示样式 */
.media-duration-indicator {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  z-index: 2;
  backdrop-filter: blur(2px);
  font-weight: 500;
}

/* 增强媒体信息显示 */
.media-info {
  margin-top: 8px;
  font-size: 12px;
  overflow: hidden;
}

.media-filename {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.media-meta {
  display: flex;
  justify-content: space-between;
  color: var(--chat-muted-soft, #8c8c8c);
  margin-bottom: 6px;
}

.media-size,
.media-duration {
  display: inline-block;
  background-color: var(--chat-accent-soft, #f5f5f5);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  margin-right: 6px;
}

/* 模态框中的媒体详情 */
.media-details {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 8px 0;
}

.media-details span {
  background-color: var(--chat-accent-soft, #f5f5f5);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

/* 消息气泡内的媒体样式 */
.message-media-preview {
  margin: 4px 0;
}

.message-voice {
  margin: 4px 0;
}

/* 修复消息气泡内媒体布局 */
.message-bubble .message-media {
  margin: 8px 0;
}

.message-bubble .message-media .media-preview {
  max-width: 100%;
  margin: 0;
}

.own-bubble .message-media .media-preview {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
}

.own-bubble .message-media .media-info {
  background: rgba(255, 255, 255, 0.1);
  border-top-color: rgba(255, 255, 255, 0.2);
}

.own-bubble .message-media .media-filename {
  color: rgba(255, 255, 255, 0.9);
}

.own-bubble .message-media .media-size {
  color: rgba(255, 255, 255, 0.7);
}

.own-bubble .message-media .ant-btn {
  color: rgba(255, 255, 255, 0.8);
}

.own-bubble .message-media .ant-btn:hover {
  color: rgba(255, 255, 255, 1);
  background: rgba(255, 255, 255, 0.1);
}

/* 移动端适配 */
@media (max-width: 768px) {
  .media-preview {
    max-width: 220px;
  }

  .media-thumbnail img,
  .video-thumbnail video {
    max-width: 200px !important;
    max-height: 130px !important;
  }

  .media-overlay {
    opacity: 0.8;
  }

  .media-info {
    padding: 8px 12px;
  }

  .media-filename {
    font-size: 12px;
  }

  .media-size {
    font-size: 10px;
  }

  .media-info .ant-btn {
    font-size: 11px;
    padding: 0 2px;
  }
}

/* 小屏幕优化 */
@media (max-width: 480px) {
  .media-preview {
    max-width: 180px;
  }

  .media-thumbnail img,
  .video-thumbnail video {
    max-width: 160px !important;
    max-height: 100px !important;
  }

  .media-info {
    padding: 6px 10px;
  }
}

/* 媒体预览模态框样式 */
.media-preview-modal {
  width: 90% !important;
  max-width: 1200px;
  top: 20px;
}

.media-preview-modal .ant-modal-content {
  padding: 20px;
  border-radius: 12px;
  overflow: hidden;
}

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

.media-preview-modal .ant-image {
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
}

.media-preview-modal .ant-image img {
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.media-preview-modal .ant-image img:hover {
  transform: scale(1.02);
}

/* 缩放预览蒙版样式 */
.zoom-mask,
.image-zoom-mask {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  display: flex !important;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.zoom-mask:hover,
.image-zoom-mask:hover {
  background: rgba(0, 0, 0, 0.7);
}

/* Ant Design 图片预览组件增强 */
.ant-image-preview-operations {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 8px 16px;
}

.ant-image-preview-operations .ant-image-preview-operations-operation {
  color: white;
  font-size: 18px;
  transition: all 0.2s ease;
}

.ant-image-preview-operations .ant-image-preview-operations-operation:hover {
  color: var(--chat-primary, #4c6fff);
  transform: scale(1.1);
}

/* 视频预览模态框样式 */
.video-preview-modal .ant-modal-content {
  background: #000;
  border-radius: 12px;
}

.video-preview-modal .ant-modal-body {
  padding: 0;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.video-preview-modal video {
  border-radius: 8px;
  outline: none;
}
