<template>
	<div id="app">
		<el-container class="wrapper">
			<el-header>
				<nav class="navbar">
					<div class="nav-brand">
						<div class="brand-icon">
							<img src="@/assets/icons/header-logo.png" alt="" />
						</div>
						<div class="brand-text">
							<div class="text-ch">某方向风险监测预警系统</div>
							<div class="text-en">
								National Science and Technology Security Risk Monitoring and Early Warning System
							</div>
						</div>
					</div>
					<div class="nav-menu">
						<el-dropdown @command="handleHomeCommand" class="home-dropdown">
							<div class="nav-link dropdown-trigger">
								<el-icon><House /></el-icon>
								<span>首页</span>
								<el-icon class="dropdown-arrow"><ArrowDown /></el-icon>
							</div>
							<template #dropdown>
								<el-dropdown-menu>
									<el-dropdown-item command="/billHome">法案首页</el-dropdown-item>
									<el-dropdown-item command="/decree">政令首页</el-dropdown-item>
									<el-dropdown-item command="/thinkTank">智库首页</el-dropdown-item>
									<el-dropdown-item command="/exportControl">出口管制</el-dropdown-item>
									<el-dropdown-item command="/marketAccessRestrictions">市场准入限制</el-dropdown-item>
								</el-dropdown-menu>
							</template>
						</el-dropdown>
						<div class="nav-link">
							<el-icon><User /></el-icon>
							<span>国家</span>
						</div>
						<div class="nav-link">
							<el-icon><Location /></el-icon>
							<span>领域</span>
						</div>
						<div class="nav-link">
							<el-icon><Document /></el-icon>
							<span>要素</span>
						</div>
						<div class="nav-link">
							<el-icon><Bell /></el-icon>
							<span>事件</span>
						</div>
					</div>
					<div class="user-info">
						<div class="email">
							<img src="@/assets/icons/header-icon.png" alt="" />
						</div>
						<div class="avator">
							<img src="@/assets/icons/header-avator.png" alt="" />
						</div>
						<span class="user">管理员</span>
					</div>
				</nav>
			</el-header>

			<!-- 面包屑导航 -->
			<!-- <Breadcrumb /> -->

			<el-main class="main-container">
				<router-view />
			</el-main>
			<div class="ai-btn" @click="openAiBox">
				<div class="icon">
					<img src="@/assets/icons/ai-icon.png" alt="" />
				</div>
				<div class="text">智能问答</div>
			</div>
			<div class="ai-dialog" v-if="isShowAiBox">
				<AiBox @close="closeAiBox" />
			</div>
		</el-container>
	</div>
</template>

<script setup>
import { ref } from "vue";
import { Monitor, House, User, Location, Document, Bell, Message, ArrowDown } from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
import Breadcrumb from "@/components/BreadCrumb/index.vue";
import AiBox from "./components/AiBox.vue";

const router = useRouter();

const isShowAiBox = ref(false);

const closeAiBox = () => {
	isShowAiBox.value = false;
};

const openAiBox = () => {
	isShowAiBox.value = true;
};

const handleHomeCommand = command => {
	router.push(command);
};
</script>

<style>
/* 全局样式重置 */
* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
}

body {
	font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}
</style>

<style lang="scss" scoped>
#app {
	font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
	width: 100%;
	height: 100vh;
	// overflow-y: hidden;
}

/* 确保Element Plus容器组件占满宽度 */
.el-container {
	width: 100%;
	height: 100%;
}

.navbar {
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 0 24px;
	background: white;
	color: #333;
	height: 100%;
	border-bottom: 1px solid #e5e7eb;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	position: relative;
	box-sizing: border-box;
	height: 96px;
}

.main-container {
	/* 移除宽度限制，让子页面自己控制布局 */
	width: 100%;
	height: 984px;
	position: relative;
}
.nav-brand {
	display: flex;
	align-items: center;
	gap: 12px;
	position: absolute;
	left: 160px;
	.brand-icon {
		width: 48px;
		height: 48px;
		img {
			width: 100%;
			height: 100%;
		}
	}
}

.brand-icon {
	font-size: 24px;
	color: #1e3a8a;
}

.brand-text {
	.text-ch {
		height: 42px;
		color: rgba(10, 18, 30, 1);
		font-family: Microsoft YaHei;
		font-size: 32px;
		font-weight: 700;
		line-height: 42px;
	}
	.text-en {
		color: rgba(10, 18, 30, 1);
		font-family: Microsoft YaHei;
		font-size: 10px;
		font-weight: 400;
		line-height: 13px;
	}
}

.nav-menu {
	display: flex;
	align-items: center;
	gap: 32px;
}

.nav-link {
	display: flex;
	align-items: center;
	gap: 6px;
	color: #333;
	text-decoration: none;
	padding: 8px 12px;
	border-radius: 6px;
	transition: all 0.3s;
	font-size: 14px;
	cursor: pointer;
}

.nav-link:hover,
.nav-link.router-link-active {
	background-color: #1459bb;
	color: #fff;
}

.home-dropdown {
	display: inline-block;
}

.dropdown-trigger {
	cursor: pointer;
}

.dropdown-arrow {
	font-size: 12px;
	margin-left: 4px;
	transition: transform 0.3s;
}

.home-dropdown:hover .dropdown-arrow {
	transform: rotate(180deg);
}

.user-info {
	display: flex;
	align-items: center;
	gap: 20px;
	padding: 8px 12px;
	border-radius: 6px;
	color: #333;
	position: absolute;
	right: 159px;
	.email {
		width: 20px;
		height: 20px;
		img {
			width: 100%;
			height: 100%;
		}
	}
	.avator {
		width: 32px;
		height: 32px;
		img {
			width: 100%;
			height: 100%;
		}
	}
	.user {
		color: rgba(59, 65, 75, 1);
		font-family: Microsoft YaHei;
		font-size: 16px;
		font-weight: 400;
		line-height: 30px;
	}
}

.wrapper {
	position: relative;
	.ai-btn {
		position: absolute;
		top: 50%;
		right: 46px;
		cursor: pointer;
		.icon {
			width: 96px;
			height: 96px;
			img {
				width: 100%;
				height: 100%;
			}
		}
		.text {
			height: 24px;
			color: rgba(59, 65, 75, 1);
			font-family: Microsoft YaHei;
			font-size: 16px;
			font-weight: 400;
			line-height: 24px;
			text-align: center;
		}
	}
	.ai-dialog {
		position: absolute;
		right: 100px;
		top: 50px;
		z-index: 9999;
	}
}

.el-header {
	padding: 0;
	height: 96px;
	position: relative;
	z-index: 1;
}

.el-main {
	padding: 0;
	height: calc(100vh - 96px);
	background-color: rgba(246, 251, 255, 1);
}
</style>
