<template>
  <div class="kids-mode" @click="showControls" @mousemove="showControls">
    <!-- 主内容区 -->
    <div class="kids-content">
      <!-- 绘本展示 -->
      <div v-if="currentResourceType === 'ebook'" class="content-viewer">
        <EbookViewer
          :pages="ebookPages"
          :current-page="currentEbookPage"
          :audio-url="syncAudioUrl"
          :auto-play="autoPlayAudio"
          @page-change="handlePageChange"
          @toggle-audio-sync="toggleAudioSync"
        />
      </div>

      <!-- 视频播放 -->
      <div v-else-if="currentResourceType === 'video'" class="content-viewer">
        <VideoPlayer
          :src="currentResourceUrl"
          :title="currentResourceName"
          @ended="handleMediaEnded"
        />
      </div>

      <!-- 音频播放 -->
      <div v-else-if="currentResourceType === 'audio'" class="content-viewer">
        <AudioPlayer
          :src="currentResourceUrl"
          :title="currentResourceName"
          :background-image="backgroundImageUrl"
          @ended="handleMediaEnded"
        />
      </div>

      <!-- PPT/挂图展示 -->
      <div v-else-if="currentResourceType === 'ppt' || currentResourceType === 'poster'" class="content-viewer">
        <SlidesViewer
          :pages="slidesPages"
          :current-page="currentSlidePage"
          :type="currentResourceType"
          @page-change="handleSlideChange"
        />
      </div>

      <!-- 课程资源展示 (从底部点击的PPT/挂图) -->
      <div v-else-if="showingResource" class="content-viewer">
        <SlidesViewer
          :pages="[showingResource.url]"
          :current-page="0"
          :type="(showingResource.type as 'ppt' | 'poster')"
        />
        <div class="resource-header">
          <span class="resource-title">{{ showingResource.name }}</span>
          <button class="close-resource-btn" @click="showingResource = null">
            <X :size="20" />
          </button>
        </div>
      </div>

      <!-- 空状态 -->
      <div v-else class="empty-content">
        <div class="empty-icon">
          <BookOpen :size="80" :stroke-width="1.5" />
        </div>
        <div class="empty-text">{{ currentStep?.stepName || '准备开始' }}</div>
        <div class="empty-hint">点击下方环节开始上课</div>
      </div>
    </div>

    <!-- 底部固定导航 -->
    <div class="kids-nav" :class="{ hidden: !controlsVisible }">
      <!-- 环节导航 + 关联资源 -->
      <div class="steps-section">
        <div class="section-label">教学环节</div>
        <div class="steps-container">
          <div
            v-for="(script, index) in scripts"
            :key="script.id"
            class="step-group"
            :class="{ active: currentStepIndex === index }"
          >
            <button
              class="step-chip"
              :class="{
                active: currentStepIndex === index,
                completed: index < currentStepIndex
              }"
              @click.stop="handleStepClick(index)"
            >
              <span class="step-icon">
                <Check v-if="index < currentStepIndex" :size="16" />
                <component v-else :is="getStepIcon(script.stepType)" :size="16" />
              </span>
              <span class="step-name">{{ script.stepName }}</span>
            </button>
            <!-- 环节关联的资源 -->
            <div v-if="getStepResources(script).length > 0" class="step-resources">
              <button
                v-for="resource in getStepResources(script)"
                :key="resource.id"
                class="resource-mini-chip"
                :class="{ active: showingResource?.id === resource.id }"
                @click.stop="handleResourceClick(resource)"
              >
                <component :is="getResourceIcon(resource.type)" :size="12" />
                <span>{{ resource.name }}</span>
              </button>
            </div>
          </div>
        </div>
      </div>

      <!-- 进度条 -->
      <div class="progress-section">
        <div class="progress-track">
          <div class="progress-fill" :style="{ width: progressPercent + '%' }"></div>
        </div>
        <div class="progress-info">
          <span>{{ currentStepIndex + 1 }}/{{ scripts.length }} 环节</span>
          <span v-if="timerSeconds > 0" class="timer">{{ formatTime(timerSeconds) }}</span>
        </div>
      </div>

      <!-- 延伸活动 -->
      <div v-if="activities.length > 0" class="activities-section">
        <div class="section-label">延伸活动</div>
        <div class="activities-track">
          <button
            v-for="activity in activities"
            :key="activity.id"
            class="activity-chip"
            @click.stop="handleActivityClick(activity)"
          >
            <component :is="getActivityIcon(activity.activityType)" :size="16" />
            <span>{{ activity.name }}</span>
          </button>
        </div>
      </div>

      <!-- 教学资源 (未关联环节的PPT/挂图) -->
      <div v-if="unassociatedResources.length > 0" class="resources-section">
        <div class="section-label">其他资源</div>
        <div class="resources-track">
          <button
            v-for="resource in unassociatedResources"
            :key="resource.id"
            class="resource-chip"
            :class="{ active: showingResource?.id === resource.id }"
            @click.stop="handleResourceClick(resource)"
          >
            <Presentation v-if="resource.type === 'ppt'" :size="16" />
            <Image v-else :size="16" />
            <span>{{ resource.name }}</span>
          </button>
        </div>
      </div>

      <!-- 控制按钮 -->
      <div class="nav-controls">
        <button class="ctrl-btn" :disabled="currentStepIndex === 0" @click.stop="prevStep">
          <ChevronLeft :size="24" />
          <span>上一环节</span>
        </button>
        <button class="ctrl-btn primary" :disabled="currentStepIndex >= scripts.length - 1" @click.stop="nextStep">
          <span>下一环节</span>
          <ChevronRight :size="24" />
        </button>
        <button class="ctrl-btn exit" @click.stop="handleExit">
          <X :size="20" />
          <span>退出</span>
        </button>
      </div>
    </div>

    <!-- 延伸活动弹窗 -->
    <a-modal
      v-model:open="activityModalVisible"
      :title="selectedActivity?.name"
      :footer="null"
      width="90%"
      class="activity-modal"
      @cancel="activityModalVisible = false"
    >
      <div v-if="selectedActivity" class="activity-content">
        <div v-if="activityResourceUrl" class="activity-media">
          <video v-if="activityResourceType === 'video'" :src="activityResourceUrl" controls style="width: 100%; max-height: 50vh;"></video>
          <img v-else-if="activityResourceType === 'image'" :src="activityResourceUrl" style="width: 100%; max-height: 50vh; object-fit: contain;">
        </div>
        <div class="activity-info">
          <div class="info-item" v-if="selectedActivity.objectives">
            <div class="info-label">活动目标</div>
            <div class="info-value">{{ selectedActivity.objectives }}</div>
          </div>
          <div class="info-item" v-if="selectedActivity.activityGuide">
            <div class="info-label">活动指引</div>
            <div class="info-value">{{ selectedActivity.activityGuide }}</div>
          </div>
          <div class="info-item" v-if="selectedActivity.duration">
            <div class="info-label">预计时长</div>
            <div class="info-value">{{ selectedActivity.duration }} 分钟</div>
          </div>
        </div>
      </div>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
