/* ===== 全局重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #333;
  height: 100vh;
  overflow: hidden;
}

/* ===== 布局 ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== 顶栏 ===== */
#topbar {
  background: #1a1a2e;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
#topbar h1 {
  font-size: 18px;
  font-weight: 600;
}
.badge {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 10px;
}
.badge-ok { background: #52c41a; color: #fff; }
.badge-warn { background: #faad14; color: #000; }
.badge-danger { background: #ff4d4f; color: #fff; }
.hidden { display: none !important; }

/* ===== 侧栏 ===== */
#sidebar {
  width: 240px;
  background: #fff;
  border-right: 1px solid #e8e8e8;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
#agent-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.agent-item {
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 9px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}
.agent-item:hover { background: #f0f5ff; }
.agent-item.active { background: #e6f4ff; border: 1px solid #91caff; box-shadow: 0 1px 4px rgba(24,144,255,0.1); }
.agent-item .avatar,
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}
.agent-item .info { flex: 1; min-width: 0; }
.agent-item .info .name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.agent-item .info .sub { font-size: 11px; color: #999; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-item .role-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  background: #f0f0f0;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
}
.agent-item .role-tag.admin { background: #fff7e6; color: #d48806; }
.agent-item .unread-badge {
  background: #ff4d4f;
  color: #fff;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  font-weight: 600;
}

#sync-controls {
  padding: 8px;
  border-top: 1px solid #e8e8e8;
}
#btn-sync-import {
  width: 100%;
  padding: 8px;
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  background: #fafafa;
  cursor: pointer;
  font-size: 13px;
  color: #666;
}
#btn-sync-import:hover { background: #f0f0f0; border-color: #1890ff; color: #1890ff; }

/* ===== 消息区 ===== */
#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
}

#chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#chat-title { font-weight: 600; font-size: 16px; }

/* 消息列表 */
#message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.placeholder {
  text-align: center;
  color: #bbb;
  margin-top: 60px;
  font-size: 14px;
}

/* 单条消息 */
.message {
  margin-bottom: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #f8f9fb;
  border-left: 3px solid #e8e8e8;
  max-width: 85%;
}
.message.self { background: #e6f7ff; border-left-color: #1890ff; margin-left: auto; }
.message .msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #999;
}
.message .msg-sender { font-weight: 600; color: #333; }
.message .msg-time { font-size: 11px; color: #bbb; }
.message .msg-content {
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.message .msg-content .at-mention {
  background: #fff7e6;
  color: #d48806;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}
.message .msg-receipt {
  margin-top: 6px;
  font-size: 12px;
  color: #999;
  border-top: 1px dashed #eee;
  padding-top: 4px;
}
.message .msg-receipt .reply-text {
  color: #52c41a;
  font-style: italic;
}

/* 已读/未读状态 */
.message .read-status {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.message .read-status.read {
  color: #52c41a;
  background: #f6ffed;
}
.message .read-status.unread {
  color: #faad14;
  background: #fffbe6;
}
.message .read-status-detail {
  font-size: 10px;
  color: #999;
  margin-left: 4px;
}

/* @班长 通知栏 */
#mention-bar {
  padding: 10px 20px;
  background: #fff7e6;
  border-top: 2px solid #faad14;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#mention-bar span { flex: 1; font-size: 14px; }
#btn-ack-all {
  padding: 6px 14px;
  background: #faad14;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
#btn-ack-all:hover { background: #d48806; }

/* 输入区 */
#input-area {
  padding: 12px 20px 16px;
  border-top: 1px solid #e8e8e8;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fafafa;
}
#receiver-select {
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  min-width: 120px;
  background: #fff;
}
#msg-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
}
#msg-input:focus { outline: none; border-color: #1890ff; }
#btn-send {
  padding: 8px 24px;
  background: #1890ff;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
#btn-send:hover { background: #096dd9; }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* Markdown 渲染样式 */
.msg-content .md-h1,
.msg-content .md-h2,
.msg-content .md-h3 { margin: 8px 0 4px; font-weight: 600; }
.msg-content .md-h1 { font-size: 16px; color: #1890ff; }
.msg-content .md-h2 { font-size: 15px; color: #52c41a; }
.msg-content .md-h3 { font-size: 14px; color: #fa8c16; }
.msg-content .md-hr { border: none; border-top: 1px solid #e8e8e8; margin: 8px 0; }
.msg-content strong { color: #000; }
.msg-content code { background: #f5f5f5; padding: 1px 5px; border-radius: 3px; font-size: 13px; color: #722ed1; }
.msg-content pre { background: #1a1a2e; padding: 10px; border-radius: 6px; overflow-x: auto; margin: 6px 0; }
.msg-content pre code { background: none; padding: 0; color: #e0e0e0; }
/* 全局页暗色主题适配 */
#global-view .msg .txt .md-h1 { color: #4fc3f7; }
#global-view .msg .txt .md-h2 { color: #81c784; }
#global-view .msg .txt .md-h3 { color: #ffb74d; }
#global-view .msg .txt .md-hr { border-top-color: #2a3a5a; }
