/* === 海哥AI分身 · ChatGPT 风格 === */

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

:root {
  --bg: #ffffff;
  --bg-secondary: #f7f7f8;
  --bg-sidebar: #f9f9f9;
  --bg-hover: #ececec;
  --text: #2d2d2d;
  --text-muted: #6e6e80;
  --text-on-active: #2d2d2d;
  --border: #e5e5e5;
  --accent: #19c37d;
  --error: #d9534f;
  --active-bg: #ececec;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #212121;
    --bg-secondary: #2a2a2a;
    --bg-sidebar: #171717;
    --bg-hover: #2a2a2a;
    --text: #ececec;
    --text-muted: #a0a0a8;
    --border: #3a3a3a;
    --active-bg: #2f2f2f;
  }
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

/* ===== 整体布局 ===== */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== 侧栏 ===== */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.sidebar-header {
  padding: 12px;
}
.new-chat-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}
.new-chat-btn:hover {
  background: var(--bg-hover);
}
.convo-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}
.convo-list::-webkit-scrollbar { width: 4px; }
.convo-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.convo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 2px;
  position: relative;
  transition: background 0.15s;
}
.convo-item:hover {
  background: var(--bg-hover);
}
.convo-item.active {
  background: var(--active-bg);
}
.convo-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.convo-delete {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
}
.convo-item:hover .convo-delete {
  display: block;
}
.convo-delete:hover {
  background: var(--border);
  color: var(--error);
}
.sidebar-footer {
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
}
.footer-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.footer-name {
  font-size: 13px;
  font-weight: 500;
}
.footer-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== 主区域 ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.header {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}
.menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.menu-btn:hover {
  background: var(--bg-hover);
}
.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
}
.header-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.header-spacer { flex: 1; }

/* 对话区 */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  scroll-behavior: smooth;
}
.chat-inner {
  max-width: 760px;
  margin: 0 auto;
}
.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* 欢迎页 */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 20px;
  max-width: 600px;
  margin: 0 auto;
}
.welcome-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin-bottom: 18px;
  object-fit: cover;
}
.welcome h2 {
  font-size: 24px;
  margin-bottom: 8px;
  font-weight: 600;
}
.welcome p {
  color: var(--text-muted);
  margin-bottom: 28px;
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.suggest {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.suggest:hover { background: var(--bg-hover); }

/* 消息 */
.message {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
}
.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.message-body {
  flex: 1;
  min-width: 0;
}
.message-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.message-content {
  white-space: pre-wrap;
  word-wrap: break-word;
}
.message-content strong { font-weight: 600; }
.message-content em { color: var(--text-muted); font-style: normal; font-size: 13px; }
.message-content blockquote {
  border-left: 3px solid var(--border);
  padding: 6px 12px;
  margin: 8px 0;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-radius: 0 4px 4px 0;
}
.message.user .message-avatar { background: #5b67e0; color: white; }
.message.assistant .message-avatar { background: white; }

.intent-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  margin-bottom: 6px;
}
.intent-tag.撮合 { background: #e8f5e9; color: #2e7d32; }
.intent-tag.答疑 { background: #e3f2fd; color: #1565c0; }
.intent-tag.闲聊 { background: #f3e5f5; color: #7b1fa2; }
.intent-tag.敏感 { background: #ffebee; color: #c62828; }

@media (prefers-color-scheme: dark) {
  .intent-tag.撮合 { background: #1b3a1f; color: #81c784; }
  .intent-tag.答疑 { background: #1a2e44; color: #64b5f6; }
}

.cursor {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: var(--text);
  animation: blink 0.8s infinite;
  vertical-align: middle;
  margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* 输入区 */
.input-bar {
  border-top: 1px solid var(--border);
  padding: 14px 20px 18px;
  flex-shrink: 0;
  background: var(--bg);
}
.input-wrap {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 12px;
  max-width: 760px;
  margin: 0 auto;
  transition: border-color 0.15s;
}
.input-wrap:focus-within { border-color: var(--text-muted); }
#input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  max-height: 200px;
  padding: 6px 0;
}
.send-btn {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.footer-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* 移动端遮罩 */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
}
.sidebar-overlay.show {
  display: block;
}

/* 移动端响应 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    z-index: 101;
    height: 100%;
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .menu-btn {
    display: block;
  }
}
