/* ==========================================
   HomeGym PWA Core Style Sheet
   ========================================== */

/* 全局自定义变量 */
:root {
  --bg-primary: #09090b;
  --bg-secondary: #16161c;
  --bg-card: rgba(22, 22, 28, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;
  
  --accent-color: #ff5f38;
  --accent-hover: #ff7e5f;
  --accent-glow: rgba(255, 95, 56, 0.25);
  
  --success-color: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --danger-color: #ef4444;
  --danger-hover: #f87171;
  
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease-out;
  
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 基础重置 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* 禁用移动端点击高亮 */
}

body {
  font-family: 'Outfit', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 针对电脑端浏览的手机壳模拟，手机端则全屏 */
#app-shell {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  background-color: var(--bg-primary);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

@media (min-width: 480px) {
  body {
    background: radial-gradient(circle at top right, #1f1b24, var(--bg-primary) 70%);
  }
  #app-shell, body > .app-header, body > .app-main, body > .app-nav, body > .timer-overlay {
    width: 480px;
    height: 92vh;
    border-radius: 32px;
    border: 6px solid #1c1c24;
    overflow: hidden;
  }
}

/* ==========================================
   Layout Layout & Navigation
   ========================================== */

/* 顶栏 */
.app-header {
  position: fixed;
  top: 0;
  width: 100%;
  max-width: 480px;
  height: calc(56px + var(--safe-top));
  padding-top: var(--safe-top);
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

.header-container {
  height: 56px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-accent {
  color: var(--accent-color);
  text-shadow: 0 0 12px var(--accent-glow);
}

/* 底栏导航 */
.app-nav {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  height: calc(58px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  flex: 1;
  height: 58px;
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.nav-item i {
  font-size: 18px;
}

.nav-item span {
  font-size: 10px;
  font-weight: 600;
}

.nav-item.active {
  color: var(--accent-color);
}

.nav-item.active i {
  transform: translateY(-2px);
  text-shadow: 0 0 10px var(--accent-glow);
}

/* 主内容滚动区 */
.app-main {
  width: 100%;
  height: 100vh;
  padding-top: calc(70px + var(--safe-top));
  padding-bottom: calc(72px + var(--safe-bottom));
  overflow-y: auto;
  scroll-behavior: smooth;
  /* 隐藏滚动条 */
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.app-main::-webkit-scrollbar {
  display: none;
}

/* ==========================================
   Component Styling (Card, Buttons)
   ========================================== */

/* 视图容器 */
.app-view {
  display: none;
  padding: 0 16px;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.25s ease-out forwards;
}

.app-view.active {
  display: flex;
}

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

/* 卡片 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: var(--transition-smooth);
}

.card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.card p.subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* 按钮 */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent-color);
  color: var(--text-primary);
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:active {
  background-color: var(--accent-hover);
  transform: scale(0.98);
}

.btn-secondary {
  background-color: var(--bg-tertiary, #27272a);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:active {
  background-color: #3f3f46;
}

.btn-success {
  background-color: var(--success-color);
  color: var(--text-primary);
  box-shadow: 0 4px 15px var(--success-glow);
}

.btn-danger {
  background-color: var(--danger-color);
  color: var(--text-primary);
}

.btn-danger:active {
  background-color: var(--danger-hover);
}

.btn-block {
  width: 100%;
}

.btn-large {
  padding: 16px 20px;
  font-size: 16px;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

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

/* ==========================================
   1. Plan View (规划页面)
   ========================================== */

.hero-card {
  text-align: center;
  background: linear-gradient(135deg, rgba(255, 95, 56, 0.08) 0%, rgba(22, 22, 28, 0.8) 100%);
  border: 1px solid rgba(255, 95, 56, 0.15);
}

.split-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.btn-split {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-split i {
  font-size: 20px;
}

.btn-split span {
  font-size: 13px;
  font-weight: 700;
}

.btn-split small {
  font-size: 9px;
  color: var(--text-muted);
}

.btn-split.selected {
  background: rgba(255, 95, 56, 0.1);
  border-color: var(--accent-color);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px var(--accent-glow);
}

/* 配置状态 */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.status-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-item .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.status-item .value {
  font-size: 13px;
  font-weight: 600;
}

/* ==========================================
   2. Active Workout View (训练页面)
   ========================================== */

.workout-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-indicator {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-color);
}

/* 动作主卡片 */
.exercise-card {
  padding: 0;
  overflow: hidden;
}

.exercise-media-box {
  width: 100%;
  height: 220px;
  background-color: #0f0f14;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.exercise-media-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.exercise-info {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.exercise-header h2 {
  font-size: 18px;
  font-weight: 800;
}

.badge {
  background: rgba(255, 95, 56, 0.15);
  color: var(--accent-color);
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 6px;
  text-transform: uppercase;
}

.instructions {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* 组列表 */
.sets-header {
  display: grid;
  grid-template-columns: 1fr 2fr 2fr 1fr;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

.sets-row {
  display: grid;
  grid-template-columns: 1fr 2fr 2fr 1fr;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  text-align: center;
}

.sets-row span {
  font-size: 14px;
  font-weight: 600;
}

.input-num {
  width: 70%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 6px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  margin: 0 auto;
}

.input-num:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* 复选框动作 */
.btn-check-set {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: none;
  color: transparent;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  margin: 0 auto;
  transition: var(--transition-fast);
}

.btn-check-set.checked {
  background-color: var(--success-color);
  border-color: var(--success-color);
  color: var(--text-primary);
  box-shadow: 0 0 10px var(--success-glow);
}

.sets-control-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}

/* 翻页器 */
.workout-pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
}

.workout-pager .btn {
  flex: 1;
}

/* ==========================================
   3. History View (历史记录)
   ========================================== */

.stats-overview {
  display: flex;
  gap: 16px;
  margin-top: 10px;
}

.stat-box {
  flex: 1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.stat-box .number {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent-color);
  text-shadow: 0 0 12px var(--accent-glow);
}

.stat-box .label {
  font-size: 11px;
  color: var(--text-secondary);
}

.history-list-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-list-section h3 {
  font-size: 14px;
  color: var(--text-secondary);
}

.history-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.history-item-header .date {
  font-size: 12px;
  color: var(--text-muted);
}

.history-item-header .title {
  font-size: 14px;
  font-weight: 700;
}

.history-item-body {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item-body .exercise-row {
  display: flex;
  justify-content: space-between;
}

.history-item-body .exercise-name {
  font-weight: 600;
}

.history-item-body .exercise-sets {
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-state i {
  font-size: 40px;
}

/* ==========================================
   4. Settings View (系统设置)
   ========================================== */

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dumbbell-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.dumbbell-tag {
  background: rgba(255, 95, 56, 0.1);
  border: 1px solid var(--accent-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-color);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dumbbell-tag button {
  background: none;
  border: none;
  color: var(--accent-color);
  cursor: pointer;
  font-size: 12px;
}

.add-weight-form {
  display: flex;
  gap: 10px;
}

.input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 12px;
  font-size: 14px;
}

.input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.danger-card {
  border-color: rgba(239, 68, 68, 0.2);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.05) 0%, rgba(22, 22, 28, 0.8) 100%);
}

.danger-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ==========================================
   Rest Timer Overlay (休息计时浮层)
   ========================================== */

.timer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(9, 9, 11, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 999;
  animation: fadeIn 0.3s ease-out;
}

.timer-overlay.active {
  display: flex;
}

.timer-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.timer-progress-ring {
  position: relative;
  width: 180px;
  height: 180px;
}

.ring-svg {
  transform: rotate(-90deg);
  width: 180px;
  height: 180px;
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.03);
  stroke-width: 8;
}

.ring-bar {
  fill: none;
  stroke: var(--accent-color);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 440; /* 2 * PI * r (r=70) */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.1s linear;
}

.timer-digits {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
}

#timer-countdown {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -2px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums; /* 等宽数字防止抖动 */
}

.timer-digits .unit {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
}

.timer-caption {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 600;
}

.timer-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-timer-action {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  transition: var(--transition-fast);
}

.btn-timer-action:active {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0.95);
}

.btn-timer-skip {
  padding: 14px 28px;
  border-radius: 30px;
  font-size: 15px;
}
