/* ============================================
   EXERCISE FORM (new layout) - used by the coach hub
   Put this file in your hub-css folder and link it in coach-hub.html
   ============================================ */

.xf-root { display: block; }
.xf-main, .xf-side { min-width: 0; }

/* ---------- sections ---------- */
.xf-sec {
  background: #faf7f2;
  border: 1px solid #eee6da;
  border-radius: 12px;
  margin-bottom: 0.6rem;
  overflow: hidden;
}
.xf-sec.xf-main-sec { border-color: #c6b7e2; box-shadow: 0 0 0 1px #c6b7e2; background: #fff; }
.xf-head {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  text-align: left;
  color: #3f3550;
  font: inherit;
}
.xf-caret { color: #8a8073; font-size: 0.8rem; width: 0.9rem; flex-shrink: 0; }
.xf-title { font-weight: 700; font-size: 0.95rem; }
.xf-summary {
  flex: 1;
  min-width: 0;
  color: #8a8073;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
.xf-body { display: none; padding: 0 0.8rem 0.8rem; }
.xf-sec.open .xf-body { display: block; }

/* ---------- fields ---------- */
.xf-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #8a8073;
  margin: 0.5rem 0 0.25rem;
}
.xf-row { display: flex; gap: 0.6rem; align-items: flex-end; }
.xf-field { display: block; }
.xf-field.xf-sets { width: 5.5rem; flex-shrink: 0; }
.xf-field .hub-input { margin-bottom: 0; }
.xf-amount-row { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.xf-amount-row .hub-input { margin: 0; flex: 1; min-width: 0; }
.xf-input-wrap { position: relative; margin-top: 0.4rem; }
.xf-input-wrap .hub-input { margin: 0; padding-right: 2.2rem; }
.xf-unit {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: #8a8073;
  font-size: 0.85rem;
  pointer-events: none;
}
/* weight box with the "By set" pill on its left; By set on swaps the box for one box per set */
.xf-weight-row { display: flex; gap: 0.5rem; align-items: flex-start; margin-top: 0.4rem; }
.xf-weight-row .xf-input-wrap { flex: 1; min-width: 0; margin-top: 0; }
.xf-byset-btn {
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #ddd2eb;
  border-radius: 999px;
  padding: 0.5rem 0.8rem;
  min-height: 2.75rem;   /* same height as the weight box beside it */
  color: #4b3f5c;
  font: inherit;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
}
.xf-byset-btn.on { background: #ece6f5; border-color: #c6b7e2; font-weight: 700; color: #3f3550; }
.xf-byset { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.xf-byset .xf-hint { margin-top: 0.55rem; }
.xf-byset-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: #4b3f5c; }
.xf-byset-label { width: 3rem; flex-shrink: 0; }
.xf-byset-row .hub-input { width: 5.5rem; margin: 0; }
.xf-byset-unit { color: #8a8073; }
.xf-step-row { font-size: 0.8rem; color: #4b3f5c; margin-top: 0.5rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.xf-step { width: 3.4rem !important; margin: 0 !important; padding: 0.25rem 0.4rem !important; text-align: center; }
.xf-bad { border-color: #b3402f !important; }
.xf-err { color: #b3402f; font-size: 0.78rem; line-height: 1.35; min-height: 0; }
.xf-err:empty { display: none; }
.xf-hint { color: #8a8073; font-size: 0.75rem; margin-top: 0.3rem; }
.xf-q-section { margin-top: 0.4rem; }
.xf-note-slot { margin-top: 0.4rem; }
.xf-note-slot textarea { width: 100%; box-sizing: border-box; }

/* ---------- segmented switches (Reps | Time, Weight | Band ...) ---------- */
.xf-seg { display: flex; gap: 0.35rem; }
.xf-seg button {
  flex: 1;
  background: #fff;
  border: 1px solid #ddd2eb;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  color: #4b3f5c;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.xf-seg button.on { background: #ece6f5; border-color: #c6b7e2; font-weight: 700; color: #3f3550; }
.xf-seg-sm { flex-shrink: 0; }
.xf-seg-sm button { flex: none; padding: 0.4rem 0.6rem; }

/* ---------- chips (muscles + Applies to) ---------- */
.xf-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.4rem; }
.xf-chip-wrap { display: inline-flex; align-items: stretch; }
.xf-chip {
  background: #fff;
  border: 1px solid #ddd2eb;
  border-radius: 10px;
  padding: 0.4rem 0.7rem;
  color: #4b3f5c;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.xf-chip.on { background: #ece6f5; border-color: #c6b7e2; font-weight: 700; }
.xf-chip.primary { background: #c6b7e2; border-color: #a893cf; color: #3d2f52; font-weight: 700; }
.xf-chip.secondary { background: #f4effa; border: 1px dashed #a893cf; color: #5b4a78; }
.xf-chip.add { color: #7c5cbf; border-style: dashed; }
.xf-chip-wrap .xf-chip.on + .xf-chip-x,
.xf-chip-x { background: none; border: none; color: #8a8073; cursor: pointer; padding: 0 0.3rem; font-size: 1rem; }
.xf-muscle-search { margin: 0.2rem 0 0 !important; }
.xf-q-add { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.4rem; }
.xf-q-add .hub-input { margin: 0; flex: 1; min-width: 8rem; }
.xf-q-times-wrap { font-size: 0.8rem; color: #4b3f5c; display: flex; align-items: center; gap: 0.4rem; }
.xf-q-times { width: 4rem !important; flex: none !important; }
.xf-q-add .hub-btn, .xf-q-add .hub-back-btn { width: auto; margin: 0; padding: 0.4rem 0.8rem; }
/* ---------- preview ---------- */
.xf-side { margin-top: 0.4rem; }
.xf-side-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #8a8073;
  margin: 0.6rem 0 0.3rem;
}
.xf-preview { background: #fff; border: 1px solid #eee6da; border-radius: 12px; padding: 0.8rem; }
.xf-preview-name { font-weight: 700; color: #3f3550; margin-bottom: 0.4rem; }
.xf-preview-line { background: #ece6f5; color: #4b3f5c; border-radius: 8px; padding: 0.5rem 0.7rem; font-size: 0.9rem; }
.xf-preview-line.empty { color: #8a8073; font-style: italic; }
.xf-preview-note { margin-top: 0.5rem; font-size: 0.82rem; color: #4b3f5c; line-height: 1.4; }
.xf-addslot { margin-top: 0.7rem; }
.xf-addslot .hub-btn { width: 100%; }

/* ---------- muscle chart: wide screens only ---------- */
.xf-chart { display: none; }
.xf-has-chart .xf-chart { display: block; }
.xf-chart-seg { margin-bottom: 0.5rem; }
.xf-bar-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: #4b3f5c; margin-bottom: 0.3rem; }
.xf-bar-name { width: 6.5rem; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xf-bar-track { flex: 1; height: 0.8rem; background: #f2ede4; border-radius: 4px; display: flex; overflow: hidden; }
.xf-bar-rest { background: #b8b0a4; height: 100%; }
.xf-bar-mine { background: #7c5cbf; height: 100%; }
.xf-bar-val { width: 3.6rem; text-align: right; color: #3f3550; flex-shrink: 0; }
.xf-credit { font-size: 0.78rem; color: #4b3f5c; margin-top: 0.6rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.xf-credit-input { width: 3.2rem !important; margin: 0 !important; padding: 0.2rem 0.4rem !important; text-align: center; }
.xf-credit-status { color: #8a8073; }
.xf-chart-legend { font-size: 0.72rem; color: #8a8073; margin-top: 0.4rem; }

/* ---------- wide screens: form left, sticky preview right ---------- */
@media (min-width: 900px) {
  .xf-root { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 1.2rem; align-items: start; }
  .xf-side { position: sticky; top: 1rem; margin-top: 0; }
  .xf-side-label:first-child { margin-top: 0; }

  /* Widen the builder screens on desktop. They break out of the narrow
     parent column and center on the screen (not full width).
     Change 1200px / 92vw to make it wider or narrower. */
  #template-builder-view,
  #workout-builder-view,
  #exercise-builder-view {
    --xf-wide: min(1200px, 92vw);
    width: var(--xf-wide);
    max-width: none;
    box-sizing: border-box;
    position: relative;
    left: 50%;
    margin-left: calc(var(--xf-wide) / -2);
  }
}
/* ---------- PHONES (under 900px) ---------- */
@media (max-width: 899px) {
  .xf-sec { margin-bottom: 0.7rem; }
  .xf-sec.xf-main-sec { border-width: 2px; border-color: #a893cf; box-shadow: 0 2px 10px rgba(124, 92, 191, 0.18); }

  .xf-head { align-items: center; min-height: 3rem; padding: 0.6rem 0.9rem; }
  .xf-title { font-size: 1rem; }
  .xf-summary { font-size: 0.8rem; }
  .xf-caret { font-size: 0.9rem; }
  .xf-body { padding: 0 0.9rem 1rem; }

  /* 16px stops iPhones zooming in on tap */
  .xf-root .hub-input,
  .xf-root input,
  .xf-root select,
  .xf-root textarea { font-size: 16px; min-height: 2.75rem; }
  .xf-root textarea { min-height: 5rem; }

  .xf-label { margin-top: 0.8rem; }
  .xf-row { gap: 0.7rem; }
  .xf-field.xf-sets { width: 6rem; }

  /* 44px+ tap targets */
  .xf-seg button { min-height: 2.75rem; font-size: 0.95rem; }
  .xf-seg-sm button { padding: 0.5rem 0.8rem; }
  .xf-chip { min-height: 2.75rem; padding: 0.5rem 0.9rem; font-size: 0.95rem; }
  .xf-chips { gap: 0.5rem; }
  .xf-chip-x { min-width: 2.2rem; min-height: 2.75rem; font-size: 1.2rem; }
  .xf-step { width: 4.5rem !important; min-height: 2.5rem; }
  .xf-byset-btn { font-size: 0.9rem; }
  .xf-step-row { gap: 0.6rem; font-size: 0.9rem; }
  .xf-q-add .hub-btn, .xf-q-add .hub-back-btn { min-height: 2.75rem; padding: 0.5rem 1rem; }
  .xf-q-times { width: 4.5rem !important; }

  /* preview + Add button at the bottom */
  .xf-side { margin-top: 0.8rem; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .xf-preview { padding: 0.9rem; }
  .xf-preview-line { font-size: 1rem; padding: 0.7rem 0.8rem; }
  .xf-addslot { margin-top: 0.9rem; }
  .xf-addslot .hub-btn { min-height: 3rem; font-size: 1rem; }

  /* belt and braces: never show the chart on phones */
  .xf-chart { display: none !important; }
}
/* ---------- tag search dropdown + General chip ---------- */
.xf-chip.general { background: #e8f1ec; border-color: #9cc2ad; color: #2f5a44; }
.xf-suggest { border: 1px solid #ddd2eb; border-radius: 8px; background: #fff; margin: 0.3rem 0 0.5rem; max-height: 14rem; overflow-y: auto; }
.xf-suggest-item { display: flex; justify-content: space-between; gap: 0.6rem; width: 100%; background: none; border: none; border-bottom: 1px solid #f2ede4; padding: 0.6rem 0.8rem; font: inherit; font-size: 0.9rem; color: #3f3550; text-align: left; cursor: pointer; }
.xf-suggest-item:last-child { border-bottom: none; }
.xf-suggest-role { color: #8a8073; font-size: 0.75rem; }
.xf-suggest-create { color: #7c5cbf; justify-content: flex-start; }
.xf-chips { margin-top: 0.4rem; }
@media (max-width: 899px) { .xf-suggest-item { min-height: 2.75rem; align-items: center; font-size: 1rem; } }
/* ---------- "Applies to" search box ---------- */
.xf-q-box { display: flex; align-items: center; gap: 0.5rem; }
.xf-q-box .hub-input { margin: 0; flex: 1; min-width: 0; }
.xf-q-clear { background: none; border: none; color: #7c5cbf; font: inherit; font-size: 0.8rem; text-decoration: underline; cursor: pointer; padding: 0.3rem; flex-shrink: 0; }
.xf-suggest-row { display: flex; align-items: stretch; border-bottom: 1px solid #f2ede4; }
.xf-suggest-row:last-child { border-bottom: none; }
.xf-suggest-row .xf-suggest-item { flex: 1; width: auto; border-bottom: none; }
.xf-q-new-name { flex-basis: 100%; font-size: 0.85rem; font-weight: 700; color: #3f3550; }
@media (max-width: 899px) { .xf-q-clear { min-height: 2.75rem; padding: 0.5rem; } }
/* ---------- right column: workout so far / chart / assign (wide screens) ---------- */
.xf-right-box { margin-bottom: 0.8rem; }
.xf-workout-box {
  background: #fff;
  border: 1px solid #eee6da;
  border-radius: 12px;
  padding: 0.8rem;
}
.xf-workout-box .xf-side-label { margin-top: 0; }
.xf-workout-inner #exercise-list-coach { max-height: 22rem; overflow-y: auto; }
.xf-assign-box > div { margin-top: 0 !important; flex-direction: column; }
.xf-assign-box .hub-skip-btn { width: 100%; }
.xf-assign-box #finish-workout-btn { background: #d4ecd2; border-color: #b6dbb3; color: #2f5a34; font-weight: 700; }
@media (min-width: 900px) {
  .xf-side { max-height: calc(100vh - 2rem); overflow-y: auto; }
}
/* ---------- Strength | Aerobic + the aerobic interval editor (coach-exercise-form-aerobic.js) ---------- */
.xf-kind { margin-bottom: 0.3rem; }
.xf-kind button { padding: 0.55rem 0.7rem; }
.xf-aer-head, .xf-aer-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 4.2rem 7.6rem 22px;
  gap: 6px;
  align-items: center;
}
.xf-aer-head { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #8a8073; margin-bottom: 0.2rem; }
.xf-aer-item { margin-bottom: 6px; background: #fff; border-radius: 8px; }
.xf-aer-item.xf-aer-dragging { box-shadow: 0 4px 14px rgba(60, 40, 90, 0.18); position: relative; z-index: 2; }
.xf-aer-row .hub-input { margin: 0; padding: 0.45rem 0.5rem; font-size: 0.88rem; min-width: 0; }
.xf-aer-handle { color: #8a8073; cursor: grab; touch-action: none; user-select: none; text-align: center; line-height: 1; padding: 0.4rem 0; }
.xf-aer-x { background: none; border: none; color: #8a8073; font-size: 1.1rem; cursor: pointer; padding: 0; }
.xf-aer-type-wrap { position: relative; display: block; min-width: 0; }
.xf-aer-type-wrap .xf-aer-swatch { position: absolute; left: 0.45rem; top: 50%; transform: translateY(-50%); pointer-events: none; }
.xf-aer-type-wrap select.hub-input { width: 100%; padding-left: 1.3rem; padding-right: 0.2rem; }
.xf-aer-row-err { margin: 2px 0 0 22px; }
.xf-aer-add {
  width: 100%; margin-top: 2px;
  background: #fff; color: #7c5cbf;
  border: 1px dashed #c6b7e2; border-radius: 8px;
  padding: 0.45rem; font: inherit; font-size: 0.85rem; cursor: pointer;
}
.xf-aer-bar { margin-top: 0.6rem; }   /* bar + type colors: aerobic.css */
.xf-aer-modeline { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.45rem; font-size: 0.85rem; color: #4b3f5c; }
.xf-aer-modeline .hub-input { width: 4.6rem; margin: 0; text-align: center; padding: 0.45rem; }
.xf-aer-sum { background: #faf7f2; border-radius: 8px; padding: 0.5rem 0.6rem; margin-top: 0.7rem; font-size: 0.8rem; color: #4b3f5c; line-height: 1.6; }
.xf-aer-sum b { color: #3f3550; }
.xf-aer-note { margin: 0.2rem 0 0.4rem; color: #a3542e; }
/* Narrow phones: name on its own line, time + type under it */
@media (max-width: 430px) {
  .xf-aer-head { display: none; }
  .xf-aer-row {
    grid-template-columns: 16px 4.4rem minmax(0, 1fr) 22px;
    grid-template-areas: "h name name x" "h time type type";
    row-gap: 5px;
  }
  .xf-aer-handle { grid-area: h; align-self: stretch; display: flex; align-items: center; justify-content: center; }
  .xf-aer-label { grid-area: name; }
  .xf-aer-time { grid-area: time; }
  .xf-aer-type-wrap { grid-area: type; }
  .xf-aer-x { grid-area: x; }
  .xf-aer-item { padding: 6px 0; border-bottom: 1px solid #f0ebe3; border-radius: 0; background: none; }
}
