<template>
  <div class="feature-info-wrapper">
    <div class="feature-info-container" v-if="data && Object.keys(data).length > 0">
      <el-tabs v-model="activeTab" type="card" class="feature-tabs">
        <!-- 小班属性标签页 -->
        <el-tab-pane label="小班属性" name="attributes">
          <div class="attributes-section">
            <div class="attributes-grid">
              <div
                class="attribute-item"
                v-for="(value, key) in filteredData"
                :key="key"
              >
                <span class="attribute-label">{{ key }}：</span>
                <span class="attribute-value">{{ value }}</span>
              </div>
            </div>
            <div v-if="Object.keys(filteredData).length === 0" class="no-data">
              <p>暂无属性数据</p>
            </div>
          </div>
        </el-tab-pane>

        <!-- 照片标签页 -->
        <el-tab-pane :label="`照片 (${imageCount})`" name="images">
          <div class="images-section" v-if="data.imagedata && data.imagedata.length > 0">
            <div class="image-viewer">
              <!-- 左侧切换按钮 -->
              <div 
                class="nav-button prev-button" 
                @click.stop="prevImage"
                v-if="data.imagedata && data.imagedata.length > 1"
              >
                <i class="el-icon-arrow-left"></i>
              </div>
              
              <!-- 照片显示区域 -->
              <div class="image-container">
                <img
                  :key="`image-${currentImageIndex}`"
                  :src="currentImageUrl"
                  class="feature-image"
                  @click="openFullscreen"
                  @error="handleImageError"
                />
                
                <!-- 照片计数器 -->
                <div class="image-counter" v-if="data.imagedata && data.imagedata.length > 1">
                  {{ currentImageIndex + 1 }} / {{ data.imagedata.length }}
                </div>
              </div>
              
              <!-- 右侧切换按钮 -->
              <div 
                class="nav-button next-button" 
                @click.stop="nextImage"
                v-if="data.imagedata && data.imagedata.length > 1"
              >
                <i class="el-icon-arrow-right"></i>
              </div>
            </div>
            
            <!-- 缩略图导航（可选） -->
            <div class="thumbnail-nav" v-if="data.imagedata.length > 1">
              <div
                class="thumbnail-item"
                v-for="(imageUrl, index) in data.imagedata"
                :key="index"
                :class="{ active: index === currentImageIndex }"
                @click="switchToImage(index)"
              >
                <img :src="imageUrl" alt="缩略图" />
              </div>
            </div>
          </div>
          <div v-else class="no-data">
            <p>暂无照片</p>
          </div>
        </el-tab-pane>

        <!-- 视频标签页 -->
        <el-tab-pane :label="`视频 (${videoCount})`" name="videos">
          <div class="videos-section">
            <div class="videos-grid" v-if="data.videodata && data.videodata.length > 0">
              <div
                class="video-item"
                v-for="(videoUrl, index) in data.videodata"
                :key="index"
              >
                <video
                  :src="videoUrl"
                  controls
                  class="feature-video"
                  preload="metadata"
                >
                  您的浏览器不支持视频播放
                </video>
              </div>
            </div>
            <div v-else class="no-data">
              <p>暂无视频</p>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div v-else class="no-data">
      <p>暂无数据</p>
    </div>

    <!-- 照片大图查看 Dialog -->
    <el-dialog
      :visible.sync="fullscreenVisible"
      :append-to-body="true"
      :close-on-click-modal="false"
      :close-on-press-escape="true"
      :show-close="true"
      custom-class="image-viewer-dialog"
      width="800px"
      @close="closeFullscreen"
    >
      <div class="dialog-image-content" @wheel.prevent="handleWheel">
        <div class="dialog-image-viewer">
          <!-- 工具栏 -->
          <div class="dialog-toolbar">
            <el-button-group>
              <el-button
                size="small"
                icon="el-icon-zoom-out"
                @click="zoomOut"
                :disabled="imageScale <= 0.5"
                title="缩小"
              ></el-button>
              <el-button
                size="small"
                @click="resetZoom"
                title="重置"
              >{{ Math.round(imageScale * 100) }}%</el-button>
              <el-button
                size="small"
                icon="el-icon-zoom-in"
                @click="zoomIn"
                :disabled="imageScale >= 3"
                title="放大"
              ></el-button>
            </el-button-group>
            <el-button
              size="small"
              icon="el-icon-refresh-left"
              @click="resetImageTransform"
              title="重置位置"
            ></el-button>
          </div>
          
          <!-- 左侧切换按钮 -->
          <el-button
            v-if="data.imagedata && data.imagedata.length > 1"
            class="dialog-nav-button prev-button"
            icon="el-icon-arrow-left"
            circle
            @click="fullscreenPrevImage"
            :disabled="currentImageIndex === 0"
          ></el-button>
          
          <!-- 照片显示区域 -->
          <div 
            class="dialog-image-container"
            @mousedown="startDrag"
            @mousemove="onDrag"
            @mouseup="endDrag"
            @mouseleave="endDrag"
          >
            <div 
              class="dialog-image-wrapper"
              :style="imageTransformStyle"
            >
              <img
                :key="`dialog-image-${currentImageIndex}`"
                :src="currentImageUrl"
                class="dialog-image"
                @error="handleImageError"
                @load="onImageLoad"
              />
            </div>
            
            <!-- 照片计数器 -->
            <div v-if="data.imagedata && data.imagedata.length > 1" class="dialog-image-counter">
              {{ currentImageIndex + 1 }} / {{ data.imagedata.length }}
            </div>
          </div>
          
          <!-- 右侧切换按钮 -->
          <el-button
            v-if="data.imagedata && data.imagedata.length > 1"
            class="dialog-nav-button next-button"
            icon="el-icon-arrow-right"
            circle
            @click="fullscreenNextImage"
            :disabled="currentImageIndex === data.imagedata.length - 1"
          ></el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'FeatureInfo',
  props: {
    data: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      activeTab: 'attributes',
      currentImageIndex: 0,
      fullscreenVisible: false,
      imageScale: 1,
      imageTranslateX: 0,
      imageTranslateY: 0,
      isDragging: false,
      dragStartX: 0,
      dragStartY: 0,
      dragStartTranslateX: 0,
      dragStartTranslateY: 0
    }
  },
  computed: {
    // 过滤掉不需要显示的字段
    filteredData() {
      if (!this.data) return {}
      const filtered = {}
      const excludeKeys = ['imagedata', 'videodata', 'mediaFileURLs', 'id']
      for (const key in this.data) {
        // 排除数组类型的字段（除了imagedata和videodata已经在excludeKeys中）
        if (
          !excludeKeys.includes(key) && 
          this.data[key] !== null && 
          this.data[key] !== undefined &&
          !Array.isArray(this.data[key]) &&
          typeof this.data[key] !== 'object'
        ) {
          filtered[key] = this.data[key]
        }
      }
      return filtered
    },
    // 照片数量
    imageCount() {
      return this.data && this.data.imagedata ? this.data.imagedata.length : 0
    },
    // 视频数量
    videoCount() {
      return this.data && this.data.videodata ? this.data.videodata.length : 0
    },
    // 当前照片URL
    currentImageUrl() {
      if (this.data && this.data.imagedata && this.data.imagedata.length > 0) {
        const index = Math.max(0, Math.min(this.currentImageIndex, this.data.imagedata.length - 1))
        return this.data.imagedata[index] || this.data.imagedata[0]
      }
      return ''
    },
    // 图片变换样式
    imageTransformStyle() {
      return {
        transform: `translate(${this.imageTranslateX}px, ${this.imageTranslateY}px) scale(${this.imageScale})`,
        transition: this.isDragging ? 'none' : 'transform 0.3s ease'
      }
    }
  },
  methods: {
    // 上一张照片
    prevImage() {
      if (this.data && this.data.imagedata && this.data.imagedata.length > 0) {
        this.currentImageIndex = (this.currentImageIndex - 1 + this.data.imagedata.length) % this.data.imagedata.length
        // 强制更新视图
        this.$nextTick(() => {
          this.$forceUpdate()
        })
      }
    },
    // 下一张照片
    nextImage() {
      if (this.data && this.data.imagedata && this.data.imagedata.length > 0) {
        this.currentImageIndex = (this.currentImageIndex + 1) % this.data.imagedata.length
        // 强制更新视图
        this.$nextTick(() => {
          this.$forceUpdate()
        })
      }
    },
    // 切换到指定照片
    switchToImage(index) {
      if (this.data && this.data.imagedata && index >= 0 && index < this.data.imagedata.length) {
        this.currentImageIndex = index
        // 强制更新视图
        this.$nextTick(() => {
          this.$forceUpdate()
        })
      }
    },
    // 打开照片大图查看
    openFullscreen() {
      this.fullscreenVisible = true
      this.resetImageTransform()
    },
    // 关闭照片大图查看
    closeFullscreen() {
      this.fullscreenVisible = false
      this.resetImageTransform()
    },
    // 全屏模式下上一张
    fullscreenPrevImage() {
      this.prevImage()
      this.resetImageTransform()
    },
    // 全屏模式下下一张
    fullscreenNextImage() {
      this.nextImage()
      this.resetImageTransform()
    },
    // 处理图片加载错误
    handleImageError(event) {
      event.target.style.display = 'none'
      const errorDiv = document.createElement('div')
      errorDiv.className = 'image-slot'
      errorDiv.innerHTML = '<i class="el-icon-picture-outline"></i><p>图片加载失败</p>'
      event.target.parentNode.appendChild(errorDiv)
    },
    // 处理键盘事件
    handleKeydown(event) {
      if (this.fullscreenVisible && this.data && this.data.imagedata) {
        if (event.key === 'ArrowLeft' || event.keyCode === 37) {
          event.preventDefault()
          this.fullscreenPrevImage()
        } else if (event.key === 'ArrowRight' || event.keyCode === 39) {
          event.preventDefault()
          this.fullscreenNextImage()
        }
      }
    },
    // 放大
    zoomIn() {
      if (this.imageScale < 3) {
        this.imageScale = Math.min(3, this.imageScale + 0.25)
      }
    },
    // 缩小
    zoomOut() {
      if (this.imageScale > 0.5) {
        this.imageScale = Math.max(0.5, this.imageScale - 0.25)
        // 如果缩小到1以下，重置位置
        if (this.imageScale <= 1) {
          this.resetImageTransform()
        }
      }
    },
    // 重置缩放
    resetZoom() {
      this.imageScale = 1
      this.resetImageTransform()
    },
    // 重置图片变换
    resetImageTransform() {
      this.imageScale = 1
      this.imageTranslateX = 0
      this.imageTranslateY = 0
    },
    // 处理鼠标滚轮缩放
    handleWheel(event) {
      if (!this.fullscreenVisible) return
      event.preventDefault()
      const delta = event.deltaY > 0 ? -0.1 : 0.1
      const newScale = Math.max(0.5, Math.min(3, this.imageScale + delta))
      this.imageScale = newScale
      // 如果缩小到1以下，重置位置
      if (this.imageScale <= 1) {
        this.imageTranslateX = 0
        this.imageTranslateY = 0
      }
    },
    // 开始拖拽
    startDrag(event) {
      if (this.imageScale <= 1) return
      if (event.button !== 0) return // 只响应左键
      this.isDragging = true
      this.dragStartX = event.clientX
      this.dragStartY = event.clientY
      this.dragStartTranslateX = this.imageTranslateX
      this.dragStartTranslateY = this.imageTranslateY
      event.preventDefault()
    },
    // 拖拽中
    onDrag(event) {
      if (!this.isDragging || this.imageScale <= 1) return
      const deltaX = event.clientX - this.dragStartX
      const deltaY = event.clientY - this.dragStartY
      this.imageTranslateX = this.dragStartTranslateX + deltaX
      this.imageTranslateY = this.dragStartTranslateY + deltaY
    },
    // 结束拖拽
    endDrag() {
      this.isDragging = false
    },
    // 图片加载完成
    onImageLoad() {
      this.resetImageTransform()
    }
  },
  watch: {
    // 当数据变化时，重置照片索引
    'data.imagedata'() {
      this.currentImageIndex = 0
      this.resetImageTransform()
    },
    // 当切换到照片标签页时，重置索引
    activeTab(newVal) {
      if (newVal === 'images') {
        this.currentImageIndex = 0
        this.resetImageTransform()
      }
    },
    // 当切换照片时，重置变换
    currentImageIndex() {
      if (this.fullscreenVisible) {
        this.resetImageTransform()
      }
    }
  },
  mounted() {
    // 监听键盘事件，支持 ESC 关闭全屏，左右箭头切换照片
    document.addEventListener('keydown', this.handleKeydown)
  },
  beforeDestroy() {
    // 移除键盘事件监听
    document.removeEventListener('keydown', this.handleKeydown)
    // 确保恢复页面滚动
    document.body.style.overflow = ''
  }
}
</script>

