/**
 * FitChallenge 首页专用样式
 * Created: 2025-09-30
 * Purpose: 独立首页样式，避免与其他页面样式冲突
 */

/* ============================================
   CSS变量定义
   ============================================ */
:root {
  /* 渐变色 */
  --home-gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --home-gradient-welcome: linear-gradient(135deg, #48cc6c 0%, #6dd5ed 100%);
  --home-gradient-success: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
  --home-gradient-warning: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --home-gradient-info: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  
  /* 主题色 */
  --home-primary: #667eea;
  --home-primary-dark: #5568d3;
  --home-secondary: #48cc6c;
  --home-accent: #ff6b35;
  
  /* 文字颜色 */
  --home-text-primary: #2d3748;
  --home-text-secondary: #718096;
  --home-text-tertiary: #a0aec0;
  
  /* 背景色 */
  --home-bg-primary: #f8fafc;
  --home-bg-secondary: #ffffff;
  --home-bg-tertiary: #f7fafc;
  
  /* 边框和阴影 */
  --home-border: #e2e8f0;
  --home-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --home-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --home-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --home-shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
  
  /* 间距 */
  --home-space-1: 4px;
  --home-space-2: 8px;
  --home-space-3: 12px;
  --home-space-4: 16px;
  --home-space-5: 20px;
  --home-space-6: 24px;
  --home-space-8: 32px;
  --home-space-10: 40px;
  --home-space-12: 48px;
  
  /* 圆角 */
  --home-radius-sm: 6px;
  --home-radius-md: 8px;
  --home-radius-lg: 12px;
  --home-radius-xl: 16px;
  --home-radius-2xl: 24px;
  --home-radius-full: 9999px;
  
  /* 字体大小 */
  --home-text-xs: 12px;
  --home-text-sm: 14px;
  --home-text-base: 16px;
  --home-text-lg: 18px;
  --home-text-xl: 20px;
  --home-text-2xl: 24px;
  --home-text-3xl: 30px;
  --home-text-4xl: 36px;
}

/* ============================================
   页面容器
   ============================================ */
.home-page {
  min-height: 100vh;
  background: var(--home-bg-primary);
  padding: var(--home-space-4);
  padding-bottom: 100px; /* 为底部导航留空间 */
}

/* ============================================
   欢迎卡片
   ============================================ */
.home-welcome-card {
  background: var(--home-gradient-welcome);
  border-radius: var(--home-radius-2xl);
  padding: var(--home-space-8);
  margin-bottom: var(--home-space-6);
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: var(--home-shadow-lg);
}

/* 背景装饰 */
.home-welcome-card::before {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--home-radius-full);
  opacity: 0.6;
}

.home-welcome-card::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: -40px;
  width: 160px;
  height: 160px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--home-radius-full);
}

.home-welcome-header {
  position: relative;
  z-index: 2;
  margin-bottom: var(--home-space-6);
}

.home-welcome-title {
  font-size: var(--home-text-3xl);
  font-weight: 700;
  margin: 0 0 var(--home-space-2) 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.home-welcome-subtitle {
  font-size: var(--home-text-base);
  margin: 0;
  opacity: 0.9;
  font-weight: 400;
}

.home-user-info {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--home-space-4);
}

.home-user-greeting {
  font-size: var(--home-text-lg);
  margin: 0;
}

.home-user-greeting strong {
  font-weight: 700;
}

.home-logout-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.5);
  padding: var(--home-space-2) var(--home-space-5);
  border-radius: var(--home-radius-lg);
  font-size: var(--home-text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.home-logout-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

/* 统计数据网格 */
.home-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--home-space-4);
  position: relative;
  z-index: 2;
  margin-top: var(--home-space-6);
}

.home-stat-card {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: var(--home-radius-lg);
  padding: var(--home-space-4);
  text-align: center;
}

/* 步数卡片头部布局 */
.home-stat-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--home-space-2);
  margin-bottom: var(--home-space-1);
}

.home-stat-value {
  font-size: var(--home-text-2xl);
  font-weight: 700;
  margin-bottom: var(--home-space-1);
  display: block;
}

