/* ===== 拆分自 dark-mode.css（第 3 部分，原第 929-1261 行）—— 必须紧跟在上一部分之后按序加载，顺序影响层叠结果 ===== */
/* ===================================
   三栏布局（仅暗色模式生效）
   结构：左侧栏 240px + 主内容 + 右侧栏 288px
   响应式：<1280 隐右栏；<992 折叠左栏 + 显示底部 TabBar
   =================================== */
[data-theme="dark"] .tuquan-layout {
  display: block;
  min-height: 100vh;
  background: var(--bg-primary);
}

[data-theme="dark"] .sidebar-left {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100vh;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: var(--z-chrome);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  transition: transform 0.3s ease;
}
/* 与顶栏 .site-topbar .navbar-brand 保持完全一致（同一组品牌变量 + 同一字体） */
[data-theme="dark"] .sidebar-left .sidebar-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 10px;
  color: var(--text-primary);
  font-family: 'TQ Brand Title', 'Resource Han Rounded CN', var(--font-family-base);
  font-weight: 400;
  font-size: var(--topbar-brand-font-size);
  line-height: var(--topbar-brand-logo-size);
  white-space: nowrap;
  text-decoration: none;
}
[data-theme="dark"] .sidebar-left .sidebar-logo img {
  display: block;
  flex: none;
  width: var(--topbar-brand-logo-size);
  height: var(--topbar-brand-logo-size);
}
[data-theme="dark"] .sidebar-left .sidebar-logo:hover {
  color: var(--primary-color);
}
[data-theme="dark"] .sidebar-left .nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 12px 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
[data-theme="dark"] .sidebar-left .nav-link-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  margin: 1px 0;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
[data-theme="dark"] .sidebar-left .nav-link-item i {
  width: 20px;
  text-align: center;
  font-size: 0.9rem;
}
[data-theme="dark"] .sidebar-left .nav-link-item:hover {
  background: rgba(124, 58, 237, 0.12);
  color: var(--text-primary);
  transform: translateX(2px);
}
[data-theme="dark"] .sidebar-left .nav-link-item.active {
  background: var(--gift-gradient);
  color: #fff;
  box-shadow: 0 0.25rem 0.75rem rgba(124, 58, 237, 0.25);
}
[data-theme="dark"] .sidebar-left .nav-link-item .badge {
  margin-left: auto;
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger-color);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
}
[data-theme="dark"] .sidebar-left .sidebar-user {
  margin-top: auto;
  padding: 8px 12px;
  border-top: 1px solid var(--border-divider);
  display: flex;
  align-items: center;
  gap: 10px;
}
[data-theme="dark"] .sidebar-left .sidebar-user .avatar-wrap {
  position: relative;
}
/* 只约束头像本体，不能命中 avatar-decoration.js 注入的框图层 <img class="avatar-deco-frame">：
   框图层需要由脚本按孔位设置尺寸，若被 32px 强制覆盖会缩在左上角、与头像错位。 */
[data-theme="dark"] .sidebar-left .sidebar-user .avatar-wrap > img,
[data-theme="dark"] .sidebar-left .sidebar-user .avatar-wrap .avatar-deco > .avatar-deco-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

/* 桌面布局下的主内容偏移（右栏已移除：左 240 + 内容自适应） */
[data-theme="dark"] .main-content-three-col {
  padding-left: 240px;
  padding-right: 0;
  padding-top: 0;
  min-height: 100vh;
  background: var(--bg-primary);
}
/* 桌面（≥992px，Bootstrap lg）三栏下隐藏原顶栏（功能合并到左侧栏） */
@media (min-width: 992px) {
  [data-theme="dark"] body.has-three-col .site-topbar {
    display: none;
  }
}

/* 手机版极简头部导航栏：默认隐藏（桌面端及白名单页面不显示）。
   返回按钮是栏内子元素，栏隐藏时按钮一并隐藏。 */
[data-theme="dark"] .mobile-minimal-head { display: none; }

