/* =============================================================
   PROGRESS TAB
   Three-column layout, chart/calendar panels, and the
   bodybuilding-specific progress stats panel.
   Depends on: tokens.css
   ============================================================= */

/* ── Layout: horizontal mini-tab nav on top, chart panel below ── */

.progress-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.progress-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.progress-nav::-webkit-scrollbar {
  display: none;
}

.progress-nav button {
  flex: none;
  margin: 0;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border-color);
  background: var(--elevated-bg);
  color: var(--secondary-text);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.progress-nav button.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.progress-nav input[type="date"] {
  flex: none;
  width: 132px;
  margin: 0 0 0 4px;
}

@media (max-width: 600px) {
  #progressCanvas {
    height: 300px;
  }
}

/* ── Progress sub-views (mini tabs) ────────────────────────── */

.progress-subview {
  display: none;
}

.progress-subview.active {
  display: block;
}

/* ── Chart and calendar panels ──────────────────────────────── */

.progress-chart,
.progress-calendar {
  background: linear-gradient(180deg, rgba(18, 27, 23, 0.94), rgba(12, 18, 15, 0.97));
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
  color: var(--text-color);
}

/* ── Bodybuilding progress panel ────────────────────────────── */

#bodybuildingProgressPanel {
  margin-top: 14px;
  color: var(--text-color);
}

#bodybuildingProgressPanel h3 {
  margin: 0 0 10px;
  color: #f6faf8;
  letter-spacing: 0.01em;
}

#bodybuildingProgressPanel h4 {
  margin: 10px 0 6px;
  color: #dce7e1;
  font-size: 1rem;
}

#bodybuildingProgressPanel table {
  width: 100%;
  margin-top: 6px;
  font-size: 0.9rem;
  border-collapse: collapse;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(14, 21, 18, 0.92);
  box-shadow: none;
}

#bodybuildingProgressPanel th {
  background: rgba(35, 57, 47, 0.9);
  color: #f3f8f5;
  font-weight: 600;
  border-color: rgba(121, 150, 137, 0.4);
}

#bodybuildingProgressPanel td {
  color: #e5ece8;
  border-color: rgba(115, 143, 131, 0.28);
}

#bodybuildingProgressPanel .progress-empty {
  color: #b8c2bc;
}

/* ── Exercise progress chart ────────────────────────────────── */

.ex-picker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.ex-picker-select {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--elevated-bg);
  color: var(--text-color);
  font-size: 0.9rem;
  margin: 0;
}

.ex-metric-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.ex-metric-btn {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border-color);
  background: var(--elevated-bg);
  color: var(--secondary-text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  margin: 0;
  box-shadow: none;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.ex-metric-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.ex-chart-wrap {
  position: relative;
  height: 240px;
  margin-bottom: 14px;
}

.ex-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Summary stat chips */
.ex-chart-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.ex-stat-chip {
  flex: 1;
  min-width: 80px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}

.ex-stat-chip .ex-stat-val {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-color);
  line-height: 1.15;
}

.ex-stat-chip .ex-stat-lbl {
  display: block;
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* All-exercises mini card grid */
.ex-all-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.ex-summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: none;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

.ex-summary-card:hover,
.ex-summary-card:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(45,125,91,0.18);
}

.ex-summary-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ex-summary-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}

.ex-summary-delta {
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.ex-summary-sessions {
  font-size: 0.67rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* PR card grid */
#bodybuildingProgressPanel .bb-pr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

#bodybuildingProgressPanel .bb-pr-card {
  background: rgba(15, 24, 20, 0.86);
  border: 1px solid rgba(113, 141, 129, 0.35);
  border-radius: 8px;
  padding: 8px;
}

#bodybuildingProgressPanel ul {
  margin: 6px 0 0 18px;
  padding: 0;
  color: #d7e2dc;
}

#bodybuildingProgressPanel li {
  margin: 4px 0;
}

#bodybuildingProgressPanel details {
  margin-top: 8px;
  color: #c2cdc7;
}

#bodybuildingProgressPanel summary {
  color: #dce7e1;
}

/* ── Recovery Map panel ──────────────────────────────────────── */

.recovery-panel {
  margin-top: 14px;
  color: var(--text-color);
  /* fatigue scale — semantic, deliberately separate from --primary/--highlight */
  --scale-0: #f2ece0;
  --scale-1: #f3d36b;
  --scale-2: #e8863f;
  --scale-3: var(--danger);
}

.recovery-sub {
  margin: 0 0 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.recovery-figures {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.recovery-figure-col {
  text-align: center;
  width: 170px;
}

.recovery-figure-col svg {
  width: 100%;
  height: auto;
}

.recovery-figure-label {
  margin: 2px 0 0;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--text-muted);
}

.recovery-zone {
  stroke: var(--card-bg);
  stroke-width: 1.5;
  cursor: pointer;
  transition: opacity 0.15s ease, stroke-width 0.15s ease;
}

.recovery-zone.is-dim {
  opacity: 0.28;
}

.recovery-zone.is-active {
  stroke: var(--text-color);
  stroke-width: 2.5;
}

.recovery-neutral {
  fill: var(--elevated-bg);
  stroke: var(--border-color);
  stroke-width: 1;
}

.recovery-legend {
  max-width: 380px;
  margin: 20px auto 0;
}

.recovery-legend-bar {
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--scale-0), var(--scale-1), var(--scale-2), var(--scale-3));
}

.recovery-legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.recovery-hint {
  text-align: center;
  margin: 14px 0 10px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.recovery-table-wrap {
  overflow-x: auto;
}

.recovery-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  background: rgba(14, 21, 18, 0.92);
}

.recovery-table th {
  text-align: left;
  padding: 6px 10px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.recovery-table th.num {
  text-align: right;
}

.recovery-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(132, 157, 144, 0.12);
  color: #e5ece8;
  vertical-align: middle;
}

.recovery-table td.muscle {
  font-weight: 600;
}

.recovery-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.recovery-table td.recovery-days {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.recovery-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.recovery-table tbody tr:hover {
  background: rgba(244, 247, 245, 0.03);
}

.recovery-table tbody tr.is-dim {
  opacity: 0.35;
}

.recovery-table tbody tr.is-active {
  background: rgba(198, 148, 79, 0.08);
}

.ratio-track {
  position: relative;
  width: 90px;
  height: 6px;
  border-radius: 3px;
  background: var(--elevated-bg);
  overflow: hidden;
}

.ratio-fill {
  position: absolute;
  inset: 0;
  width: 0;
  background: var(--primary);
  border-radius: 3px;
}

.ratio-track.is-over .ratio-fill {
  background: var(--highlight);
}

.recovery-table .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.recovery-table .chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

@media (max-width: 460px) {
  .recovery-table th:nth-child(4),
  .recovery-table td:nth-child(4) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .recovery-zone,
  .recovery-table tbody tr,
  .ratio-fill {
    transition: none;
  }
}
