<template>
  <div class="monitor-card">
    <div class="monitor-header">
      <h3 class="monitor-title">{{ title }}</h3>
      <div class="monitor-controls">
        <el-tag size="small" :type="isLive &&!isHistory? 'success':'info' " @click="isHistory=false"
          style="cursor: pointer;margin-right: 10px;">直播中</el-tag>
        <el-popconfirm width="300" icon-color="#626AEF" hide-icon>
          <template #reference>
            <el-tag size="small" :type="isHistory? 'success':'info'" @click="handleSelectStation"
              style="cursor: pointer;">回放中</el-tag>
          </template>
          <template #actions="{ confirm, cancel }">
            <div class="popover-container" v-loading="loading"
              style="min-height: 300px;max-height: 600px;overflow-y: auto;">
              <div style="display: flex; flex-direction: column; gap: 8px; cursor: pointer;">
                <div class="popover-item" style="text-align: left" v-for="item in videoHistoryList" :key="item.id"
                  @click="handleSelectVideo(item)">
                  <el-icon v-if="item.isSelected" style="margin-right: 10px;" color="#626AEF">
                    <Select />
                  </el-icon>
                  <span style="margin-left: 10px">{{ item.taskId?.replace(
                    /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})$/,
                    '$1-$2-$3 $4:$5'
                    )}}</span>
                  <span
                    style="margin-left: 10px; font-size: 12px; color: #626AEF">{{item.originVideo?'原视频':item.resultVideo?'识别后':''
                    }}</span>
                </div>
              </div>
              <div class="popover-item" style="text-align: left"
                v-if="videoHistoryList.length  !== Number(total)*2 && total > 0" @click="handleMore">
                <span style="margin-left: 10px">更多</span>
              </div>

              <!-- 播放源主选项 -->
              <!-- <div class="popover-item source-header" @click="isSourceExpanded = !isSourceExpanded">
                    <span style="margin-left: 10px">播放源</span>
                    <el-icon :class="['arrow-icon', { 'rotate-icon': isSourceExpanded }]">
                      <ArrowDown />
                    </el-icon>
                  </div> -->

              <!-- 二级菜单（展开效果） -->
              <!-- <transition name="el-zoom-in-top">
                    <div v-show="isSourceExpanded" class="sub-menu">
                      <div class="sub-item popover-item">直播</div>
                      <div class="sub-item popover-item">2025-01-01 10:00:00</div>
                      <div class="sub-item popover-item">2025-01-01 10:00:00</div>
                      <div class="sub-item popover-item">更多</div>
                    </div>
                  </transition> -->
            </div>
          </template>
        </el-popconfirm>
        <el-button icon="VideoCamera" size="small" circle @click="handleRecordEvent" />
      </div>
    </div>
    <div class="monitor-content">
      <div class="video-placeholder" @mouseenter="handleMouseEnter" @mouseleave="handleMouseLeave"
        @click="handleVideoClick">
        <!-- 未直播占位图 -->
        <div v-if="error && !isHistory" class="no-live-placeholder">
          <div class="placeholder-content">
            <el-icon :size="80" color="#909399">
              <VideoCamera />
            </el-icon>
            <p class="placeholder-text">暂未直播</p>
          </div>
        </div>
        <div v-if="!isEmbeddedPlayer && isHistory" class="control-bar"
          :class="{ 'control-bar-visible': showControlBar, 'control-bar-hidden': !showControlBar }"
          @mouseenter="handleControlBarMouseEnter"
          @mouseleave="handleControlBarMouseLeave">
          <div style="align-self: flex-start;">
            <!-- <el-popconfirm width="320" icon-color="#626AEF" hide-icon min-heigh="600">
              <template #reference>
                <el-icon color="#000" @click="handleSelectStation">
                  <MoreFilled />
                </el-icon>
              </template>
              <template #actions="{ confirm, cancel }">
                <div class="popover-container" v-loading="loading">
                  <div style="display: flex; flex-direction: column; gap: 8px; cursor: pointer;">
                    <div class="popover-item" style="text-align: left" v-for="item in videoHistoryList" :key="item.id"
                      @click="handleSelectVideo(item)">
                      <el-icon v-if="item.isSelected" style="margin-right: 10px;" color="#626AEF">
                        <Select />
                      </el-icon>
                      <span style="margin-left: 10px">{{ item.name }}</span>
                    </div>
                  </div> -->

            <!-- 播放源主选项 -->
            <!-- <div class="popover-item source-header" @click="isSourceExpanded = !isSourceExpanded">
                    <span style="margin-left: 10px">播放源</span>
                    <el-icon :class="['arrow-icon', { 'rotate-icon': isSourceExpanded }]">
                      <ArrowDown />
                    </el-icon>
                  </div> -->

            <!-- 二级菜单（展开效果） -->
            <!-- <transition name="el-zoom-in-top">
                    <div v-show="isSourceExpanded" class="sub-menu">
                      <div class="sub-item popover-item">直播</div>
                      <div class="sub-item popover-item">2025-01-01 10:00:00</div>
                      <div class="sub-item popover-item">2025-01-01 10:00:00</div>
                      <div class="sub-item popover-item">更多</div>
                    </div>
                  </transition> -->
            <!-- </div>
              </template>
            </el-popconfirm> -->
          </div>
          <div style="display: flex; align-items: center;gap: 12px;flex: 1;justify-content: center;" class="video-bar">
            <el-icon color="#000" @click.stop="togglePlay">
              <VideoPause v-if="isPlaying" />
              <VideoPlay v-else />
            </el-icon>
            <div class="progress-container">
              <el-slider v-model="currentTime" :max="duration" :show-tooltip="false" @change="handleProgressChange"
                @click.stop />
              <div class="time-info">
                <span>{{ formatTime(currentTime) }}</span>
                <span>/</span>
                <span>{{ formatTime(duration) }}</span>
              </div>
            </div>
          </div>
        </div>
        <!-- <video ref="videoElement" class="video-player" :controls="false" autoplay muted @click="togglePlay"></video> -->
        <!-- HLS播放器/普通video播放器 -->
        <video v-if="!isEmbeddedPlayer&&isHlsStream&&(props.isLive||isHistory)" crossorigin="anonymous"
          ref="videoElementTemp" loop :src="isHlsStream ? undefined : videoUrl" class="video-player" :controls="false"
          autoplay muted></video>
        <video v-if="!isEmbeddedPlayer&&!isHlsStream&&(props.isLive||isHistory)" crossorigin="anonymous"
          ref="videoElementTempHistory" loop class="video-player" :controls="false" autoplay muted>
          <source :src="videoSrc" type="video/mp4">
        </video>
        <iframe v-if="isEmbeddedPlayer&&(props.isLive||isHistory)" :src="videoSrc" class="embedded-player"
          frameborder="0" allowfullscreen></iframe>
        <!-- 暂停图标显示在视频中间 -->
        <transition name="fade">
          <div v-if="showPauseIcon || (!isPlaying && isHistory && !isEmbeddedPlayer)" class="pause-icon-overlay"
            @click.stop="handleVideoClick">
            <!-- <el-icon :size="180" color="#fff">
              <VideoPause />
            </el-icon> -->
            <svg t="1763625759014" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
              p-id="2645" width="150" height="150">
              <path
                d="M170.666667 256.256c0-140.586667 160.512-220.885333 273.024-136.533333l341.205333 255.658666c91.093333 68.266667 91.093333 204.885333 0 273.152L443.733333 904.234667C331.178667 988.586667 170.666667 908.288 170.666667 767.701333V256.213333z m221.866666-68.266667C336.213333 145.834667 256 185.984 256 256.256v511.402667c0 70.314667 80.213333 110.464 136.533333 68.266666l341.205334-255.658666a85.333333 85.333333 0 0 0 0-136.576L392.490667 187.989333z"
                fill="#515151" p-id="2646"></path>
            </svg>
          </div>
        </transition>
      </div>
    </div>
  </div>
  <el-dialog v-model="isShowSource" width="300" draggable title="站点1的播放源">
    <div style="display: flex; flex-direction: column; gap: 10px;padding: 0;cursor: pointer;">
      <div>直播</div>
      <div>2025-01-01 10:00:00</div>
      <div>2025-01-01 10:00:00</div>
      <div>2025-01-01 10:00:00</div>
      <div>2025-01-01 10:00:00</div>
      <div>更多</div>
    </div>
  </el-dialog>
  <!-- 隐藏的canvas元素 -->
  <canvas ref="canvas" style="display: none;"></canvas>
