/* Training Parameters Panel Workspace
   ============================================
   Three-level visual hierarchy:
     PARTS (toggle buttons) → STAGES (panels) → PARAMETERS (fields)
   Each physiological system has a consistent color identity.
   ============================================ */

:root {
  --panel-clr-thresholds: #7c3aed;
  --panel-clr-zones: #4f46e5;
  --panel-clr-cardiovascular: #e11d48;
  --panel-clr-recovery: #059669;
  --panel-clr-metabolism: #d97706;
  --panel-clr-biomechanics: #0891b2;

  --panel-clr-thresholds-light: #ede9fe;
  --panel-clr-zones-light: #e0e7ff;
  --panel-clr-cardiovascular-light: #ffe4e6;
  --panel-clr-recovery-light: #d1fae5;
  --panel-clr-metabolism-light: #fef3c7;
  --panel-clr-biomechanics-light: #cffafe;
}

/* ============================================================ */
/*  LEVEL 1 — PARTS: GROUP TOGGLE BUTTONS                        */
/*  Large, prominent pills with color identity.                  */
/* ============================================================ */

.group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: var(--radius-btn, 0.5rem);
  border: 1.5px solid var(--color-border-light, #e2e8f0);
  background: var(--color-panel-main, #ffffff);
  color: var(--color-txt-main, #0f172a);
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1.3;
  user-select: none;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.04));
  position: relative;
}