<style scoped lang="scss">
.feature-info-wrapper {
  position: relative;
}

.feature-info-container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  border: 1px solid rgba(129, 199, 132, 0.3);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.1);
  overflow: hidden;
}

.feature-tabs {
  :deep(.el-tabs__header) {
    margin: 0;
    background: linear-gradient(90deg, #e8f5e9, #f1f8f4);
    border-bottom: 1px solid rgba(129, 199, 132, 0.3);
  }

  :deep(.el-tabs__nav) {
    border: none;
  }

  :deep(.el-tabs__item) {
    color: #2e7d32;
    font-weight: 500;
    border: 1px solid rgba(129, 199, 132, 0.3);
    border-bottom: none;
    margin-right: 4px;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;

    &:hover {
      color: #1b5e20;
      background: rgba(232, 245, 233, 0.8);
    }

    &.is-active {
      color: #1b5e20;
      background: rgba(255, 255, 255, 0.95);
      border-color: rgba(129, 199, 132, 0.5);
      font-weight: 600;
    }
  }

  :deep(.el-tabs__content) {
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
  }
}

.attributes-section {
  max-height: 400px;
  overflow-y: auto;
  min-height: 200px;
  
  /* 自定义滚动条样式 */
  &::-webkit-scrollbar {
    width: 8px;
  }
  
  &::-webkit-scrollbar-track {
    background: rgba(232, 245, 233, 0.3);
    border-radius: 4px;
  }
  
  &::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #81c784, #66bb6a);
    border-radius: 4px;
    
    &:hover {
      background: linear-gradient(180deg, #66bb6a, #4caf50);
    }
  }
}

.images-section,
.videos-section {
  min-height: 200px;
}

.attributes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.attribute-item {
  display: flex;
  align-items: flex-start;
  padding: 10px;
  background: rgba(232, 245, 233, 0.5);
  border-radius: 8px;
  border: 1px solid rgba(129, 199, 132, 0.2);
  transition: all 0.3s ease;
  
  &:hover {
    background: rgba(232, 245, 233, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.15);
  }
}

.attribute-label {
  font-weight: 600;
  color: #2e7d32;
  margin-right: 8px;
  flex-shrink: 0;
  min-width: 100px;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

.attribute-value {
  color: #1b5e20;
  word-break: break-word;
  flex: 1;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

.images-section,
.videos-section {
  margin-top: 0;
}

.image-viewer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 270px;
  margin-bottom: 0px;
  width: 100%;
  overflow: visible;
}

.image-container {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  height: 270px;
  z-index: 1;
}

.feature-image {
  max-width: 100%;
  max-height: 500px;
  object-fit: contain;
  display: block;
  cursor: pointer;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
  transition: transform 0.3s ease;
  
  &:hover {
    transform: scale(1.02);
  }
}

.nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(76, 175, 80, 0.8);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: all 0.3s ease;
  font-size: 20px;
  pointer-events: auto;
  user-select: none;
  
  &:hover {
    background: rgba(76, 175, 80, 1);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
  }
  
  &.prev-button {
    left: 20px;
  }
  
  &.next-button {
    right: 20px;
  }
}

.image-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 5;
}

