/* ==========================================================
   profile-calls-system.css — 个人资料与状态、通话、骨架屏、空状态、快捷键帮助、手机差异
   ========================================================== */

/* ---------- 我的状态 ---------- */
.me-chip { position: relative; flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.me-chip:hover { background: var(--bg-hover); }
.me-chip .avatar.xs { width: 30px; height: 30px; font-size: 13px; }
.avatar .st-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border: 2px solid var(--bg); }
.avatar.xl .st-dot { width: 22px; height: 22px; border-width: 3px; right: 2px; bottom: 2px; }
.avatar .st-dot.s-invisible { background: var(--bg); }
.mc-emoji { position: absolute; left: -2px; top: -2px; font-size: 13px; line-height: 1; }
.my-profile .np-avatar { position: relative; background: none; }
.field-hint { display: block; font-size: 12px; margin: 4px 2px 0; color: var(--text-3); }
.field-hint.right { text-align: right; }
.field-hint.ok { color: var(--online); }
.field-hint.err { color: var(--danger); }
.phone-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.status-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.status-list button { min-height: 40px; padding: 6px 12px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; text-align: left; }
.status-list button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.custom-status { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.custom-status .field-input { height: 42px; flex: 1; min-width: 0; }
.cs-emoji { width: 42px; height: 42px; flex-shrink: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; font-size: 22px; color: var(--text-2); }
.cs-pop { margin-top: 6px; max-height: 200px; overflow-y: auto; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); }
.cs-pop[hidden] { display: none; }
.cp-me { border-bottom: 1px solid var(--border); padding: 4px 0; }

