/* =========================================================
   历史对话侧栏（PC 常驻 / 移动端抽屉）
   ========================================================= */

/* 聊天两栏：历史(272) + 主区（右侧员工说明面板已按用户要求移除 2026-09-16） */
.chat-layout.pro { grid-template-columns: 272px minmax(0, 1fr); }
.chat-layout.pro.hist-collapsed { grid-template-columns: 54px minmax(0, 1fr); }

.history-aside {
  background: #f6f8f5;
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

/* —— 头部 —— */
.history-aside .ha-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.history-aside .ha-head h3 { font-size: 13px; margin: 0; letter-spacing: -.01em; }
.ha-collapse {
  width: 26px; height: 26px; flex: none; border: 1px solid var(--line);
  background: #fff; border-radius: 7px; color: #6c7a73; font-size: 13px; line-height: 1;
  display: grid; place-items: center;
}
.ha-collapse:hover { color: var(--green); border-color: #cad7ce; }

/* —— 新建对话 —— */
.ha-new {
  height: 38px; border: 0; border-radius: 9px; background: var(--green); color: #fff;
  font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 6px 14px rgba(18, 60, 47, .16);
}
.ha-new span { font-size: 15px; line-height: 1; }
.ha-new:hover { background: #17513f; }

/* —— 搜索 —— */
.ha-search { position: relative; }
.ha-search input {
  width: 100%; height: 34px; border: 1px solid #dce3dc; background: #fff;
  border-radius: 8px; padding: 0 10px; font-size: 11px; outline: 0;
}
.ha-search input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(18, 60, 47, .06); }

/* —— 筛选 —— */
.ha-filter { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; padding-bottom: 1px; }
.ha-filter::-webkit-scrollbar { display: none; }
.ha-filter button {
  flex: none; border: 1px solid var(--line); background: #fff; color: #6b7770;
  border-radius: 20px; padding: 5px 9px; font-size: 9px; white-space: nowrap;
}
.ha-filter button.on { background: var(--mint); border-color: #bdd8cd; color: var(--green); font-weight: 700; }

/* —— 列表 —— */
.ha-list { flex: 1; overflow: auto; margin: 0 -4px; padding: 0 4px; }
.ha-list::-webkit-scrollbar { width: 4px; }
.ha-list::-webkit-scrollbar-thumb { background: #d5ded7; border-radius: 4px; }
.ha-group { font-size: 9px; color: #9aa39e; letter-spacing: .1em; padding: 12px 6px 5px; }
.ha-group:first-child { padding-top: 2px; }

.ha-item {
  position: relative; display: flex; align-items: center; gap: 6px;
  border-radius: 9px; padding: 9px 8px; margin: 2px 0; cursor: pointer; transition: .15s;
}
.ha-item:hover { background: #ecf1ed; }
.ha-item.active { background: #e3ede7; }
.ha-item.active:before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--green);
}
.ha-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ha-item-main b {
  font-size: 12px; font-weight: 600; color: #24312b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ha-item-main small {
  font-size: 9px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ha-pin { font-style: normal; font-size: 8px; background: var(--green); color: #fff; border-radius: 3px; padding: 1px 3px; margin-right: 4px; }
.ha-fav { font-style: normal; color: #e0a02a; margin-right: 3px; }
.ha-time { font-size: 9px; color: #a4ada8; flex: none; }
.ha-more {
  width: 20px; height: 20px; flex: none; border: 0; background: transparent;
  color: #97a29c; border-radius: 5px; font-size: 13px; line-height: 1; opacity: 0;
}
.ha-item:hover .ha-more, .ha-item.active .ha-more { opacity: 1; }
.ha-more:hover { background: #dae4dd; color: var(--green); }

.ha-menu {
  position: absolute; right: 6px; top: 32px; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 12px 28px rgba(18, 60, 47, .14); padding: 4px; min-width: 108px;
  display: flex; flex-direction: column;
}
.ha-menu button {
  border: 0; background: transparent; text-align: left; font-size: 11px;
  color: #46534d; padding: 7px 9px; border-radius: 6px;
}
.ha-menu button:hover { background: #f0f4f1; }
.ha-menu button.danger { color: var(--wine); }
.ha-menu button.danger:hover { background: #fbeef2; }

.ha-empty { font-size: 10px; color: #9aa39e; line-height: 1.8; padding: 22px 8px; text-align: center; }

/* —— PC 收起态 —— */
.history-aside.collapsed { padding: 14px 8px; align-items: center; }
.history-aside.collapsed .ha-head h3,
.history-aside.collapsed .ha-search,
.history-aside.collapsed .ha-filter,
.history-aside.collapsed .ha-list,
.history-aside.collapsed .ha-new span + * { display: none; }
.history-aside.collapsed .ha-new { width: 38px; padding: 0; }
.history-aside.collapsed .ha-new { font-size: 0; }
.history-aside.collapsed .ha-new span { font-size: 17px; }

/* —— 聊天头部按钮 —— */
.chat-hist-btn {
  display: none; width: 34px; height: 34px; flex: none; border: 1px solid var(--line);
  background: #fff; border-radius: 9px; color: #4a5b53; align-items: center; justify-content: center;
}
.chat-new-btn { font-size: 16px; line-height: 1; padding: 0 12px; }

/* —— 遮罩（移动端抽屉用） —— */
.ha-mask {
  position: fixed; inset: 0; background: rgba(11, 26, 21, .42);
  z-index: 39; opacity: 0; pointer-events: none; transition: .2s;
}
.ha-mask.show { opacity: 1; pointer-events: auto; }

/* =========================================================
   ≤1023px（平板 + 手机）：历史侧栏变抽屉
   ========================================================= */
@media (max-width: 1023px) {
  .chat-layout.pro,
  .chat-layout.pro.hist-collapsed { grid-template-columns: minmax(0, 1fr); }

  .chat-hist-btn { display: inline-flex; }

  .history-aside {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: min(78vw, 288px); max-width: 288px;
    transform: translateX(-104%); transition: transform .24s cubic-bezier(.4, 0, .2, 1);
    z-index: 40; box-shadow: 0 20px 50px rgba(18, 60, 47, .18);
    border-right: 1px solid var(--line); background: #f6f8f5;
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .history-aside.drawer-open { transform: translateX(0); }
  .history-aside.collapsed { padding: 14px 12px; align-items: stretch; }
  .history-aside.collapsed .ha-head h3,
  .history-aside.collapsed .ha-search,
  .history-aside.collapsed .ha-filter,
  .history-aside.collapsed .ha-list { display: block; }
  .history-aside.collapsed .ha-filter { display: flex; }
  .history-aside.collapsed .ha-list { display: block; }
  .history-aside.collapsed .ha-new { width: auto; font-size: 12px; }

  .ha-more { opacity: 1; }
  .ha-item { padding: 11px 8px; }
  .ha-item-main b { font-size: 13px; }
}
