* { box-sizing: border-box; margin: 0; padding: 0; }

body.workbench {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  height: 100vh;
  overflow: hidden;
  background: #e8e8e8;
  color: #333;
} 

.workbench-layout {
  display: flex;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.08);
  min-height: 0;
  overflow: hidden;
}

/* ── 左侧边栏 ── */
.sidebar {
  width: 300px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: #f7f7f7;
  border-right: 1px solid #e0e0e0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: #f0f0f0;
  border-bottom: 1px solid #e0e0e0;
}

.staff-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.staff-avatar {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #ddd;
  flex-shrink: 0;
}

.staff-name {
  font-size: 15px;
  font-weight: 600;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.staff-mobile {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #666;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: #e0e0e0;
  color: #c92a2a;
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px;
  padding: 8px 12px;
  background: #e8e8e8;
  border-radius: 4px;
}
.sidebar-search i {
  color: #999;
  font-size: 13px;
}
.sidebar-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  outline: none;
  color: #333;
}
.sidebar-search input::placeholder {
  color: #aaa;
}

.sidebar-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 12px 12px;
}
.stat-item {
  background: #fff;
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px solid #ebebeb;
}
.stat-label {
  display: block;
  font-size: 11px;
  color: #999;
}
.stat-value {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: #c92a2a;
  margin-top: 2px;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  background: #f7f7f7;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #efefef;
  transition: background 0.15s;
}
.conv-item:hover {
  background: #ededed;
}
.conv-item.active {
  background: #e0e0e0;
}

.conv-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.conv-avatar {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  object-fit: cover;
  background: #ddd;
}
.conv-unread {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #fa5252;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #f7f7f7;
}

.conv-body {
  flex: 1;
  min-width: 0;
}
.conv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.conv-name {
  font-size: 14px;
  font-weight: 500;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-time {
  font-size: 11px;
  color: #aaa;
  flex-shrink: 0;
  margin-left: 8px;
}
.conv-preview {
  font-size: 13px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-preview.unread {
  color: #555;
}

/* ── 右侧聊天区 ── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #f5f5f5;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #bbb;
  gap: 16px;
}
.chat-empty.hidden {
  display: none;
}
.chat-empty i {
  font-size: 64px;
}
.chat-empty p {
  font-size: 15px;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.chat-main.hidden {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}
.chat-user-name {
  font-size: 16px;
  font-weight: 600;
  color: #222;
}
.chat-user-mobile {
  display: inline-block;
  font-size: 12px;
  color: #c92a2a;
  background: #fff5f5;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
}
.online-badge {
  font-size: 12px;
  color: #52c41a;
}
.online-badge i {
  font-size: 8px;
  margin-right: 4px;
}

.messages-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 消息气泡 */
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 70%;
}
.msg-row.mine {
  margin-left: auto;
}
.msg-row.theirs {
  margin-right: auto;
}

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e0e0e0;
}

.msg-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  max-width: 100%;
}
.msg-row.theirs .msg-bubble {
  background: #fff;
  color: #333;
  border-radius: 4px;
  border: 1px solid #e8e8e8;
}
.msg-row.mine .msg-bubble {
  background: #95ec69;
  color: #000;
  border-radius: 4px;
}

.msg-bubble img {
  max-width: 240px;
  max-height: 240px;
  border-radius: 4px;
  cursor: pointer;
  display: block;
}

.emoji-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 16px;
  background: #fff;
  border-top: 1px solid #e8e8e8;
  max-height: 120px;
  overflow-y: auto;
  flex-shrink: 0;
}
.emoji-panel.hidden {
  display: none;
}
.emoji-item {
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.emoji-item:hover {
  background: #f0f0f0;
}

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: #f5f5f5;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.tool-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: #666;
  font-size: 20px;
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
}
.tool-btn:hover {
  color: #c92a2a;
  background: #ebebeb;
}
.input-wrap {
  flex: 1;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 8px 12px;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
}
.input-wrap textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
  background: transparent;
  min-height: 22px;
}
.send-btn {
  height: 36px;
  padding: 0 20px;
  border: none;
  background: #07c160;
  color: #fff;
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.send-btn:hover {
  background: #06ad56;
}

.empty-tip {
  text-align: center;
  color: #bbb;
  padding: 40px 20px;
  font-size: 14px;
}

/* ── 登录页 ── */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8e8e8 0%, #f5f5f5 50%, #ebebeb 100%);
}

.login-card {
  display: flex;
  width: 900px;
  max-width: calc(100vw - 48px);
  min-height: 520px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.login-brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: linear-gradient(160deg, #c92a2a 0%, #e03131 50%, #fa5252 100%);
  color: #fff;
  text-align: center;
}
.login-brand-icon {
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 24px;
}
.login-brand h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 12px;
}
.login-brand p {
  font-size: 14px;
  opacity: 0.85;
  line-height: 1.6;
  max-width: 280px;
}

.login-form-panel {
  width: 400px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 40px;
}
.login-form-panel h2 {
  font-size: 22px;
  font-weight: 600;
  color: #222;
  margin-bottom: 8px;
}
.login-form-panel .subtitle {
  font-size: 13px;
  color: #999;
  margin-bottom: 32px;
}

.login-field {
  margin-bottom: 20px;
}
.login-field label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
}
.login-field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.login-field input:focus {
  border-color: #c92a2a;
}

.login-error {
  font-size: 13px;
  color: #e03131;
  text-align: center;
  margin-bottom: 16px;
  min-height: 20px;
}
.login-error.hidden {
  display: none;
}

.login-submit {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 4px;
  background: #07c160;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.login-submit:hover {
  background: #06ad56;
}
.login-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .login-card {
    flex-direction: column;
    min-height: auto;
  }
  .login-brand {
    padding: 32px 24px;
  }
  .login-brand h1 {
    font-size: 22px;
  }
  .login-form-panel {
    width: 100%;
    padding: 32px 24px;
  }
}

/* 滚动条 */
.conv-list::-webkit-scrollbar,
.messages-area::-webkit-scrollbar {
  width: 6px;
}
.conv-list::-webkit-scrollbar-thumb,
.messages-area::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}
.conv-list::-webkit-scrollbar-thumb:hover,
.messages-area::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* 图片上传 loading */
.chat-upload-loading {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.35);
  align-items: center;
  justify-content: center;
}
.chat-upload-loading.visible {
  display: flex;
}
.chat-upload-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 32px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  color: #666;
}
.chat-upload-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e0e0e0;
  border-top-color: #07c160;
  border-radius: 50%;
  animation: chat-upload-spin 0.8s linear infinite;
}
@keyframes chat-upload-spin {
  to { transform: rotate(360deg); }
}
