/* ============================================================
   Sidebar — left navigation rail (home page only)
   ============================================================ */

:root{
  --ai-sb-width: 264px;
  --ai-sb-bg: #ffffff;            /* white */
  --ai-sb-border: rgba(0,0,0,0.06);
  --ai-sb-hover: rgba(0,0,0,0.035);
  --ai-sb-soft:  rgba(0,0,0,0.045); /* secondary highlight (e.g. 首页) */
  --ai-sb-active: #F7F7F7;       /* primary active pill */
  --ai-sb-ink: #1d1d1f;
  --ai-sb-ink-2: #5a5a62;
  --ai-sb-ink-3: #9a9aa0;
  --ai-sb-badge-bg: #ececea;
  --ai-sb-badge-ink: #8a8a90;
  --ai-sb-serif: "Iowan Old Style", "Apple Garamond", "Baskerville", "Times New Roman", Georgia, serif;
}

.ai-sidebar{
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--ai-sb-width);
  /* sidebar 不在 .t4 作用域里，不会继承 .t4 *{ box-sizing: border-box }，默认是
     content-box —— width 264 + padding 14*2 + border 1 实际占 293px，比
     .ft-page 让出来的 padding-left (264) 多 29px，导致主内容区左侧被 sidebar
     盖掉。强制 border-box，让 width 就是总占位宽度。 */
  box-sizing: border-box;
  z-index: 20;
  background: var(--ai-sb-bg);
  border-right: 1px solid #e6e6e2;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", system-ui, sans-serif;
  letter-spacing: -0.005em;
  overflow: hidden;
  min-height: 0;
}

