/* AI Community - DeepSeek 风格 CSS */
:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #2a2a2a;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-muted: #666;
  --accent: #4d9fff;
  --accent-hover: #3a8ae6;
  --border: #333;
  --success: #52c41a;
  --error: #ff4d4f;
  --warning: #faad14;
}

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

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

.page { display: none; height: 100vh; }
.page.active { display: flex; }

/* ============ 登录/注册页 ============ */
#auth-page {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0d0d0d 0%, #1a1a2e 100%);
}

.auth-container {
  width: 400px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.logo { font-size: 48px; margin-bottom: 10px; }
.auth-header h1 { font-size: 24px; color: var(--text-primary); }
.auth-header p { color: var(--text-secondary); font-size: 14px; margin-top: 8px; }

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 4px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s;
}

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

.auth-form { display: none; }
.auth-form.active { display: block; }

.form-group {
  margin-bottom: 16px;
}

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

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
}

.email-row {
  display: flex;
  gap: 8px;
}

.email-row input { flex: 1; }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}

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

.btn-secondary {
  padding: 12px 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}

.code-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-box span:first-child { color: var(--text-secondary); font-size: 12px; }
.code-box span:last-child { color: var(--accent); font-size: 18px; font-weight: bold; letter-spacing: 2px; }

.hint { color: var(--text-muted); font-size: 12px; margin-top: 6px; }

/* ============ 主应用 ============ */
#app-page { flex-direction: row; }

/* 侧边栏 */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.btn-new {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.sidebar-nav {
  display: flex;
  gap: 4px;
  padding: 8px;
}

.nav-btn {
  flex: 1;
  padding: 8px 4px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  font-size: 12px;
  transition: all 0.2s;
}

.nav-btn:hover, .nav-btn.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conv-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.2s;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item:hover { background: var(--bg-tertiary); }
.conv-item.active { background: var(--bg-tertiary); color: var(--text-primary); }

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

.free-time { font-size: 12px; color: var(--warning); }
.btn-text { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 13px; }

/* 主内容区 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.content-page { display: none; flex-direction: column; height: 100%; }
.content-page.active { display: flex; }

/* 聊天页 */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-header h2 { flex: 1; font-size: 16px; font-weight: 500; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: none;
}

.chat-mode-selector select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-message {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.welcome-message h2 { font-size: 28px; color: var(--text-primary); margin-bottom: 12px; }

.quick-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 10px 18px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message.thinking {
  font-size: 12px;
  color: var(--text-muted);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  margin-bottom: 8px;
}

.input-area {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
}

.input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 120px;
  font-family: inherit;
}

.btn-send {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

.input-tools {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.tool-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

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

/* 角色页面 */
.page-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.page-header h2 { font-size: 18px; margin-bottom: 12px; }

.filter-bar { display: flex; gap: 8px; }

.filter-btn {
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.characters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.character-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.character-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.character-card .char-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 10px;
}

.character-card h3 { font-size: 15px; margin-bottom: 4px; }
.character-card p { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }

.char-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* 游戏页面 */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px;
}

.game-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.game-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.game-icon { font-size: 40px; margin-bottom: 10px; }
.game-card h3 { font-size: 15px; margin-bottom: 4px; }
.game-card p { font-size: 12px; color: var(--text-secondary); }

/* 个人中心 */
.profile-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 30px;
  margin: 16px;
  text-align: center;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin: 0 auto 16px;
}

.profile-card h3 { font-size: 18px; margin-bottom: 4px; }
.profile-card p { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 20px;
}

.stat { text-align: center; }
.stat-value { display: block; font-size: 24px; font-weight: bold; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-secondary); }

.profile-actions { margin-top: 20px; }

.btn-outline {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

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

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  z-index: 9999;
  transition: transform 0.3s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--error); }
.toast.success { border-color: var(--success); }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    z-index: 100;
    transition: left 0.3s;
  }
  .sidebar.open { left: 0; }
  .btn-icon { display: block; }
  .auth-container { padding: 24px; }
  .characters-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* 滚动条 */
::-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); }

/* 打字动画 */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* 钉钉登录按钮 */
.btn-dingtalk {
  width: 100%;
  padding: 12px;
  background: #0089FF;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 10px;
}
.btn-dingtalk:hover { background: #0073E6; }

.divider {
  text-align: center;
  margin: 15px 0;
  position: relative;
}
.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}
.divider span {
  background: var(--bg-secondary);
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 13px;
  position: relative;
}
