/* ============================================
   三方会议室 - 样式表
   ============================================ */

/* ====== CSS 变量 ====== */
:root {
  --bg: #f8f7f5;
  --bg-card: #ffffff;
  --bg-sidebar: #f0efed;
  --bg-input: #ffffff;
  --text: #2c2c2a;
  --text-secondary: #6b6b68;
  --text-muted: #9a9996;
  --border: #e0dfdc;
  --border-light: #ededea;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* 角色色 */
  --wuge-blue: #185FA5;
  --wuge-blue-light: #e8f1fb;
  --wuge-blue-bg: #dce9f7;
  --jiumei-green: #0F6E56;
  --jiumei-green-light: #e8f7f2;
  --jiumei-green-bg: #d4f0e5;
  --sam-orange: #D85A30;
  --sam-orange-light: #fef4ef;
  --sam-orange-bg: #fde8dc;

  /* 拍板 */
  --decision-bg: #fdecea;
  --decision-border: #e74c3c;
  --decision-text: #c0392b;

  /* 系统消息 */
  --system-bg: #f5f4f1;
  --system-text: #7a7975;

  /* 过渡 */
  --transition: 0.2s ease;
}

/* ====== 暗色模式 ====== */
body.dark {
  --bg: #1a1a18;
  --bg-card: #252523;
  --bg-sidebar: #1f1f1d;
  --bg-input: #2a2a28;
  --text: #e8e7e3;
  --text-secondary: #b0afab;
  --text-muted: #6e6d6a;
  --border: #3a3936;
  --border-light: #2f2f2d;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.5);

  --wuge-blue-light: #1c3a5c;
  --wuge-blue-bg: #152d48;
  --jiumei-green-light: #1a3e34;
  --jiumei-green-bg: #123026;
  --sam-orange-light: #3d2014;
  --sam-orange-bg: #301a10;

  --decision-bg: #3d1a16;
  --system-bg: #2a2a28;
  --system-text: #8a8985;
}

/* ====== 全局重置 ====== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ====== 顶部导航栏 ====== */
.top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 100;
  flex-shrink: 0;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text);
}

.meeting-info {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.no-meeting {
  color: var(--text-muted);
}

.top-bar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 8px;
}

.search-box input[type="text"] {
  width: 180px;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font);
}

.search-box input[type="date"] {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 12px;
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font);
}

.search-box select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 12px;
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ====== 按钮基础 ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--wuge-blue);
  color: #fff;
  border-color: var(--wuge-blue);
}

.btn-primary:hover {
  background: #134b82;
  border-color: #134b82;
}

.btn-danger {
  background: #e74c3c;
  color: #fff;
  border-color: #e74c3c;
}

.btn-danger:hover {
  background: #c0392b;
  border-color: #c0392b;
}

.btn-send {
  background: var(--wuge-blue);
  color: #fff;
  border-color: var(--wuge-blue);
  font-weight: 600;
  padding: 10px 20px;
}

.btn-send:hover {
  background: #134b82;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
}

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

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  border: none;
  background: transparent;
}

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

.btn-search {
  background: var(--wuge-blue);
  color: #fff;
  border-color: var(--wuge-blue);
  font-size: 12px;
  padding: 5px 10px;
}

/* ====== 主内容区域 ====== */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ====== 对话区域（左侧70%） ====== */
.conversation-area {
  flex: 7;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

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

/* 欢迎屏幕 */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-secondary);
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.welcome-screen h2 {
  font-size: 22px;
  margin-bottom: 8px;
  color: var(--text);
}

.welcome-screen p {
  font-size: 14px;
  margin-bottom: 4px;
  line-height: 1.6;
}

.welcome-hint {
  margin-top: 20px;
  padding: 12px 20px;
  background: var(--wuge-blue-light);
  border-radius: var(--radius);
  color: var(--wuge-blue);
}

/* ====== 日期分隔线 ====== */
.date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.date-separator::before,
.date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ====== 消息气泡 ====== */
.message-wrapper {
  display: flex;
  margin-bottom: 8px;
  position: relative;
}

.message-wrapper.decision-highlight {
  animation: decisionPulse 0.6s ease;
}

@keyframes decisionPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.message-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius);
  position: relative;
  word-break: break-word;
  line-height: 1.55;
  font-size: 14px;
}

/* 五哥消息（蓝色系） */
.message-bubble.sender-wuge {
  background: var(--wuge-blue-light);
  border: 1px solid var(--wuge-blue-bg);
  border-top-left-radius: 4px;
}

.message-bubble.sender-wuge .msg-sender-name {
  color: var(--wuge-blue);
}

/* 九妹消息（绿色系） */
.message-bubble.sender-jiumei {
  background: var(--jiumei-green-light);
  border: 1px solid var(--jiumei-green-bg);
  border-top-right-radius: 4px;
}

.message-bubble.sender-jiumei .msg-sender-name {
  color: var(--jiumei-green);
}

/* Sam 消息（橙色系） */
.message-bubble.sender-sam {
  background: var(--sam-orange-light);
  border: 1px solid var(--sam-orange-bg);
  border-top-right-radius: 4px;
  margin-left: auto;
}

.message-bubble.sender-sam .msg-sender-name {
  color: var(--sam-orange);
}

/* 系统消息 */
.message-bubble.type-system {
  background: var(--system-bg);
  border: 1px dashed var(--border);
  max-width: 90%;
  margin: 0 auto;
  text-align: center;
  font-size: 13px;
  color: var(--system-text);
  border-radius: var(--radius);
}