import {
  BookOpen,
  Check,
  ChevronLeft,
  ChevronRight,
  X,
  Target,
  BookText,
  MessageCircle,
  Palette,
  Sparkles,
  Star,
  Pencil,
  Scissors,
  Music,
  Trophy,
  Puzzle,
  Presentation,
  Image,
  Video,
  FileText,
} from 'lucide-vue-next';
import EbookViewer from './viewers/EbookViewer.vue';
import VideoPlayer from './viewers/VideoPlayer.vue';
import AudioPlayer from './viewers/AudioPlayer.vue';
import SlidesViewer from './viewers/SlidesViewer.vue';

// Props
interface Props {
  course: any;
  scripts: any[];
  activities: any[];
  currentStepIndex: number;
  timerSeconds: number;
}

const props = defineProps<Props>();

// Emits
const emit = defineEmits<{
  (e: 'exit'): void;
  (e: 'stepChange', index: number): void;
}>();

// 控制栏显示状态
const controlsVisible = ref(true);
let hideControlsTimer: number | null = null;

// 当前资源状态
const currentResourceType = ref<string>('');
const currentResourceUrl = ref<string>('');
const currentResourceName = ref<string>('');
const currentEbookPage = ref(0);
const currentSlidePage = ref(0);

// 绘本音频同步
const syncAudioUrl = ref<string>('');
const autoPlayAudio = ref(false);