.thumbnail-nav {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 4px 0;
  height: 60px;
  border-top: 1px solid rgba(129, 199, 132, 0.3);
}

.thumbnail-item {
  width: 72px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0.6;
  
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  
  &:hover {
    opacity: 0.8;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
  }
  
  &.active {
    opacity: 1;
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
  }
}

.image-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 200px;
  background: #f5f5f5;
  color: #909399;
  font-size: 30px;
}

.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.video-item {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(129, 199, 132, 0.3);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.1);
  transition: all 0.3s ease;
  
  &:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
  }
}

.feature-video {
  width: 100%;
  max-height: 400px;
  display: block;
  background: #000;
}

.no-data {
  padding: 40px;
  text-align: center;
  color: #909399;
  font-size: 14px;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

/* 滚动条样式 */
.feature-tabs :deep(.el-tabs__content)::-webkit-scrollbar {
  width: 8px;
}

.feature-tabs :deep(.el-tabs__content)::-webkit-scrollbar-track {
  background: rgba(232, 245, 233, 0.5);
  border-radius: 4px;
}

.feature-tabs :deep(.el-tabs__content)::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #81c784, #66bb6a);
  border-radius: 4px;
}

.feature-tabs :deep(.el-tabs__content)::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #66bb6a, #4caf50);
}

