/* ── Workout page layout ─────────────────────────────────────────── */
.workout-page { min-height: calc(100vh - 60px); display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ── Exercise selector ───────────────────────────────────────────── */
.exercise-selector {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
}
.selector-inner { text-align: center; max-width: 800px; width: 100%; }
.selector-inner h1 { margin-bottom: .75rem; }
.selector-sub { color: var(--text-muted); margin-bottom: 3rem; }

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  text-align: left;
}

.exercise-card {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1.75rem 1.5rem;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .2s, transform .15s, box-shadow .2s;
  text-align: left;
  color: var(--text);
  font-family: inherit;
}
.exercise-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,229,160,.15);
}
.exercise-card-icon { font-size: 3rem; }
.exercise-card h3 { font-size: 1.15rem; }
.exercise-card p { color: var(--text-muted); font-size: .875rem; line-height: 1.5; flex: 1; }

/* ── Workout session layout ──────────────────────────────────────── */
.workout-session {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  height: calc(100vh - 62px);
  overflow: hidden;
}

/* Camera side */
.workout-camera-side {
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
}

.camera-container {
  position: relative;
  flex: 1;
  overflow: hidden;
}

#workout-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#workout-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
}

.camera-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.8);
  gap: 1rem;
  color: var(--text-muted);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pose-feedback {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1.25rem;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(8px);
  color: var(--text-muted);
  font-size: .875rem;
}
.feedback-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background .3s;
}
.feedback-dot.active { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.feedback-dot.warning { background: var(--warning); }
.feedback-dot.error { background: var(--danger); }

/* Stats side */
.workout-stats-side {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.workout-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.workout-header h2 { font-size: 1.3rem; }
.exercise-desc-text { color: var(--text-muted); font-size: .85rem; margin-top: .25rem; }

.btn-stop {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,71,87,.15);
  color: var(--danger);
  border: 1px solid rgba(255,71,87,.3);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s;
}
.btn-stop:hover { background: rgba(255,71,87,.3); }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
}
.stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat-label { color: var(--text-muted); font-size: .8rem; margin-top: .4rem; text-transform: uppercase; letter-spacing: .05em; }

/* Quality section */
.quality-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.quality-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
  font-size: .875rem;
  color: var(--text-muted);
}
.quality-score-text { font-weight: 700; color: var(--accent); font-size: 1rem; }
.quality-bar-bg {
  height: 12px;
  background: var(--bg-card);
  border-radius: 99px;
  overflow: hidden;
}
.quality-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--danger), var(--warning) 50%, var(--success));
  transition: width .4s ease;
}
.quality-labels {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: .75rem;
  margin-top: .4rem;
}

/* Angle monitor */
.angle-monitor {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.angle-label { color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem; }

.angle-display { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.angle-arc-container { width: 120px; }
.angle-arc { width: 100%; }

.angle-value-display {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  min-width: 80px;
  font-variant-numeric: tabular-nums;
}

.angle-thresholds {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: .75rem;
  margin-top: .5rem;
}

/* Rep history */
.rep-history { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.rep-history-label { color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem; }
.rep-dots { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 24px; }

.rep-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  color: #0f0f1a;
  animation: popIn .25s cubic-bezier(.34,1.56,.64,1) both;
}
.rep-dot.quality-high   { background: var(--success); }
.rep-dot.quality-medium { background: var(--warning); }
.rep-dot.quality-low    { background: var(--danger); }

@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Session summary ─────────────────────────────────────────────── */
.session-summary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
}
.summary-inner {
  text-align: center;
  max-width: 540px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 3rem 2.5rem;
}
.summary-trophy { font-size: 4rem; margin-bottom: 1rem; animation: bounce .6s .3s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes bounce {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}
.summary-inner h2 { margin-bottom: 2rem; }

.summary-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.summary-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
}
.summary-value { font-size: 2rem; font-weight: 800; color: var(--accent); line-height: 1; }
.summary-label { color: var(--text-muted); font-size: .8rem; margin-top: .4rem; }

.rep-quality-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: center;
  margin-bottom: 2rem;
  min-height: 0;
}
.summary-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .workout-session {
    grid-template-columns: 1fr;
    grid-template-rows: 50vh 1fr;
    height: auto;
  }
  .workout-stats-side { max-height: 60vh; }
}

@media (max-width: 600px) {
  .exercise-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .summary-stats-grid { grid-template-columns: 1fr 1fr; }
}
