/* 学习平台移动端底部导航（小程序风格） */

.portal-mobile-nav {
  display: none;
}

@media (max-width: 640px) {
  .portal-main {
    /* 为底部导航预留空间，避免内容被遮挡 */
    padding-bottom: 60px;
  }

  .portal-mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    background: var(--um-bg-panel);
    border-top: 1px solid var(--um-border);
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    z-index: 40;
  }

  .portal-mobile-nav__item {
    flex: 1 1 0;
    border: none;
    background: transparent;
    padding: 4px 0 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    color: var(--um-text-secondary);
    cursor: pointer;
  }

  .portal-mobile-nav__item:focus-visible {
    outline: 2px solid var(--um-accent);
    outline-offset: -2px;
  }

  .portal-mobile-nav__item.is-active {
    color: var(--um-accent);
  }

  .portal-mobile-nav__icon {
    width: 22px;
    height: 22px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .portal-mobile-nav__icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.7;
    fill: none;
  }

  .portal-mobile-nav__label {
    line-height: 1.1;
  }

  /* 学科（结构）模式：树结构单独页面显示 */

  .portal-layout {
    position: relative;
  }

  /* 默认在手机端隐藏侧边栏，只保留右侧内容 */
  .portal-sidebar {
    display: none;
  }

  .portal-layout--subject .portal-sidebar {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 56px; /* 底部导航高度 */
    top: 0;
    background: var(--um-bg-panel);
    border-right: none;
    box-shadow: var(--um-shadow);
    overflow: hidden;
    z-index: 35;
    /* 使用纵向 flex 布局，让内部 section 撑满高度，树容器再占据剩余空间 */
    display: flex;
    flex-direction: column;
  }

  /* 让包含标题 + 树容器的 section 撑满侧边栏高度 */
  .portal-layout--subject .portal-sidebar-section {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0; /* 允许内部滚动区域正确收缩 */
  }

  .portal-layout--subject .portal-content {
    display: none;
  }

  /* 为树结构容器在移动端做一些内边距与高度适配 */
  .portal-layout--subject .cm-tree-wrapper--portal {
    /* 适当增大底部内边距，确保最后一个节点完整露出 */
    padding: 8px 10px 16px;
    /* 在 section 内作为 flex 子项，占据标题下方剩余空间 */
    flex: 1 1 auto;
    max-height: none;
  }

  /* 移动端隐藏顶部header中的消息图标 */
  .portal-message-icon-btn {
    display: none;
  }

  /* 消息按钮徽章 */
  .portal-mobile-nav__item--message {
    position: relative;
  }

  .portal-mobile-nav__badge {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(14px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  }
}
