<template>
  <aside class="sidebar">
    <!-- Logo -->
    <div class="sidebar-logo">
      <router-link to="/" class="logo-link">
        <img src="/images/backgrounds/logo.svg?v=2" alt="Logo" class="logo-img" />
      </router-link>
    </div>

    <!-- 主导航 -->
    <nav class="sidebar-nav">
      <div
        class="nav-item"
        :class="{ active: active === 'profile' }"
        @click="navigate('/profile')"
      >
        <UserOutlined class="nav-icon" />
        <span class="nav-label">{{ t('profile.title') }}</span>
      </div>
      <div
        class="nav-item"
        :class="{ active: active === 'subscription' }"
        @click="navigate('/subscription')"
      >
        <CompassOutlined class="nav-icon" />
        <span class="nav-label">{{ t('profile.subscription') }}</span>
      </div>
      <div
        class="nav-item"
        :class="{ active: active === 'works' }"
        @click="navigate('/works')"
      >
        <FileOutlined class="nav-icon" />
        <span class="nav-label">{{ t('profile.myWorks') }}</span>
      </div>
      <div
        class="nav-item"
        :class="{ active: active === 'workflow-videos' }"
        @click="navigate('/workflow-videos')"
      >
        <VideoCameraOutlined class="nav-icon" />
        <span class="nav-label">{{ t('nav.workflowVideos') }}</span>
      </div>
    </nav>

    <!-- 分隔线 + 工具标签 -->
    <div class="sidebar-divider">
      <span class="divider-text">{{ t('profile.tools') }}</span>
    </div>

    <!-- 工具菜单 -->
    <nav class="sidebar-nav">
      <div class="nav-item" @click="navigate('/text-to-video/create')">
        <PlayCircleOutlined class="nav-icon" />
        <span class="nav-label">{{ t('home.textToVideo') }}</span>
        <span class="nav-badge badge-pro">Pro</span>
      </div>
      <div class="nav-item" @click="navigate('/image-to-video/create')">
        <PictureOutlined class="nav-icon" />
        <span class="nav-label">{{ t('home.imageToVideo') }}</span>
        <span class="nav-badge badge-pro">Pro</span>
      </div>
      <div class="nav-item" @click="navigate('/storyboard-video/create')">
        <VideoCameraOutlined class="nav-icon" />
        <span class="nav-label">{{ t('home.storyboardVideo') }}</span>
        <span class="nav-badge badge-max">Max</span>
      </div>
      <div
        class="nav-item"
        :class="{ active: active === 'novel-comic' }"
        @click="navigate('/novel-comic/create')"
      >
        <ReadOutlined class="nav-icon" />
        <span class="nav-label">小说漫剧</span>
        <span class="nav-badge badge-new">New</span>
      </div>
    </nav>
  </aside>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import {
  UserOutlined,
  CompassOutlined,
  FileOutlined,
  PlayCircleOutlined,
  PictureOutlined,
  VideoCameraOutlined,
  ReadOutlined
} from '@ant-design/icons-vue'
// VideoCameraOutlined is reused for workflow videos nav item

defineProps({
  active: {
    type: String,
    required: true,
  validator: (v) => ['profile', 'subscription', 'works', 'novel-comic', 'workflow-videos'].includes(v)
  }
})

const { t } = useI18n()
const router = useRouter()

const navigate = (path) => {
  router.push(path)
}
</script>

<style scoped>
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-6) 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: var(--z-sticky);
  height: 100vh;
  overflow-y: auto;
}

/* Logo */
.sidebar-logo {
  padding: 0 var(--space-6) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo-img {
  height: 36px;
  width: auto;
  transition: var(--transition-transform);
}

.logo-img:hover {
  transform: scale(1.03);
}

/* Navigation */
.sidebar-nav {
  padding: 0 var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-all);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-glow-light);
  color: var(--primary-400);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary-500);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-icon {
  font-size: 18px;
  margin-right: var(--space-3);
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
  font-weight: var(--font-medium);
}

/* Badges */
.nav-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: var(--font-semibold);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.badge-pro {
  background: var(--primary-glow-light);
  color: var(--primary-400);
}

.badge-max {
  background: rgba(255, 100, 150, 0.12);
  color: #FF7EB3;
}

.badge-new {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 182, 212, 0.12));
  color: #10B981;
}

/* Divider */
.sidebar-divider {
  padding: var(--space-6) var(--space-6) var(--space-4);
}

.divider-text {
  color: var(--text-disabled);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: var(--space-3) 0;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .sidebar-logo {
    padding: 0 var(--space-4);
  }

  .sidebar-nav {
    flex-direction: row;
    gap: var(--space-1);
    padding: 0 var(--space-3);
  }

  .nav-item {
    white-space: nowrap;
    padding: var(--space-2) var(--space-3);
  }

  .sidebar-divider {
    display: none;
  }

  .nav-item.active::before {
    display: none;
  }
}
</style>
