<template>
  <div class="screen-layout">
    <!-- 顶部状态栏 -->
    <StatusBar :title="robotName" />

    <!-- 主内容区 -->
    <div class="layout-main">
      <div class="menu-page">
        <!-- 动态背景层 -->
        <div class="bg-layer">
          <div class="bg-orb orb-1"></div>
          <div class="bg-orb orb-2"></div>
          <div class="bg-orb orb-3"></div>
          <div class="bg-grid-overlay"></div>
        </div>

        <!-- 欢迎引导区 -->
        <div class="menu-hero">
          <h1 class="hero-title">请选择需要的服务</h1>
          <p class="hero-sub">触摸下方入口办理业务，也可以直接说出您的需求</p>
        </div>

        <!-- 服务按钮区 -->
        <div class="menu-service-area">
          <MainMenu />
        </div>

        <!-- 悬浮返回按钮 -->
        <button class="btn-back" @click="goBack">
          <svg class="back-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
            <path d="M15 18l-6-6 6-6" />
          </svg>
          <span>返回待机</span>
        </button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import StatusBar from '@/components/StatusBar.vue'
import MainMenu from '@/components/MainMenu.vue'
import { useScreenStore } from '@/stores/screen'

const router = useRouter()
const screenStore = useScreenStore()

const robotName = computed(() => screenStore.screenTheme?.robotName || '迎宾巡逻机器人')

const goBack = () => {
  router.push('/idle')
}
</script>

<style scoped>
.screen-layout {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 动态背景 */
.bg-layer {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #e8f1fd 0%, #dbeeff 30%, #eef5ff 60%, #e5f0f8 100%);
  overflow: hidden;
}

/* 光晕球 */
.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}

.orb-1 {
  top: -180px;
  right: -120px;
  width: 600px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(59, 130, 246, 0.14) 0%, transparent 65%);
  animation: orbFloat 18s ease-in-out infinite;
}

.orb-2 {
  bottom: -140px;
  left: -100px;
  width: 480px;
  height: 480px;
  background: radial-gradient(ellipse, rgba(6, 182, 212, 0.11) 0%, transparent 65%);
  animation: orbFloat 22s ease-in-out infinite reverse;
}

.orb-3 {
  top: 40%;
  left: 45%;
  transform: translate(-50%, -50%);
  width: 320px;
  height: 320px;
  background: radial-gradient(ellipse, rgba(47, 142, 229, 0.06) 0%, transparent 65%);
  animation: orbFloat 15s ease-in-out infinite;
  animation-delay: -5s;
}

/* 网格叠加 */
.bg-grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(47, 142, 229, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 142, 229, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -15px) scale(1.05); }
  66% { transform: translate(-15px, 20px) scale(0.97); }
}

/* 主内容 */
.layout-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.menu-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: 54px 0 24px;
}

/* 欢迎引导区 */
.menu-hero {
  text-align: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  padding-top: 0;
  margin-bottom: 0;
}

.hero-title {
  font-size: 54px;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: 3px;
  margin: 0 0 6px;
  line-height: 1.05;
}

.hero-sub {
  font-size: 22px;
  color: var(--text-secondary);
  margin: 0;
  font-weight: 500;
  line-height: 1.25;
}

/* 服务按钮区 */
.menu-service-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1060px;
  margin-top: 0;
  transform: translateY(-34px);
  position: relative;
  z-index: 1;
}

/* 悬浮返回按钮 */
.btn-back {
  position: absolute;
  left: 42px;
  bottom: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 66px;
  padding: 0 30px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(47, 142, 229, 0.20);
  border-radius: 999px;
  box-shadow:
    0 12px 36px rgba(47, 142, 229, 0.14),
    0 2px 8px rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
  font-size: 23px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.22s ease;
  letter-spacing: 1.5px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.97);
  color: var(--primary);
  box-shadow:
    0 18px 48px rgba(47, 142, 229, 0.22),
    0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-3px);
}

.btn-back:active {
  transform: scale(0.97);
  box-shadow: 0 8px 24px rgba(47, 142, 229, 0.12);
}

.back-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* 响应式 */
@media (max-width: 900px), (max-height: 660px) {
  .menu-page { padding: 42px 0 22px; }
  .hero-title { font-size: 46px; letter-spacing: 2px; margin-bottom: 5px; }
  .hero-sub { font-size: 20px; line-height: 1.25; }
  .menu-service-area { transform: translateY(-24px); }
  .btn-back { left: 30px; bottom: 24px; height: 62px; padding: 0 28px; font-size: 21px; }
}
</style>
