<template>
	<div id="app">
		<el-container>
			<el-header>
				<nav class="navbar">
					<div class="nav-brand">
						<el-icon class="brand-icon"><Monitor /></el-icon>
						<span class="brand-text">某方向风险监测预警系统</span>
					</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="/">智库首页</el-dropdown-item>
									<el-dropdown-item command="/billHome">法案首页</el-dropdown-item>
									<el-dropdown-item command="/exportControl">出口管制</el-dropdown-item>
									<el-dropdown-item command="/decree">政令</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">
						<el-icon><Message /></el-icon>
						<el-icon><User /></el-icon>
						<span>管理员</span>
					</div>
				</nav>
			</el-header>

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

			<el-main class="main-container">
				<router-view />
			</el-main>
		</el-container>
	</div>
</template>

<script setup>
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";

const router = useRouter();

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 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%;
	/* min-height: 100vh; */
	height: 100%;
	margin-bottom: 20px;
}

.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;
}

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

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

.brand-text {
	font-size: 18px;
	font-weight: 600;
	color: #333;
}

.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: 8px;
	padding: 8px 12px;
	background: #f3f4f6;
	border-radius: 6px;
	color: #333;
	position: absolute;
	right: 24px;
}

.el-header {
	padding: 0;
	height: 60px;
}

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