</template>

<script setup lang="ts">
import { defineProps, defineEmits, ref, computed, onMounted, onBeforeUnmount, watch,nextTick } from 'vue';
import {
  VideoCamera,
  Select,
  VideoPlay,
  VideoPause,
  MoreFilled,
  ArrowDown,
  Loading
} from '@element-plus/icons-vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { upload } from '@/utils/upload';
import { get } from '@/api/public/basic'
import { getVideoList } from '@/api/event/videoList'

// 引入 hls.js
import Hls from 'hls.js';

const props = defineProps({
  title: {
    type: String,
    required: true
  },
  isLive: {
    type: Boolean,
    default: false
  },
  videoUrl: {
    type: String,
    required: true
  },
  type: {
  },
  autoPlay: {
    type: Boolean,
    default: true
  },
  muted: {
    type: Boolean,
    default: true
  }
});

// 检测是否为嵌入式播放器
const isEmbeddedPlayer = computed(() => {
  return props.videoUrl && videoSrc.value.includes('/live/input/');
});

const emit = defineEmits(['record-event', 'play', 'pause', 'error', 'ready']);
const videoElement = ref<HTMLVideoElement | null>(null);
const videoElementTemp = ref<HTMLVideoElement | null>();
const videoElementTempHistory = ref<HTMLVideoElement | null>();
const isPlaying = ref(true);
const isMouseEnter = ref(false);
const currentTime = ref(0);
const duration = ref(0);
const showPauseIcon = ref(false);
const hideControlBarTimer = ref<number | null>(null);
const showControlBar = ref(false);
const isShowSource = ref(false);
const loading = ref(false);
const error = ref(false); // 直播视频 播放是否出错
const isHistory = ref(false);
const queryParams = ref({
  pageSize:20,
  pageNum:1,
  stationId:'03001', // 暂时写死固定的站点ID
})
const total = ref(0)
const videoHistoryList = ref<any>([])
const videoSrc = ref('')

