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

    <!-- 主内容区 -->
    <div class="layout-main">
      <div class="visitor-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="visitor-content">
          <!-- 标题区 -->
          <div class="visitor-hero">
            <h1 class="page-title">访客登记</h1>
            <p class="page-subtitle">请选择您的到访方式</p>
          </div>

          <!-- 服务入口区 -->
          <div class="visitor-service-area">
            <!-- 入口卡片 -->
            <div class="visitor-options">
            <!-- 预约到访 -->
            <div
              class="option-card appointment-card"
              role="button"
              tabindex="0"
              aria-label="预约到访"
              @click="goToAppointment"
              @keydown.enter="goToAppointment"
            >
              <div class="card-body">
                <div class="option-icon appointment-icon">
                  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <rect x="3" y="4" width="18" height="18" rx="2" ry="2" />
                    <line x1="16" y1="2" x2="16" y2="6" />
                    <line x1="8" y1="2" x2="8" y2="6" />
                    <line x1="3" y1="10" x2="21" y2="10" />
                    <circle cx="12" cy="15" r="2" />
                  </svg>
                </div>
                <div class="option-content">
                  <h3>预约到访</h3>
                  <p>已提前预约，可通过手机号或身份证核验</p>
                </div>
              </div>
            </div>

            <!-- 现场登记 -->
            <div
              class="option-card walkin-card"
              role="button"
              tabindex="0"
              aria-label="现场登记"
              @click="goToWalkIn"
              @keydown.enter="goToWalkIn"
            >
              <div class="card-body">
                <div class="option-icon walkin-icon">
                  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
                    <circle cx="12" cy="7" r="4" />
                    <line x1="20" y1="8" x2="20" y2="14" />
                    <line x1="23" y1="11" x2="17" y2="11" />
                  </svg>
                </div>
                <div class="option-content">
                  <h3>现场登记</h3>
                  <p>未预约访客，可现场填写信息完成登记</p>
                </div>
              </div>
            </div>
          </div>
          </div>
        </div>

        <!-- 悬浮返回按钮 -->
        <button class="btn-back" @click="goToMenu">
          <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 { useScreenStore } from '@/stores/screen'

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

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

const goToAppointment = () => {
  router.push('/visitor/appointment')
}

const goToWalkIn = () => {
  router.push('/visitor/walk-in')
}

const goToMenu = () => {
  router.push('/menu')
}
</script>

<style scoped>
/* 页面布局：与 /menu 完全一致 */
.visitor-layout {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

/* 访客页面容器 */
.visitor-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: 0;
}

/* 动态背景 */
.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: 560px;
  height: 560px;
  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); }
}

/* 标题区 */
.visitor-hero {
  text-align: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  margin-bottom: 40px;
  padding-top: 64px;
}

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

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

/* 服务入口区 */
.visitor-service-area {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1100px;
  position: relative;
  z-index: 1;
}

/* 入口卡片 */
.visitor-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 48px;
  width: 100%;
}

.option-card {
  height: 440px;
  padding: 52px 56px 48px;
  border-radius: 44px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.80);
  box-shadow:
    0 28px 80px rgba(30, 64, 175, 0.14),
    0 2px 10px rgba(255, 255, 255, 0.72) inset;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  cursor: pointer;
  transition: all 0.22s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.option-card:hover {
  transform: translateY(-6px);
  box-shadow:
    0 34px 88px rgba(30, 64, 175, 0.18),
    0 2px 10px rgba(255, 255, 255, 0.78) inset;
}

.option-card:active {
  transform: scale(0.984);
}

/* 卡片内容容器 */
.card-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* 卡片图标 */
.option-icon {
  width: 120px;
  height: 120px;
  border-radius: 34px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  flex-shrink: 0;
}

.option-icon svg {
  width: 62px;
  height: 62px;
}

.appointment-icon {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  box-shadow: 0 20px 38px rgba(37, 99, 235, 0.24);
}

.walkin-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 20px 38px rgba(16, 185, 129, 0.24);
}

/* 卡片文字 */
.option-content {
  display: flex;
  flex-direction: column;
}

.option-content h3 {
  font-size: 46px;
  font-weight: 900;
  color: var(--text-primary);
  margin: 0 0 12px;
  letter-spacing: 1.5px;
  line-height: 1.15;
}

.option-content p {
  font-size: 24px;
  color: var(--text-secondary);
  line-height: 1.50;
  margin: 0;
  max-width: 380px;
  font-weight: 500;
}

/* 悬浮返回按钮 */
.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) {
  .visitor-hero {
    margin-bottom: 30px;
    padding-top: 50px;
  }

  .page-title {
    font-size: 46px;
    letter-spacing: 2px;
    margin-bottom: 5px;
  }

  .page-subtitle {
    font-size: 20px;
  }

  .visitor-options {
    gap: 36px;
  }

  .option-card {
    height: 370px;
    padding: 40px 44px 36px;
    border-radius: 38px;
  }

  .option-icon {
    width: 98px;
    height: 98px;
    border-radius: 30px;
    margin-bottom: 28px;
  }

  .option-icon svg {
    width: 52px;
    height: 52px;
  }

  .option-content h3 {
    font-size: 38px;
    margin-bottom: 12px;
  }

  .option-content p {
    font-size: 20px;
    line-height: 1.42;
  }

  .btn-back {
    left: 30px;
    bottom: 24px;
    height: 62px;
    padding: 0 28px;
    font-size: 21px;
  }
}
</style>
