/* ================================================================
   LOGBOOK.CSS — Logbook page (tables, graphs, PR history, body weight)
   Part of the RustyBlade BootCamp stylesheet, split for maintainability.
   ================================================================ */

/* ================================================================
   LOGBOOK PAGE
   ================================================================ */

.logbook-page {
  padding: 16px;
  overscroll-behavior: contain;
}
.logbook-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.logbook-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(1.25rem, 2.5vw, 1.8rem);
  font-weight: 700;
  margin: 0;
}
.logbook-header-actions {
  display: flex;
  gap: 8px;
}
.tab-group {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-variant);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.tab-group .btn {
  flex: 1 1 auto;
  white-space: nowrap;
}
.tab-group .btn.btn-outline {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--text-secondary);
}
.tab-group .btn.btn-outline:hover {
  background: var(--surface-raised);
  color: var(--text);
  border-color: transparent;
}
.logbook-filter-bar {
  display: flex;
  /* FIX: was flex-wrap: wrap, which let Date Range and Show-only-PRs
     wrap onto separate lines on narrow screens — newer guidance wants
     this bar to always stay on one line, achieved by letting its
     children shrink (below) rather than wrap. */
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.logbook-filter-bar .filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 1;
  min-width: 0;
}
.logbook-filter-bar label.filter-label {
  font-size: clamp(0.5rem, 1vw, 0.7rem);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logbook-filter-bar select {
  font-size: clamp(0.5rem, 1vw, 0.7rem);
  padding: 6px 8px;
  min-width: 0;
  flex-shrink: 1;
  /* FIX: no minimum height before — could render under the 44px touch
     target the mobile-optimization spec calls for. */
  min-height: 44px;
}
.logbook-filter-bar .checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(0.5rem, 1vw, 0.7rem);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 1;
  min-width: 0;
  white-space: nowrap;
  /* FIX: same 44px touch-target minimum, applied to the label itself
     since that's the actual clickable/tappable area, not just the
     checkbox input. */
  min-height: 44px;
}
.logbook-filter-bar .checkbox-label input {
  width: 20px;
  height: 20px;
  padding: 0;
  accent-color: var(--accent);
}
.logbook-filter-bar .btn {
  align-self: center;
  margin-top: 0;
}
.logbook-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.logbook-card.chart-card {
  padding: 16px;
}

