/* ============================================================
   FLMC 左侧边栏样式（还原原站 gr CSS Module 结构）
   结构：顶部用户触发器 / 主导航 / 在线用户 / Discord / 底部用户区
   ============================================================ */

/* ---------- 布局容器 ---------- */
.sb-shell {
  display: flex;
  min-height: 100vh;
}

.sb-sidebar {
  flex: 0 0 248px;
  width: 248px;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}

.sb-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶部：品牌 + 新建 ---------- */
.sb-top {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.sb-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sb-brand svg {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.sb-brand em {
  font-style: normal;
  color: var(--accent);
}

.sb-new-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 600;
  color: #0e1519;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-radius: 9px;
  padding: 9px 0;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.sb-new-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

/* ---------- 主导航（还原 navRow） ---------- */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sb-nav-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 14px 10px 6px;
}

.sb-nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  padding: 9px 10px;
  border-radius: 8px;
  transition: color var(--dur), background var(--dur);
  cursor: pointer;
  text-decoration: none;
}

.sb-nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.sb-nav-link.active {
  color: var(--text);
  background: var(--accent-glow);
}

.sb-nav-link.active .sb-nav-ico {
  color: var(--accent);
}

.sb-nav-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-faint);
  transition: color var(--dur);
}

.sb-nav-link:hover .sb-nav-ico {
  color: var(--text-dim);
}

/* 在线用户区（还原 onlineSection） */
.sb-online {
  padding: 4px 10px 6px;
}

.sb-online-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px;
}

.sb-online-user {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 7px;
}

.sb-online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

/* ---------- 底部：Discord + 语言 + 用户区 ---------- */
.sb-bottom {
  border-top: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sb-row {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: color var(--dur), background var(--dur);
  text-decoration: none;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
}

.sb-row:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.sb-row .sb-nav-ico {
  color: var(--text-faint);
}

.sb-row:hover .sb-nav-ico {
  color: var(--text-dim);
}

.sb-row-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* 用户触发器（还原 triggerRow + avatar + inlineCredits） */
.sb-user-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  margin-top: 4px;
  border-radius: 9px;
  cursor: pointer;
  transition: background var(--dur);
  position: relative;
}

.sb-user-trigger:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #0e1519;
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
}

.sb-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sb-user-text {
  flex: 1;
  min-width: 0;
}

.sb-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-user-email {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 积分按钮（还原 inlineCreditsButton + creditsDot） */
.sb-credits {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 11px;
  cursor: pointer;
  transition: all var(--dur);
  white-space: nowrap;
}

.sb-credits:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sb-credits-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f9634e;
  box-shadow: 0 0 6px rgba(249, 99, 78, 0.6);
  flex-shrink: 0;
}

/* 用户下拉菜单 */
.sb-user-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 10px;
  right: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  padding: 6px;
  display: none;
  z-index: 60;
}

.sb-user-menu.open {
  display: block;
  animation: pop-in 0.22s var(--ease);
}

.sb-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.sb-menu-head .sb-avatar {
  width: 38px;
  height: 38px;
  font-size: 15px;
}

.sb-menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  transition: color var(--dur), background var(--dur);
}

.sb-menu-row:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.sb-menu-row.danger {
  color: var(--danger);
}

.sb-menu-row.danger:hover {
  background: rgba(248, 113, 113, 0.08);
}

.sb-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* 语言下拉 */
.sb-lang-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 10px;
  right: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  padding: 6px;
  display: none;
  z-index: 60;
}

.sb-lang-menu.open {
  display: block;
  animation: pop-in 0.22s var(--ease);
}

.sb-lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--dur);
}

.sb-lang-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.sb-lang-item.active {
  color: var(--accent);
}

/* ---------- 响应式：窄屏折叠为顶部图标栏 ---------- */
@media (max-width: 900px) {
  .sb-sidebar {
    flex-basis: 64px;
    width: 64px;
  }
  .sb-nav-label,
  .sb-nav-link span:not(.sb-nav-ico),
  .sb-online-header,
  .sb-online-user span,
  .sb-row span,
  .sb-user-text,
  .sb-credits,
  .sb-brand span {
    display: none;
  }
  .sb-brand {
    justify-content: center;
    padding: 7px;
    min-width: 36px;
    min-height: 36px;
  }
  .sb-nav-link,
  .sb-row,
  .sb-user-trigger {
    justify-content: center;
    padding: 10px;
  }
  .sb-new-btn span {
    display: none;
  }
  .sb-user-menu,
  .sb-lang-menu {
    left: 66px;
    right: auto;
    min-width: 200px;
    bottom: 10px;
  }
}

/* 顶部导航用户头像已移到 style.css（定价/文档/关于页不加载本文件，
   头像会退化成 17px 的裸按钮） */