/* <992 折叠左栏 + 显示底部 TabBar（与 Bootstrap lg 断点对齐） */
@media (max-width: 991.98px) {
  [data-theme="dark"] .sidebar-left {
    transform: translateX(-100%);
    z-index: var(--z-overlay, 1035);
  }
  [data-theme="dark"] .sidebar-left.is-open {
    transform: translateX(0);
    box-shadow: 0 0 2rem rgba(0, 0, 0, 0.5);
  }
  /* 侧栏遮罩层 */
  [data-theme="dark"] .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-chrome, 1030);
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  [data-theme="dark"] .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }
  [data-theme="dark"] .main-content-three-col {
    padding-left: 0;
    /* 手机端顶栏（sticky，占据文档流）与底部 TabBar 各占一段高度，
       基样的 min-height:100vh 会让主内容区在两段 chrome 之外再补足一整个视口，
       内容偏短的页面（如 /u/ 个人主页）因此会在卡片与页脚之间留下大片空白。
       这里改为只撑到顶栏与底部 TabBar 之间；背景仍由 .tuquan-layout 的 100vh 兜住。 */
    min-height: calc(100vh - var(--chrome-top) - var(--chrome-bottom));
  }
  [data-theme="dark"] body.has-three-col .site-topbar {
    display: block;
  }
  /* 手机端个人中心（/user 及其子页面，layouts/user.php 会加 body.user-center）不显示顶栏：
     导航出口由 .uc-mobile-head 返回条、/user 首页的设置式列表与侧栏「返回首页」承载。
     --chrome-top 同步清零，避免引用该变量算高度的区块（如侧栏 max-height）留下顶栏空白。 */
  [data-theme="dark"] body.user-center {
    --chrome-top: 0px;
    /* 基样 style.css 给 body 设了 min-height:100vh，而 main{flex:1 1 auto} 会把这段高度全部撑开。
       个人中心子页（如 /user/coins 我的钱包）内容不足一屏时，最后一张卡片下方就会留下
       一整屏可滚动的空白。这里取消该地板，让页面高度回归内容本身；
       html 无背景，body 背景仍会传播到画布，短页下方不会露白。 */
    min-height: 0;
  }
  [data-theme="dark"] body.user-center .site-topbar {
    display: none !important;
  }
  /* 抽屉侧栏里不再重复展示底部 TabBar 已有的入口 */
  [data-theme="dark"] .sidebar-left .nav-link-item.is-mobile-tab {
    display: none;
  }
  /* 底部 TabBar：玻璃拟态 */
  [data-theme="dark"] .mobile-tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(22px) saturate(1.4);
    -webkit-backdrop-filter: blur(22px) saturate(1.4);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    z-index: var(--z-chrome);
  }
  [data-theme="dark"] .mobile-tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative; /* 未读角标的定位基准 */
    color: var(--text-muted);
    font-size: 11px;
    text-decoration: none;
    gap: 2px;
  }
  [data-theme="dark"] .mobile-tabbar a i {
    font-size: 1.1rem;
  }
  /* 「消息」tab 的未读角标：私信未读 + 好友申请 + 通知未读（手机端通知只在消息页内可达），
     节点常驻，由 main.php 输出、notification-polling.js 按 .js-tabbar-unread-badge 写值与 hidden */
  [data-theme="dark"] .mobile-tabbar .js-tabbar-unread-badge {
    position: absolute;
    top: 4px;
    left: calc(50% + 4px);
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 8px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 15px;
    text-align: center;
    pointer-events: none;
  }
  [data-theme="dark"] .mobile-tabbar a.active {
    color: var(--primary-color);
  }
  /* 手机端不再显示页脚（友情链接 / 联系我们 / 版权），底部只保留 TabBar。
     唯一例外是未登录落地页（body.lp-page），它没有 TabBar，页脚仍要展示。
     原先避让 TabBar 的 56px 间距加在 footer 上，footer 隐藏后改由布局容器兜底，
     否则最后一屏内容会被固定的 TabBar 盖住。 */
  [data-theme="dark"] body:not(.lp-page) .site-footer {
    display: none;
  }
  [data-theme="dark"] body:not(.lp-page):not(.mobile-minimal-chrome) .tuquan-layout {
    padding-bottom: var(--chrome-bottom, 56px);
  }

  /* 手机版极简头部：白名单外页面隐藏顶栏与底部 TabBar，仅保留左上角返回按钮 */
  [data-theme="dark"] body.mobile-minimal-chrome .site-topbar,
  [data-theme="dark"] body.mobile-minimal-chrome .mobile-tabbar {
    display: none !important;
  }
  /* 极简头部导航栏：私信会话头（.tq-chat-head）同款形态——
     返回箭头嵌在栏内左侧、页面标题居中、右侧等宽占位保证标题真正居中。
     sticky 占文档流顶部（非悬浮），不遮挡页面原有内容。 */
  [data-theme="dark"] body.mobile-minimal-chrome .mobile-minimal-head {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: var(--z-chrome, 1030);
    height: 48px;
    padding: 0 8px;
    border-bottom: 1px solid var(--border-divider, #3a2f45);
    /* 不透明底色 + 下边框：sticky 贴顶时下方滚过的内容不会透出来形成叠字 */
    background: var(--bg-primary);
  }
  /* 房间详情页（/room/{id}）头部自带「返回房间列表」按钮，不显示顶部嵌入式返回栏。
     body.mobile-minimal-head-hidden 由 main.php 直出、main.js 软导航时同步。 */
  [data-theme="dark"] body.mobile-minimal-head-hidden .mobile-minimal-head {
    display: none !important;
  }
  [data-theme="dark"] body.mobile-minimal-chrome .mobile-minimal-title {
    min-width: 0;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary, #f4f4f5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 6px;
  }
  [data-theme="dark"] body.mobile-minimal-chrome .mobile-minimal-head-spacer {
    width: 40px;
    height: 40px;
  }
  /* 返回箭头嵌在左列：沿用 .tq-page-back 圆形透明态，与私信头一致 */
  [data-theme="dark"] body.mobile-minimal-chrome .mobile-minimal-back {
    display: inline-flex;
    justify-self: start;
  }
  /* 帖子详情页内容区的标题头部：顶部导航栏已显示同一标题，
     极简模式下隐藏内容区这份，避免重复（桌面端 ≥992px 不在本媒体查询内，不受影响） */
  [data-theme="dark"] body.mobile-minimal-chrome .post-title-head {
    display: none;
  }
  /* 其他页面内容区的标题头部：极简头部已显示页面名称，
     内容区再显示一遍就是重复，统一隐藏 */
  [data-theme="dark"] body.mobile-minimal-chrome .tq-page-head {
    display: none;
  }
}
@media (min-width: 992px) {
  [data-theme="dark"] .mobile-tabbar { display: none; }
}

/* ===================================
   全站页脚定位：始终位于所有栏目内容之下
   ≥992px 桌面端：左栏 + 主内容包在 .layout-main-row 中并改为两列 grid；
   左栏由 fixed 改为 sticky：滚动时跟随视口，sticky 约束边界为行容器，
   因此滚到底部时左栏停在 footer 上方，绝不与页脚重叠；footer 在行容器之外整宽展示
   =================================== */
@media (min-width: 992px) {
  [data-theme="dark"] .layout-main-row {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: start;
  }
  [data-theme="dark"] .sidebar-left {
    position: sticky;
    top: 0;
    left: auto;
  }
  [data-theme="dark"] .main-content-three-col {
    padding-left: 0;
    padding-right: 0;
  }
}

