/* ============================================
   大家庭成员记录 - 全局样式
   手机优先设计，暖色调配色
   ============================================ */

/* CSS变量定义 */
:root {
  /* 暖色调配色 */
  --bg-primary: #FDF8F3;
  --bg-secondary: #FFF5EB;
  --bg-card: #FFFFFF;
  --text-primary: #3D3D3D;
  --text-secondary: #6B6B6B;
  --accent: #E8833A;
  --accent-light: #FFAA6C;
  --accent-dark: #C6692A;
  --border: #E8DDD3;
  --shadow: rgba(0, 0, 0, 0.08);
  --shadow-hover: rgba(0, 0, 0, 0.15);
  --timeline-line: #E8DDD3;
  --timeline-dot: #E8833A;
  --error: #E74C3C;
  --success: #27AE60;
  
  /* 尺寸变量 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;
  
  /* 动画 */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   密码保护弹窗
   ============================================ */
.password-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.password-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 32px var(--shadow);
  text-align: center;
  animation: fadeInUp 0.5s ease;
}

.password-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 32px;
}

.password-box h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.password-box p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.password-input-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.password-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  text-align: center;
  letter-spacing: 4px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.password-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 131, 58, 0.15);
}

.password-input::placeholder {
  letter-spacing: normal;
  color: var(--text-secondary);
}

.password-btn {
  width: 100%;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.password-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(232, 131, 58, 0.35);
}

.password-btn:active {
  transform: translateY(0);
}

.password-error {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 12px;
  min-height: 20px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.password-error.show {
  opacity: 1;
}

/* ============================================
   加载状态
   ============================================ */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px 20px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  margin-top: 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ============================================
   错误提示
   ============================================ */
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px 20px;
  text-align: center;
}

.error-icon {
  width: 80px;
  height: 80px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 20px;
}

.error-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.error-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 280px;
  line-height: 1.6;
}

/* ============================================
   首页 - 头部
   ============================================ */
.header {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  padding: 40px 20px 32px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.header-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ============================================
   首页 - 成员网格（优化20人布局）
   ============================================ */
.members-container {
  padding: 24px 16px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

.members-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* 成员卡片 */
.member-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.member-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-light) 0%, var(--accent) 100%);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.member-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px var(--shadow-hover);
}

.member-card:hover::before {
  opacity: 1;
}

.member-avatar {
  width: 70px;
  height: 70px;
  border-radius: var(--radius-full);
  object-fit: cover;
  margin: 0 auto 10px;
  border: 3px solid var(--bg-primary);
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform var(--transition-normal);
}

.member-card:hover .member-avatar {
  transform: scale(1.05);
}

.member-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.member-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: var(--bg-primary);
  padding: 3px 8px;
  border-radius: 20px;
}

/* ============================================
   详情页 - 头部
   ============================================ */
.detail-header {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  padding: 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.detail-header-content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.back-btn:hover {
  background: var(--bg-primary);
  transform: translateX(-2px);
}

.back-btn svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-primary);
}

.detail-avatar {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 3px solid var(--bg-card);
  box-shadow: 0 2px 8px var(--shadow);
  flex-shrink: 0;
}

.detail-info {
  flex: 1;
  min-width: 0;
}

.detail-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.detail-stats {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ============================================
   详情页 - 时间轴
   ============================================ */
.timeline-container {
  padding: 32px 20px 40px;
  max-width: 800px;
  margin: 0 auto;
}

.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--timeline-line) 0%, var(--timeline-dot) 50%, var(--timeline-line) 100%);
  border-radius: 1px;
}

/* 时间轴项目 */
.timeline-item {
  position: relative;
  margin-bottom: 32px;
  animation: fadeInUp 0.5s ease backwards;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

/* 交错动画 */
.timeline-item:nth-child(1) { animation-delay: 0.05s; }
.timeline-item:nth-child(2) { animation-delay: 0.1s; }
.timeline-item:nth-child(3) { animation-delay: 0.15s; }
.timeline-item:nth-child(4) { animation-delay: 0.2s; }
.timeline-item:nth-child(5) { animation-delay: 0.25s; }
.timeline-item:nth-child(n+6) { animation-delay: 0.3s; }

.timeline-dot {
  position: absolute;
  left: -28px;
  top: 8px;
  width: 14px;
  height: 14px;
  background: var(--timeline-dot);
  border-radius: 50%;
  border: 3px solid var(--bg-primary);
  box-shadow: 0 0 0 2px var(--timeline-dot);
}

.timeline-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 2px 12px var(--shadow);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  border: 1px solid var(--border);
}

