/* ==========================================================================
   components.css — 微信通用组件：导航栏 / 列表 / 气泡 / 弹层 / 卡片 / Toast
   ========================================================================== */

/* ---------- 导航栏 ---------- */
.navbar {
  height: calc(var(--nav-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--bg-nav);
  display: flex; align-items: center;
  position: relative; flex: none;
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.navbar .nav-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 17px; font-weight: 500;
}
.navbar .nav-left, .navbar .nav-right {
  display: flex; align-items: center; gap: 14px; padding: 0 14px; z-index: 2;
}
.navbar .nav-left { margin-right: auto; }
.navbar .nav-right { margin-left: auto; }
.navbar .nav-back {
  display: flex; align-items: center; gap: 2px; font-size: 17px;
}
.nav-icon {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  position: relative; color: var(--text-main);
}
.nav-icon svg { width: 22px; height: 22px; }
.nav-icon .badge-dot {
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--wx-red); color: #fff; border-radius: 8px;
  font-size: 11px; display: flex; align-items: center; justify-content: center;
}

/* ---------- 搜索输入 ---------- */
.search-bar {
  padding: 8px 12px; background: var(--bg-nav); flex: none;
}
.search-bar .search-inner {
  height: 32px; background: var(--bg-input); border-radius: var(--radius);
  display: flex; align-items: center; gap: 6px; padding: 0 10px; color: var(--text-sub);
}
[data-theme="dark"] .search-bar .search-inner { background: #2C2C2C; }
.search-bar input { flex: 1; color: var(--text-main); }
.search-bar input::placeholder { color: var(--text-sub); }

/* ---------- 列表 ---------- */
.list { background: var(--bg-list); overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.list-group-title {
  padding: 16px 16px 6px; font-size: 14px; color: var(--text-desc); background: var(--bg-page);
}
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--bg-list); position: relative; cursor: pointer;
}
.list-item:active { background: var(--bg-active); }
.list-item + .list-item::before {
  content: ""; position: absolute; left: 68px; right: 0; top: 0; height: 1px; background: var(--line);
}
.list-item .avatar { width: 46px; height: 46px; font-size: 18px; position: relative; }
.list-item .li-body { flex: 1; min-width: 0; }
.list-item .li-top { display: flex; align-items: center; }
.list-item .li-name { font-size: 17px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-time { font-size: 12px; color: var(--text-sub); flex: none; margin-left: 6px; }
.list-item .li-preview {
  font-size: 14px; color: var(--text-sub); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-item .li-preview .red { color: var(--wx-red); }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--wx-red); color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.avatar .badge { position: absolute; top: -6px; right: -6px; }
.badge-mute { width: 8px; height: 8px; border-radius: 50%; background: var(--wx-red); }

/* 置顶 */
.pinned { background: var(--bg-hover); }

/* ---------- 单元格（设置/我的） ---------- */
.cell-group { background: var(--bg-list); margin-bottom: 10px; }
.cell {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; cursor: pointer;
  position: relative; min-height: 50px;
}
.cell:active { background: var(--bg-active); }
.cell + .cell::before {
  content: ""; position: absolute; left: 16px; right: 0; top: 0; height: 1px; background: var(--line);
}
.cell .cell-icon { width: 24px; height: 24px; border-radius: 5px; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; }
.cell .cell-icon svg { width: 16px; height: 16px; }
.cell .cell-body { flex: 1; min-width: 0; }
.cell .cell-title { font-size: 16px; }
.cell .cell-value { font-size: 14px; color: var(--text-sub); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .cell-arrow { color: var(--text-sub); flex: none; }
.cell .cell-arrow svg { width: 18px; height: 18px; display: block; }
.cell.danger .cell-title { color: var(--wx-red); }

/* ---------- 开关 ---------- */
.switch {
  width: 48px; height: 28px; border-radius: 14px; background: #DADADA;
  position: relative; transition: background .2s; flex: none; cursor: pointer;
}
[data-theme="dark"] .switch { background: #3A3A3A; }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px;
  background: #fff; border-radius: 50%; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch.on { background: var(--wx-green); }
.switch.on::after { left: 22px; }

/* ---------- 按钮 ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; border-radius: var(--radius); font-size: 16px; padding: 0 16px;
  transition: opacity .15s; user-select: none;
}
.btn:active { opacity: .75; }
.btn-primary { background: var(--wx-green); color: #fff; }
.btn-primary:disabled { background: #9EDFC0; cursor: not-allowed; }
.btn-plain { background: var(--bg-input); color: var(--text-main); border: 1px solid var(--line); }
.btn-danger { background: var(--wx-red); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { height: 32px; font-size: 14px; padding: 0 12px; }

/* ---------- 输入行 ---------- */
.field {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--bg-list); position: relative;
}
.field + .field::before { content:""; position:absolute; left:16px; right:0; top:0; height:1px; background: var(--line); }
.field label { width: 78px; font-size: 15px; color: var(--text-main); flex: none; }
.field input, .field select, .field textarea {
  flex: 1; min-width: 0; font-size: 15px; background: transparent; color: var(--text-main);
}
.field textarea { resize: vertical; min-height: 76px; line-height: 1.5; padding: 6px 0; }
.field .hint { color: var(--text-sub); font-size: 13px; }

/* ---------- 聊天区 ---------- */
.chat-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-page); }
.chat-header {
  height: calc(var(--nav-h) + var(--safe-top)); padding-top: var(--safe-top);
  background: var(--bg-nav); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding-left: 12px; padding-right: 12px; flex: none; z-index: 20;
}
.chat-header .chat-peer { flex: 1; text-align: center; font-size: 17px; font-weight: 500; }
[data-theme="dark"] .chat-wrap { background: #111; }

.messages {
  flex: 1; overflow-y: auto; padding: 12px 14px 20px;
  -webkit-overflow-scrolling: touch; overflow-x: hidden;
}
[data-theme="dark"] .messages { background: #111; }

/* 时间胶囊 */
.msg-time { text-align: center; margin: 12px 0; }
.msg-time span {
  background: rgba(0,0,0,.12); color: #fff; font-size: 12px;
  padding: 2px 8px; border-radius: 4px;
}
[data-theme="dark"] .msg-time span { background: rgba(255,255,255,.14); }

/* 系统提示（居中灰胶囊） */
.msg-system { text-align: center; margin: 12px 0; }
.msg-system span {
  background: rgba(0,0,0,.06); color: var(--text-desc); font-size: 12px;
  padding: 3px 10px; border-radius: 4px; line-height: 1.5; max-width: 78%; display: inline-block;
}
[data-theme="dark"] .msg-system span { background: rgba(255,255,255,.08); }

/* 消息行 */
.msg-row { display: flex; gap: 10px; margin-bottom: 16px; align-items: flex-start; }
.msg-row.me { flex-direction: row-reverse; }
.msg-row .avatar { width: 40px; height: 40px; font-size: 15px; }
.msg-col { max-width: 68%; min-width: 0; display: flex; flex-direction: column; }
.msg-row.me .msg-col { align-items: flex-end; }
.msg-sender { font-size: 12px; color: var(--text-desc); margin: 0 4px 4px; }

/* 气泡 */
.bubble {
  position: relative; padding: 9px 12px; border-radius: var(--radius);
  font-size: 16px; line-height: 1.5; word-break: break-word; white-space: pre-wrap;
  background: var(--wx-bubble-other); color: var(--text-main);
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.msg-row.me .bubble { background: var(--wx-bubble-me); color: #191919; }
.bubble::after {
  content: ""; position: absolute; top: 11px; width: 0; height: 0;
  border: 6px solid transparent;
}
.msg-row.other .bubble::after { left: -11px; border-right-color: var(--wx-bubble-other); }
.msg-row.me .bubble::after { right: -11px; border-left-color: var(--wx-bubble-me); }
.bubble a { color: var(--wx-link); }

/* 引用/联想中的“正在输入” */
.typing { display: inline-flex; gap: 3px; align-items: center; padding: 3px 0; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-sub);
  animation: typing 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%,60%,100% { opacity:.3; transform: translateY(0);} 30% { opacity:1; transform: translateY(-2px);} }

/* 链接分享卡片 */
.link-card {
  width: 240px; background: var(--bg-list); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line);
}
.link-card .lc-title { padding: 10px 12px 6px; font-size: 15px; line-height: 1.4; }
.link-card .lc-desc { padding: 0 12px 10px; font-size: 12px; color: var(--text-sub); line-height: 1.4; max-height: 52px; overflow: hidden; }
.link-card .lc-foot { padding: 8px 12px; font-size: 12px; color: var(--text-sub); border-top: 1px solid var(--line); }

/* ---------- 转账 / 红包卡片 ---------- */
.pay-card {
  width: 240px; border-radius: var(--radius); overflow: hidden; color: #fff; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.pay-card.transfer { background: linear-gradient(160deg,#FA9D3B,#F0883B); }
.pay-card.redpacket { background: linear-gradient(160deg,#FA5151,#D6382F); }
.pay-card .pc-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 8px; }
.pay-card .pc-icon { width: 30px; height: 30px; }
.pay-card .pc-icon svg { width: 30px; height: 30px; }
.pay-card .pc-amount { font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.pay-card .pc-note { padding: 0 14px 12px; font-size: 12px; opacity: .92; line-height: 1.4; }
.pay-card .pc-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; font-size: 12px; background: rgba(0,0,0,.08);
}
.pay-card.done { opacity: .72; }
.pay-card .pc-open { background: rgba(255,255,255,.25); padding: 2px 10px; border-radius: 12px; }

/* ---------- 底部输入栏 ---------- */
.composer {
  flex: none; background: var(--bg-nav); border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  display: flex; align-items: flex-end; gap: 8px;
}
.composer .comp-icon {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  color: var(--text-main); flex: none; margin-bottom: 2px;
}
.composer .comp-icon svg { width: 26px; height: 26px; }
.composer .comp-input {
  flex: 1; min-height: 36px; max-height: 120px; background: var(--bg-input);
  border-radius: var(--radius); padding: 8px 10px; font-size: 16px; line-height: 1.35;
  resize: none; overflow-y: auto;
}
.composer .comp-send {
  background: var(--wx-green); color: #fff; height: 36px; padding: 0 16px;
  border-radius: var(--radius); font-size: 15px; flex: none;
}
.composer .comp-send:disabled { background: #C6E9D5; }

/* 表情/工具栏面板 */
.panel-grid {
  background: var(--bg-panel); border-top: 1px solid var(--line); padding: 10px 12px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; flex: none;
}
.panel-grid .pg-item {
  background: var(--bg-list); border-radius: var(--radius); padding: 14px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--text-desc);
}
.panel-grid .pg-item:active { background: var(--bg-active); }
.panel-grid .pg-item svg { width: 26px; height: 26px; color: var(--text-main); }

/* 表情行 */
.emoji-row { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px; background: var(--bg-panel); border-top: 1px solid var(--line); }
.emoji-row .emoji { font-size: 26px; padding: 4px 8px; cursor: pointer; border-radius: 6px; line-height: 1; }
.emoji-row .emoji:active { background: var(--bg-active); }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: 100%; max-width: 420px; max-height: 84vh; background: var(--bg-list);
  border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column;
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal-head {
  padding: 16px 20px 10px; font-size: 17px; font-weight: 500; text-align: center; flex: none;
}
.modal-body { padding: 4px 20px 16px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; border-top: 1px solid var(--line); flex: none; }
.modal-foot button {
  flex: 1; height: 48px; font-size: 16px; color: var(--wx-link);
}
.modal-foot button + button { border-left: 1px solid var(--line); }
.modal-foot button.primary { color: var(--wx-green); font-weight: 500; }
.modal-foot button.danger { color: var(--wx-red); }

/* 底部弹出面板 / ActionSheet */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000;
  display: flex; align-items: flex-end; animation: fade .18s ease;
}
.sheet {
  width: 100%; background: var(--bg-list); border-radius: 12px 12px 0 0;
  padding-bottom: var(--safe-bottom); animation: slideUp .22s ease; overflow: hidden;
}
@keyframes slideUp { from { transform: translateY(100%) } to { transform: translateY(0) } }
.sheet-item {
  height: 52px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--text-main); position: relative; cursor: pointer;
}
.sheet-item + .sheet-item::before { content:""; position:absolute; left:12px; right:12px; top:0; height:1px; background: var(--line); }
.sheet-item:active { background: var(--bg-active); }
.sheet-item.danger { color: var(--wx-red); }
.sheet-cancel { margin-top: 8px; background: var(--bg-list); }

/* 居中 ActionSheet（桌面右键模拟） */
.center-sheet {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.4);
}
.center-sheet .cs-box { background: var(--bg-list); border-radius: var(--radius-lg); min-width: 240px; overflow: hidden; }

/* ---------- Toast ---------- */
.toast-root {
  position: fixed; left: 0; right: 0; top: 30%; z-index: 4000;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  background: rgba(0,0,0,.8); color: #fff; font-size: 14px;
  padding: 10px 16px; border-radius: 8px; max-width: 70%; text-align: center;
  animation: toastIn .2s ease; line-height: 1.4;
}
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity:0; transform: translateY(8px) } to { opacity:1; transform:none } }
@keyframes toastOut { to { opacity:0; transform: translateY(-6px) } }

/* ---------- 全屏图片查看 ---------- */
.viewer { position: fixed; inset: 0; background: #000; z-index: 3000; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- 空状态 ---------- */
.empty { padding: 60px 24px; text-align: center; color: var(--text-sub); font-size: 14px; }
.empty svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .5; }

/* ---------- 标签 ---------- */
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg-active); color: var(--text-desc); }
.tag.green { background: rgba(7,193,96,.14); color: var(--wx-green); }

/* ---------- 数量键盘（转账） ---------- */
.numpad { display: grid; grid-template-columns: repeat(3,1fr); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; }
.numpad button { background: var(--bg-list); height: 52px; font-size: 22px; font-variant-numeric: tabular-nums; }
.numpad button:active { background: var(--bg-active); }
.numpad button.fn { font-size: 16px; }
.amount-display { font-size: 34px; font-variant-numeric: tabular-nums; text-align: center; padding: 8px 0 4px; letter-spacing: 1px; }
.amount-display .cur { font-size: 20px; margin-right: 2px; }

/* ---------- 进度条 ---------- */
.progress { height: 6px; border-radius: 3px; background: var(--bg-active); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--wx-green); border-radius: 3px; transition: width .3s; }
