<template>
  <div class="error-page">
    <div class="error-content">
      <div class="error-icon">
        <el-icon :size="120" color="#909399">
          <Warning />
        </el-icon>
      </div>
      <h1 class="error-title">404</h1>
      <p class="error-desc">抱歉，您访问的页面不存在</p>
      <p class="error-tips">请检查您输入的网址是否正确，或点击下方按钮返回首页</p>
      <div class="error-actions">
        <el-button @click="goBack">返回上一页</el-button>
        <el-button type="primary" @click="goHome">返回首页</el-button>
      </div>
      
      <div class="error-illustration">
        <svg viewBox="0 0 400 300" xmlns="http://www.w3.org/2000/svg">
          <g opacity="0.8">
            <circle cx="200" cy="150" r="100" fill="#f5f7fa"/>
            <path d="M150 120 Q200 100, 250 120" stroke="#909399" stroke-width="3" fill="none"/>
            <circle cx="170" cy="130" r="10" fill="#909399"/>
            <circle cx="230" cy="130" r="10" fill="#909399"/>
            <path d="M170 180 Q200 160, 230 180" stroke="#909399" stroke-width="3" fill="none"/>
          </g>
        </svg>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'

const router = useRouter()

/**
 * 返回上一页
 */
const goBack = () => {
  router.back()
}

/**
 * 返回首页
 */
const goHome = () => {
  router.push('/dashboard')
}
</script>

<style lang="scss" scoped>
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  padding: 20px;

  .error-content {
    text-align: center;
    max-width: 500px;

    .error-icon {
      margin-bottom: 24px;
      animation: shake 2s ease-in-out infinite;
    }

    .error-title {
      font-size: 120px;
      font-weight: 700;
      color: #333;
      margin: 0;
      line-height: 1;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    .error-desc {
      font-size: 24px;
      font-weight: 600;
      color: #333;
      margin: 24px 0 16px;
    }

    .error-tips {
      font-size: 16px;
      color: #666;
      margin-bottom: 32px;
    }

    .error-actions {
      display: flex;
      gap: 16px;
      justify-content: center;
      margin-bottom: 48px;

      .el-button {
        min-width: 120px;

        &--primary {
          background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
          border: none;
        }
      }
    }

    .error-illustration {
      max-width: 300px;
      margin: 0 auto;
      opacity: 0.6;

      svg {
        width: 100%;
        height: auto;
      }
    }
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

// 响应式
@media (max-width: 768px) {
  .error-page {
    .error-content {
      .error-title {
        font-size: 80px;
      }

      .error-desc {
        font-size: 20px;
      }

      .error-actions {
        flex-direction: column;

        .el-button {
          width: 100%;
        }
      }
    }
  }
}
</style>