/* nav 区域可独立滚动，留住顶部 greeting 和底部 user/settings */
.ai-sb-nav{
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
.ai-sb-nav::-webkit-scrollbar{ width: 6px; }
.ai-sb-nav::-webkit-scrollbar-thumb{ background: rgba(0,0,0,0.08); border-radius: 4px; }

/* greeting */
.ai-sb-greeting{
  font-family: var(--ai-sb-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--ai-sb-ink);
  padding: 6px 10px 26px;
}
.ai-sb-logo{
  display: block;
  width: 100%;
  height: auto;
  max-width: 140px;
}

/* nav */
.ai-sb-nav{
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
/* 一个分类（含标题 + 子项列表）。is-collapsed 把子项整块藏起来。 */
.ai-sb-section{
  display: flex;
  flex-direction: column;
}
.ai-sb-section.is-collapsed .ai-sb-subnav{
  display: none;
}

/* 分类标题（社区 / 找工互助区 / 我的）—— 可点的折叠按钮。
   button 默认带 UA 样式（背景、边框、padding），全要重置。 */
.ai-sb-section-title{
  appearance: none;
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ai-sb-ink-3);
  letter-spacing: 0.02em;
  user-select: none;
  transition: color .15s ease;
}
.ai-sb-section-title:hover{ color: var(--ai-sb-ink-2); }
.ai-sb-section-title:focus-visible{
  outline: 2px solid rgba(0, 0, 0, 0.15);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ▼ 折叠箭头：展开 0deg，收起旋转 -90deg（指向右） */
.ai-sb-section-toggle{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  transition: transform .18s ease;
}
.ai-sb-section-toggle svg{ width: 100%; height: 100%; }
.ai-sb-section.is-collapsed .ai-sb-section-toggle{
  transform: rotate(-90deg);
}

/* sub nav */
.ai-sb-subnav{
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0 4px;
  margin-left: 0;
}

/* 叶子项的容器（02 方案里 leaf 用，比 .ai-sb-subnav 更紧凑）。
   - padding 极小：相邻 leaf（如 社区 + profile）贴紧
   - 后面紧跟 .ai-sb-section 时加 margin-top：跟下面的分类拉开呼吸 */
.ai-sb-flat{
  display: flex;
  flex-direction: column;
  padding: 2px 0;
}
.ai-sb-flat + .ai-sb-section{
  margin-top: 10px;
}
/* 反向：section 后面跟 leaf（03 方案里 profile 在找工互助区下方）也加同样的呼吸 */
.ai-sb-section + .ai-sb-flat{
  margin-top: 10px;
}
.ai-sb-sub{
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  /* 左 padding=14px 让 emoji 起点与分类标题文字大致对齐；right padding 留 badge 呼吸 */
  padding: 0 12px 0 14px;
  border-radius: 8px;
  /* 未激活态：用 ink-2（中灰），跟「通知/设置」一致；图标 opacity 配合 */
  color: var(--ai-sb-ink-2);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

/* 子项前的 SVG 图标。未激活态 opacity 让黑色 stroke 跟 ink-2 文字搭配协调；
   hover / 激活态恢复不透明，跟深色文字一起强调"被选中"。 */
.ai-sb-icon-img{
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity .15s ease;
}
.ai-sb-sub:hover .ai-sb-icon-img,
.ai-sb-sub.is-active .ai-sb-icon-img{
  opacity: 1;
}
.ai-sb-avatar-img{
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
}
.ai-sb-sub:hover{
  background: var(--ai-sb-soft);
  color: var(--ai-sb-ink);
}
/* secondary / current-trail state (e.g. 首页 in screenshot) */
.ai-sb-sub.is-current{
  background: var(--ai-sb-soft);
  color: var(--ai-sb-ink);
  font-weight: 400;
}
/* primary active state */
.ai-sb-sub.is-active{
  background: var(--ai-sb-active);
  color: var(--ai-sb-ink);
  font-weight: 600;
}
.ai-sb-sub .ai-sb-label{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 激活态在文案后追加一个蓝色感叹号，跟 Bonjour! logo 的视觉呼应。
   用 ::after 伪元素而不是 JSX：纯装饰，无需进 DOM 也不影响无障碍朗读。 */
.ai-sb-sub.is-active .ai-sb-label::after{
  content: "！";
  margin-left: 2px;
  color: #007aff;
  font-weight: 700;
}
.ai-sb-sub .ai-sb-badge{
  /* margin-left:auto 把 badge 推到行尾，避免依赖父元素 space-between */
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
  color: var(--ai-sb-badge-ink);
  background: rgba(0,0,0,0.05);
  padding: 4px 9px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

/* footer block */
.ai-sb-footer{
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-sb-settings{
  display: flex;
  align-items: center;
  gap: 12px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ai-sb-ink-2);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.ai-sb-settings:hover{ background: var(--ai-sb-hover); color: var(--ai-sb-ink); }
.ai-sb-settings .ai-sb-icon{ width: 16px; height: 16px; color: var(--ai-sb-ink-3); }
.ai-sb-settings .ai-sb-icon svg{ width:100%; height:100%; }
/* footer 用静态 SVG，尺寸与原先 inline svg 一致（16px） */
.ai-sb-settings .ai-sb-footer-icon{
  width: 16px;
  height: 16px;
  opacity: 0.55;
}
.ai-sb-settings:hover .ai-sb-footer-icon{
  opacity: 1;
}

/* ============================================================
   Layout adjustments — only when sidebar is mounted
   ============================================================ */
.ai-has-sidebar.ft-page{
  padding-left: var(--ai-sb-width);
}
.ai-has-sidebar .ft-header{
  left: var(--ai-sb-width);
}

/* ============================================================
   Mobile drawer trigger / backdrop / close button
   桌面端全部 display:none，仅 < 900px 媒体查询里启用。
   ============================================================ */
.ai-sb-mobile-trigger{ display: none; }
.ai-sb-close-mobile{ display: none; }
.ai-sb-backdrop{ display: none; }

@media (max-width: 900px){
  /* 内容区不再为 sidebar 让出左 padding，因为 sidebar 改为浮层覆盖 */
  .ai-has-sidebar.ft-page{ padding-left: 0; }
  .ai-has-sidebar .ft-header{ left: 0; }

  /* sidebar 改为抽屉：默认滑出屏幕左侧，加 .is-mobile-open 滑入。
     宽度限制最大 85vw，超窄屏（如 iPhone SE 320px）也能露出右边一点点内容。
     z-index 比 backdrop 高一档，确保盖在遮罩之上。 */
  .ai-sidebar{
    display: flex;
    width: min(var(--ai-sb-width), 85vw);
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 30;
  }
  .ai-sidebar.is-mobile-open{
    transform: translateX(0);
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.12);
  }

  /* 汉堡触发按钮：左上角固定，sidebar 关闭时露出。
     z-index 比 sidebar 低，sidebar 滑出时会盖住它（视觉上"按钮被抽屉接管"）。 */
  .ai-sb-mobile-trigger{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 10px;
    left: 10px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid var(--ai-sb-border);
    color: var(--ai-sb-ink);
    cursor: pointer;
    z-index: 25;
    padding: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  }
  .ai-sb-mobile-trigger:active{
    background: var(--ai-sb-hover);
  }
  .ai-sb-mobile-trigger svg{
    width: 20px;
    height: 20px;
  }

  /* sidebar 内部右上角的关闭 X 按钮 */
  .ai-sb-close-mobile{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 14px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 0;
    background: transparent;
    color: var(--ai-sb-ink-2);
    cursor: pointer;
    border-radius: 8px;
    padding: 0;
  }
  .ai-sb-close-mobile:hover{
    background: var(--ai-sb-hover);
    color: var(--ai-sb-ink);
  }
  .ai-sb-close-mobile svg{
    width: 18px;
    height: 18px;
  }

  /* 半透明遮罩：抽屉打开时铺满屏幕，点击关闭。
     默认 opacity:0 + pointer-events:none，is-open 时淡入并可点。 */
  .ai-sb-backdrop{
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    z-index: 28;
  }
  .ai-sb-backdrop.is-open{
    opacity: 1;
    pointer-events: auto;
  }
}