.home-stat-label {
  font-size: var(--home-text-sm);
  opacity: 0.8;
}

/* 未登录状态的CTA按钮 */
.home-cta-buttons {
  position: relative;
  z-index: 2;
  display: flex;
  gap: var(--home-space-4);
  margin-top: var(--home-space-6);
}

.home-cta-btn {
  flex: 1;
  padding: var(--home-space-4);
  border-radius: var(--home-radius-lg);
  font-size: var(--home-text-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
}

.home-cta-btn.primary {
  background: white;
  color: var(--home-primary);
  box-shadow: var(--home-shadow-md);
}

.home-cta-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--home-shadow-lg);
}

.home-cta-btn.outline {
  background: transparent;
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.home-cta-btn.outline:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   快捷功能区 - 2x2网格布局
   ============================================ */
.home-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 改为2列 */
  gap: var(--home-space-4);
  margin-bottom: var(--home-space-6);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.home-action-card {
  background: white;
  border-radius: var(--home-radius-xl);
  padding: var(--home-space-5);
  text-align: center;
  box-shadow: var(--home-shadow-sm);
  transition: all 0.3s ease;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--home-space-2);
}

.home-action-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--home-shadow-lg);
}

.home-action-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--home-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  margin-bottom: var(--home-space-2);
}

.home-action-icon.challenge {
  background: var(--home-gradient-primary);
}

.home-action-icon.wallet {
  background: var(--home-gradient-success);
}

.home-action-icon.team {
  background: var(--home-gradient-info);
}

.home-action-icon.leaderboard {
  background: var(--home-gradient-warning);
}

.home-action-label {
  font-size: var(--home-text-sm);
  font-weight: 600;
  color: var(--home-text-primary);
}

/* ============================================
   统计数据区域
   ============================================ */
.home-stats-section {
  margin-bottom: var(--home-space-6);
}

/* ============================================
   挑战区域
   ============================================ */
.home-challenge-section {
  background: white;
  border-radius: var(--home-radius-xl);
  padding: var(--home-space-6);
  box-shadow: var(--home-shadow-md);
  margin-bottom: var(--home-space-6);
}

.home-challenge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--home-space-4);
}

.home-challenge-title {
  font-size: var(--home-text-xl);
  font-weight: 700;
  color: var(--home-text-primary);
  margin: 0;
}

.home-challenge-badge {
  background: var(--home-gradient-primary);
  color: white;
  padding: var(--home-space-1) var(--home-space-3);
  border-radius: var(--home-radius-full);
  font-size: var(--home-text-xs);
  font-weight: 600;
}

.home-challenge-card {
  background: white;
  border-radius: var(--home-radius-xl);
  border: 1px solid rgba(82, 93, 255, 0.08);
  box-shadow: var(--home-shadow-sm);
  padding: var(--home-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--home-space-4);
}

.home-challenge-card.loading {
  align-items: center;
  text-align: center;
  gap: var(--home-space-3);
}