// 延伸活动弹窗
const activityModalVisible = ref(false);
const selectedActivity = ref<any>(null);
const activityResourceUrl = ref<string>('');
const activityResourceType = ref<string>('');

// 课程资源显示状态 (PPT/挂图)
const showingResource = ref<{ id: string; type: string; name: string; url: string } | null>(null);

// 计算属性
const currentStep = computed(() => props.scripts[props.currentStepIndex]);

const progressPercent = computed(() => {
  if (props.scripts.length === 0) return 0;
  return ((props.currentStepIndex + 1) / props.scripts.length) * 100;
});

const ebookPages = computed(() => {
  if (!props.course?.ebookPaths) return [];
  return props.course.ebookPaths.map((p: any) => getFileUrl(p.path));
});

const slidesPages = computed(() => {
  // 如果正在显示课程资源（PPT/挂图）
  if (showingResource.value) {
    if (showingResource.value.type === 'ppt') {
      return [showingResource.value.url];
    }
    if (showingResource.value.type === 'poster') {
      return [showingResource.value.url];
    }
  }
  // 如果是环节关联的PPT/挂图
  if (currentResourceType.value === 'ppt' && props.course?.pptPath) {
    return [getFileUrl(props.course.pptPath)];
  }
  if (currentResourceType.value === 'poster' && props.course?.posterPaths) {
    return props.course.posterPaths.map((p: any) => getFileUrl(p.path));
  }
  return [];
});

// 课程资源列表 (所有资源)
const allCourseResources = computed(() => {
  const resources: { id: string; type: string; name: string; url: string }[] = [];

  // 添加电子绘本
  if (props.course?.ebookPaths && props.course.ebookPaths.length > 0) {
    props.course.ebookPaths.forEach((ebook: any, index: number) => {
      resources.push({
        id: `ebook-${index}`,
        type: 'ebook',
        name: ebook.name || `绘本${index + 1}`,
        url: getFileUrl(ebook.path),
      });
    });
  }

  // 添加音频
  if (props.course?.audioPaths && props.course.audioPaths.length > 0) {
    props.course.audioPaths.forEach((audio: any, index: number) => {
      resources.push({
        id: `audio-${index}`,
        type: 'audio',
        name: audio.name || `音频${index + 1}`,
        url: getFileUrl(audio.path),
      });
    });
  }

  // 添加视频
  if (props.course?.videoPaths && props.course.videoPaths.length > 0) {
    props.course.videoPaths.forEach((video: any, index: number) => {
      resources.push({
        id: `video-${index}`,
        type: 'video',
        name: video.name || `视频${index + 1}`,
        url: getFileUrl(video.path),
      });
    });
  }

  // 添加PPT
  if (props.course?.pptPath) {
    resources.push({
      id: 'ppt-0',
      type: 'ppt',
      name: props.course.pptName || '教学PPT',
      url: getFileUrl(props.course.pptPath),
    });
  }

  // 添加挂图
  if (props.course?.posterPaths && props.course.posterPaths.length > 0) {
    props.course.posterPaths.forEach((poster: any, index: number) => {
      resources.push({
        id: `poster-${index}`,
        type: 'poster',
        name: poster.name || `挂图${index + 1}`,
        url: getFileUrl(poster.path),
      });
    });
  }

  return resources;
});

// 获取环节关联的资源
const getStepResources = (script: any): { id: string; type: string; name: string; url: string }[] => {
  if (!script?.resourceIds || script.resourceIds.length === 0) return [];

  return script.resourceIds
    .map((resId: string) => {
      const resource = allCourseResources.value.find(r => r.id === resId);
      return resource;
    })
    .filter(Boolean) as { id: string; type: string; name: string; url: string }[];
};

// 获取资源图标
const getResourceIcon = (type: string) => {
  const iconMap: Record<string, typeof BookOpen> = {
    'ebook': BookOpen,
    'audio': Music,
    'video': Video,
    'ppt': Presentation,
    'poster': Image,
  };
  return iconMap[type] || FileText;
};

