/* 全局重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 全屏 canvas 固定于背景 */
#bgCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Microsoft YaHei', '微软雅黑', Arial, Helvetica, sans-serif;
  line-height: 2;
  background-color: #f0f0f0;
  color: #333;
}


/* 全局段落样式（用于 header、footer 等，正文中的 p 用 .main-text 内的设置） */
p {
  margin-top: 1em;
}

/* 为 header 与 footer 内的 p 设置居中 */
header p,
footer p {
  text-align: center;
  color: #fff;
}

/* 主内容区域整体容器 */
.main-wrapper {
  margin-left: 240px;
  width: calc(100% - 240px);
  min-height: 100vh;      /* 设置最小高度为视窗高度 */
  display: flex;          /* 关键 */
  flex-direction: column; /* 关键：竖直排列header、content、footer */
}

/* 菜单展开状态样式 */
li.expanded > .sub-nav {
  display: block;
}

/* 外层容器 */
.wrapper {
  display: flex;
  min-height: 100vh;
}

/* 默认桌面端：sidebar固定在左 */
.sidebar {
  width: 240px;
  background-color: #333;
  color: #fff;
  height: 100vh;
  max-height: 100vh;
  padding: 20px;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
  transition: transform 0.3s ease; /* 动画过渡 */
  transform: translateX(0);       /* 桌面端保持不动 */
  /* 确保在所有情况下都能正常滚动 */
  -webkit-overflow-scrolling: touch; /* iOS滚动优化 */
}

/* 顶级导航样式 */
.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-list > li {
  margin-bottom: 15px;
}

/* 顶级导航链接和标签 */
.nav-list > li > a,
.nav-list > li > span {
  color: #fff;
  text-decoration: none;
  font-size: 1.1em;
  display: block;
  padding: 5px 0;
}

/* 鼠标悬停效果 */
.nav-list > li > a:hover,
.nav-list > li > span:hover {
  color: #4CAF50;
}

/* 子菜单样式 */
.sub-nav {
  list-style: none;
  padding-left: 15px;
  margin-top: 5px;
}

.sub-nav li a {
  color: #ccc;
  text-decoration: none;
  display: block;
  padding: 3px 0;
  font-size: 0.95em;
}

.sub-nav li a:hover {
  color: #4CAF50;
}

/* 激活状态 */
a.active {
  color: #4CAF50;
  font-weight: bold;
}

/* 主内容区域 */
.content {
  margin: 20px auto;
  padding: 20px;
  flex: 1;
  background-color: rgba(255, 255, 255, 0.5);
  max-width: 1000px;
  width: 90%;
}

.container {
  max-width: 600px;
  margin: 20px auto;
  padding: 20px;
  border-radius: 8px;
}

label {
  display: block;
  margin: 10px 0 5px;
  font-weight: bold;
}

input[type="file"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* 全局按钮样式 */
button {
  cursor: pointer;
  background-color: #007bff;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  transition: all 0.3s ease;
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

button:hover:not(:disabled) {
  background-color: #0056b3;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

/* 按钮加载状态样式 */
button.loading {
  position: relative;
  color: transparent;
}

button.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-top: -8px;
  margin-left: -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 防重复点击按钮专用样式 */
.disable-on-click {
  position: relative;
  overflow: hidden;
}

.disable-on-click.loading {
  background-color: #0056b3 !important;
}

/* 正文多栏容器（仅针对正文内容） */
.main-text {
  column-count: 1;
}

/* 正文多栏容器中的段落样式 */
.main-text p {
  margin-top: 1em;
  /* 清除全局 p 可能设置的宽度限制 */
  max-width: none;
}

/* 页眉 */
header {
  background-color: #4CAF50;
  color: #fff;
  padding: 20px;
  text-align: center;
}

/* 大标题 */
.header h1 {
  margin-bottom: 10px;
}

.header p {
  color: #f0f0f0;
}

/* Logo 样式 */
.header .logo {
}

/* 页脚 */
footer {
  background-color: #333;
  color: #fff;
  text-align: center;
  padding: 10px;
  margin-top: auto;
}

#progressBar {
  width: 100%;
  height: 10px;
  background-color: #eee;
  margin-top: 20px;
}

#progressBar div {
  height: 100%;
  width: 0%;
  background-color: #4CAF50;
  transition: width 0.4s ease;
}

/* 汉堡按钮样式 - 固定在左上角 */
.hamburger-btn {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 9999;
  
  display: none; /* 默认隐藏，仅在小屏时显示 */
  
  font-size: 24px;
  background: #333;
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.hamburger-btn:hover {
  background: #555;
  transform: scale(1.05);
}

.hamburger-btn:active {
  transform: scale(0.95);
}

/* 响应式调整：屏幕宽度较小时，导航栏显示在顶部 */
@media (max-width: 768px) {
  .wrapper {
    flex-direction: column;
  }
  .sidebar {
    position: fixed;
    width: 240px;
    height: 100%;
    top: 0;
    left: 0;
    transform: translateX(-100%); /* 默认向左移出屏幕 */
    z-index: 9998;
    transition: transform 0.3s ease;
  }
  .sidebar.open {
    transform: translateX(0);     /* 当有 .open 类时滑出屏幕 */
  }
  /* 侧边栏过渡动画效果 */
  .sidebar.transitioning {
    transition: transform 0.3s ease;
  }
  /* 隐藏桌面端 margin-left */
  .content {
    margin-left: 0;
    margin-right: 0;
    padding: 15px;
    max-width: none;
    width: 100%;
  }
  .main-wrapper {
    margin-left: 0;
    width: 100%;
  }
  /* 在小屏幕上显示汉堡按钮 */
  .hamburger-btn {
    display: block;
  }
}

/* ========== 左侧折叠菜单 ========== */

/* 基础结构 */
.sidebar .nav-list,
.sidebar .sub-nav {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.sidebar .nav-item {
  margin: 0;
}

/* 有子菜单的 nav 标题 */
.sidebar .nav-item.has-children > .nav-label {
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: #fff;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
}

/* hover 效果 */
.sidebar .nav-item.has-children > .nav-label:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* 小箭头（用 ::after 画） */
.sidebar .nav-item.has-children > .nav-label::after {
  content: "▸";
  font-size: 0.8em;
  margin-left: 0.3em;
  transition: transform 0.2s ease;
}

/* 展开状态箭头旋转 */
.sidebar .nav-item.expanded > .nav-label::after {
  transform: rotate(90deg);
}

/* 子菜单默认收起 */
.sidebar .sub-nav {
  display: none;
  margin-left: 0.75rem;      /* 二三级缩进 */
  padding-left: 0.25rem;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

/* 父 li 有 .expanded 时展开子菜单 */
.sidebar .nav-item.expanded > .sub-nav {
  display: block;
}

/* 子链接样式 */
.sidebar .sub-nav .nav-item > a {
  display: block;
  padding: 4px 10px 4px 4px;
  color: #ddd;
  font-size: 0.9rem;
  text-decoration: none;
}

.sidebar .sub-nav .nav-item > a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* 当前页面高亮（你原来的 active class 也可以继续用） */
.sidebar .nav-list a.active {
  color: #4CAF50;
  font-weight: bold;
}
