/* =========================================================
   Echat 用户端样式
   主色 #5e6ad2，圆角 + 柔和阴影，支持浅色/深色双主题
   ========================================================= */

:root {
  --primary: #5e6ad2;
  --primary-dark: #4c58bd;
  --primary-soft: #eef0fb;
  --danger: #e0483b;
  --danger-soft: #fdecea;
  --success: #24a148;
  --warn: #d98521;

  --bg: #f6f7f9;
  --bg-panel: #ffffff;
  --bg-hover: #f2f3f5;
  --bg-subtle: #fafbfc;
  --border: #e6e8eb;
  --text: #1d1d1f;
  --text-sub: #6b6f76;
  --text-mute: #9aa0a6;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .10);
  --radius: 12px;
  --sidebar-w: 68px;
  --panel-w: 300px;
}

[data-theme="dark"] {
  --primary: #7c86e8;
  --primary-dark: #5e6ad2;
  --primary-soft: #24263a;
  --bg: #17181c;
  --bg-panel: #1f2126;
  --bg-hover: #262931;
  --bg-subtle: #1b1d22;
  --border: #2e3138;
  --text: #e6e7ea;
  --text-sub: #a2a8b3;
  --text-mute: #71767f;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select, button { outline: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 布局骨架 ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 10px;
  position: sticky; top: 0; height: 100vh;
  z-index: 20;
}
.sidebar-logo img { width: 34px; height: 34px; border-radius: 9px; margin-bottom: 18px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); width: 80%; align-items: center; }

.nav-item {
  position: relative; width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-sub); transition: background .15s, color .15s;
}
.nav-item .icon { font-size: 20px; line-height: 1; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.nav-item .dot {
  position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff; border-radius: 8px; font-size: 10px;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}

.main { flex: 1; min-width: 0; padding: 0; }
.main-plain { padding: 0; }

/* 三栏：会话列表 + 内容 */
.two-col { display: flex; height: 100vh; overflow: hidden; }
.col-list {
  width: var(--panel-w); flex: none; background: var(--bg-panel);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  overflow: hidden;
}
.col-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

.col-head {
  height: 56px; flex: none; padding: 0 14px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border); font-weight: 600;
}
.col-head .spacer { flex: 1; }
.col-body { flex: 1; overflow-y: auto; }
.col-foot { flex: none; border-top: 1px solid var(--border); padding: 10px 14px; background: var(--bg-panel); }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg-panel); color: var(--text); cursor: pointer;
  font-size: 13px; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-sub); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.input, .textarea, .select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--bg-panel); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(94, 106, 210, .13);
}
.textarea { min-height: 90px; resize: vertical; }
.form-row { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; color: var(--text-sub); margin-bottom: 6px; }
.form-hint { font-size: 12px; color: var(--text-mute); margin-top: 5px; }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 11px;
  background: var(--primary-soft); color: var(--primary);
}
.badge-gray { background: var(--bg-hover); color: var(--text-sub); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-green { background: rgba(36,161,72,.12); color: var(--success); }

.muted { color: var(--text-sub); }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }

.empty { padding: 60px 20px; text-align: center; color: var(--text-mute); }
.empty .icon { font-size: 40px; display: block; margin-bottom: 10px; opacity: .5; }

.pager { display: flex; gap: 6px; justify-content: center; padding: 20px 0; flex-wrap: wrap; }
.pager-item {
  padding: 5px 11px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg-panel); color: var(--text-sub); font-size: 13px;
}
.pager-item.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.section-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .spacer { flex: 1; }

.list-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s;
}
.list-item:hover { background: var(--bg-hover); }
.list-item.active { background: var(--primary-soft); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 12px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--bg-hover); flex: none; }
.avatar-lg { width: 76px; height: 76px; }
.avatar-sm { width: 32px; height: 32px; }
.avatar-wrap { position: relative; flex: none; }
.avatar-online::after {
  content: ''; position: absolute; right: 1px; bottom: 1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--success); border: 2px solid var(--bg-panel);
}