.group-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.group-toggle:focus-visible {
  outline: 2px solid var(--color-border-focus, #6366f1);
  outline-offset: 2px;
}

.group-toggle .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.group-toggle:hover .dot {
  transform: scale(1.2);
}

/* Active state — full color fill with white text + shadow */
.group-toggle.active {
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.group-toggle.active:hover {
  opacity: 0.92;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
}

.group-toggle.active .dot {
  background: rgba(255, 255, 255, 0.9) !important;
}

/* Per-color toggle active state */
.group-toggle--thresholds.active      { background: var(--panel-clr-thresholds); }
.group-toggle--zones.active           { background: var(--panel-clr-zones); }
.group-toggle--cardiovascular.active  { background: var(--panel-clr-cardiovascular); }
.group-toggle--recovery.active        { background: var(--panel-clr-recovery); }
.group-toggle--metabolism.active      { background: var(--panel-clr-metabolism); }
.group-toggle--biomechanics.active    { background: var(--panel-clr-biomechanics); }

/* Per-color dot (inactive state) */
.dot--thresholds      { background: var(--panel-clr-thresholds); }
.dot--zones           { background: var(--panel-clr-zones); }
.dot--cardiovascular  { background: var(--panel-clr-cardiovascular); }
.dot--recovery        { background: var(--panel-clr-recovery); }
.dot--metabolism      { background: var(--panel-clr-metabolism); }
.dot--biomechanics    { background: var(--panel-clr-biomechanics); }

/* ============================================================ */
/*  LEVEL 2 — STAGES: COLLAPSIBLE PANELS                         */
/*  Color-header with gradient tint + left accent bar.           */
/* ============================================================ */

.panel {
  border: 1px solid var(--color-border-light, #e2e8f0);
  border-radius: var(--radius-form, 0.75rem);
  background: var(--color-panel-main, #ffffff);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.panel:not(.hidden) {
  animation: panelSlideIn 0.2s ease-out;
}

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

/* Color accent bars + subtle background tint */
.panel--thresholds {
  border-left: 4px solid var(--panel-clr-thresholds);
}
.panel--zones {
  border-left: 4px solid var(--panel-clr-zones);
}
.panel--cardiovascular {
  border-left: 4px solid var(--panel-clr-cardiovascular);
}
.panel--recovery {
  border-left: 4px solid var(--panel-clr-recovery);
}
.panel--metabolism {
  border-left: 4px solid var(--panel-clr-metabolism);
}
.panel--biomechanics {
  border-left: 4px solid var(--panel-clr-biomechanics);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--color-txt-main, #0f172a);
  border-bottom: 1px solid var(--color-border-light, #e2e8f0);
  position: relative;
}

/* Color-tinted header backgrounds */
.panel--thresholds .panel__header     { background: var(--panel-clr-thresholds-light); }
.panel--zones .panel__header          { background: var(--panel-clr-zones-light); }
.panel--cardiovascular .panel__header { background: var(--panel-clr-cardiovascular-light); }
.panel--recovery .panel__header       { background: var(--panel-clr-recovery-light); }
.panel--metabolism .panel__header     { background: var(--panel-clr-metabolism-light); }
.panel--biomechanics .panel__header   { background: var(--panel-clr-biomechanics-light); }

/* Small color indicator dot in header */
.panel__header::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.panel--thresholds .panel__header::before     { background: var(--panel-clr-thresholds); }
.panel--zones .panel__header::before          { background: var(--panel-clr-zones); }
.panel--cardiovascular .panel__header::before { background: var(--panel-clr-cardiovascular); }
.panel--recovery .panel__header::before       { background: var(--panel-clr-recovery); }
.panel--metabolism .panel__header::before     { background: var(--panel-clr-metabolism); }
.panel--biomechanics .panel__header::before   { background: var(--panel-clr-biomechanics); }

/* Span inside header gets the dot spacing */
.panel__header > span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}

.panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--color-txt-muted, #64748b);
  cursor: pointer;
  border-radius: 0.3rem;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
  transition: all 0.12s;
  font-weight: 700;
}

.panel__close:hover {
  color: var(--color-txt-main, #0f172a);
  background: rgba(0, 0, 0, 0.08);
}

.panel__body {
  padding: 0.85rem;
}

/* ============================================================ */
/*  LEVEL 3 — PARAMETERS: INDIVIDUAL FIELD CARDS                 */
/*  Labels are prominent, inputs are clean.                      */
/* ============================================================ */

.param-card {
  background: var(--color-panel-muted, #f8fafc);
  border: 1px solid var(--color-border-light, #e2e8f0);
  border-radius: 0.5rem;
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.param-card:focus-within {
  border-color: var(--color-border-focus, #6366f1);
  box-shadow: 0 0 0 2px var(--color-brand-light, #eef2ff);
}

.param-card__label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-txt-muted, #64748b);
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}

.param-card:focus-within .param-card__label {
  color: var(--color-txt-main, #0f172a);
}

/* Override Tailwind's .hidden */
.param-card.hidden {
  display: none;
}

/* Inline layout for config rows (checkbox + label inline) */
.param-card--inline {
  flex-direction: row;
  gap: 0.4rem;
  padding: 0.4rem 0.65rem;
}

/* Select fields in zone config (mode, base) */
.param-field--select {
  max-width: 7rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
}

/* --- Parameter Input Fields --- */

.param-field {
  width: 100%;
  max-width: 6rem;
  border: 1.5px solid var(--color-border-light, #e2e8f0);
  border-radius: 0.5rem;
  padding: 0.35rem 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--color-panel-main, #ffffff);
  color: var(--color-txt-main, #0f172a);
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.param-field:focus {
  outline: none;
  border-color: var(--color-border-focus, #6366f1);
  box-shadow: 0 0 0 2px var(--color-brand-light, #eef2ff);
}

.param-field--wide {
  max-width: 9rem;
}

.param-field--full {
  max-width: 100%;
}

.param-field--baseline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  font-weight: 600;
}

.bpm-label {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--color-txt-muted, #64748b);
  line-height: 1;
}

/* ============================================================ */
/*  PARAMETER SUB-BLOCKS (Metabolism panel grouping)             */
/* ============================================================ */

.param-subblock {
  background: var(--color-panel-muted, #f8fafc);
  border: 1px solid var(--color-border-light, #e2e8f0);
  border-radius: 0.5rem;
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}

.param-subblock__title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-txt-muted, #64748b);
  text-align: center;
  width: 100%;
  padding-bottom: 0.3rem;
  border-bottom: 1.5px solid var(--color-border-light, #e2e8f0);
}

.param-subblock .param-field-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: 100%;
}

.param-subblock .param-field-row__label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-txt-muted, #64748b);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.param-subblock .stat-chip {
  margin-top: 0.2rem;
}

/* ============================================================ */
/*  ZONE RANGE DISPLAY                                           */
/* ============================================================ */

.zone-range-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: var(--color-panel-muted, #f8fafc);
  border: 1px solid var(--color-border-light, #e2e8f0);
  border-radius: 0.5rem;
  padding: 0.5rem 0.35rem;
  transition: border-color 0.15s;
}

.zone-range-cell:focus-within {
  border-color: var(--color-border-focus, #6366f1);
  box-shadow: 0 0 0 2px var(--color-brand-light, #eef2ff);
}

/* Override Tailwind's .hidden */
.zone-range-cell.hidden {
  display: none;
}

.zone-range {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.zone-range__input {
  width: 3.2rem;
  max-width: 3.2rem;
  border: 1.5px solid var(--color-border-light, #e2e8f0);
  border-radius: 0.35rem;
  padding: 0.25rem 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--color-panel-main, #ffffff);
  color: var(--color-txt-main, #0f172a);
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.zone-range__input:focus {
  outline: none;
  border-color: var(--color-border-focus, #6366f1);
  box-shadow: 0 0 0 2px var(--color-brand-light, #eef2ff);
}

.zone-range__sep {
  font-size: 0.65rem;
  color: var(--color-txt-muted, #64748b);
  flex-shrink: 0;
  user-select: none;
  font-weight: 700;
}

/* Calculated zone value (read-only in auto mode) */
.zone-range__calc {
  width: 3.2rem;
  max-width: 3.2rem;
  padding: 0.25rem 0.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-txt-main, #0f172a);
  background: var(--color-brand-light, #eef2ff);
  border: 1px solid var(--color-border-light, #e2e8f0);
  border-radius: 0.35rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

.zone-range__calc--low {
  color: var(--color-txt-muted, #64748b);
  background: var(--color-panel-muted, #f8fafc);
}

.zone-range__calc--high {
  background: var(--color-brand-light, #eef2ff);
  border-color: var(--color-border-focus, #6366f1);
}

/* ============================================================ */
/*  STAT CHIP — read-only computed values                        */
/* ============================================================ */

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--color-panel-main, #ffffff);
  border: 1.5px solid var(--color-border-light, #e2e8f0);
  color: var(--color-txt-main, #0f172a);
}

.stat-chip__value {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--color-txt-main, #0f172a);
}

/* ============================================================ */
/*  ZONE MODE CONFIG CONTROLS (auto-calc row)                    */
/* ============================================================ */

/* The inline config row (checkbox, mode select, base select) */
.param-card:has(.zone-mode-config) {
  flex-direction: row;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
}

/* Baseline field display in auto mode */
.baseline-field {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  background: var(--color-brand-light, #eef2ff);
  border: 1px solid var(--color-border-light, #e2e8f0);
  border-radius: 0.35rem;
  font-size: 0.72rem;
}

.baseline-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