// 所有环节关联的资源ID集合
const associatedResourceIds = computed(() => {
  const ids = new Set<string>();
  props.scripts.forEach((script: any) => {
    (script.resourceIds || []).forEach((id: string) => ids.add(id));
  });
  return ids;
});

// 未关联环节的资源 (PPT和挂图)
const unassociatedResources = computed(() => {
  return allCourseResources.value.filter(r =>
    (r.type === 'ppt' || r.type === 'poster') && !associatedResourceIds.value.has(r.id)
  );
});

const backgroundImageUrl = computed(() => {
  if (props.course?.coverImagePath) {
    return getFileUrl(props.course.coverImagePath);
  }
  return '';
});

// 方法
const getFileUrl = (filePath: string | null | undefined): string => {
  if (!filePath) return '';
  if (filePath.startsWith('http://') || filePath.startsWith('https://')) {
    return filePath;
  }
  const SERVER_BASE = import.meta.env.VITE_SERVER_BASE_URL || 'http://localhost:3000';
  return `${SERVER_BASE}${filePath}`;
};

const formatTime = (seconds: number) => {
  const mins = Math.floor(seconds / 60);
  const secs = seconds % 60;
  return `${String(mins).padStart(2, '0')}:${String(secs).padStart(2, '0')}`;
};

// 获取环节图标组件
const getStepIcon = (stepType: string): typeof Target => {
  const iconMap: Record<string, typeof Target> = {
    '导入': Target,
    '共读': BookText,
    '讨论': MessageCircle,
    '活动': Palette,
    '创作': Pencil,
    '总结': Star,
  };
  return iconMap[stepType] || BookOpen;
};

// 获取活动图标组件
const getActivityIcon = (activityType: string): typeof Puzzle => {
  const iconMap: Record<string, typeof Puzzle> = {
    'ART': Palette,
    'GAME': Puzzle,
    'OUTDOOR': Trophy,
    'MUSIC': Music,
    'READING': BookOpen,
    'HANDCRAFT': Scissors,
    'OTHER': Sparkles,
  };
  return iconMap[activityType] || Sparkles;
};

// 加载当前环节资源
const loadCurrentStepResources = () => {
  const step = currentStep.value;
  if (!step) {
    currentResourceType.value = '';
    currentResourceUrl.value = '';
    return;
  }

  const resourceIds = step.resourceIds || [];
  if (resourceIds.length === 0) {
    currentResourceType.value = '';
    currentResourceUrl.value = '';
    return;
  }

  const resourceId = resourceIds[0];
  const resource = getResourceById(resourceId);

  if (resource) {
    currentResourceType.value = resource.type === '电子绘本' ? 'ebook' :
                                 resource.type === '音频' ? 'audio' :
                                 resource.type === '视频' ? 'video' :
                                 resource.type === 'PPT课件' ? 'ppt' :
                                 resource.type === '教学挂图' ? 'poster' : '';
    currentResourceUrl.value = resource.url ? getFileUrl(resource.url) : '';
    currentResourceName.value = resource.name;

    if (currentResourceType.value === 'ebook' && props.course?.audioPaths?.length > 0) {
      syncAudioUrl.value = getFileUrl(props.course.audioPaths[0].path);
    }
  }
};

const getResourceById = (resId: string) => {
  if (!resId || !props.course) return null;

  const parts = resId.split('-');
  if (parts.length !== 2) return null;

  const type = parts[0];
  const index = parseInt(parts[1]);

  const typeNames: Record<string, string> = {
    ebook: '电子绘本',
    audio: '音频',
    video: '视频',
    ppt: 'PPT课件',
    poster: '教学挂图',
  };

  switch (type) {
    case 'ebook': {
      const ebooks = props.course.ebookPaths || [];
      if (index < ebooks.length) {
        return { id: resId, name: ebooks[index].name || `电子绘本${index + 1}`, type: typeNames.ebook, url: ebooks[index].path };
      }
      break;
    }
    case 'audio': {
      const audios = props.course.audioPaths || [];
      if (index < audios.length) {
        return { id: resId, name: audios[index].name || `音频${index + 1}`, type: typeNames.audio, url: audios[index].path };
      }
      break;
    }
    case 'video': {
      const videos = props.course.videoPaths || [];
      if (index < videos.length) {
        return { id: resId, name: videos[index].name || `视频${index + 1}`, type: typeNames.video, url: videos[index].path };
      }
      break;
    }
    case 'ppt': {
      if (props.course.pptPath) {
        return { id: resId, name: props.course.pptName || '教学PPT', type: typeNames.ppt, url: props.course.pptPath };
      }
      break;
    }
    case 'poster': {
      const posters = props.course.posterPaths || [];
      if (index < posters.length) {
        return { id: resId, name: posters[index].name || `挂图${index + 1}`, type: typeNames.poster, url: posters[index].path };
      }
      break;
    }
  }
  return null;
};

