<template>
  <div class="video-card">
    <div class="video-cover">
      <img :src="data.cover" :alt="data.title" />
      <div class="play-icon">▶</div>
      <span class="platform-tag">{{ data.platform }}</span>
    </div>
    <div class="video-info">
      <h4>{{ data.title }}</h4>
      <p v-if="data.author" class="video-author">👤 {{ data.author }}</p>
      <p v-if="data.description" class="video-desc">{{ data.description }}</p>
    </div>
    <div class="video-actions">
      <button class="save-btn" @click="handleSave">📥 保存到云盘并获取下载链接</button>
    </div>
  </div>
</template>

<script setup lang="ts">
import type { VideoParseResult } from '../types'

const props = defineProps<{
  data: VideoParseResult
}>()

const emit = defineEmits<{
  save: [data: VideoParseResult]
}>()

function handleSave() {
  emit('save', props.data)
}
</script>

<style scoped>
.video-card {
  display: flex;
  background: var(--bg-white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.video-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}
.video-cover {
  position: relative;
  flex-shrink: 0;
  width: 200px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
}
.video-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
}
.platform-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 12px;
  border-radius: 4px;
}
.video-info {
  flex: 1;
  min-width: 0;
}
.video-info h4 {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  margin-bottom: 8px;
}
.video-author {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.video-desc {
  font-size: 14px;
  color: #606266;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-actions {
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
}
.save-btn {
  padding: 10px 20px;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.2s;
}
.save-btn:hover {
  background: var(--primary-dark);
}
</style>