/* ── PR History cards (feature request: UI refresh) ── */
.pr-history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.pr-history-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--gold);
}
.pr-history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.pr-history-chevron {
  color: var(--text-muted);
}
@keyframes pr-history-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.pr-history-card-header h3 {
  font-size: 0.95rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.pr-history-trophy {
  width: 18px;
  height: 18px;
  color: var(--gold);
  flex-shrink: 0;
}
.pr-history-count {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-variant);
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}
.pr-history-timeline {
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}
.pr-history-entry {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
}
.pr-history-entry.newest {
  background: var(--gold-soft, rgba(245, 166, 35, 0.1));
}
.pr-history-entry-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pr-history-entry-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pr-history-entry-label {
  font-size: 0.8rem;
  color: var(--text);
}
.pr-history-entry.older {
  opacity: 0.7;
}
.pr-history-entry.newest .pr-history-entry-label {
  font-weight: 700;
  font-size: 0.85rem;
}
.pr-history-newest-badge {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #000;
  background: var(--gold);
  padding: 1px 7px;
  border-radius: 8px;
  flex-shrink: 0;
}
.pr-history-entry-date {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  /* FIX: Chart.js only respects a CSS height when maintainAspectRatio
     is false (set in logbook.js) AND the canvas's parent has an actual
     height — a canvas element with no sized ancestor collapses to 0.
     This is what makes the responsive clamp() height actually take
     effect instead of the old fixed max-height. */
  height: clamp(200px, 40vh, 350px);
}
.chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
.empty-state-sm {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: clamp(0.65rem, 2vw, 0.8125rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.logbook-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.logbook-table {
  width: 100%;
  border-collapse: collapse;
  /* FIX: fixed 0.75rem regardless of screen size — clamp() keeps it
     legible on mobile without ballooning on desktop. */
  font-size: clamp(0.5rem, 2vw, 0.75rem);
}
.logbook-table th,
.logbook-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
  border-right: 1px solid var(--border-strong);
  text-align: left;
}
.logbook-table th:last-child,
.logbook-table td:last-child {
  border-right: none;
}
.logbook-table thead th {
  white-space: nowrap !important;
  /* FIX: max-width, overflow:hidden and text-overflow:ellipsis removed
     — the 145px cap forced every week column to stay narrow, which in
     turn forced set lines to wrap. Without it the table auto-sizes
     each column to its widest set line, so nowrap actually has room
     to work. Overflow is handled by the table's own horizontal scroll
     (.logbook-table-wrap has overflow-x:auto), so nothing is clipped. */
  min-width: 145px;
  background: var(--surface-variant);
  font-weight: 600;
  font-size: clamp(0.55rem, 1.8vw, 0.6875rem);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.logbook-table th.col-exercise,
.logbook-table td.col-exercise {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  font-weight: 600;
  color: var(--text);
  min-width: 110px;
  /* FIX: exercise name column capped at 120px per spec (was 160px) so
     it can't eat most of a 375px screen's width on its own. Wraps
     rather than truncates — same reasoning as .set-line above. */
  max-width: 120px;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}
.logbook-table thead th.col-exercise {
  background: var(--surface-variant);
  z-index: 3;
}
.logbook-table tr.session-header td {
  background: var(--surface-variant);
  font-weight: 700;
  color: var(--text);
}
.logbook-table td.empty-cell {
  text-align: center;
  color: var(--text-muted);
  white-space: normal;
}
.logbook-table .set-line {
  display: block;
  font-size: clamp(0.55rem, 1.8vw, 0.7rem);
  line-height: 1.6;
  color: var(--text);
  /* FIX: nowrap so every logged set — weight, reps, RIR, and the 🏆 PR
     trophy — always renders on a single line for scannability. The
     table's own horizontal scroll (.logbook-table-wrap has
     overflow-x:auto) handles any overflow, so nothing is clipped or
     truncated. The previous wrapping behaviour (and the ellipsis
     before that) both made a single set hard to read at a glance. */
  white-space: nowrap;
}
.logbook-table td.weight-value {
  text-align: right;
  font-weight: 600;
}
.logbook-table td.weight-action {
  text-align: center;
}
.icon-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}
.icon-btn-danger:hover {
  background: var(--red);
  color: #fff;
}
.exercise-filter-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.exercise-filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.exercise-filter-header .section-label {
  font-weight: 600;
  font-size: clamp(0.6rem, 1.8vw, 0.75rem);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.exercise-filter-count {
  font-size: clamp(0.55rem, 1.8vw, 0.6875rem);
  color: var(--text-muted);
}
.exercise-filter-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.exercise-session-group {
  margin-bottom: 10px;
}
.exercise-session-group .session-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(0.5rem, 1.6vw, 0.625rem);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.exercise-session-group .session-abbr {
  font-weight: 400;
  color: var(--text-muted);
  background: var(--surface-variant);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  font-size: clamp(0.45rem, 1.5vw, 0.5625rem);
}
.exercise-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.exercise-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* FIX: fixed padding/font-size regardless of screen width, and no
     touch-target minimum — per the mobile-optimization spec. */
  padding: 4px 8px;
  min-height: 36px;
  border-radius: 20px;
  font-size: clamp(0.5rem, 2vw, 0.7rem);
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  transition: var(--transition);
}
.exercise-pill:hover {
  border-color: var(--border-strong);
  background: var(--surface-variant);
}
.exercise-pill .swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}
.exercise-pill.selected {
  background: var(--accent-soft);
  border-color: var(--swatch, var(--accent));
  color: var(--text);
}
.exercise-pill.selected .swatch {
  background: var(--swatch, var(--accent));
}
/* FIX (feature request): removed the strikethrough + opacity dimming
   for unselected pills — the request wanted a cleaner look with just
   the selected state's red border/dot doing the work, no visual
   penalty applied to unselected ones. */
/* FIX: filter bar (date range + PR toggle) used to stay in a row and
   get squeezed at narrow widths — stacking vertically at this
   breakpoint per the mobile-optimization spec keeps both controls at
   full readable/tappable width instead of cramped side by side.
   SUPERSEDED: newer guidance wants this filter bar to stay on one line
   even on mobile (nowrap + shrink) rather than stack — see the
   .logbook-filter-bar rule and the 480px block below instead. */
@media (max-width: 480px) {
  /* FIX: was 12px — spec calls for 8px on mobile. */
  .logbook-page { padding: 8px; }
  .logbook-filter-bar select { min-width: 0; flex: 1; }
  /* FIX: table cells kept their desktop 8px/10px padding on mobile,
     eating into already-limited horizontal space. */
  .logbook-table th,
  .logbook-table td {
    padding: 4px 6px;
  }
}
.btn-danger-outline.btn-outline {
  color: var(--red);
  border-color: var(--red-soft);
}
.btn-danger-outline.btn-outline:hover {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red);
}