/* ---------- 通用右侧悬浮 AI 助手：首页 / 工作区 ---------- */
.surface-assist {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  width: 300px;
  max-height: 70vh;
  /* 2026-09-19：允许用户在右下角自由拖大/拖小（原来写死 300px 拉不动） */
  resize: both;
  min-width: 280px;
  min-height: 260px;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.surface-assist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}

.surface-assist-head h2 {
  font-size: 14px;
  font-weight: 700;
}

.surface-assist-head p {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 1px;
}

.surface-assist-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
  flex-shrink: 0;
}

.surface-assist-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
}

.surface-assist-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 8px;
  min-height: 60px;
}

.surface-assist-msg {
  font-size: 12.5px;
  line-height: 1.6;
  padding: 8px 11px;
  border-radius: 10px;
  margin-bottom: 8px;
  max-width: 92%;
}

.surface-assist-msg.user {
  margin-left: auto;
  background: var(--accent);
  color: #0e1519;
}

.surface-assist-msg.bot {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

.surface-assist-input {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}

.surface-assist-input textarea {
  flex: 1;
  resize: vertical;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
  max-height: 90px;
}

.surface-assist-input textarea:focus {
  border-color: var(--accent);
}

/* ============================================================
   右侧悬浮 AI 助手 · 收起/展开状态机
   目的：助手面板永远不遮挡页面主操作按钮（此前 1500px 以下会被
   position:static 甩到页脚之后，1500px 以上又会盖住首页发送按钮）。
   html[data-assist] 四种取值：
     wide           宽屏常驻浮窗（≥1560px），主内容右侧预留安全带
     narrow-closed  收起为右下角胶囊按钮（窄屏默认 / 宽屏手动关闭）
     narrow-open    展开为右下角抽屉（窄屏，点击外部可关闭）
     （未设置）      页面没有助手面板，不做任何干预
============================================================ */

/* ============================================================
   左侧栏窄屏自动收起
   页面内容左边界统一在
   30~35px，说明原站窄屏下不显示左栏（只保留顶部导航）。
   这里在 ≤1279px 时把左栏收起为左下角圆钮抽屉，宽屏仍常驻。
   ============================================================ */
.sb-toggle {
  display: none;
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 97;
  height: 40px;
  padding: 0 14px 0 10px;
  gap: 7px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  transition: transform var(--dur) var(--ease), background var(--dur);
}

.sb-toggle:hover {
  background: var(--btn-fill-hover);
  transform: translateY(-1px);
}

.sb-toggle svg { width: 18px; height: 18px; }
.sb-toggle-label { line-height: 1; }

.sb-toggle svg {
  width: 20px;
  height: 20px;
}

.sb-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 109;
  background: rgba(0, 0, 0, 0.5);
}

/* 左栏自动收起阈值：2026-09-13 由 1279px 下调到 1079px。
   原因：1200~1279px 的普通笔记本窗口此前会把左栏藏起来，用户会以为"菜单没了"。 */
@media (max-width: 1079px) {
  .sb-sidebar {
    display: none;
  }

  .sb-toggle {
    display: inline-flex;
  }

  body.sb-drawer .sb-sidebar {
    display: flex;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 110;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
  }

  body.sb-drawer .sb-backdrop {
    display: block;
  }
}

/* 右下角胶囊开关 */
.assist-toggle {
  display: none;
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 97;
  width: 44px;
  height: 44px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--accent);
  cursor: pointer;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  transition: transform var(--dur) var(--ease), border-color var(--dur), background var(--dur);
}

.assist-toggle:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.assist-toggle-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
  border: 2px solid var(--bg-elev);
}

.assist-toggle svg {
  width: 20px;
  height: 20px;
}

/* 展开态的透明遮罩（点击任意处收起） */
.assist-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 96;
  background: rgba(0, 0, 0, 0.28);
}

/* 面板内的收起按钮 */
.assist-close {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--dur);
}

.assist-close:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- 收起态 ---------- */
html[data-assist="narrow-closed"] .assist-toggle {
  display: inline-flex;
}

html[data-assist="narrow-closed"] .surface-assist,
html[data-assist="narrow-closed"] .tv-assist {
  display: none;
}

/* ---------- 窄屏展开态（右下抽屉） ---------- */
html[data-assist="narrow-open"] .assist-toggle {
  display: inline-flex;
}

html[data-assist="narrow-open"] .assist-backdrop {
  display: block;
}

html[data-assist="narrow-open"] .surface-assist,
html[data-assist="narrow-open"] .tv-assist {
  position: fixed;
  right: 12px;
  top: auto;
  bottom: 76px;
  transform: none;
  width: min(340px, calc(100vw - 24px));
  max-height: min(62vh, 540px);
  margin: 0;
  z-index: 98;
}

/* ---------- 宽屏常驻态：主内容预留安全带，彻底避免压住按钮 ---------- */
html[data-assist="wide"] .assist-toggle {
  display: none;
}

@media (min-width: 1560px) {
  html[data-assist="wide"] .sb-main {
    padding-right: 336px;
  }
}
