<template>
  <div id="microapp-vue3-container">
    <header class="sub-app-header">
      <h1>🟢 Vue3 子应用</h1>
      <nav>
        <router-link to="/">首页</router-link>
        <router-link to="/about">关于</router-link>
        <router-link to="/map">地图</router-link>
        <router-link to="/map-switch-demo">切换演示</router-link>
        <router-link to="/image-overlay">图片叠加</router-link>
      </nav>
    </header>
    <main class="sub-app-main">
      <router-view />
    </main>
  </div>
</template>

<script setup lang="ts">
// 子应用根组件
</script>

<style>
/* 消除 body/html 默认 margin，确保全屏无滚动条 */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

/* 子应用挂载点 — 必须撑满才能让内部 100% 生效 */
#microapp-vue3-root {
  height: 100%;
}

/* 子应用全局样式 — 使用独立的选择器前缀避免污染主应用 */
#microapp-vue3-container {
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, 'Microsoft YaHei', sans-serif;
  color: #333;
  height: 100%;
  overflow: hidden;
  background: #fafafa;
}

/* 子应用头部 */
.sub-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 48px;
  background: linear-gradient(135deg, #42b883 0%, #35495e 100%);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.sub-app-header h1 {
  font-size: 16px;
  font-weight: 600;
}

.sub-app-header nav {
  display: flex;
  gap: 4px;
}

.sub-app-header nav a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 4px 14px;
  border-radius: 4px;
  font-size: 13px;
  transition: all 0.2s;
}

.sub-app-header nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.sub-app-header nav a.router-link-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.25);
  font-weight: 500;
}

.sub-app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* 默认允许垂直滚动（首页/关于页等长内容页面需要），
     地图页面通过自身 overflow: hidden 阻止滚动 */
  overflow-y: auto;
  overflow-x: hidden;
}
</style>