const showControls = () => {
  controlsVisible.value = true;
  resetHideTimer();
};

const resetHideTimer = () => {
  if (hideControlsTimer) clearTimeout(hideControlsTimer);
  hideControlsTimer = setTimeout(() => {
    controlsVisible.value = false;
  }, 5000) as unknown as number;
};

const handleExit = () => emit('exit');
const handleStepClick = (index: number) => emit('stepChange', index);
const prevStep = () => { if (props.currentStepIndex > 0) emit('stepChange', props.currentStepIndex - 1); };
const nextStep = () => { if (props.currentStepIndex < props.scripts.length - 1) emit('stepChange', props.currentStepIndex + 1); };

// 处理课程资源点击 (PPT/挂图)
const handleResourceClick = (resource: { id: string; type: string; name: string; url: string }) => {
  if (showingResource.value?.id === resource.id) {
    // 再次点击取消显示
    showingResource.value = null;
  } else {
    showingResource.value = resource;
    showControls();
  }
};

const handlePageChange = (page: number) => { currentEbookPage.value = page; };
const handleSlideChange = (page: number) => { currentSlidePage.value = page; };
const handleMediaEnded = () => {};
const toggleAudioSync = () => { autoPlayAudio.value = !autoPlayAudio.value; };

const handleActivityClick = (activity: any) => {
  selectedActivity.value = activity;
  if (activity.onlineMaterials) {
    try {
      const materials = typeof activity.onlineMaterials === 'string' ? JSON.parse(activity.onlineMaterials) : activity.onlineMaterials;
      if (materials.length > 0) {
        activityResourceUrl.value = getFileUrl(materials[0].path);
        activityResourceType.value = materials[0].type || 'image';
      }
    } catch { activityResourceUrl.value = ''; }
  }
  activityModalVisible.value = true;
};

// 键盘事件
const handleKeydown = (e: KeyboardEvent) => {
  showControls();
  if (e.key === 'ArrowLeft' || e.key === 'a' || e.key === 'A') prevStep();
  else if (e.key === 'ArrowRight' || e.key === 'd' || e.key === 'D') nextStep();
  else if (e.key === 'Escape') handleExit();
};

watch(() => props.currentStepIndex, () => {
  loadCurrentStepResources();
  currentEbookPage.value = 0;
  currentSlidePage.value = 0;
}, { immediate: true });

onMounted(() => {
  document.addEventListener('keydown', handleKeydown);
  resetHideTimer();
});

onUnmounted(() => {
  document.removeEventListener('keydown', handleKeydown);
  if (hideControlsTimer) clearTimeout(hideControlsTimer);
});
</script>

<style scoped lang="scss">
.kids-mode {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kids-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: 0;
  min-height: 0;
  overflow: hidden;
}

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

.empty-content {
  text-align: center;
  color: #fff;

  .empty-icon {
    opacity: 0.3;
    margin-bottom: 24px;
  }

  .empty-text {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #FF8C42;
  }

  .empty-hint {
    font-size: 18px;
    opacity: 0.6;
  }
}

// 底部固定导航
.kids-nav {
  flex-shrink: 0;
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 16px 24px 24px;
  transform: translateY(0);
  transition: transform 0.3s ease;

  &.hidden {
    transform: translateY(100%);
  }
}