// HLS相关
let hls: Hls | null = null;

// 判断是否为HLS流
const isHlsStream = computed(() => {
  // 检查当前视频源是否为HLS流
  const currentVideoUrl =  props.videoUrl;
  return props.isLive && currentVideoUrl && currentVideoUrl.endsWith('.m3u8')&&!isHistory.value;
});


// 初始化HLS播放器
const initHlsPlayer = () => {
  if (isHlsStream.value && videoElementTemp.value) {
    // 获取当前视频源
    const currentVideoUrl =  props.videoUrl;
    
    if (Hls.isSupported()) {
      hls = new Hls();
      hls.loadSource(currentVideoUrl);
      hls.attachMedia(videoElementTemp.value);
      hls.on(Hls.Events.ERROR, function (event, data) {
        error.value = true;
        // ElMessage.error('HLS 播放出错');
        console.error('HLS错误详情:', data);
      });
      hls.on(Hls.Events.MANIFEST_PARSED, function () {
        console.log('HLS清单解析成功，开始播放');
        if (props.autoPlay) {
          videoElementTemp.value?.play().catch(err => {
            console.error('自动播放失败:', err);
          });
        }
      });
    } else if (videoElementTemp.value.canPlayType('application/vnd.apple.mpegurl')) {
      videoElementTemp.value.src = currentVideoUrl;
      if (props.autoPlay) {
        videoElementTemp.value.play().catch(err => {
          console.error('自动播放失败:', err);
        });
      }
    }
  } else if (videoElementTempHistory.value && !isHlsStream.value) {
    // 非HLS流的处理
    const currentVideoUrl = videoSrc.value || props.videoUrl;
    videoElementTempHistory.value.src = currentVideoUrl;
    if (props.autoPlay) {
      videoElementTempHistory.value.play().catch(err => {
        console.error('自动播放失败:', err);
      });
    }
    // 添加视频事件监听器
    setupVideoListeners();
  }
};

