/* 聊天可视化：消息气泡、媒体卡片、表情面板、图片查看器、搜索面板。 */

/* ============ 消息列表 ============ */
.msg { display: flex; gap: 8px; padding: 2px 0; position: relative; }
.msg.out { flex-direction: row-reverse; }
.msg.grouped { padding-top: 0; }
.msg .msg-avatar { width: 34px; height: 34px; font-size: 13px; margin-top: 1px; flex: none; }
.msg .msg-avatar.hidden { visibility: hidden; }
.msg .bubble-wrap { display: flex; flex-direction: column; gap: 3px; max-width: min(72%, 640px); min-width: 0; }
.msg.out .bubble-wrap { align-items: flex-end; }
.msg .sender-name { font-size: 11.5px; color: var(--text-3); padding: 0 4px; }
.msg .bubble {
  position: relative; padding: 8px 12px; border-radius: 14px;
  background: var(--bubble-in); border: 1px solid var(--bubble-in-border);
  font-size: 14.5px; line-height: 1.55; color: var(--text);
  word-break: break-word; overflow-wrap: anywhere; box-shadow: var(--shadow-1);
  transition: box-shadow var(--speed) var(--ease);
}
.msg.in .bubble { border-bottom-left-radius: 5px; }
.msg.out .bubble { background: var(--bubble-out); border-color: var(--bubble-out-border); border-bottom-right-radius: 5px; }
.msg .bubble:hover { box-shadow: var(--shadow-2); }
.msg .bubble:has(.media-image) { padding: 3px; overflow: hidden; }
.msg .bubble.emoji-only { background: transparent; border-color: transparent; box-shadow: none; padding: 2px 4px; font-size: 40px; line-height: 1.2; }
.msg .bubble.text .link { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.msg .bubble.text { white-space: pre-wrap; }
.msg .bubble .link { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.msg .error-text { color: var(--danger); font-size: 10.5px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .bubble.system { background: var(--surface-3); color: var(--text-2); font-size: 12.5px; padding: 5px 12px; border-color: transparent; box-shadow: none; }

.msg .meta { display: flex; align-items: center; gap: 5px; padding: 0 3px; font-size: 10.5px; color: var(--text-3); opacity: 0; transition: opacity var(--speed); min-height: 14px; }
.msg:hover .meta, .msg.failed .meta, .msg.pending .meta, .msg.unknown .meta { opacity: 1; }
/* 触屏设备没有 hover：默认展示时间与发送状态 */
@media (hover: none) {
  .msg .meta { opacity: 1; }
  .msg .hover-actions { display: none; }
}
.msg .meta .status { display: inline-flex; align-items: center; gap: 3px; }
.msg .meta .status svg { width: 13px; height: 13px; }
.msg.out.status-failed .bubble { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.msg .retry-btn { color: var(--danger); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.msg .retry-btn svg { width: 12px; height: 12px; }
.msg.unknown .bubble { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }
.msg .reply-quote {
  display: flex; gap: 6px; padding: 5px 8px; margin-bottom: 5px; border-radius: 8px;
  background: color-mix(in srgb, var(--text) 5%, transparent); font-size: 12px; color: var(--text-2);
  border-left: 2px solid var(--brand);
}
.msg .reply-quote .quote-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 气泡操作 */
.msg .hover-actions { position: absolute; top: -10px; display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: opacity 120ms; z-index: 5; }
.msg.in .hover-actions { left: 42px; }
.msg.out .hover-actions { right: 42px; }
.msg:hover .hover-actions { opacity: 1; pointer-events: auto; }
.msg .hover-actions button { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); }
.msg .hover-actions button:hover { background: var(--surface-3); color: var(--text); }
.msg .hover-actions svg { width: 15px; height: 15px; }

/* 媒体 */
.media-image { display: block; border-radius: 11px; max-width: min(300px, 46vw); max-height: 320px; object-fit: cover; cursor: zoom-in; background: var(--surface-3); }
.media-image.loading { min-width: 180px; min-height: 120px; }
.media-video { max-width: min(340px, 52vw); border-radius: 11px; background: #000; display: block; }
.media-file {
  display: flex; align-items: center; gap: 10px; min-width: 210px; max-width: 300px;
  padding: 8px; border-radius: 10px; background: color-mix(in srgb, var(--text) 4%, transparent);
}
.media-file .file-icon { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-700); flex: none; }
.media-file .file-icon svg { width: 19px; height: 19px; }
.media-file .file-name { font-size: 13px; font-weight: 550; word-break: break-all; line-height: 1.35; }
.media-file .file-size { font-size: 11px; color: var(--text-3); }
.media-file .file-download { flex: none; color: var(--text-3); }
.media-file .file-download:hover { color: var(--brand); }
.media-audio { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.audio-play { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.audio-play svg { width: 16px; height: 16px; }
.audio-wave { display: flex; align-items: center; gap: 2px; height: 22px; }
.audio-wave i { width: 3px; border-radius: 2px; background: currentColor; opacity: 0.35; }
.msg.out .audio-play { background: var(--brand-700); }
.audio-duration { font-size: 12px; color: var(--text-3); min-width: 30px; }
.voice-unplayable { font-size: 12px; color: var(--text-3); }

/* 正在输入 */
.typing-bubble { display: flex; align-items: center; gap: 8px; padding: 4px 2px 8px; }
.typing-bubble .bubble { padding: 8px 12px; }

/* 时间分隔 / 新消息提示 */
.date-sep { align-self: center; margin: 14px 0 8px; font-size: 11.5px; color: var(--text-3); background: color-mix(in srgb, var(--bg) 60%, var(--surface)); padding: 3px 10px; border-radius: 999px; }
.new-msg-btn {
  position: absolute; right: 24px; bottom: 14px; z-index: 8;
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; box-shadow: var(--shadow-2);
  animation: slide-up 200ms var(--ease);
}
.new-msg-btn svg { width: 14px; height: 14px; }

/* ============ 表情面板 ============ */
.emoji-panel {
  position: absolute; z-index: 40; bottom: calc(100% + 10px); left: 0; width: min(372px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; overflow: hidden; animation: pop-in 160ms var(--ease);
}
.emoji-tabs { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.emoji-tab { height: 28px; padding: 0 10px; border-radius: 7px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.emoji-tab.active { background: var(--brand-soft); color: var(--brand-700); font-weight: 600; }
.emoji-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; padding: 8px; max-height: 240px; overflow-y: auto; }
.emoji-grid button { aspect-ratio: 1; border-radius: 8px; font-size: 22px; line-height: 1; display: grid; place-items: center; transition: background 100ms, transform 100ms; }
.emoji-grid button:hover { background: var(--surface-3); transform: scale(1.12); }

/* ============ 图片查看器 ============ */
.lightbox {
  position: fixed; inset: 0; z-index: 300; background: rgba(6, 12, 10, 0.92);
  display: flex; flex-direction: column; animation: fade-in 160ms;
}
.lightbox-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: #e8f1ed; font-size: 13px; }
.lightbox-head .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-head .spacer { flex: 1; }
.lightbox-head a, .lightbox-head button { color: #e8f1ed; display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 8px; }
.lightbox-head a:hover, .lightbox-head button:hover { background: rgba(255, 255, 255, 0.12); }
.lightbox-body { flex: 1; display: grid; place-items: center; overflow: auto; padding: 0 18px 18px; }
.lightbox-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); animation: pop-in 200ms var(--ease); }

/* ============ 会话内搜索 ============ */
.search-panel {
  position: absolute; z-index: 30; inset: 0 0 auto; background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-2); animation: slide-up 180ms var(--ease);
}
.search-panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.search-results { max-height: min(46vh, 420px); overflow-y: auto; padding: 6px; }
.search-result { display: flex; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.search-result:hover { background: var(--surface-2); }
.search-result .sr-time { font-size: 11px; color: var(--text-3); flex: none; }
.search-result .sr-text { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-result mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ============ 输入区扩展 ============ */
.composer-tools { display: flex; align-items: center; gap: 2px; }
.voice-recording { display: flex; align-items: center; gap: 10px; padding: 6px 4px; flex: 1; color: var(--danger); font-size: 13px; }
.voice-recording .rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse-dot 1s infinite; }
.voice-recording .rec-time { font-family: var(--font-mono); }
.voice-recording .rec-actions { margin-left: auto; display: flex; gap: 6px; }
.attachment-uploading { position: relative; }
.attachment-uploading .progress { position: absolute; left: 6px; right: 6px; bottom: 4px; }

/* 会话列表附加状态 */
.list-search-empty { padding: 30px 16px; text-align: center; color: var(--text-3); font-size: 13px; }
.ci-channel { font-size: 10px; padding: 1px 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-3); flex: none; }
