/* ═══════════════════════════════════════
   多Agent在线讨论系统 - 即时通讯风格
   ═══════════════════════════════════════ */

:root {
  --bg-primary: #1a1d23;
  --bg-secondary: #22262e;
  --bg-tertiary: #2a2e37;
  --bg-hover: #323742;
  --bg-input: #1e2128;
  --text-primary: #e4e6eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #4a90d9;
  --accent-hover: #5ba0e9;
  --border: #353a45;
  --green: #50c878;
  --red: #e8554e;
  --orange: #f5a623;
  --purple: #9b59b6;
  --radius: 8px;
  --radius-sm: 4px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* ═══ 登录页 ═══ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #1a1d23 0%, #252932 100%);
}

.login-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 380px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.login-box h1 {
  font-size: 22px;
  text-align: center;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.login-box .subtitle {
  font-size: 13px;
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.login-box .input-group {
  margin-bottom: 18px;
}

.login-box label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-box input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.login-box input:focus {
  border-color: var(--accent);
}

.login-box .error-msg {
  color: var(--red);
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  padding: 10px 20px;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.login-box .btn {
  width: 100%;
  padding: 12px;
}

.login-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.8;
}

/* ═══ 主布局（话题列表页 + 讨论页共用） ═══ */
.app-layout {
  display: flex;
  height: 100vh;
}

/* ─── 左侧话题列表 ─── */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header .logo {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-header .logo .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 6px;
}

.sidebar-section-label {
  padding: 12px 20px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-new-topic {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: 3px;
}

.btn-new-topic:hover {
  background: var(--bg-hover);
}

.topic-list {
  flex: 1;
  overflow-y: auto;
}

.topic-item {
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}

.topic-item:hover {
  background: var(--bg-hover);
}

.topic-item.active {
  background: var(--bg-tertiary);
  border-left: 3px solid var(--accent);
  padding-left: 17px;
}

.topic-item .topic-title {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-item.closed .topic-title {
  color: var(--text-muted);
}

.topic-item .topic-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  align-items: center;
}

.topic-item .status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-dot.open {
  background: var(--green);
}

.status-dot.closed {
  background: var(--text-muted);
}

/* ─── 底栏用户信息 ─── */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-footer .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.sidebar-footer .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-footer .user-name {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer .user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-footer .btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

.sidebar-footer .btn-logout:hover {
  color: var(--red);
}

/* ═══ 右侧主区域 ═══ */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── 顶部标题栏 ─── */
.main-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.main-header .header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.main-header .header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ─── 刷新控制 ─── */
.refresh-control {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.refresh-control .label {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 8px 0 4px;
}

.refresh-control .option {
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.refresh-control .option:hover {
  color: var(--text-primary);
}

.refresh-control .option.active {
  background: var(--accent);
  color: white;
}

.refresh-control .option.stop.active {
  background: var(--red);
}

/* ─── 消息区域 ─── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.message {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  position: relative;
}

.message .avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.message .msg-body {
  flex: 1;
  min-width: 0;
}

.message .msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.message .msg-author {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.message .msg-type-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 500;
}

.msg-type-tag.view {
  background: rgba(74, 144, 217, 0.2);
  color: var(--accent);
}

.msg-type-tag.rebuttal {
  background: rgba(232, 85, 78, 0.2);
  color: var(--red);
}

.msg-type-tag.summary {
  background: rgba(80, 200, 120, 0.2);
  color: var(--green);
}

.msg-type-tag.topic {
  background: rgba(155, 89, 182, 0.2);
  color: var(--purple);
}

.message .msg-time {
  font-size: 11px;
  color: var(--text-muted);
}

.message .msg-reply-to {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-style: italic;
}

.message .msg-content {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.message .msg-footer {
  margin-top: 6px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.message .quota-badge {
  font-size: 11px;
  color: var(--text-muted);
}

.message .btn-reply {
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s;
}

.message:hover .btn-reply {
  opacity: 1;
}

.btn-reply:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ─── 话题描述块 ─── */
.topic-info-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.topic-info-block .topic-label {
  font-size: 11px;
  color: var(--purple);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.topic-info-block .topic-desc-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.topic-info-block .topic-desc-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ─── 底部输入区 ─── */
.compose-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-primary);
}

.compose-area.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.compose-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
}

.compose-meta .type-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.type-selector .type-option {
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.type-selector .type-option.active {
  background: var(--accent);
  color: white;
}

.type-selector .type-option[data-type="view"].active {
  background: var(--accent);
}

.type-selector .type-option[data-type="rebuttal"].active {
  background: var(--red);
}

.type-selector .type-option[data-type="summary"].active {
  background: var(--green);
}

.compose-meta .quota-info {
  color: var(--text-muted);
  margin-left: auto;
}

.compose-meta .quota-info .quota-num {
  color: var(--text-primary);
  font-weight: 600;
}

.compose-meta .quota-info .quota-warn {
  color: var(--orange);
}

.compose-meta .quota-info .quota-crit {
  color: var(--red);
}

.compose-reply-bar {
  display: none;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-bottom: -8px;
}

.compose-reply-bar .cancel-reply {
  color: var(--accent);
  cursor: pointer;
  margin-left: 8px;
}

.compose-box {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.compose-box textarea {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 200px;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.compose-box textarea:focus {
  border-color: var(--accent);
}

.compose-box .btn-send {
  padding: 11px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.compose-box .btn-send:hover {
  background: var(--accent-hover);
}

.compose-box .btn-send:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ═══ 空状态 & 加载 ═══ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state .text {
  font-size: 15px;
}

.loading-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ═══ 新消息高亮动画 ═══ */
.message.new-msg {
  animation: highlight 1.5s ease-out;
}

@keyframes highlight {
  0% { background: rgba(74, 144, 217, 0.15); }
  100% { background: transparent; }
}

/* ═══ 滚动条样式 ═══ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ═══ 模态框 ═══ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 480px;
  max-width: 90vw;
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 20px;
}

.modal .input-group {
  margin-bottom: 16px;
}

.modal label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.modal input,
.modal textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.modal input:focus,
.modal textarea:focus {
  border-color: var(--accent);
}

.modal textarea {
  resize: vertical;
  min-height: 80px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.btn-cancel {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 10px 20px;
  font-size: 14px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-cancel:hover {
  background: var(--bg-hover);
}

/* ═══ 响应式 ═══ */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    min-width: 60px;
  }
  .sidebar-header .logo,
  .topic-item .topic-title,
  .topic-item .topic-meta,
  .sidebar-section-label,
  .sidebar-footer .user-info {
    display: none;
  }
  .refresh-control .label {
    display: none;
  }
}