// 设置视频事件监听器
const setupVideoListeners = () => {
  const video = videoElementTempHistory.value;
  if (!video) return;
  
  video.addEventListener('loadedmetadata', () => {
    duration.value = video.duration;
  });
  
  video.addEventListener('timeupdate', () => {
    currentTime.value = video.currentTime;
  });
};

// 销毁HLS播放器
const destroyHlsPlayer = () => {
  if (hls) {
    hls.destroy();
    hls = null;
  }
};

// 监听 videoUrl、isLive 或 videoSrc 变化，重新初始化播放器
watch(
  () => [props.videoUrl, props.isLive,isHistory.value],
  () => {
    destroyHlsPlayer();
    setTimeout(() => {
      initHlsPlayer();
    }, 0);
  }
);

onMounted(() => {
  // 确保初始videoSrc有值
  if (!videoSrc.value && props.videoUrl) {
    videoSrc.value = props.videoUrl;
  }
  initHlsPlayer();
});

onBeforeUnmount(() => {
  destroyHlsPlayer();
  clearHideControlBarTimer();
});

const canvas = ref();
const screenshotDataUrl = ref(null);


const isSourceExpanded = ref(false);



// 获取当前站点播放记录
const getCurrentSitePlayRecord = async() => {
  loading.value = true
  const newVideoHistoryList = [] as any
  const res = await getVideoList(queryParams.value)
  if (res.status == 0) {
    // 收集已存在的 taskId
    const existingTaskIds = new Set()
    videoHistoryList.value.forEach(item => {
      if (item.taskId) {
        existingTaskIds.add(item.taskId)
      }
    })
    
    // 使用 Map 根据 taskId 去重新数据
    const uniqueTaskMap = new Map()
    res.data?.result?.forEach(item => {
      // 只添加不存在于已有列表中的 taskId
      if (!existingTaskIds.has(item.taskId) && !uniqueTaskMap.has(item.taskId)) {
        uniqueTaskMap.set(item.taskId, item)
      }
    })
    
    // 将去重后的新数据转换为视频列表
    uniqueTaskMap.forEach(item => {
      const extra = item?.extra ? JSON.parse(item.extra) : {}
      newVideoHistoryList.push({
        ...item,
        isSelected: false,
        originVideo: extra?.risk?.video?.origin,
      })
      newVideoHistoryList.push({
        ...item,
        isSelected: false,
        resultVideo: extra?.risk?.video?.result,
      })
    })
    total.value = res.data?.count || 0
    loading.value = false
  }
  videoHistoryList.value = [...videoHistoryList.value, ...newVideoHistoryList]
}

const handleSelectStation = () => {
  queryParams.value.pageNum = 1
  nextTick(() => {
    getCurrentSitePlayRecord()
  })
}


