<template>
  <div class="error-page">
    <div class="error-content">
      <!-- 装饰背景 -->
      <div class="error-bg">
        <div class="bg-circle circle-1"></div>
        <div class="bg-circle circle-2"></div>
        <div class="bg-circle circle-3"></div>
      </div>

      <!-- 主内容 -->
      <div class="error-main">
        <div class="error-code">{{ error?.statusCode || 404 }}</div>
        <div class="error-title">{{ errorTitle }}</div>
        <div class="error-desc">{{ errorDesc }}</div>

        <div class="error-actions">
          <a-button size="large" type="primary" @click="goHome">
            🏠 返回首页
          </a-button>
          <a-button size="large" @click="goBack">
            ← 返回上一页
          </a-button>
        </div>

        <!-- 快速导航 -->
        <div class="quick-nav-section">
          <div class="quick-nav-title">您可能想访问</div>
          <div class="quick-nav-grid">
            <NuxtLink class="quick-nav-item" to="/">首页</NuxtLink>
            <NuxtLink class="quick-nav-item" to="/news">政策要闻</NuxtLink>
            <NuxtLink class="quick-nav-item" to="/consultation">决策咨询</NuxtLink>
            <NuxtLink class="quick-nav-item" to="/expert">专家资讯</NuxtLink>
            <NuxtLink class="quick-nav-item" to="/think-tank">智库观察</NuxtLink>
            <NuxtLink class="quick-nav-item" to="/suggestions">建言献策</NuxtLink>
            <NuxtLink class="quick-nav-item" to="/about">关于我们</NuxtLink>
            <NuxtLink class="quick-nav-item" to="/membership">会员服务</NuxtLink>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
const props = defineProps<{
  error?: {
    statusCode?: number
    message?: string
  }
}>()

const errorCode = computed(() => props.error?.statusCode || 404)

const errorTitle = computed(() => {
  switch (errorCode.value) {
    case 403: return '没有访问权限'
    case 404: return '页面不存在'
    case 500: return '服务器错误'
    default: return '出错了'
  }
})

const errorDesc = computed(() => {
  switch (errorCode.value) {
    case 403: return '抱歉，您没有权限访问此页面'
    case 404: return '抱歉，您访问的页面不存在或已被删除'
    case 500: return '抱歉，服务器发生了一些问题，请稍后再试'
    default: return '抱歉，发生了一些未知错误'
  }
})

function goHome() {
  clearError({ redirect: '/' })
}

function goBack() {
  if (import.meta.client) {
    window.history.back()
  }
  clearError({ redirect: '/' })
}

useHead({
  title: computed(() => `${errorCode.value} - ${errorTitle.value} | 广西决策咨询网`),
})
</script>

<style scoped>
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 50%, #f5f3ff 100%);
  position: relative;
  overflow: hidden;
}

.error-content {
  text-align: center;
  padding: 40px 20px;
  position: relative;
  z-index: 1;
}

/* 装饰圆形 */
.error-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  pointer-events: none;
}
.bg-circle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.08;
}
.circle-1 {
  width: 600px;
  height: 600px;
  background: #1e3a5f;
  top: -200px;
  right: -100px;
}
.circle-2 {
  width: 400px;
  height: 400px;
  background: #3b82f6;
  bottom: -100px;
  left: -100px;
}
.circle-3 {
  width: 200px;
  height: 200px;
  background: #f97316;
  top: 50%;
  left: 20%;
}

.error-main {
  position: relative;
}

.error-code {
  font-size: 160px;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #1e3a5f 0%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
  letter-spacing: -8px;
  text-shadow: 0 4px 30px rgba(30, 58, 95, 0.1);
}

.error-title {
  font-size: 32px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 12px;
}

.error-desc {
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 40px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

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

.quick-nav-section {
  max-width: 560px;
  margin: 0 auto;
}

.quick-nav-title {
  font-size: 14px;
  color: #9ca3af;
  margin-bottom: 16px;
  font-weight: 500;
}

.quick-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.quick-nav-item {
  padding: 8px 20px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 100px;
  font-size: 14px;
  color: #374151;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.quick-nav-item:hover {
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(30, 58, 95, 0.2);
}

@media (max-width: 640px) {
  .error-code {
    font-size: 100px;
    letter-spacing: -4px;
  }
  .error-title {
    font-size: 24px;
  }
  .error-actions {
    flex-direction: column;
    align-items: center;
  }
}
</style>