.timeline-content:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--shadow-hover);
}

/* 图片/视频容器 - 保持原比例 */
.timeline-image-wrapper {
  position: relative;
  width: 100%;
  min-height: 200px;
  max-height: 600px;
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-image {
  max-width: 100%;
  max-height: 600px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* 视频样式 */
.timeline-video {
  max-width: 100%;
  max-height: 600px;
  width: 100%;
  height: auto;
  display: block;
  background: #000;
}

/* 视频标记 */
.video-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10;
}

.timeline-info {
  padding: 16px;
}

.timeline-date {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.timeline-desc {
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.5;
}

/* 日期来源标记 */
.date-source {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-left: 8px;
  font-weight: normal;
}

/* ============================================
   空状态
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

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

.empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 240px;
}

/* ============================================
   动画关键帧
   ============================================ */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* 页面淡入 */
.page-content {
  animation: fadeIn 0.5s ease;
}

/* ============================================
   响应式设计 - 平板和桌面（优化20人布局）
   ============================================ */
@media (min-width: 480px) {
  .members-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }
  
  .member-avatar {
    width: 75px;
    height: 75px;
  }
  
  .member-name {
    font-size: 1rem;
  }
}

@media (min-width: 640px) {
  .members-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
  
  .member-card {
    padding: 18px 14px;
  }
  
  .member-avatar {
    width: 80px;
    height: 80px;
  }
}

@media (min-width: 768px) {
  .header {
    padding: 50px 40px 35px;
  }
  
  .header h1 {
    font-size: 2rem;
  }
  
  .members-container {
    padding: 35px 24px 50px;
  }
  
  .members-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
  }
  
  .member-card {
    padding: 20px 16px;
  }
  
  .member-avatar {
    width: 85px;
    height: 85px;
  }
  
  .timeline-container {
    padding: 48px 32px 60px;
  }
  
  .timeline {
    padding-left: 40px;
  }
  
  .timeline::before {
    left: 10px;
    width: 3px;
  }
  
  .timeline-dot {
    left: -40px;
    width: 18px;
    height: 18px;
    border-width: 4px;
  }
  
  .timeline-info {
    padding: 20px;
  }
  
  .timeline-date {
    font-size: 1rem;
  }
  
  .timeline-desc {
    font-size: 1.125rem;
  }
}

@media (min-width: 1024px) {
  .members-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
  }
  
  .member-avatar {
    width: 90px;
    height: 90px;
  }
  
  .detail-header-content {
    gap: 24px;
  }
  
  .detail-avatar {
    width: 72px;
    height: 72px;
  }
  
  .detail-name {
    font-size: 1.5rem;
  }
}

/* 大屏幕 - 支持20人显示 */
@media (min-width: 1280px) {
  .members-grid {
    grid-template-columns: repeat(7, 1fr);
    gap: 20px;
  }
  
  .members-container {
    max-width: 1600px;
  }
}

@media (min-width: 1536px) {
  .members-grid {
    grid-template-columns: repeat(8, 1fr);
    gap: 24px;
  }
}

/* ============================================
   微信内置浏览器优化
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* iOS设备 */
  body {
    /* 防止iOS橡皮筋效果 */
    overscroll-behavior-y: none;
  }
  
  .member-card,
  .timeline-content,
  .back-btn,
  .password-btn {
    /* 防止iOS点击高亮 */
    -webkit-tap-highlight-color: transparent;
  }
}

/* ============================================
   图片加载错误样式
   ============================================ */
img.error {
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

img.error::after {
  content: '🖼️';
  font-size: 32px;
}

/* ============================================
   滚动条美化
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-light);
}

/* ============================================
   选中文字样式
   ============================================ */
::selection {
  background: var(--accent-light);
  color: white;
}
