/* ui-base.css — 按钮、头像、登录、左栏头部与菜单、会话列表项、空状态、对话顶栏（由 components.css 按顺序拆出，层叠顺序不变） */
/* ==========================================================
   components.css — 按钮、列表项、气泡、面板、设置控件、选择器
   ========================================================== */

/* ---------- 通用按钮 ---------- */
.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.sm { width: 36px; height: 36px; }
.icon-btn.on { color: var(--accent); }

.btn-primary {
  width: 100%; height: 52px;
  border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent);
  font-weight: 600; letter-spacing: .05em;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-text {
  height: 44px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--accent); font-size: 14px; border-radius: var(--radius-sm);
}
.btn-text .ti { font-size: 18px; }
.btn-text:hover { background: var(--accent-soft); }
.btn {
  height: 36px; padding: 0 14px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 14px;
  transition: background .15s, border-color .15s;
}
.btn .ti { font-size: 18px; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }

/* ---------- 头像 ---------- */
.avatar {
  position: relative;
  width: 54px; height: 54px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--avatar-radius);
  color: #fff; font-weight: 600; font-size: 20px;
  background: var(--c1);
}
.avatar.sm { width: 42px; height: 42px; font-size: 17px; }
.avatar.xs { width: 34px; height: 34px; font-size: 14px; }
.avatar.xl { width: 96px; height: 96px; font-size: 38px; }
.avatar .ti { font-size: 24px; }
.avatar.sm .ti, .avatar.xs .ti { font-size: 19px; }
.c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); }
.c4 { background: var(--c4); } .c5 { background: var(--c5); } .c6 { background: var(--c6); }
.c7 { background: var(--c7); }
.me-bg { background: var(--accent); }
.c2-text { color: var(--c2); } .c3-text { color: var(--c3); } .c4-text { color: var(--c4); }
.c6-text { color: var(--c6); }
.online-dot {
  position: absolute; right: 0; bottom: 0;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--online); border: 2px solid var(--bg);
}
:root[data-online="off"] .online-dot { display: none; }

/* ---------- 登录 ---------- */
.login-mark {
  width: 96px; height: 96px; margin: 0 auto 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent);
}
.login-mark .ti { font-size: 52px; }
.login h1 { font-size: 24px; font-weight: 600; margin-bottom: 8px; }
.login-desc { color: var(--text-2); font-size: 14px; margin-bottom: 28px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; color: var(--text-2); margin: 0 0 6px 2px; }
.field-input {
  width: 100%; height: 52px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); outline: none;
  transition: border-color .15s;
}
.field-input:focus { border-color: var(--accent); }
.check-row { display: flex; align-items: center; gap: 10px; margin: 4px 2px 24px; font-size: 14px; color: var(--text-2); }
.check-row input { width: 18px; height: 18px; margin: 0; }
.login-hint { font-size: 13px; color: var(--text-3); margin: -4px 0 20px; }
.login .btn-text { margin-top: 12px; }

/* ---------- 左栏头部 / 菜单 ---------- */
.side-head {
  position: relative;
  background: var(--side-head-bg);
  height: var(--head-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  padding: env(safe-area-inset-top) 10px 0 6px;
  box-sizing: content-box;
}
.search {
  flex: 1; height: 40px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  border: 1px solid transparent;
  color: var(--text-3);
}
.search:focus-within { border-color: var(--accent); background: var(--bg); }
.search .ti { font-size: 18px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 100%; color: var(--text); }
.search input::placeholder { color: var(--text-3); }

.menu {
  position: absolute; top: calc(var(--head-h) + env(safe-area-inset-top) - 4px); left: 8px; z-index: 50;
  min-width: 200px; padding: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
}
.menu.open { display: block; }
.menu button {
  width: 100%; height: 44px; padding: 0 12px;
  display: flex; align-items: center; gap: 14px;
  border-radius: var(--radius-sm); font-size: 14px;
}
.menu button .ti { font-size: 20px; color: var(--text-2); }
.menu button:hover { background: var(--bg-hover); }

/* ---------- 会话列表项 ---------- */
.chat-item {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--item-h);
  padding: 6px 8px;
  cursor: pointer;
  transition: background .12s;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item > .avatar { width: var(--item-avatar); height: var(--item-avatar); }
:root[data-density="compact"] .chat-item > .avatar { font-size: 17px; }
.ci-body { flex: 1; min-width: 0; }
.ci-row { display: flex; align-items: center; gap: 8px; }
.ci-row + .ci-row { margin-top: 3px; }
:root[data-density="compact"] .ci-row + .ci-row { margin-top: 0; }
.ci-name {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 4px;
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ci-type { font-size: 16px; color: var(--text-2); }
.ci-mute { font-size: 15px; color: var(--text-3); }
.ci-time { display: flex; align-items: center; gap: 3px; font-size: 12px; color: var(--text-2); flex-shrink: 0; }
.ci-time .ti { font-size: 16px; color: var(--accent); }
.ci-last { flex: 1; min-width: 0; color: var(--text-2); font-size: .934em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-last b { font-weight: 500; color: var(--text); }
.accent-text { color: var(--accent); }
.ci-pin { font-size: 17px; color: var(--text-3); transform: rotate(45deg); }
.badge {
  min-width: 22px; height: 22px; padding: 0 7px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px;
  background: var(--badge-bg); color: var(--badge-fg);
  font-size: 12px; font-weight: 600;
}
.chat-item.muted .badge { background: var(--badge-muted); }
:root[data-receipts="off"] .ci-time .ti { display: none; }

/* 选中：贴满列表宽度 */
.chat-item.active { background: var(--item-active-bg); }
.chat-item.active :is(.ci-name, .ci-last b, .accent-text) { color: var(--item-active-fg); }
.chat-item.active :is(.ci-last, .ci-time, .ci-time .ti, .ci-type, .ci-mute, .ci-pin) { color: var(--item-active-fg-2); }
.chat-item.active .badge { background: var(--item-active-fg); color: var(--item-active-bg); }

/* ---------- 空状态 ---------- */
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.empty-inner {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 24px;
  border-radius: var(--radius);
  background: var(--sys-bg); color: #fff;
}
.empty-inner .ti { font-size: 40px; opacity: .9; }
.empty-inner p { font-size: 14px; }

/* ---------- 对话顶栏 ---------- */
.chat-head {
  height: var(--head-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 4px;
  padding: env(safe-area-inset-top) 8px 0 12px;
  box-sizing: content-box;
  background: var(--head-bg); color: var(--head-fg);
  border-bottom: 1px solid var(--head-border);
}
.chat-head .icon-btn { color: var(--head-fg-2); }
.back-btn { display: none; }
.chat-title {
  flex: 1; min-width: 0; height: 48px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 6px; text-align: left;
  border-radius: var(--radius-sm);
}
.ct-text { display: flex; flex-direction: column; min-width: 0; }
.ct-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-sub { font-size: 13px; color: var(--head-fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-sub.online, .ct-sub.typing { color: var(--head-accent); }
.head-actions { display: flex; gap: 2px; }