.home-challenge-skeleton {
  width: 100%;
  height: 120px;
  border-radius: var(--home-radius-lg);
  background: linear-gradient(90deg, rgba(82,93,255,0.08) 25%, rgba(82,93,255,0.15) 50%, rgba(82,93,255,0.08) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.home-challenge-title-group {
  display: flex;
  align-items: center;
  gap: var(--home-space-3);
}


.home-challenge-body {
  display: flex;
  flex-direction: column;
  gap: var(--home-space-3);
}

.home-challenge-desc {
  margin: 0;
  font-size: var(--home-text-sm);
  color: var(--home-text-secondary);
}

.home-challenge-progress {
  display: flex;
  flex-direction: column;
  gap: var(--home-space-2);
}

.home-challenge-progress-head {
  display: flex;
  justify-content: space-between;
  font-size: var(--home-text-sm);
  color: var(--home-text-secondary);
}

.home-challenge-progress-head strong {
  color: var(--home-text-primary);
  font-size: var(--home-text-lg);
}

.home-challenge-progress-bar {
  width: 100%;
  height: 10px;
  border-radius: var(--home-radius-full);
  background: rgba(82, 93, 255, 0.15);
  overflow: hidden;
}

.home-challenge-progress-inner {
  height: 100%;
  background: var(--home-gradient-primary);
  border-radius: inherit;
  transition: width 0.3s ease;
}

.home-challenge-progress-meta {
  font-size: var(--home-text-xs);
  color: var(--home-text-secondary);
  text-align: right;
}

.home-challenge-footer {
  display: flex;
  flex-direction: column;
  gap: var(--home-space-3);
}

.home-challenge-reward {
  display: flex;
  flex-direction: column;
  gap: var(--home-space-1);
}

.home-challenge-reward span {
  font-size: var(--home-text-xs);
  color: var(--home-text-secondary);
}

.home-challenge-reward strong {
  font-size: var(--home-text-lg);
  color: var(--home-text-primary);
}

.home-challenge-action {
  width: 100%;
  padding: var(--home-space-3) var(--home-space-4);
  border-radius: var(--home-radius-md);
  border: none;
  background: var(--home-gradient-primary);
  color: white;
  font-weight: 600;
  font-size: var(--home-text-sm);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.home-challenge-action:hover {
  opacity: 0.9;
}

.home-challenge-action:active {
  opacity: 0.8;
}

.home-challenge-card.empty,
.home-challenge-card.error {
  align-items: center;
  text-align: center;
  gap: var(--home-space-2);
}

.home-challenge-empty-icon {
  font-size: 36px;
  color: var(--primary-500);
}

.home-challenge-empty-title {
  margin: 0;
  font-size: var(--home-text-base);
  font-weight: 600;
  color: var(--home-text-primary);
}

.home-challenge-empty-desc {
  margin: 0;
  font-size: var(--home-text-sm);
  color: var(--home-text-secondary);
}

/* ============================================
   平台功能介绍区
   ============================================ */
.home-features-section {
  margin-bottom: var(--home-space-6);
}

.home-section-title {
  font-size: var(--home-text-2xl);
  font-weight: 700;
  color: var(--home-text-primary);
  margin: 0 0 var(--home-space-5) 0;
  text-align: center;
}

.home-features-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--home-space-4);
}

.home-feature-card {
  background: white;
  border-radius: var(--home-radius-xl);
  padding: var(--home-space-6);
  box-shadow: var(--home-shadow-sm);
  transition: all 0.3s ease;
}

.home-feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--home-shadow-md);
}

.home-feature-content {
  display: flex;
  align-items: flex-start;
  gap: var(--home-space-4);
}

.home-feature-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--home-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  flex-shrink: 0;
}

.home-feature-icon.trophy {
  background: var(--home-gradient-primary);
}

.home-feature-icon.users {
  background: var(--home-gradient-success);
}

.home-feature-icon.wallet {
  background: var(--home-gradient-info);
}

.home-feature-icon.target {
  background: var(--home-gradient-warning);
}

.home-feature-info {
  flex: 1;
}

.home-feature-title {
  font-size: var(--home-text-lg);
  font-weight: 600;
  color: var(--home-text-primary);
  margin: 0 0 var(--home-space-2) 0;
}

.home-feature-desc {
  font-size: var(--home-text-sm);
  color: var(--home-text-secondary);
  margin: 0;
  line-height: 1.6;
}

/* ============================================
   API占位符样式
   ============================================ */
.api-placeholder {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px dashed #f59e0b;
  border-radius: var(--home-radius-lg);
  padding: var(--home-space-6);
  text-align: center;
  color: #92400e;
}

.api-placeholder-icon {
  font-size: 32px;
  margin-bottom: var(--home-space-3);
  color: #f59e0b;
}

.api-placeholder-text {
  font-size: var(--home-text-lg);
  font-weight: 700;
  margin-bottom: var(--home-space-2);
}

