/* ShapeUp — Exercise Log: History tab styles.
 *
 * Ported from the Claude Design mockup (example/shapeup-history.html) but recut
 * to the project's tokens/conventions (see exercise.css :root + .xl-* sizing) —
 * Montserrat, the shared color vars, and the same card radii/shadows as the Log
 * tab. Split colors are data-driven (per workout day) so they come in inline
 * from history.js via CSS custom properties (--split / --split-tint).
 *
 * Class prefix: .hist-* (lives inside #xl-panel-history > .xl-hist). */

.xl-hist { font-family: var(--font); }

/* ───────── month navigation ───────── */

.hist-monthnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 320px;
  margin: 0 auto 2px;
}
.hist-navbtn {
  width: 32px; height: 32px;
  flex: none;
  display: grid; place-items: center;
  border: none; border-radius: 8px;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  color: var(--slate);
  font-size: 16px; font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.hist-navbtn:hover:not(:disabled) { color: var(--blue); }
.hist-navbtn:disabled {
  background: var(--bg);
  color: var(--border);
  box-shadow: none;
  cursor: not-allowed;
}
.hist-month {
  font-size: 14px; font-weight: 600;
  color: var(--ink);
}
.hist-month-sub {
  text-align: center;
  font-size: 11px; font-weight: 400;
  color: var(--muted);
  margin-bottom: 14px;
  min-height: 14px;
}

/* ───────── months layout (1 on mobile, 2 on desktop) ───────── */

.hist-months {
  display: flex;
  justify-content: center;
  gap: 36px;
}
/* Each month block caps its own width so cells don't blow up; centered. */
.hist-month-block {
  flex: 0 1 320px;
  max-width: 320px;
}
/* Per-block month name — shown only in the two-up desktop layout (the single
 * mobile month is already labeled by the .hist-month nav title). */
.hist-month-name {
  display: none;
  text-align: center;
  font-size: 13px; font-weight: 600;
  color: var(--ink);
  margin-bottom: 1px;
}
/* The previous-month block is desktop-only. */
.hist-month-prev { display: none; }

@media (min-width: 700px) {
  .hist-month-prev { display: block; }
  .hist-month-name { display: block; }
  /* Frame both calendars: widen the nav and hide its now-redundant title
   * (each block carries its own month name). */
  .hist-monthnav { max-width: 676px; }
  .hist-monthnav .hist-month { visibility: hidden; }
}

/* ───────── calendar grid ───────── */

.hist-weekdays,
.hist-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.hist-weekdays { margin-bottom: 4px; }
.hist-week { margin-bottom: 4px; }

.hist-weekday {
  text-align: center;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* A single day cell. --split / --split-tint set inline for workout days.
 * Shorter than wide (aspect-ratio < 1) to keep the calendar compact. */
.hist-day {
  aspect-ratio: 7 / 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.hist-day-num {
  font-size: 12px; font-weight: 600;
  color: var(--border);          /* non-workout day number */
}
.hist-day.blank { pointer-events: none; }

/* Workout day: faint split tint + colored number, clickable. */
.hist-day.workout {
  background: var(--split-tint, var(--blue-light));
  cursor: pointer;
}
.hist-day.workout .hist-day-num { color: var(--split, var(--blue)); }

/* Today: blue inset ring (only when not the selected day). */
.hist-day.today { box-shadow: inset 0 0 0 2px var(--blue); }

/* Selected workout day: solid split fill + lift. */
.hist-day.selected.workout {
  background: var(--split, var(--blue));
  box-shadow: 0 3px 10px var(--split-shadow, rgba(37, 99, 201, 0.45));
}
.hist-day.selected.workout .hist-day-num { color: #fff; }

/* ───────── split legend ───────── */

.hist-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  max-width: 320px;
  margin: 14px auto 4px;
}
.hist-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.hist-legend-swatch {
  width: 9px; height: 9px;
  border-radius: 3px;
  flex: none;
}
.hist-legend-label {
  font-size: 11px; font-weight: 500;
  color: var(--slate);
}

/* ───────── empty / loading states ───────── */

.hist-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 28px 20px;
  line-height: 1.6;
}

/* ───────── detail area (session list / session detail, below calendar) ─────────
 * Always present below the calendar grid + legend; filled in place when a day is
 * clicked. The calendar above is never cleared. */

.hist-detailarea:not(:empty) { margin-top: 16px; }

/* ───────── day session list (multi-session day) ───────── */

.hist-sessions-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px;
}
.hist-session-pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-left: 5px solid var(--split, var(--blue));
  padding: 13px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hist-session-pick:hover {
  border-color: var(--split, var(--blue));
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
}
.hist-session-pick-main { min-width: 0; }
.hist-session-pick-title {
  font-size: 12px; font-weight: 600; color: var(--ink);
}
.hist-session-pick-meta {
  font-size: 11px; color: var(--muted); margin-top: 2px;
}
.hist-session-pick-split {
  flex: none;
  font-size: 11px; font-weight: 600;
  color: var(--split, var(--blue));
  background: var(--split-tint, var(--blue-light));
  border-radius: 6px;
  padding: 4px 9px;
}

/* ───────── session detail ───────── */

.hist-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 4px 2px;
  margin-bottom: 12px;
  color: var(--slate);
  font-family: var(--font);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.hist-detail-back:hover { color: var(--blue); }
.hist-detail-back svg { width: 14px; height: 14px; }

/* summary card (left-border split colored) */
.hist-summary {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
  padding: 15px;
  border-left: 5px solid var(--split, var(--blue));
}
.hist-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}
.hist-summary-title {
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.hist-summary-split {
  flex: none;
  font-size: 11px; font-weight: 600;
  color: var(--split, var(--blue));
  background: var(--split-tint, var(--blue-light));
  border-radius: 6px;
  padding: 4px 9px;
}
.hist-summary-meta {
  font-size: 11px; color: var(--muted);
  margin-bottom: 12px;
}
.hist-stats { display: flex; gap: 8px; }
.hist-stat {
  flex: 1;
  background: var(--bg);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.hist-stat-val {
  font-size: 14px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.hist-stat-label {
  font-size: 9px; font-weight: 500; letter-spacing: 0.02em;
  color: var(--muted);
  margin-top: 2px;
  text-transform: uppercase;
}

/* ───────── exercise detail cards ───────── */

.hist-ex {
  background: var(--white);
  border: 1px solid #ececec;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  padding: 14px;
  margin-top: 10px;
}
.hist-ex-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.hist-ex-headleft {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
/* B / U category badge — sized/weighted to match the Log tab's current logged
   sets (.xl-cs-cat): 18px square, 10/700, same green/rust. --cat-bg set inline. */
.hist-ex-cat {
  width: 18px; height: 18px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: var(--cat-bg, var(--slate));
  color: #fff;
  font-size: 10px; font-weight: 700;
}
.hist-ex-name {
  font-size: 12px; font-weight: 500; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Equipment badge — flat blue, matching the Log tab's logged sets
   (.xl-cs-equip): no per-equipment colors. */
.hist-ex-equip {
  flex: none;
  font-size: 11px; font-weight: 600;
  color: var(--blue); background: rgba(37, 99, 201, 0.1);
  border-radius: 6px;
  padding: 4px 9px;
}

/* ───────── collapse / expand ───────── */

.hist-ex-headright {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}
.hist-ex-chev {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: transform 0.2s ease, color 0.15s;
}
.hist-ex-chev svg { width: 17px; height: 17px; }
.hist-ex-head:hover .hist-ex-chev { color: var(--slate); }
/* Chevron points down when expanded; collapse rotates it to point right. */
.hist-ex.collapsed .hist-ex-chev { transform: rotate(-90deg); }

/* Collapsed summary line — hidden while expanded, shown only when collapsed.
   The full per-set body is hidden in the collapsed state. */
.hist-ex-summary { display: none; }
.hist-ex.collapsed .hist-ex-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
/* Keep a little breathing room between the head row and the summary line so the
   PR badge isn't crammed right under the equipment pill. */
.hist-ex.collapsed .hist-ex-head { margin-bottom: 8px; }
.hist-ex.collapsed .hist-ex-body { display: none; }
.hist-ex-sum-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}
.hist-ex-sum-top {
  font-size: 13px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hist-ex-sum-sets {
  font-size: 11px; font-weight: 500; color: var(--muted);
  white-space: nowrap;
}
/* Pull the PR badge left by the chevron's footprint (17px svg + 9px headright
   gap) so its right edge lines up with the equipment pill above, not the
   chevron. */
.hist-ex-sum-right {
  display: flex;
  align-items: center;
  flex: none;
  margin-right: 26px;
}

/* ───────── compact collapsed density ───────── */
/* Scoped to .collapsed so the expanded full-set card keeps its current sizing. */

.hist-ex.collapsed {
  padding: 10px 12px;   /* was 14px */
  margin-top: 6px;      /* was 10px — tighter stacking */
}
.hist-ex.collapsed .hist-ex-cat {
  width: 16px; height: 16px;   /* was 18px */
}
.hist-ex.collapsed .hist-ex-sum-top {
  font-size: 12px;      /* was 13px */
  font-weight: 500;     /* lighter — not bold */
}
.hist-ex.collapsed .hist-ex-sum-sets {
  font-size: 10.5px;    /* was 11px */
}

/* "Exercises" control bar (Collapse all / Expand all) — sits between the
   summary card and the first exercise card. */
.hist-collapse-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding: 0 2px;
}
.hist-collapse-label {
  font-size: 12px; font-weight: 600; color: var(--slate);
}
.hist-collapse-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  border: 1px solid #d9dde3;
  border-radius: 8px;
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 11px; font-weight: 600;
  color: var(--slate);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.hist-collapse-all:hover { color: var(--blue); border-color: var(--blue); }
.hist-collapse-all svg { width: 14px; height: 14px; }

.hist-set {
  background: #f4f4f5;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
}
.hist-set:last-child { margin-bottom: 0; }
.hist-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.hist-set-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.hist-set-wr {
  font-size: 12px; font-weight: 500; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
/* PR badge styling is shared — see .pr-badge in exercise.css (loads on this page
   too). No badge rules here on purpose, so there's one source of truth. */
.hist-set-right {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}
.hist-set-effort {
  font-size: 11px; font-weight: 500; color: #6f8f8a;
  font-variant-numeric: tabular-nums;
}
.hist-set-time {
  font-size: 11px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Per-set remark reuses the Log tab's .xl-cs-rmk style (exercise.css) for a
   100% match — no .hist-set-note rules needed here. */

/* ───────── swipe-to-edit/delete (per set row) ───────── */

/* A swipeable set row clips its sliding content; the Edit/Delete actions sit
   behind it (revealed when the slide shifts left). */
.hist-set-swipe {
  position: relative;
  overflow: hidden;
  padding: 0;            /* the slide carries the padding now */
  background: #f4f4f5;
  touch-action: pan-y;   /* let vertical scroll through; we handle horizontal */
}
.hist-set-actions {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  display: flex;
  align-items: stretch;
}
.hist-set-act {
  width: 60px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.hist-set-act svg { width: 18px; height: 18px; }
.hist-set-act-edit { background: var(--blue); }
.hist-set-act-del { background: #c0392b; }
/* The sliding content layer — covers the row, transforms left on swipe. */
.hist-set-slide {
  position: relative;
  background: #f4f4f5;
  padding: 10px 12px;
  transform: translateX(0);
  transition: transform 0.18s ease;
  z-index: 1;
  touch-action: pan-y;
}

/* ───────── inline edit form ───────── */
/* Styles live in exercise.css (.xl-edit-*) — loaded on the same page. */
.hist-set-swipe.editing { overflow: visible; }
