/* ============================================================
   移动端抽屉导航补丁 · mobile-nav.css   (2026-12-04)
   ------------------------------------------------------------
   问题：窄屏下侧栏被压成 56px 图标条，既挤占内容宽度，又认不出
        菜单名字；顶栏也没有入口。
   做法：≤900px 时侧栏改为「汉堡按钮 + 左侧滑出抽屉」，点遮罩 /
        关闭按钮 / 选中菜单 / Esc 收起。≥901px 完全不受影响。
   注意：纯样式覆盖，不修改任何构建产物。后台「一键更新」会整覆
        web/，之后重新执行 apply-mobile-nav.sh 即可恢复。
   ============================================================ */

.mnav-btn,
.mnav-close,
.mnav-scrim {
  display: none;
}

@media (max-width: 900px) {
  /* ── 1. 顶栏汉堡按钮 ── */
  .mnav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 38px;
    height: 38px;
    padding: 0;
    margin-right: 2px;
    border: 1px solid var(--brd, rgba(15, 32, 51, .12));
    border-radius: 10px;
    background: var(--surface-2, transparent);
    color: var(--ink, #1b2431);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s ease;
  }
  .mnav-btn:hover { background: var(--primary-soft, rgba(59, 94, 143, .1)); }
  .mnav-btn:active { transform: scale(.95); }
  .mnav-btn svg { display: block; }

  /* 顶栏排版：汉堡 + 标题 + 右侧操作，标题可省略不撑破 */
  .subtop-inner { gap: 10px; }
  .subtop-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nav-inner { gap: 10px; }

  /* ── 2. 侧栏 → 抽屉 ──
     上游窄屏把 .sidenav 改成了「顶部横向条」（flex-direction:row /
     height:auto / position:sticky / border-bottom），这里逐条覆盖回来。 */
  .app-shell.layout-sidebar > .sidenav,
  .app-shell.layout-rail > .sidenav {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    width: min(84vw, 320px) !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: calc(16px + env(safe-area-inset-top)) 14px
             calc(16px + env(safe-area-inset-bottom)) !important;
    z-index: 1200 !important;
    transform: translateX(-104%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    will-change: transform;

    /* 关键：从「横向条」改回「竖排抽屉」 */
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;

    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border-right: 1px solid var(--brd, rgba(15, 32, 51, .1)) !important;
    border-bottom: 0 !important;
    background: var(--surface, #fff);
    box-shadow: none;
  }
  html.mnav-open .app-shell.layout-sidebar > .sidenav,
  html.mnav-open .app-shell.layout-rail > .sidenav {
    transform: translateX(0);
    box-shadow: 0 24px 70px rgba(8, 16, 30, .34);
  }

  /* ── 3. 抽屉内恢复被窄屏隐藏 / 压扁的结构 ── */
  html body .app-shell .sidenav .brand-text,
  html body .app-shell .sidenav .side-label {
    display: inline !important;
  }
  /* 账号单独成块，好让「已登录」标题压在它上面（对齐参考图） */
  html body .app-shell .sidenav .admin-name {
    display: block !important;
    text-align: left;
    padding-left: 2px;
  }
  html body .app-shell .sidenav .side-foot .el-button:not(.is-circle) {
    display: inline-flex !important;
  }

  /* 品牌行：横排、左对齐、去掉窄屏的竖分隔线 */
  html body .app-shell .sidenav .side-brand {
    order: 0 !important;
    flex: 0 0 auto !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    padding: 6px 40px 14px 10px !important;
    margin: 0 0 4px !important;
    border-bottom: 1px solid var(--brd, rgba(15, 32, 51, .1)) !important;
    border-right: 0 !important;
    align-self: auto !important;
  }
  html body .app-shell .sidenav .side-brand .brand-text { font-size: 17px; }

  /* 菜单区：竖排、可换行、去掉窄屏的横滑与渐隐遮罩 */
  html body .app-shell .sidenav .side-pills {
    order: 0 !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    min-width: 0 !important;
    min-height: 0 !important;
    width: 100% !important;
    gap: 4px !important;
    padding: 0 !important;
    /* 菜单多时自己滚动，把底部「账号 / 退出」钉在抽屉底 */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    -webkit-mask-image: none !important;
    mask-image: none !important;
  }
  html body .app-shell .sidenav .side-group {
    display: block !important;
    padding: 12px 12px 4px !important;
    font-size: 12px;
  }
  html body .app-shell .sidenav .side-pills > .side-group:first-child { padding-top: 2px !important; }
  html body .app-shell .sidenav .side-link {
    flex: 0 0 auto !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    padding: 10px 12px !important;
    font-size: 15px;
    gap: 12px;
    border-radius: 10px;
  }
  html body .app-shell .sidenav .side-link .el-icon { font-size: 17px; }

  /* 底部：账号 + 退出竖排显示（窄屏曾把它改成横排并加左边框，这里改回来） */
  html body .app-shell .sidenav .side-foot {
    order: 0 !important;
    flex: 0 0 auto !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 8px;
    width: 100% !important;
    align-self: auto !important;
    padding: 12px 0 0 0 !important;
    border-left: 0 !important;
    border-top: 1px solid var(--brd, rgba(15, 32, 51, .1)) !important;
  }
  html body .app-shell .sidenav .side-tool {
    height: 36px;
    border-radius: 10px;
  }
  html body .app-shell .sidenav .admin-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink, #1b2431);
    padding-left: 2px;
  }
  html body .app-shell .sidenav .admin-name::before {
    content: "已登录";
    display: block;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: .04em;
    color: var(--ink-3, #8a94a0);
  }

  /* ── 4. 关闭按钮（抽屉右上角） ── */
  .mnav-close {
    display: inline-flex;
    position: absolute;
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: var(--surface-2, rgba(15, 32, 51, .06));
    color: var(--ink-2, #41505f);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mnav-close:active { transform: scale(.95); }

  /* ── 5. 遮罩 ── */
  .mnav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1190;
    background: rgba(8, 16, 30, .44);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
  }
  html.mnav-open .mnav-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  /* 抽屉展开时锁页面滚动，避免背景跟着滑 */
  html.mnav-open body { overflow: hidden; }
}

/* 尊重「减少动态效果」偏好 */
@media (prefers-reduced-motion: reduce) {
  .mnav-btn,
  .mnav-scrim,
  .app-shell > .sidenav,
  .mnav-close {
    transition: none !important;
  }
}
