<template>
  <div class="error-page">
    <div class="error-container">
      <!-- SVG 404 插图 -->
      <div class="illustration">
        <svg viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg">
          <!-- 背景 -->
          <rect width="800" height="600" fill="#f8f9fa"/>
          
          <!-- 星星 -->
          <circle class="star" cx="100" cy="100" r="2" fill="#fbbf24" opacity="0.6"/>
          <circle class="star" cx="200" cy="150" r="1.5" fill="#f59e0b" opacity="0.5"/>
          <circle class="star" cx="150" cy="200" r="1" fill="#fbbf24" opacity="0.7"/>
          <circle class="star" cx="700" cy="80" r="2" fill="#f59e0b" opacity="0.6"/>
          <circle class="star" cx="650" cy="120" r="1.5" fill="#fbbf24" opacity="0.5"/>
          <circle class="star" cx="600" cy="180" r="1" fill="#f59e0b" opacity="0.4"/>
          <circle class="star" cx="300" cy="50" r="1.5" fill="#fbbf24" opacity="0.6"/>
          <circle class="star" cx="500" cy="70" r="2" fill="#f59e0b" opacity="0.5"/>
          
          <!-- 宇航员 -->
          <g class="astronaut">
            <!-- 身体 -->
            <ellipse cx="200" cy="350" rx="40" ry="50" fill="#e5e7eb"/>
            <!-- 头盔 -->
            <circle cx="200" cy="300" r="35" fill="#60a5fa"/>
            <circle cx="200" cy="300" r="28" fill="#3b82f6" opacity="0.3"/>
            <!-- 面罩反光 -->
            <ellipse cx="195" cy="295" rx="15" ry="18" fill="white" opacity="0.4"/>
            <!-- 手臂 -->
            <rect x="160" y="340" width="15" height="40" rx="7" fill="#e5e7eb" transform="rotate(-30 167 360)"/>
            <rect x="225" y="340" width="15" height="40" rx="7" fill="#e5e7eb" transform="rotate(30 232 360)"/>
            <!-- 腿 -->
            <rect x="185" y="390" width="12" height="45" rx="6" fill="#e5e7eb"/>
            <rect x="203" y="390" width="12" height="45" rx="6" fill="#e5e7eb"/>
            <!-- 氧气罐 -->
            <rect x="180" y="360" width="40" height="25" rx="5" fill="#94a3b8"/>
          </g>
          
          <!-- 大号 4 -->
          <g class="number-4-left">
            <path d="M 280 250 L 280 350 L 320 350 L 320 370 L 280 370 L 280 400 L 260 400 L 260 370 L 180 370 L 180 345 L 260 250 Z M 260 280 L 205 350 L 260 350 Z" 
                  fill="#3b82f6" stroke="#60a5fa" stroke-width="3"/>
          </g>
          
          <!-- 0 -->
          <g class="number-0">
            <ellipse cx="410" cy="325" rx="50" ry="75" fill="none" stroke="#3b82f6" stroke-width="20"/>
            <circle cx="390" cy="310" r="8" fill="#60a5fa"/>
            <circle cx="430" cy="340" r="8" fill="#60a5fa"/>
          </g>
          
          <!-- 大号 4 -->
          <g class="number-4-right">
            <path d="M 520 250 L 520 350 L 560 350 L 560 370 L 520 370 L 520 400 L 500 400 L 500 370 L 420 370 L 420 345 L 500 250 Z M 500 280 L 445 350 L 500 350 Z" 
                  fill="#3b82f6" stroke="#60a5fa" stroke-width="3"/>
          </g>
          
          <!-- 飞碟 -->
          <g class="ufo">
            <ellipse cx="650" cy="300" rx="60" ry="20" fill="#60a5fa" opacity="0.8"/>
            <ellipse cx="650" cy="290" rx="40" ry="25" fill="#3b82f6"/>
            <circle cx="650" cy="285" r="15" fill="#1e3a8a" opacity="0.5"/>
            <!-- 光束 -->
            <path d="M 630 320 L 620 380 L 680 380 L 670 320 Z" fill="#fbbf24" opacity="0.3" class="beam"/>
          </g>
          
          <!-- 行星 -->
          <circle cx="120" cy="450" r="40" fill="#8b5cf6" opacity="0.6"/>
          <ellipse cx="120" cy="450" rx="55" ry="8" fill="none" stroke="#a78bfa" stroke-width="3" opacity="0.4"/>
        </svg>
      </div>
      
      <!-- 文字内容 -->
      <div class="content">
        <h2 class="error-title">哎呀！页面走丢了</h2>
        <p class="error-description">
          您访问的页面在宇宙中迷路了...<br>
          可能已经被外星人劫持，或者从未存在过
        </p>
        <div class="actions">
          <router-link to="/index" class="btn-home">
            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
              <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
              <polyline points="9 22 9 12 15 12 15 22"></polyline>
            </svg>
            返回首页
          </router-link>
          <button @click="goBack" class="btn-back">
            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
              <line x1="19" y1="12" x2="5" y2="12"></line>
              <polyline points="12 19 5 12 12 5"></polyline>
            </svg>
            返回上一页
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()