/* 拍板消息 */
.message-bubble.is-decision {
  border: 2px solid var(--decision-border) !important;
  background: var(--decision-bg) !important;
  box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.08);
}

.decision-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--decision-border);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 8px;
  letter-spacing: 0.5px;
}

/* 消息头部 */
.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}

.msg-sender-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

.msg-sender-avatar.avatar-wuge {
  background: var(--wuge-blue);
}

.msg-sender-avatar.avatar-jiumei {
  background: var(--jiumei-green);
}

.msg-sender-avatar.avatar-sam {
  background: var(--sam-orange);
}

.msg-sender-name {
  font-weight: 600;
}

.msg-time {
  color: var(--text-muted);
  margin-left: auto;
}

/* 消息操作按钮 */
.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity var(--transition);
}

.message-wrapper:hover .msg-actions {
  opacity: 1;
}

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

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

.msg-action-btn.decision-btn:hover {
  background: var(--decision-bg);
  color: var(--decision-text);
  border-color: var(--decision-border);
}

/* 消息对齐 */
.message-wrapper.sender-wuge,
.message-wrapper.sender-jiumei {
  justify-content: flex-start;
}

.message-wrapper.sender-sam {
  justify-content: flex-end;
}

/* ====== 侧边栏（右侧30%） ====== */
.sidebar {
  flex: 3;
  max-width: 360px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.sidebar-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--border-light);
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 12px 0;
}

/* 通道筛选按钮 */
.channel-filters {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.channel-btn {
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  font-family: var(--font);
}

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

.channel-btn.active {
  background: var(--wuge-blue-light);
  color: var(--wuge-blue);
  border-color: var(--wuge-blue-bg);
  font-weight: 600;
}

/* 会议列表 */
.meeting-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
}

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

.meeting-item.active {
  background: var(--jiumei-green-light);
  border-color: var(--jiumei-green-bg);
}

.meeting-item .meeting-item-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.meeting-item .meeting-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.meeting-item .meeting-status {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.meeting-status.active-status {
  background: #27ae60;
  color: #fff;
}

.meeting-status.ended-status {
  background: var(--border);
  color: var(--text-muted);
}

/* 拍板列表 */
.decision-item {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  font-size: 12px;
  border-left: 3px solid var(--decision-border);
  background: var(--decision-bg);
  cursor: pointer;
}

.decision-item .decision-item-sender {
  font-weight: 600;
  font-size: 11px;
}

.decision-item .decision-item-text {
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 统计 */
.stats-box {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.stat-item {
  text-align: center;
  padding: 8px 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--wuge-blue);
}

.stat-senders {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.stat-sender-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-sender-row .sender-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

/* ====== 底部输入区 ====== */
.bottom-bar {
  flex-shrink: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 3px rgba(0,0,0,0.04);
  z-index: 100;
}

.bottom-bar-inner {
  padding: 12px 20px;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 8px;
}

#messageInput {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  resize: none;
  outline: none;
  background: var(--bg-input);
  color: var(--text);
  transition: border-color var(--transition);
  max-height: 120px;
}

#messageInput:focus {
  border-color: var(--wuge-blue);
  box-shadow: 0 0 0 3px rgba(24, 95, 165, 0.1);
}

#messageInput::placeholder {
  color: var(--text-muted);
}

.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.action-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.sender-label,
.channel-label {
  font-weight: 500;
}

.sender-select,
.channel-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--bg-input);
  color: var(--text);
  font-family: var(--font);
}

.connection-status {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: default;
}

/* ====== 弹窗 ====== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 999;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  width: 440px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

.modal-sm {
  width: 360px;
}

.modal-title {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--text);
}

.modal-body {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  margin-top: 12px;
  color: var(--text-secondary);
}

.form-label:first-child {
  margin-top: 0;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.form-input:focus {
  border-color: var(--wuge-blue);
  box-shadow: 0 0 0 3px rgba(24, 95, 165, 0.1);
}

.form-textarea {
  resize: vertical;
}

.form-hint {
  font-size: 12px;
  color: #e74c3c;
  margin-top: 8px;
  min-height: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ====== Toast ====== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}

.toast.success {
  background: #27ae60;
}

.toast.error {
  background: #e74c3c;
}

.toast.info {
  background: var(--wuge-blue);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ====== 通知权限提示 ====== */
.notify-banner {
  display: none;
  padding: 8px 16px;
  background: var(--wuge-blue-light);
  color: var(--wuge-blue);
  text-align: center;
  font-size: 13px;
}

.notify-banner.show {
  display: block;
}

.notify-banner button {
  margin-left: 8px;
  background: var(--wuge-blue);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
}

/* ====== 搜索高亮 ====== */
.search-highlight {
  background: #fff3cd;
  padding: 1px 2px;
  border-radius: 2px;
}

body.dark .search-highlight {
  background: #5c4a1f;
}

/* ====== 响应式设计 ====== */
@media (max-width: 900px) {
  .sidebar {
    display: none;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    width: 300px;
    max-width: 85vw;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.mobile-show {
    display: flex;
  }

  .conversation-area {
    flex: 1;
  }

  .search-box {
    flex-wrap: wrap;
    justify-content: center;
  }

  .search-box input[type="text"] {
    width: 120px;
  }

  .top-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }
}

@media (max-width: 600px) {
  .message-bubble {
    max-width: 90%;
    font-size: 13px;
  }

  .action-row {
    flex-direction: column;
    gap: 8px;
  }

  .action-right {
    flex-wrap: wrap;
  }
}

/* ====== 滚动条全局 ====== */
body {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