/* 照片大图查看 Dialog 样式 */
:deep(.image-viewer-dialog) {
  .el-dialog {
    border-radius: 18px;
    border: 1px solid rgba(129, 199, 132, 0.35);
    box-shadow: 0 12px 30px rgba(76, 175, 80, 0.18);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    width: 800px !important;
    height: 600px !important;
    margin: 0 auto !important;
    margin-top: calc((100vh - 600px) / 2) !important;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .el-dialog__header {
    background: linear-gradient(135deg, #4caf50, #2e7d32);
    color: #fff;
    border-radius: 18px 18px 0 0;
    padding: 15px 20px;
    flex-shrink: 0;
  }

  .el-dialog__title {
    color: #fff;
    font-weight: 600;
    font-size: 16px;
  }

  .el-dialog__headerbtn .el-dialog__close {
    color: #fff;
    font-size: 20px;
    
    &:hover {
      color: rgba(255, 255, 255, 0.8);
    }
  }

  .el-dialog__body {
    padding: 0;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 0 0 18px 18px;
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(600px - 60px); /* 总高度减去头部高度 */
  }
}


.dialog-image-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

.dialog-image-viewer {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 200;
  display: flex;
  gap: 10px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px;
  border-radius: 8px;
  backdrop-filter: blur(10px);
  
  .el-button-group {
    .el-button {
      background: rgba(76, 175, 80, 0.8);
      border-color: rgba(76, 175, 80, 0.8);
      color: #fff;
      
      &:hover:not(:disabled) {
        background: rgba(76, 175, 80, 1);
        border-color: rgba(76, 175, 80, 1);
      }
      
      &:disabled {
        opacity: 0.5;
        cursor: not-allowed;
      }
    }
  }
  
  .el-button {
    background: rgba(76, 175, 80, 0.8);
    border-color: rgba(76, 175, 80, 0.8);
    color: #fff;
    
    &:hover {
      background: rgba(76, 175, 80, 1);
      border-color: rgba(76, 175, 80, 1);
    }
  }
}

.dialog-image-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
  
  &:active {
    cursor: grabbing;
  }
}

.dialog-image-wrapper {
  display: inline-block;
  transform-origin: center center;
  will-change: transform;
}

.dialog-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: block;
  user-select: none;
  pointer-events: none;
}