.api-placeholder-hint {
  font-size: var(--home-text-sm);
  color: #b45309;
  font-weight: 400;
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 768px) {
  .home-page {
    padding: var(--home-space-3);
  }
  
  .home-welcome-card {
    padding: var(--home-space-6);
  }
  
  .home-welcome-title {
    font-size: var(--home-text-2xl);
  }
  
  .home-stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--home-space-3);
  }
  
  .home-stat-card {
    padding: var(--home-space-3);
  }
  
  .home-stat-value {
    font-size: var(--home-text-xl);
  }
  
  .home-stat-label {
    font-size: var(--home-text-xs);
  }
  
  .home-quick-actions {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--home-space-3);
  }
  
  .home-action-icon {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  
  .home-features-grid {
    grid-template-columns: 1fr;
  }
  
  .home-user-info {
    flex-direction: column;
    gap: var(--home-space-3);
    align-items: stretch;
  }
  
  .home-logout-btn {
    width: 100%;
  }
  
  .home-cta-buttons {
    flex-direction: column;
  }

  .home-challenge-section {
    padding: var(--home-space-4);
  }
}

@media (max-width: 480px) {
  .home-welcome-card {
    padding: var(--home-space-5);
  }
  
  .home-welcome-title {
    font-size: var(--home-text-xl);
  }
  
  .home-welcome-subtitle {
    font-size: var(--home-text-sm);
  }
  
  .home-quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .home-action-card {
    padding: var(--home-space-4);
  }
  
  .home-feature-card {
    padding: var(--home-space-4);
  }
  
  .home-section-title {
    font-size: var(--home-text-xl);
  }
}

/* ============================================
   动画效果
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.home-page > * {
  animation: fadeIn 0.4s ease-out;
}

.home-page > *:nth-child(1) { animation-delay: 0s; }
.home-page > *:nth-child(2) { animation-delay: 0.1s; }
.home-page > *:nth-child(3) { animation-delay: 0.2s; }
.home-page > *:nth-child(4) { animation-delay: 0.3s; }
.home-page > *:nth-child(5) { animation-delay: 0.4s; }

/* ============================================
   步数同步按钮和状态
   ============================================ */
.home-stat-card-steps {
  position: relative;
}

.home-sync-btn {
  width: 24px;
  height: 24px;
  min-width: 24px;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  padding: 0;
  flex-shrink: 0;
  opacity: 0.8;
}

.home-sync-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

.home-sync-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.home-sync-icon {
  font-size: 14px;
  display: block;
  transition: transform 0.3s ease;
  color: rgba(255, 255, 255, 0.9);
}

.home-sync-icon.home-syncing {
  animation: home-sync-rotate 1s linear infinite;
}

@keyframes home-sync-rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.home-sync-status {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  white-space: nowrap;
  text-align: center;
  opacity: 0;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.home-sync-status:not(:empty) {
  opacity: 0.95;
}

.home-sync-status.success {
  color: #28a745;
  background: rgba(40, 167, 69, 0.15);
}

.home-sync-status.error {
  color: #dc3545;
  background: rgba(220, 53, 69, 0.15);
}

.home-sync-status.warning {
  color: #ffc107;
  background: rgba(255, 193, 7, 0.15);
}

.home-sync-status.home-syncing {
  color: #17a2b8;
  background: rgba(23, 162, 184, 0.15);
}

/* ============================================
   自动同步状态显示
   ============================================ */
.home-auto-sync-status {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.1);
  padding: 3px 8px;
  border-radius: 12px;
  backdrop-filter: blur(4px);
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator.status-running {
  background: #28a745;
  animation: pulse-indicator 2s ease-in-out infinite;
}

.status-indicator.status-stopped {
  background: #6c757d;
}

.status-indicator.status-error {
  background: #dc3545;
}

.status-indicator.status-unknown {
  background: #ffc107;
}

@keyframes pulse-indicator {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
}

.status-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .home-auto-sync-status {
    font-size: 9px;
    padding: 2px 6px;
  }
  
  .status-indicator {
    width: 5px;
    height: 5px;
  }
  
  .status-text {
    max-width: 80px;
  }
}

/* ============================================
   打印样式
   ============================================ */
@media print {
  .home-page {
    background: white;
  }

  .home-welcome-card,
  .home-action-card,
  .home-feature-card {
    box-shadow: none;
    border: 1px solid var(--home-border);
  }
}