.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 34px 30px; box-shadow: var(--shadow-lg); }
.login-card h2 { margin: 0 0 6px; font-size: 22px; }
.login-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  margin-top: 22px; padding: 12px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 14px; font-weight: 500;
}
.login-btn:hover { background: var(--primary-dark); }

.flash {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 9px; z-index: 2000; box-shadow: var(--shadow-lg);
  background: var(--bg-panel); border: 1px solid var(--border);
  animation: fadeInDown .25s ease;
}
.flash-success { border-color: rgba(36,161,72,.35); color: var(--success); }
.flash-error { border-color: rgba(224,72,59,.35); color: var(--danger); }
@keyframes fadeInDown { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.site-notice {
  background: var(--primary-soft); color: var(--primary);
  padding: 8px 16px; font-size: 13px; text-align: center;
}

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(12px);
  background: rgba(29, 29, 31, .92); color: #fff; padding: 9px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .22s; z-index: 3000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.mention { color: var(--primary); }
.topic { color: var(--primary); }

/* ---------------- 会话列表 ---------------- */
.conv-item { position: relative; display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--primary-soft); }
.conv-item.is-pinned { background: var(--bg-subtle); }
.conv-body { flex: 1; min-width: 0; }
.conv-line { display: flex; align-items: baseline; gap: 6px; }
.conv-name { font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--text-mute); flex: none; }
.conv-msg { font-size: 12px; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-unread {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; display: inline-flex; align-items: center; justify-content: center; margin-left: 4px;
}
.conv-unread.muted-dot { background: var(--text-mute); }
.pin-flag { font-size: 10px; color: var(--warn); }

/* ---------------- 聊天窗口 ---------------- */
.chat-head {
  height: 56px; flex: none; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--bg-panel);
}
.chat-head .title { font-weight: 600; }
.chat-head .sub { font-size: 12px; color: var(--text-mute); }
.chat-head .spacer { flex: 1; }