.dialog-nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(76, 175, 80, 0.9);
  border-color: rgba(76, 175, 80, 0.9);
  color: #fff;
  font-size: 20px;
  z-index: 100;
  transition: all 0.3s ease;
  
  &:hover:not(:disabled) {
    background: rgba(76, 175, 80, 1);
    border-color: rgba(76, 175, 80, 1);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
  }
  
  &:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(76, 175, 80, 0.5);
    border-color: rgba(76, 175, 80, 0.5);
  }
  
  &.prev-button {
    left: 20px;
  }
  
  &.next-button {
    right: 20px;
  }
}

.dialog-image-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 500;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  z-index: 10;
}

</style>

<style lang="scss">
/* 全局样式：确保 Dialog 能够突破父组件限制，在屏幕中央完整显示 */
.image-viewer-dialog {
  z-index: 3000 !important;
  
  & ~ .v-modal {
    z-index: 2999 !important;
  }
}

.el-dialog__wrapper.image-viewer-dialog {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 3000 !important;
  overflow: hidden !important;
}

.image-viewer-dialog .el-dialog {
  width: 800px !important;
  height: 600px !important;
  margin: 0 auto !important;
  margin-top: calc((100vh - 600px) / 2) !important;
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  display: flex !important;
  flex-direction: column !important;
}

.image-viewer-dialog .el-dialog__body {
  height: calc(600px - 60px) !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
}
</style>