const goBack = () => {
  router.back()
}
</script>

<style lang="scss" scoped>
.error-page {
  min-height: 100vh;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

.error-container {
  max-width: 1200px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 60px;
  animation: fadeIn 0.8s ease-out;
  
  @media (max-width: 968px) {
    flex-direction: column;
    text-align: center;
  }
}

.illustration {
  flex: 1;
  max-width: 600px;
  animation: float 3s ease-in-out infinite;
  
  svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.3));
  }
}

.content {
  flex: 1;
  color: #1f2937;
  animation: slideInRight 0.8s ease-out;
}

.error-code {
  font-size: 120px;
  font-weight: 900;
  margin: 0;
  background: linear-gradient(45deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  animation: pulse 2s ease-in-out infinite;
  
  @media (max-width: 768px) {
    font-size: 80px;
  }
}

.error-title {
  font-size: 36px;
  font-weight: 700;
  margin: 20px 0;
  color: #1f2937;
  
  @media (max-width: 768px) {
    font-size: 28px;
  }
}

.error-description {
  font-size: 18px;
  line-height: 1.6;
  margin-bottom: 40px;
  color: #6b7280;
  
  @media (max-width: 768px) {
    font-size: 16px;
  }
}

.actions {
  display: flex;
  gap: 15px;
  
  @media (max-width: 968px) {
    justify-content: center;
  }
  
  @media (max-width: 480px) {
    flex-direction: column;
  }
}

.btn-home,
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  
  svg {
    transition: transform 0.3s ease;
  }
  
  &:hover svg {
    transform: translateX(-3px);
  }
}

.btn-home {
  background: #3b82f6;
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
  
  &:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
  }
}

.btn-back {
  background: white;
  color: #3b82f6;
  backdrop-filter: blur(10px);
  border: 2px solid #e5e7eb;
  
  &:hover {
    background: #f3f4f6;
    transform: translateY(-2px);
    border-color: #3b82f6;
  }
}

/* 动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* SVG 动画 */
.star {
  animation: twinkle 3s ease-in-out infinite;
}

.star:nth-child(2) {
  animation-delay: 0.5s;
}

.star:nth-child(3) {
  animation-delay: 1s;
}

.star:nth-child(4) {
  animation-delay: 1.5s;
}

@keyframes twinkle {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

.astronaut {
  animation: astronautFloat 4s ease-in-out infinite;
  transform-origin: center;
}

@keyframes astronautFloat {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(10px, -10px) rotate(5deg);
  }
  50% {
    transform: translate(0, -20px) rotate(0deg);
  }
  75% {
    transform: translate(-10px, -10px) rotate(-5deg);
  }
}

.ufo {
  animation: ufoFloat 3s ease-in-out infinite;
}

@keyframes ufoFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

.beam {
  animation: beamPulse 2s ease-in-out infinite;
}

@keyframes beamPulse {
  0%, 100% {
    opacity: 0.2;
  }
  50% {
    opacity: 0.5;
  }
}
</style>