.msg-area { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.msg-row { display: flex; gap: 10px; max-width: 74%; }
.msg-row.self { align-self: flex-end; flex-direction: row-reverse; }
.msg-content { min-width: 0; }
.msg-meta { font-size: 11px; color: var(--text-mute); margin-bottom: 3px; display: flex; gap: 6px; align-items: center; }
.msg-row.self .msg-meta { justify-content: flex-end; }
.bubble {
  padding: 9px 13px; border-radius: 12px; background: var(--bg-panel); border: 1px solid var(--border);
  word-break: break-word; white-space: pre-wrap; box-shadow: var(--shadow); position: relative;
}
.msg-row.self .bubble { background: var(--primary); border-color: var(--primary); color: #fff; }
.bubble img.msg-img { max-width: 220px; border-radius: 8px; cursor: zoom-in; }
.bubble video { max-width: 260px; border-radius: 8px; }
.bubble .file-chip {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px;
  background: var(--bg-subtle); border: 1px solid var(--border); color: var(--text);
}
.msg-row.self .bubble .file-chip { background: rgba(255,255,255,.15); border-color: transparent; color: #fff; }
.bubble.recalled { color: var(--text-mute); font-size: 12px; font-style: italic; background: var(--bg-hover); }
.msg-row.self .bubble.recalled { background: transparent; border-color: transparent; color: var(--text-mute); }
.reply-quote {
  border-left: 3px solid var(--primary); padding: 4px 8px; margin-bottom: 6px;
  background: var(--bg-subtle); border-radius: 6px; font-size: 12px; color: var(--text-sub);
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-row.self .reply-quote { background: rgba(255,255,255,.14); color: rgba(255,255,255,.9); border-left-color: #fff; }
.msg-status { font-size: 11px; color: var(--text-mute); margin-left: 6px; }
.msg-sys { align-self: center; font-size: 12px; color: var(--text-mute); background: var(--bg-hover); padding: 3px 10px; border-radius: 20px; }
.msg-day { align-self: center; font-size: 11px; color: var(--text-mute); }

.composer { flex: none; border-top: 1px solid var(--border); background: var(--bg-panel); padding: 8px 12px 12px; }
.composer-tools { display: flex; gap: 4px; margin-bottom: 6px; color: var(--text-sub); }
.composer-tools .tool { padding: 5px 8px; border-radius: 7px; cursor: pointer; font-size: 15px; }
.composer-tools .tool:hover { background: var(--bg-hover); }
.composer-input { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1; min-height: 42px; max-height: 140px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg); color: var(--text); resize: none; overflow-y: auto;
}
.reply-bar { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-sub); margin-bottom: 6px; }
.emoji-pop {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; border: 1px solid var(--border);
  background: var(--bg-panel); border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 320px; position: absolute;
}
.emoji-pop span { cursor: pointer; padding: 4px; text-align: center; border-radius: 6px; }
.emoji-pop span:hover { background: var(--bg-hover); }

.typing-tip { font-size: 12px; color: var(--primary); height: 18px; padding: 0 16px; }

/* ---------------- 朋友圈 / 空间 ---------------- */
.feed-wrap { max-width: 680px; margin: 0 auto; padding: 18px 16px 40px; }
.moment-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.moment-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.moment-head .name { font-weight: 600; }
.moment-head .time { font-size: 12px; color: var(--text-mute); }
.moment-media { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.moment-media.one { grid-template-columns: repeat(1, minmax(0, 60%)); }
.moment-media.two { grid-template-columns: repeat(2, 1fr); }
.moment-media img, .moment-media video { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; cursor: zoom-in; background: var(--bg-hover); }
.moment-media.one img { aspect-ratio: auto; max-height: 320px; }
.moment-actions { display: flex; gap: 18px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-sub); }
.moment-actions .act { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.moment-actions .act:hover { color: var(--primary); }
.moment-actions .act.on { color: var(--primary); }
.comment-list { margin-top: 10px; background: var(--bg-subtle); border-radius: 8px; padding: 8px 12px; }
.comment-item { font-size: 13px; padding: 3px 0; }
.comment-item .cname { color: var(--primary); }
.comment-box { display: flex; gap: 8px; margin-top: 8px; }

.topic-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  padding: 5px 12px; border-radius: 20px; background: var(--bg-panel); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-sub); cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------------- Tab / Modal ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab-item { padding: 8px 14px; cursor: pointer; color: var(--text-sub); border-bottom: 2px solid transparent; font-size: 13px; }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center;
  justify-content: center; z-index: 2500; padding: 20px;
}
.modal {
  background: var(--bg-panel); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 440px; max-height: 86vh; overflow-y: auto; padding: 22px;
}
.modal-head { display: flex; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-close { cursor: pointer; color: var(--text-mute); font-size: 20px; line-height: 1; }

/* ---------------- 移动端 ---------------- */
.mobile-top {
  display: none; position: sticky; top: 0; z-index: 30; height: 50px; align-items: center;
  padding: 0 14px; background: var(--bg-panel); border-bottom: 1px solid var(--border);
}
.mobile-top .mt-title { font-weight: 600; flex: 1; }
.mobile-top .mt-btn { position: relative; font-size: 18px; }
.mobile-top .mt-btn .dot {
  position: absolute; top: -2px; right: -6px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center;
}

.tabbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: var(--bg-panel); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab { flex: 1; padding: 6px 0 5px; text-align: center; font-size: 11px; color: var(--text-mute); }
.tabbar .tab span { display: block; font-size: 19px; margin-bottom: 1px; }
.tabbar .tab.active { color: var(--primary); }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .mobile-top { display: flex; }
  .tabbar { display: flex; }
  .main { padding-bottom: 56px; }
  .two-col { height: calc(100vh - 50px - 56px); }
  .col-list { width: 100%; }
  .col-list.hide-mobile { display: none; }
  .col-main.hide-mobile { display: none; }
  .msg-row { max-width: 86%; }
  .feed-wrap { padding: 12px 12px 30px; }
}
