/* 护动智眸 — 全局样式（导航 + 卡片 + 按钮 + 三页布局） */

/* ===== 导航栏 ===== */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.nav-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.nav-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}
.nav-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
}

.nav-tabs {
  display: flex;
  gap: 4px;
}
.nav-tab {
  padding: 8px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.nav-tab:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.nav-tab.active {
  background: var(--accent);
  color: #fff;
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-username {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== 主容器 ===== */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== 页面切换 ===== */
.page {
  display: none;
}
.page.active {
  display: block;
  animation: page-in 0.25s ease;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 按钮 ===== */
.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: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-pressed);
}
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) {
  background: #ebebed;
}
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--bg-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-secondary);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ===== 表单 ===== */
.select,
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e2e2e6;
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.15s;
}
.select:focus,
.input:focus {
  outline: none;
  border-color: var(--accent);
}
.textarea {
  min-height: 72px;
  resize: vertical;
}
.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ===== 训练页 ===== */
.training-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.test-selector { flex: 0 0 240px; }
.training-controls {
  display: flex;
  gap: 10px;
}

.training-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.camera-container {
  flex: 0 0 65%;
}
.camera-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: #000;
  color: var(--risk-danger);
  font-size: 14px;
  text-align: center;
}

.data-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* ===== 卡片 ===== */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ===== FMS 评分卡 ===== */
.score-display {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 12px;
}
.score-number {
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.score-max {
  font-size: 20px;
  color: var(--text-tertiary);
  font-weight: 500;
}
.score-bar {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}
.score-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s, background 0.3s;
}

.issues-list,
.angles-list,
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.empty-hint {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* 关节角度项 */
.angle-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.angle-item .angle-label { color: var(--text-secondary); }
.angle-item .angle-value {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* 风险预警项 */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.alert-item.warning {
  background: rgba(255, 159, 10, 0.1);
  color: #9a6700;
}
.alert-item.danger {
  background: rgba(255, 69, 58, 0.1);
  color: #c4231a;
}
.alert-item.safe {
  color: var(--risk-safe);
}

/* ===== 报告页 ===== */
.report-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.report-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.report-card { min-height: 0; }
.report-card-full { grid-column: 1 / -1; }

.report-score-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ring-svg { width: 180px; height: 180px; }
.ring-center {
  font-size: 40px;
  font-weight: 700;
  fill: var(--text-primary);
}
.ring-label {
  font-size: 12px;
  fill: var(--text-tertiary);
}
.risk-badge {
  padding: 4px 14px;
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.risk-badge.low { background: var(--risk-safe); }
.risk-badge.moderate { background: var(--risk-warning); }
.risk-badge.high { background: var(--risk-danger); }

.radar-svg { width: 100%; max-width: 360px; }
.coaching-card {
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 14px;
}

/* ===== 设置页 ===== */
.settings-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-row {
  display: flex;
  flex-direction: column;
}
.settings-tip {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* 开关 */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  inset: 0;
  background: #e2e2e6;
  border-radius: 13px;
  transition: 0.2s;
}
.switch-slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch-slider {
  background: var(--risk-safe);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: rgba(29, 29, 31, 0.92);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 1000;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error { background: rgba(255, 69, 58, 0.92); }
.toast.success { background: rgba(48, 209, 88, 0.92); }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .training-body { flex-direction: column; }
  .camera-container { flex: none; width: 100%; }
  .data-panel { width: 100%; }
  .training-header { flex-direction: column; align-items: stretch; }
  .test-selector { flex: none; }
  .report-grid { grid-template-columns: 1fr; }
  .stats-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 模式切换器 ===== */
.mode-switcher {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}
.mode-btn {
  padding: 8px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.mode-btn:hover { color: var(--text-primary); }
.mode-btn.active {
  background: var(--bg-primary);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ===== 训练数据面板 ===== */
.train-metrics {
  display: flex;
  gap: 20px;
  justify-content: space-around;
}
.train-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.train-metric-label {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.train-metric-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* 质量明细行 */
.quality-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.quality-row.warning { background: rgba(255, 159, 10, 0.08); }
.quality-row.danger { background: rgba(255, 69, 58, 0.08); }
.quality-label { flex: 1; color: var(--text-secondary); }
.quality-value { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 500; }
.quality-penalty { color: var(--risk-danger); font-weight: 600; font-size: 12px; }

/* 疲劳状态 */
.train-fatigue-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--bg-secondary);
}
.fatigue-badge {
  padding: 3px 12px;
  border-radius: var(--radius-xl);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
}
.fatigue-badge.safe { background: rgba(48, 209, 88, 0.12); color: var(--risk-safe); }
.fatigue-badge.warning { background: rgba(255, 159, 10, 0.12); color: #9a6700; }
.fatigue-badge.danger { background: rgba(255, 69, 58, 0.12); color: #c4231a; }

/* ===== 统计页 ===== */
.stats-container { padding: 0; }
.stats-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--bg-secondary);
}
.stats-tab {
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.stats-tab:hover { color: var(--text-primary); }
.stats-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.stats-body { display: flex; flex-direction: column; gap: 16px; }

/* KPI 卡片 */
.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.stats-kpi { text-align: center; }
.stats-kpi-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.stats-kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stats-kpi-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-left: 2px;
}

/* 动作分布条 */
.dist-list { display: flex; flex-direction: column; gap: 10px; }
.dist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.dist-name { flex: 0 0 100px; color: var(--text-secondary); }
.dist-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}
.dist-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}
.dist-val {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* 安全事件标签 */
.safety-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
}
.safety-tag.danger { background: rgba(255, 69, 58, 0.12); color: #c4231a; }
.safety-tag.warning { background: rgba(255, 159, 10, 0.12); color: #9a6700; }
