/* 全局隐藏 checkbox */
.toggle-input {
  display: none;
}

/* 移动端头部默认隐藏 */
.sidebar-header-mobile {
  display: none;
}

.sidebar-title {
  font-size: 18px;
  font-weight: bold;
  color: var(--primary-color);
  padding: 25px 0;
  text-align: center;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  text-wrap: nowrap;
}

.sidebar-title::before,
.sidebar-title::after {
  content: "";
  width: 30px;
  height: 3px;
  background: var(--primary-color);
}

.menu-link {
  position: relative;
}

.menu-link .arrow {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: #bbb;
  transition: transform 0.3s ease;
}

/* 桌面端样式 */
.page-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

@media screen and (min-width: 1025px) {
  .menu-link {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 18px 10px;
    font-size: 15px;
    color: #666;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
  }

  .menu-link:hover {
    background: #f9f9f9;
    color: var(--primary-color);
    padding-left: 35px;
  }

  .menu-link.active {
    background: var(--primary-color);
    color: #fff;
  }

  .submenu {
    max-height: 0;
    overflow: hidden;
    background: #fcfcfc;
    transition: 0.4s;
  }

  .has-submenu:hover .submenu {
    max-height: 500px;
  }

  .has-submenu:hover .arrow {
    transform: rotate(180deg);
  }

  .submenu a {
    display: block;
    padding: 12px 30px 12px 50px;
    color: #888;
    font-size: 14px;
    border-bottom: 1px solid #f5f5f5;
    text-align: center;
  }

  .submenu a:hover {
    color: var(--primary-color);
  }
}

/* ==================== 6. 移动端重构样式 (核心需求) ==================== */
@media screen and (max-width: 1024px) {
  .main-content {
    flex-direction: column;
    gap: 0;
  }

  .page-sidebar {
    width: 100%;
    margin: 0 0 1.25rem 0;
    box-shadow: none;
    border-radius: 0.25rem;
    overflow: hidden;
    box-shadow: 0 0.3125rem 0.9375rem rgba(0, 0, 0, 0.05);
  }

  .sidebar-title {
    display: none;
  }

  /* 紫色头部 */
  .sidebar-header-mobile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--primary-color);
    color: #fff;
    padding: 0.9375rem 1.25rem;
    cursor: pointer;
    user-select: none;
  }

  .sh-title {
    font-size: 1.125rem;
    letter-spacing: 0.0625rem;
  }

  .sh-icon {
    font-size: 1.25rem;
    opacity: 0.9;
  }

  /* 主菜单列表 (手风琴) */
  .sidebar-menu {
    max-height: 0;
    display: block; /* 覆盖 list.css 的水平滚动布局，改为竖向 */
    overflow: hidden;
    white-space: normal;
    background: #fff;
    transition: max-height 0.5s cubic-bezier(0.25, 1, 0.5, 1);
  }

  /* 点击头部展开 */
  #sidebar-main-toggle:checked ~ .sidebar-menu {
    max-height: 125rem;
    box-shadow: 0 0.3125rem 0.9375rem rgba(0, 0, 0, 0.1);
  }

  /* 菜单项 */
  .menu-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.5rem 1.25rem;
    background: #fff;
    color: #333;
    font-size: 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: color 0.3s;
  }

  .menu-link.active {
    color: var(--primary-color);
    font-weight: bold;
  }

  .arrow {
    color: #bbb;
    font-size: 0.875rem;
    transition: transform 0.3s ease;
  }

  /* 二级菜单 */
  .submenu {
    max-height: 0;
    overflow: hidden;
    background-color: #f7f5f8;
    /* 浅底色 */
    transition: max-height 0.4s ease;
  }

  .submenu li {
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  }

  .submenu a {
    display: block;
    padding: 0.5rem 1.25rem 0.5rem 2.5rem;
    color: #666;
    font-size: 0.875rem;
  }

  .submenu a:hover {
    color: var(--primary-color);
  }

  /* 二级菜单展开逻辑 */
  .toggle-input:checked + .toggle-link .arrow {
    transform: rotate(180deg);
    color: var(--primary-color);
  }

  .toggle-input:checked + .toggle-link {
    color: var(--primary-color);
  }

  .toggle-input:checked ~ .submenu {
    max-height: 31.25rem;
  }
}