/* ---------- 通话 ---------- */
.call { position: fixed; inset: 0; z-index: 160; display: flex; flex-direction: column; background: #17212b; color: #fff; overflow: hidden; }
.call[hidden] { display: none; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.call[data-mode="video"] .call-remote { display: block; }
.call-top { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top)) 8px 8px; }
.call .icon-btn { color: rgba(255, 255, 255, .85); }
.call .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.call-enc { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 12px; border-radius: 14px; background: rgba(0, 0, 0, .3); }
.call-enc .ti { font-size: 15px; }
.call:not([data-mode="group"]) #callPeopleBtn { visibility: hidden; }
.call-center { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 0 24px; }
.call-av.avatar { width: 140px; height: 140px; font-size: 56px; }
.call-center h2 { font-size: 26px; font-weight: 600; margin-top: 12px; }
.call-center p { font-size: 16px; opacity: .8; font-variant-numeric: tabular-nums; }
.call[data-mode="video"] .call-center { justify-content: flex-start; padding-top: 12px; text-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.call[data-mode="video"] .call-av { display: none; }
.call[data-mode="video"] .call-center h2 { margin-top: 0; font-size: 20px; }
.call[data-mode="group"] .call-center { flex: 0 0 auto; padding-bottom: 8px; }
.call[data-mode="group"] .call-av { display: none; }
.call[data-mode="group"] .call-center h2 { margin-top: 0; font-size: 20px; }
.call-grid { display: none; }
.call[data-mode="group"] .call-grid { position: relative; z-index: 1; flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 16px; min-height: 0; }
.cg-tile { position: relative; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); background: #22303e; border: 3px solid transparent; transition: border-color .2s; min-height: 0; }
.cg-tile.speaking { border-color: var(--online); }
.cg-tile .avatar.xl { width: 88px; height: 88px; font-size: 34px; }
.cg-name { position: absolute; left: 10px; bottom: 8px; font-size: 13px; padding: 2px 8px; border-radius: 10px; background: rgba(0, 0, 0, .4); }
.cg-name .ti { font-size: 14px; color: #ff8a9a; vertical-align: -2px; }
.call-self { position: absolute; right: 16px; top: 72px; z-index: 3; width: 120px; height: 160px; border-radius: var(--radius); overflow: hidden; border: 2px solid rgba(255, 255, 255, .7); cursor: grab; touch-action: none; display: none; background: #22303e; }
.call[data-mode="video"] .call-self { display: block; }
.call-self img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.cs-off { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #22303e; }
.cs-off[hidden] { display: none; }
.cs-off .ti { font-size: 32px; opacity: .7; }
.call-people { position: absolute; right: 16px; top: 64px; bottom: 120px; z-index: 4; width: 260px; padding: 12px; border-radius: var(--radius); background: rgba(23, 33, 43, .96); overflow-y: auto; }
.call-people[hidden] { display: none; }
.call-people h3 { font-size: 14px; margin-bottom: 8px; opacity: .8; }
.call-people li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.call-people .m-name { flex: 1; }
.call-bar { position: relative; z-index: 2; display: flex; justify-content: center; gap: 20px; padding: 20px 16px calc(28px + env(safe-area-inset-bottom)); }
.call[data-mode="video"] .call-bar { background: rgba(0, 0, 0, .35); }
.cb { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: rgba(255, 255, 255, .85); min-width: 64px; }
.cb-ico { width: 56px; height: 56px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .16); }
.cb-ico .ti { font-size: 26px; }
.cb.on .cb-ico { background: #fff; color: #17212b; }
.cb.hang .cb-ico { background: var(--danger); }
.call:not([data-mode="voice"]) .voice-only, .call[data-mode="voice"] .video-only, .call:not([data-mode="video"]) .video-solo, .call:not([data-mode="group"]) .group-only { display: none; }

.incoming {
  position: fixed; left: 50%; top: 16px; z-index: 170; transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px)); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  background: #17212b; color: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
}
.incoming[hidden] { display: none; }
.in-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.in-text span { font-size: 13px; opacity: .75; }
.in-actions { display: flex; gap: 10px; }
.in-btn { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.in-btn span { display: none; }
.in-btn .ti { font-size: 22px; }
.in-btn.decline { background: var(--danger); }
.in-btn.accept { background: var(--online); }

/* ---------- 通话：真实音视频（js/calls.js） ---------- */
.call-remote { background: #0e1621; }
.call-self video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; transform: scaleX(-1); }
.call-note { font-size: 13px !important; padding: 4px 12px; border-radius: 12px; background: rgba(0, 0, 0, .35); opacity: 1 !important; }
.call-note[hidden] { display: none; }
.call-audio { display: none; }
.cg-tile { overflow: hidden; }
.cg-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.cg-tile.has-video video { display: block; }
.cg-tile.has-video .avatar { visibility: hidden; }
.cg-tile[data-uid="me"] video { transform: scaleX(-1); }
.cg-name { z-index: 1; }
.cg-name .hand { color: #ffd166; }
/* 宫格：2 人一行两个，3–4 人 2×2，5–6 人 3×2，7–8 人 4×2 */
.call-grid[data-n="1"] { grid-template-columns: 1fr; }
.call-grid[data-n="5"], .call-grid[data-n="6"] { grid-template-columns: repeat(3, 1fr); }
.call-grid[data-n="7"], .call-grid[data-n="8"] { grid-template-columns: repeat(4, 1fr); }
.call:not(.can-admin) .admin-only, .call.no-sink [data-cb="speaker"], .call.no-pip [data-cb="pip"] { display: none; }
.call-bar { flex-wrap: wrap; row-gap: 12px; }

/* 最小化：顶部悬浮条 */
.call-float {
  position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top)); z-index: 165; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); padding: 8px 16px; border-radius: 20px;
  background: var(--online); color: #fff; font-size: 14px; box-shadow: var(--shadow); white-space: nowrap;
}
.call-float[hidden] { display: none; }
.call-float .cf-time { font-variant-numeric: tabular-nums; opacity: .9; }
.call-float .cf-back { font-weight: 600; }
#callFloatName { overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }

/* 群通话置顶条：「通话进行中 · N 人 · 加入」 */
.call-banner { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--bg); border-bottom: 1px solid var(--border, rgba(0, 0, 0, .08)); font-size: 14px; color: var(--online); }
.call-banner[hidden] { display: none; }
.call-banner span { flex: 1; min-width: 0; color: var(--text); }
.cbn-join { padding: 5px 14px; border-radius: 14px; background: var(--online); color: #fff; font-size: 13px; font-weight: 600; }
.cbn-join:disabled { opacity: .5; }

/* 没有安全上下文（http）/ 浏览器不支持：通话入口照常显示，点了提示原因（js/calls.js callsSupported） */

@media (max-width: 640px) {
  /* 手机来电：全屏 */
  .incoming { inset: 0; top: 0; left: 0; transform: none; width: auto; border-radius: 0; flex-direction: column; justify-content: center; gap: 18px; padding: 48px 24px calc(48px + env(safe-area-inset-bottom)); }
  .incoming .avatar { width: 120px; height: 120px; font-size: 48px; }
  .in-text { flex: 0; align-items: center; text-align: center; }
  .in-text b { font-size: 24px; }
  .in-text span { font-size: 15px; }
  .in-actions { margin-top: auto; gap: 72px; }
  .in-btn { width: 68px; height: 68px; }
  .in-btn .ti { font-size: 30px; }
  .call-grid[data-n="5"], .call-grid[data-n="6"], .call-grid[data-n="7"], .call-grid[data-n="8"] { grid-template-columns: 1fr 1fr; }
  .call-bar { gap: 10px; }
  .cb { min-width: 58px; }
  .cb-ico { width: 52px; height: 52px; }
}

/* ---------- 骨架屏 ---------- */
.sk { display: block; border-radius: 6px; background: var(--bg-soft); position: relative; overflow: hidden; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bg) 70%, transparent), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-row { display: flex; align-items: center; gap: 12px; min-height: var(--item-h); padding: 6px 12px 6px 8px; list-style: none; }
.sk-av { width: var(--item-avatar); height: var(--item-avatar); border-radius: 50%; flex-shrink: 0; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk-l1 { height: 12px; width: 55%; } .sk-l2 { height: 10px; width: 80%; }
.sk-msg { display: flex; margin: 6px 0; }
.sk-msg.out { justify-content: flex-end; }
.sk-bubble { height: 44px; border-radius: var(--bubble-radius); background: color-mix(in srgb, var(--bg) 70%, transparent); }

/* ---------- 空状态 ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 36px 24px; text-align: center; color: var(--text-2); }
.es-icon { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--bg-soft); color: var(--text-3); }
.es-icon .ti { font-size: 30px; }
.empty-state p { font-size: 14px; max-width: 280px; }
.es-li { list-style: none; }
.msg-inner > .empty-state { margin: auto; background: color-mix(in srgb, var(--bg) 85%, transparent); border-radius: var(--radius); }
.msg-inner:has(> .empty-state) { min-height: 100%; justify-content: center; }

/* ---------- 快捷键帮助 ---------- */
.keys-dlg { width: min(440px, calc(100vw - 32px)); }
.keys-list { margin: 0; display: flex; flex-direction: column; }
.keys-list div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.keys-list dt { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.keys-list dd { margin: 0; font-size: 14px; color: var(--text-2); text-align: right; }
kbd { min-width: 26px; padding: 2px 7px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; font: 12px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; text-align: center; background: var(--bg-soft); }
.kplus { font-size: 12px; color: var(--text-3); }

/* ---------- 手机（< 900px） ---------- */
@media (width < 900px) {
  .toasts { top: auto; bottom: calc(88px + env(safe-area-inset-bottom)); left: 16px; right: 16px; align-items: center; }
  .asheet.as-sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; max-width: none; border-radius: var(--radius) var(--radius) 0 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  /* 顶栏：恢复电话按钮，搜索进“更多” */
  .head-actions .icon-btn#searchBtn { display: none; }
  .head-actions #callBtn { display: inline-flex; }
  .incoming { top: 0; left: 0; transform: none; width: 100vw; height: 100dvh; border-radius: 0; flex-direction: column; justify-content: center; gap: 18px; padding: 32px 24px; text-align: center; }
  .incoming .avatar { width: 120px; height: 120px; font-size: 48px; }
  .in-text b { font-size: 24px; }
  .in-actions { gap: 64px; margin-top: 48px; }
  .in-btn { width: 68px; height: 68px; flex-direction: column; position: relative; }
  .in-btn .ti { font-size: 30px; }
  .in-btn span { display: block; position: absolute; top: 76px; font-size: 13px; white-space: nowrap; }
  .call-av.avatar { width: 120px; height: 120px; }
  .call-bar { gap: 8px; }
  .cb { min-width: 56px; }
  .cb-ico { width: 52px; height: 52px; }
  .call-self { width: 96px; height: 128px; top: 64px; }
  .call-people { left: 16px; width: auto; }
  .call[data-mode="group"] .call-grid { padding: 8px; }
  .cg-tile .avatar.xl { width: 64px; height: 64px; font-size: 26px; }
  body.offline .app { padding-top: 0; }
  body.offline .sidebar, body.offline .chat-area, body.offline .settings { padding-top: 34px; }
}

/* 群通话：参与者列表展开时宫格让位（PC） */
@media (width >= 900px) { .call.people-open .call-grid { margin-right: 280px; } }
/* 号码（只读、可复制） */
.uid-row { display: flex; align-items: center; gap: 4px; }
.uid-big { font-size: 18px; font-weight: 600; letter-spacing: .04em; }

/* ---------- 跨公司群（js/chat/messages.js renderFedBar、chat-list「跨公司」小标） ---------- */
.org-tag.fed-tag { background: color-mix(in srgb, var(--accent, #3390ec) 14%, transparent); color: var(--accent, #3390ec); }
.ct-name .org-tag { margin-left: 6px; vertical-align: 2px; }
.m-name .org-tag { margin-left: 6px; }
.fed-bar { padding: 8px 16px; font-size: 13px; text-align: center; background: color-mix(in srgb, #f0a020 16%, var(--bg)); color: var(--text); border-bottom: 1px solid var(--border, rgba(0, 0, 0, .08)); }
.fed-bar[hidden] { display: none; }
/* 主服务器离线 / 只读：输入框不能用（服务端也会拒） */
#chat.fed-locked .composer { opacity: .5; pointer-events: none; }
/* 跨公司群：话题 / 自动删除 / TG 桥接 / 群类型不支持；别家建的群（镜像）里 邀请链接 / 慢速 / 隐藏 / 机器人只在建群的公司设置 */
body.chat-fed [data-fed~="hide"], body.chat-fed-mirror [data-fed~="mirror"] { display: none !important; }

/* 设置 → 帮助：阅读器占满右侧 */
.set-page-help { display: none; flex-direction: column; min-height: 0; }
.set-page-help.active { display: flex; }
.set-help { flex: 1; min-height: 0; }

/* 屏幕共享（js/calls.js）：别人共享 → 大窗放画面（等比完整显示），对方摄像头 / 群宫格缩到右上角一列；我在共享 → 顶上一条提示 */
.call-screen { position: absolute; inset: 64px 0 112px; z-index: 1; display: flex; align-items: center; justify-content: center; background: #0b1117; }
.call-screen[hidden] { display: none; }
.call-screen video { width: 100%; height: 100%; object-fit: contain; }
.csb-label { position: absolute; left: 16px; top: 12px; padding: 4px 12px; border-radius: 14px; background: rgba(0, 0, 0, .55); font-size: 13px; }
.call.screen-on .call-center { display: none; }   /* 谁在共享写在画面左上角 */
.call.screen-on .call-bar { margin-top: auto; }   /* 宫格改成绝对定位后，按钮栏仍然贴底 */
.call.screen-on .call-remote { inset: auto; top: 76px; right: 16px; width: 200px; height: 124px; border-radius: var(--radius); z-index: 3; border: 2px solid rgba(255, 255, 255, .7); }
.call.screen-on .call-self { top: 210px; width: 96px; height: 128px; }
.call[data-mode="group"].screen-on .call-grid { position: absolute; top: 76px; right: 16px; bottom: 124px; z-index: 3; width: 200px; padding: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.call[data-mode="group"].screen-on .cg-tile { flex: 0 0 124px; }
.call[data-mode="group"].screen-on .call-screen { right: 232px; }
.call[data-mode="group"].screen-on .cg-tile .avatar.xl { width: 48px; height: 48px; font-size: 20px; }
.call-sharing { position: relative; z-index: 2; align-self: center; display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 6px 14px; border-radius: 16px; background: var(--danger, #e53935); font-size: 13px; }
.call-sharing[hidden] { display: none; }
@media (width < 700px) {
  .call-screen { inset: 56px 0 212px; }   /* 手机上按钮栏是两行 */
  .call.screen-on .call-remote { top: 64px; bottom: auto; right: 12px; width: 96px; height: 128px; }
  .call.screen-on .call-self { display: none; }
  .call[data-mode="group"].screen-on .call-screen { right: 0; top: 150px; }
  .call[data-mode="group"].screen-on .call-grid { top: 56px; left: 12px; right: 12px; bottom: auto; width: auto; height: 86px; flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .call[data-mode="group"].screen-on .cg-tile { flex: 0 0 112px; }
}