.steps-section {
  margin-bottom: 12px;

  .section-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  .steps-container {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;

    &::-webkit-scrollbar { display: none; }
  }

  .step-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: fit-content;

    &.active {
      .step-chip {
        background: linear-gradient(135deg, #FF8C42 0%, #E67635 100%);
        border-color: #FF8C42;
        color: white;
        font-weight: 500;
      }

      .step-resources {
        opacity: 1;
      }
    }
  }

  .step-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;

    &:hover {
      background: rgba(255, 255, 255, 0.12);
    }

    &.active {
      background: linear-gradient(135deg, #FF8C42 0%, #E67635 100%);
      border-color: #FF8C42;
      color: white;
      font-weight: 500;
    }

    &.completed {
      background: rgba(82, 196, 26, 0.15);
      border-color: rgba(82, 196, 26, 0.3);
      color: #52c41a;
    }

    .step-icon {
      display: flex;
      align-items: center;
    }
  }

  .step-resources {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
  }

  .resource-mini-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;

    &:hover {
      background: rgba(255, 255, 255, 0.2);
      transform: scale(1.02);
    }

    &.active {
      background: rgba(255, 140, 66, 0.3);
      border-color: #FF8C42;
      color: #FF8C42;
    }
  }
}

.progress-section {
  margin-bottom: 12px;

  .progress-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
  }

  .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #FF8C42 0%, #E67635 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
  }

  .progress-info {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);

    .timer {
      font-variant-numeric: tabular-nums;
    }
  }
}

.activities-section {
  margin-bottom: 12px;

  .section-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  .activities-track {
    display: flex;
    gap: 8px;
  }

  .activity-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(24, 144, 255, 0.15);
    border: 1px solid rgba(24, 144, 255, 0.3);
    color: #1890ff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;

    &:hover {
      background: rgba(24, 144, 255, 0.25);
    }
  }
}

.resources-section {
  margin-bottom: 12px;

  .section-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  .resources-track {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;

    &::-webkit-scrollbar { display: none; }
  }

  .resource-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(255, 140, 66, 0.15);
    border: 1px solid rgba(255, 140, 66, 0.3);
    color: #FF8C42;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;

    &:hover {
      background: rgba(255, 140, 66, 0.25);
    }

    &.active {
      background: rgba(255, 140, 66, 0.4);
      border-color: #FF8C42;
    }
  }
}

.resource-header {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border-radius: 30px;
  z-index: 10;

  .resource-title {
    color: white;
    font-size: 16px;
    font-weight: 500;
  }

  .close-resource-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.2s;

    &:hover {
      background: rgba(255, 255, 255, 0.2);
    }
  }
}

.nav-controls {
  display: flex;
  justify-content: center;
  gap: 12px;

  .ctrl-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 24px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;

    &:hover:not(:disabled) {
      background: rgba(255, 255, 255, 0.15);
    }

    &:disabled {
      opacity: 0.3;
      cursor: not-allowed;
    }

    &.primary {
      background: linear-gradient(135deg, #FF8C42 0%, #E67635 100%);
      border: none;
      font-weight: 500;
    }

    &.exit {
      background: rgba(255, 77, 79, 0.15);
      border-color: rgba(255, 77, 79, 0.3);
      color: #ff4d4f;

      &:hover {
        background: rgba(255, 77, 79, 0.25);
      }
    }
  }
}

// 延伸活动弹窗
.activity-modal {
  :deep(.ant-modal-content) {
    border-radius: 16px;
    overflow: hidden;
  }

  :deep(.ant-modal-header) {
    background: linear-gradient(135deg, #FF8C42 0%, #E67635 100%);
    border-bottom: none;
    padding: 16px 24px;

    .ant-modal-title {
      color: white;
      font-size: 18px;
      font-weight: 600;
    }
  }

  :deep(.ant-modal-close) {
    color: white;
    top: 12px;
  }

  :deep(.ant-modal-body) {
    padding: 24px;
  }
}

.activity-content {
  .activity-media {
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
    background: #f5f5f5;
  }

  .activity-info {
    .info-item {
      margin-bottom: 16px;
      padding: 12px 16px;
      background: #fafafa;
      border-radius: 12px;

      .info-label {
        font-size: 12px;
        color: #999;
        margin-bottom: 6px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
      }

      .info-value {
        font-size: 15px;
        color: #333;
        line-height: 1.6;
      }
    }
  }
}
</style>