const handleSelectVideo = (data) => {
  ElMessage.success('已切换你到' + data.name)
  // 销毁当前的HLS播放器实例
  destroyHlsPlayer();
  isHistory.value = true;
  // 设置新的视频源
  const newDomain = "https://subway-guiyang.p-q.co";
  const newVideoSrc = data.originVideo || data.resultVideo;
  const newUrl2 = newVideoSrc?.replace(
    /^https?:\/\/subway-guiyang\.oss-cn-shanghai\.aliyuncs\.com/, 
    newDomain
);
  videoSrc.value = newUrl2;
  // 更新选中状态
  videoHistoryList.value.forEach((item) => {
    if (data.originVideo&&(item.originVideo == data.originVideo&&item.id == data.id) || data.resultVideo&&(item.resultVideo == data.resultVideo&&item.id == data.id)) {
      item.isSelected = true
    } else {
      item.isSelected = false
    }
  })
  
  // 等待DOM更新后重新初始化播放器
  nextTick(() => {
    setTimeout(() => {
      initHlsPlayer();
    }, 100);
  });
}

const handleMore = () => {
  queryParams.value.pageNum++
  getCurrentSitePlayRecord()
}


const togglePlay = () => {
  if (isPlaying.value) {
    videoElementTemp.value?.pause();
    videoElementTempHistory.value?.pause();
    emit('pause');
  } else {
    videoElementTemp.value?.play();
    videoElementTempHistory.value?.play();
  }
  isPlaying.value = !isPlaying.value;
  
  // 显示暂停图标并在1秒后隐藏
  if (!isPlaying.value) {
    showPauseIcon.value = true;
    setTimeout(() => {
      showPauseIcon.value = false;
    }, 1000);
  }
};

// 处理鼠标进入视频区域
const handleMouseEnter = () => {
  isMouseEnter.value = true;
  showControlBar.value = true;
  clearHideControlBarTimer();
};

// 处理鼠标离开视频区域
const handleMouseLeave = () => {
  isMouseEnter.value = false;
  // 鼠标移开时延迟隐藏控制栏
  startHideControlBarTimer();
};

// 清除隐藏定时器
const clearHideControlBarTimer = () => {
  if (hideControlBarTimer.value !== null) {
    clearTimeout(hideControlBarTimer.value);
    hideControlBarTimer.value = null;
  }
};

// 启动延迟隐藏定时器
const startHideControlBarTimer = () => {
  clearHideControlBarTimer();
  hideControlBarTimer.value = setTimeout(() => {
    showControlBar.value = false;
  }, 2000) as unknown as number;
};

// 处理控制栏鼠标进入
const handleControlBarMouseEnter = () => {
  clearHideControlBarTimer();
  showControlBar.value = true;
};

// 处理控制栏鼠标离开
const handleControlBarMouseLeave = () => {
  startHideControlBarTimer();
};

// 点击视频区域暂停/播放
const handleVideoClick = () => {
  if (isHistory.value && !isEmbeddedPlayer.value) {
    togglePlay();
  }
};

// 进度条拖动
const handleProgressChange = (value: number) => {
  const video = videoElementTempHistory.value;
  if (video) {
    video.currentTime = value;
    currentTime.value = value;
  }
};

// 格式化时间显示
const formatTime = (seconds: number) => {
  const mins = Math.floor(seconds / 60);
  const secs = Math.floor(seconds % 60);
  return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
};


const handleRecordEvent = async () => {
  // 编辑事件名称弹窗
  const { value: eventName } = await ElMessageBox.prompt('请输入事件名称', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    inputPattern: /\S/,
    inputErrorMessage: '事件名称不能为空'
  });

  let screenshotFile: File;
  if (isEmbeddedPlayer.value) {
    // 嵌入式播放器：获取随机图片并转为File对象
    const response = await fetch('https://picsum.photos/600/400?random=' + Date.now());
    const blob = await response.blob();
    screenshotFile = new File([blob], 'default-screenshot.jpg', { type: 'image/jpeg' });
  } else {
    // 常规播放器：从canvas生成高质量截图文件
    screenshotFile = await generateCanvasFile();
  }
  onRecordEvent(screenshotFile,eventName);
};

