<template>
  <div class="not-found-container">
    <!-- Loading 动效 -->
    <div class="loading-container">
      <div class="loading-spinner">
        <div class="spinner-ring"></div>
        <div class="spinner-ring"></div>
        <div class="spinner-ring"></div>
      </div>
      <p class="loading-text">正在为您跳转到统一登录门户，请稍后...</p>
    </div>
  </div>
</template>

<script>
import { isLocal, isTest, isProd } from '@/utils/apiConfig'

export default {
  name: 'NotFound',
  mounted() {
    const reason = this.$route.query.reason
    console.log('🚫 进入404页面，原因:', reason || '未知')
    console.log('🔧 当前环境:', { isLocal, isTest, isProd })
    
    // 本地/测试环境不跳转
    if (isLocal || isTest) {
      console.log('🔧 本地/测试环境：不跳转到登录门户')
      return
    }
    
    // 生产环境跳转到统一认证门户
    console.log('🔄 即将重定向到登录门户...')
    localStorage.removeItem('shudao_refresh_token')
    localStorage.removeItem('shudao_token_type')
    localStorage.removeItem('shudao_username')
    sessionStorage.removeItem('auth_debug_logs')
    setTimeout(() => {
      console.log('🚀 开始跳转到登录门户')
      window.location.href = 'https://tyrz.scgsdsj.com/iga/login_sd.html'
    }, 2000)
  }
}
</script>

<style scoped>
/* 容器样式 - 纯白色背景 */
.not-found-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  padding: 40px 20px;
  text-align: center;
}

/* Loading 容器 */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  animation: fadeIn 0.8s ease-out both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading 文字 */
.loading-text {
  font-size: 16px;
  color: #5dade2;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.5px;
}

/* Spinner 容器 */
.loading-spinner {
  position: relative;
  width: 80px;
  height: 80px;
}

/* Spinner 圆环 */
.spinner-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 4px solid transparent;
  border-radius: 50%;
  animation: spin 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.spinner-ring:nth-child(1) {
  border-top-color: #5dade2;
  animation-delay: 0s;
}

.spinner-ring:nth-child(2) {
  border-right-color: #3498db;
  animation-delay: 0.15s;
}

.spinner-ring:nth-child(3) {
  border-bottom-color: #5dade2;
  animation-delay: 0.3s;
  opacity: 0.6;
}

@keyframes spin {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.1);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

/* 移动端适配 */
@media (max-width: 768px) {
  .not-found-container {
    padding: 30px 16px;
  }

  .loading-spinner {
    width: 60px;
    height: 60px;
  }

  .loading-text {
    font-size: 14px;
  }
}
</style>

