/* LifeStory 前端样式 */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

* { 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);
  color: var(--text);
  line-height: 1.6;
}

#app { min-height: 100vh; }

/* 导航栏 */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.brand-icon { font-size: 28px; }

.nav-items {
  display: flex;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-light);
  font-size: 14px;
  transition: all 0.2s;
}

.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary); color: white; }

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name { font-size: 14px; font-weight: 500; }

/* 页面 */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 { font-size: 28px; font-weight: 700; }
.page-header p { color: var(--text-light); margin-top: 4px; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text-light); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color 0.2s;
  background: white;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }

/* 认证页 */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 24px;
}

.auth-card {
  background: white;
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.auth-header { text-align: center; margin-bottom: 32px; }
.auth-icon { font-size: 48px; }
.auth-header h1 { font-size: 24px; margin: 12px 0 8px; }
.auth-header p { color: var(--text-light); font-size: 14px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-light); }
.auth-footer a { color: var(--primary); text-decoration: none; }
.auth-error { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; min-height: 18px; }

/* 统计卡片 */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 40px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 14px; color: var(--text-light); }

.dashboard-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* 人物卡片 */
.person-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.person-card {
  display: flex;
  gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
}
.person-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.person-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  flex-shrink: 0;
}

.person-name { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.person-meta { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.person-bio { font-size: 14px; color: var(--text-light); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 时间轴 */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.timeline-dot {
  position: absolute;
  left: -28px;
  top: 24px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid white;
  box-shadow: 0 0 0 2px var(--primary);
}
.timeline-dot.mainchain { background: var(--success); box-shadow: 0 0 0 2px var(--success); }

.timeline-date { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.timeline-type { font-size: 12px; color: var(--primary); font-weight: 500; margin-bottom: 8px; }
.timeline-text { font-size: 15px; line-height: 1.7; margin-bottom: 12px; }
.timeline-location { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.timeline-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tag { padding: 2px 10px; background: var(--bg); border-radius: 12px; font-size: 12px; color: var(--text-light); }
.timeline-actions { display: flex; align-items: center; gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

.chain-badge {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.chain-badge.mainchain { background: #d1fae5; color: #065f46; }
.chain-badge.sidechain { background: #fef3c7; color: #92400e; }

/* 卡片网格 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s;
}
.card:hover { transform: translateY(-2px); }

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-icon { font-size: 24px; }
.card-title { font-size: 16px; font-weight: 600; }
.card-body { padding: 16px 20px; }
.card-body p { font-size: 14px; color: var(--text-light); margin-bottom: 12px; }
.card-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-light); }
.invite-code { margin-top: 12px; padding: 8px 12px; background: var(--bg); border-radius: var(--radius-sm); font-size: 13px; }
.invite-code code { background: var(--primary); color: white; padding: 2px 8px; border-radius: 4px; }

.capsule-card.locked { opacity: 0.8; }
.capsule-card.unlocked { border-left: 4px solid var(--success); }

/* 表单卡片 */
.form-card {
  max-width: 700px;
  margin: 0 auto;
  background: var(--bg-card);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* 选择器 */
.select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: white;
  cursor: pointer;
}

/* 模态框 */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal.hidden { display: none; }
.modal-content {
  background: white;
  padding: 32px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h3 { margin-bottom: 24px; font-size: 20px; }

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 16px;
}
.empty-state a { color: var(--primary); text-decoration: none; }

.error-state {
  text-align: center;
  padding: 40px;
  color: var(--danger);
}

/* 消息 */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.message-list { display: flex; flex-direction: column; gap: 12px; }
.message-item {
  padding: 16px 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.message-header { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--text-light); }
.message-content { font-size: 15px; line-height: 1.6; }
.letter-badge { display: inline-block; margin-top: 8px; padding: 2px 10px; background: #fef3c7; color: #92400e; border-radius: 12px; font-size: 12px; }

/* 响应式 */
@media (max-width: 768px) {
  .navbar { padding: 0 16px; }
  .nav-label { display: none; }
  .nav-item { padding: 8px 10px; }
  .page { padding: 20px 16px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .form-row { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 24px; }
}

/* ===== 扩展功能样式 ===== */

/* 文件上传 */
.upload-zone { margin: 16px 0; }
.upload-area { border: 2px dashed #ddd; border-radius: 12px; padding: 24px; text-align: center; cursor: pointer; transition: all 0.3s; background: #fafafa; }
.upload-area:hover { border-color: #667eea; background: #f0f4ff; }
.upload-icon { font-size: 32px; display: block; margin-bottom: 8px; }
.upload-text { color: #666; font-size: 14px; }
.upload-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.upload-item { display: flex; align-items: center; gap: 6px; background: #f5f5f5; padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.upload-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.upload-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-remove { background: none; border: none; color: #999; cursor: pointer; font-size: 16px; padding: 0 4px; }
.upload-remove:hover { color: #e74c3c; }
.upload-progress { margin-top: 12px; }
.progress-bar { width: 100%; height: 6px; background: #eee; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(135deg, #667eea, #764ba2); transition: width 0.3s; width: 0%; }

/* 时空地图 */
.map-container { display: flex; gap: 20px; height: calc(100vh - 180px); min-height: 500px; }
.map-sidebar { width: 300px; background: white; border-radius: 16px; padding: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); overflow-y: auto; }
.map-sidebar h3 { margin: 0 0 16px 0; font-size: 16px; }
.track-list { flex: 1; }
.track-group { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid #f0f0f0; }
.track-place { font-weight: 600; color: #333; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.track-count { background: #667eea; color: white; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.track-items { display: flex; flex-direction: column; gap: 6px; }
.track-item { display: flex; gap: 8px; font-size: 12px; color: #666; }
.track-date { color: #999; min-width: 80px; }
.track-content { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-more { font-size: 11px; color: #667eea; cursor: pointer; margin-top: 4px; }
.map-stats { display: flex; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid #f0f0f0; }
.stat-item { text-align: center; flex: 1; }
.stat-num { display: block; font-size: 24px; font-weight: 700; color: #667eea; }
.stat-label { font-size: 11px; color: #999; }
.map-main { flex: 1; position: relative; background: white; border-radius: 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); overflow: hidden; }
.map-canvas { width: 100%; height: 100%; position: relative; }
.map-placeholder { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: #ccc; }
.map-icon { font-size: 64px; display: block; margin-bottom: 16px; }
.map-hint { font-size: 13px; color: #999; margin-top: 8px; }
.map-controls { position: absolute; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; }
.map-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.15); cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.map-btn:hover { background: #f5f5f5; }

/* 写书 */
.write-container { display: flex; flex-direction: column; gap: 20px; max-width: 900px; margin: 0 auto; }
.write-intro h3 { margin: 0 0 12px 0; }
.write-intro p { color: #666; margin: 0 0 16px 0; }
.write-features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.write-feature { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #555; background: #f8f9ff; padding: 10px; border-radius: 8px; }
.write-form h3 { margin: 0 0 16px 0; }
.write-output h3 { margin: 0 0 16px 0; }
.book-content { background: #fafafa; padding: 32px; border-radius: 12px; line-height: 1.8; max-height: 600px; overflow-y: auto; }
.book-title { text-align: center; font-size: 28px; margin-bottom: 8px; }
.book-meta { text-align: center; color: #999; font-size: 13px; margin-bottom: 32px; }
.book-toc { background: white; padding: 16px; border-radius: 8px; margin-bottom: 32px; border: 1px solid #eee; }
.book-toc h3 { margin: 0 0 12px 0; font-size: 16px; }
.book-toc ul { list-style: none; padding: 0; margin: 0; }
.book-toc li { padding: 4px 0; }
.book-toc a { color: #667eea; text-decoration: none; }
.book-year { font-size: 22px; color: #667eea; margin: 32px 0 16px 0; padding-bottom: 8px; border-bottom: 2px solid #667eea; }
.book-chapter { margin-bottom: 24px; padding: 16px; background: white; border-radius: 8px; }
.chapter-date { font-size: 12px; color: #999; margin-bottom: 8px; }
.chapter-content { color: #333; white-space: pre-wrap; }
.chapter-tags { margin-top: 8px; font-size: 12px; color: #667eea; }
.book-footer { text-align: center; color: #ccc; font-size: 12px; margin-top: 48px; padding-top: 24px; border-top: 1px solid #eee; }

/* 家族认知库 */
.cognition-intro { margin-bottom: 20px; }
.cognition-intro p { margin: 0; color: #555; line-height: 1.6; }
.cognition-filters { display: flex; gap: 12px; margin-bottom: 20px; }
.cognition-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.cognition-card { transition: transform 0.2s; }
.cognition-card:hover { transform: translateY(-2px); }
.cognition-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cognition-category { background: linear-gradient(135deg, #667eea, #764ba2); color: white; font-size: 11px; padding: 3px 10px; border-radius: 10px; }
.cognition-date { font-size: 12px; color: #999; }
.cognition-title { font-size: 16px; margin: 0 0 8px 0; color: #333; }
.cognition-preview { font-size: 13px; color: #666; line-height: 1.5; margin-bottom: 12px; }

/* 数字遗产 */
.heritage-intro { margin-bottom: 20px; }
.heritage-intro p { margin: 0 0 8px 0; color: #555; line-height: 1.6; }
.heritage-notice { color: #e67e22 !important; font-size: 13px; }
.heritage-status { display: flex; align-items: center; gap: 12px; }
.status-badge { padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.status-inactive { background: #f5f5f5; color: #999; }
.status-active { background: #d4edda; color: #28a745; }
.status-hint { font-size: 12px; color: #999; }
.checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #555; cursor: pointer; }
.heritage-preview-list { display: flex; flex-direction: column; gap: 12px; }
.preview-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: #f8f9ff; border-radius: 8px; font-size: 14px; color: #555; }

/* 响应式 */
@media (max-width: 768px) {
  .map-container { flex-direction: column; height: auto; }
  .map-sidebar { width: 100%; }
  .map-main { min-height: 400px; }
  .write-features { grid-template-columns: repeat(2, 1fr); }
  .cognition-list { grid-template-columns: 1fr; }
  .nav-items { overflow-x: auto; }
}