// 从canvas生成高质量图片文件
const generateCanvasFile = async (): Promise<File> => {
  if (!videoElementTemp.value || !videoElementTempHistory.value) throw new Error('视频元素不存在');
  // 创建临时高清画布（抗锯齿处理）
  const tempCanvas = document.createElement('canvas');
  tempCanvas.width = videoElementTemp.value?.videoWidth || videoElementTempHistory.value?.videoWidth;
  tempCanvas.height = videoElementTemp.value?.videoHeight || videoElementTempHistory.value?.videoHeight;

  const tempCtx = tempCanvas.getContext('2d');
  if (tempCtx) {
    tempCtx.drawImage(videoElementTemp.value || videoElementTempHistory.value, 0, 0, tempCanvas.width, tempCanvas.height);
  }
  // 转为WebP格式的Blob（压缩质量80%）
  return new Promise((resolve, reject) => {
    tempCanvas.toBlob(blob => {
      if (!blob) {
        reject(new Error('Canvas转换失败'));
        return;
      }
      resolve(new File([blob], 'capture.webp', { type: 'image/webp' }));
    }, 'image/webp', 0.8);
  });
};

const onRecordEvent =async (event:File, eventName: string) => {
  const filId = await upload(event)
  emit('record-event', {
    fileImg: filId,
    name: eventName,
  });
};

</script>

<style scoped>
.monitor-card {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.monitor-card:hover {
  transform: translateY(-3px);
}

.monitor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background-color: #f5f7fa;
  border-bottom: 1px solid #e5e7eb;
}

.monitor-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monitor-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.monitor-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.video-placeholder {
  flex: 1;
  background-color: #000;
  position: relative;
  overflow: hidden;
  height: 600px;
}

.video-player {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.embedded-player {
  width: 100%;
  height: 100%;
  border: none;
  background-color: #000;
}

.play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  z-index: 10;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 20;
}

.loading-icon {
  animation: rotate 2s linear infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.error-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  z-index: 30;
}

.control-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  position: absolute;
  bottom: 0px;
  width: 100%;
  padding: 10px 15px;
  cursor: default;
  z-index: 40000;
  background: linear-gradient(180deg, rgb(255 255 255 / 10%) 0%, rgb(255 255 255) 100%);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.control-bar-visible {
  opacity: 1;
  transform: translateY(0);
}

.control-bar-hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.progress-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-container :deep(.el-slider) {
  flex: 1;
}

.progress-container :deep(.el-slider__runway) {
  height: 4px;
  background-color: rgba(255, 255, 255, 0.3);
}

.progress-container :deep(.el-slider__bar) {
  height: 4px;
  background-color: #626AEF;
}

.progress-container :deep(.el-slider__button) {
  width: 12px;
  height: 12px;
  border: 2px solid #626AEF;
  background-color: #fff;
}

.time-info {
  display: flex;
  gap: 4px;
  font-size: 12px;
  color: #333;
  white-space: nowrap;
  min-width: 80px;
}

.time-display {
  margin-left: auto;
  font-size: 12px;
  color: #666;
}

.play-pause-btn {
  background-color: #165DFF;
  color: white;
}

.popover-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.arrow-icon {
  transition: transform 0.3s;
  margin-right: 10px;
}

.rotate-icon {
  transform: rotate(180deg);
}

.sub-menu {
  padding-left: 24px;
  border-left: 2px solid #eee;
  margin: 4px 0 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sub-item {
  opacity: 0.9;
  font-size: 13px;
  transition: all 0.2s;
}

.sub-item:hover {
  opacity: 1;
  transform: translateX(2px);
}

.popover-item {
  padding: 6px 10px;
  border-radius: 4px;
  text-align: left;
  cursor: pointer;
}

.popover-item:hover {
  background-color: #f5f7fa;
}

/* 未直播占位样式 */
.no-live-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 1;
}

.placeholder-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.placeholder-text {
  font-size: 24px;
  color: #fff;
  margin: 0;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 暂停图标覆盖层 */
.pause-icon-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 100;
  pointer-events: none;
}

.pause-icon-overlay .el-icon {
  pointer-events: none;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* 淡入淡出动画 */
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from, .fade-leave-to {
  opacity: 0;
}
</style>