/* ═══════════════════════════════════════════════════════════════
   POST-OP EXERCISE TRACKER — 30-Day History Table
   Separated from styles.css to keep concerns isolated.
   Table is horizontally scrollable. Row-header column is sticky.
   ═══════════════════════════════════════════════════════════════ */

/* ── Scroll container ───────────────────────────────────────── */
.history-table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  /* Subtle scroll shadow to hint content continues */
  background:
    linear-gradient(to right,  #f5f7f8 30%, transparent) left  center / 32px 100% no-repeat,
    linear-gradient(to left,   #f5f7f8 30%, transparent) right center / 32px 100% no-repeat,
    linear-gradient(to right, rgba(13,79,110,0.08), transparent) left  center / 20px 100% no-repeat,
    linear-gradient(to left,  rgba(13,79,110,0.08), transparent) right center / 20px 100% no-repeat;
  background-color: #f5f7f8;
  background-attachment: local, local, scroll, scroll;
}

/* ── Table ──────────────────────────────────────────────────── */
.history-table {
  border-collapse: collapse;
  white-space: nowrap;
  min-width: 100%;
  font-size: 0.8125rem;
}

/* ── Header row ─────────────────────────────────────────────── */
.history-table thead th {
  background: var(--clr-primary);
  color: #ffffff;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 6px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 3;
  border-right: 1px solid rgba(255,255,255,0.12);
}

/* Date column header — sticky left AND sticky top */
.history-table thead th.col-date {
  left: 0;
  z-index: 4;
  min-width: 90px;
  text-align: left;
  padding-left: 12px;
  background: var(--clr-primary);
  border-right: 2px solid rgba(255,255,255,0.25);
}

/* Exercise column headers */
.history-table thead th.col-ex {
  min-width: 72px;
}

/* ── Body rows ──────────────────────────────────────────────── */
.history-table tbody tr {
  border-bottom: 1px solid var(--clr-border);
  transition: background var(--transition-fast);
}

.history-table tbody tr:last-child {
  border-bottom: none;
}

.history-table tbody tr:hover {
  background: var(--clr-primary-light);
}

/* ── Date cell (sticky left column) ────────────────────────── */
.history-table td.cell-date {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--clr-surface);
  border-right: 2px solid var(--clr-border-strong);
  padding: 6px 10px;
  min-width: 90px;
  vertical-align: middle;
  transition: background var(--transition-fast);
}

.history-table tbody tr:hover td.cell-date {
  background: var(--clr-primary-light);
}

.history-table tbody tr:nth-child(even) td.cell-date {
  background: #f0f4f7;
}

.history-table tbody tr:nth-child(even):hover td.cell-date {
  background: var(--clr-primary-light);
}

/* Date label inside the cell */
.date-line1 {
  font-weight: 700;
  color: var(--clr-text-primary);
  font-size: 0.8125rem;
  line-height: 1.2;
}

.date-line2 {
  font-size: 0.6875rem;
  color: var(--clr-text-muted);
  font-weight: 500;
  line-height: 1.2;
}

/* ── Data cells ─────────────────────────────────────────────── */
.history-table td.cell-ex {
  text-align: center;
  padding: 5px 4px;
  min-width: 72px;
  vertical-align: middle;
  line-height: 1.3;
}

.history-table tbody tr:nth-child(even) td.cell-ex {
  background: #f8fafb;
}

/* Cell states */
/* No entry (exercise was applicable but not logged): dash */
.cell-empty {
  color: var(--clr-text-disabled);
  font-size: 1rem;
}

/* Exercise not applicable that day (wrong day of week): dimmed dot */
.cell-na {
  color: var(--clr-border-strong);
  font-size: 0.875rem;
}

.cell-na-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  opacity: 0.5;
}

/* Skipped (logged with count = 0) */
.cell-skipped {
  color: var(--clr-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Logged entry — three-line format */
.cell-logged {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.cell-prog {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--clr-primary);
  background: var(--clr-primary-light);
  padding: 0 4px;
  border-radius: 3px;
  line-height: 1.4;
}

.cell-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--clr-text-primary);
  line-height: 1.3;
}

.cell-repeats {
  font-size: 0.6875rem;
  color: var(--clr-text-muted);
  font-weight: 500;
  line-height: 1.3;
}

/* Today row highlight */
.history-table tbody tr.row-today td {
  background: rgba(42,157,143,0.06);
}

.history-table tbody tr.row-today td.cell-date {
  background: rgba(42,157,143,0.1);
  border-left: 3px solid var(--clr-accent);
}

/* ── Mobile adjustments ─────────────────────────────────────── */
@media (max-width: 400px) {
  .history-table thead th.col-date,
  .history-table td.cell-date {
    min-width: 76px;
    padding: 5px 8px;
  }

  .history-table thead th.col-ex,
  .history-table td.cell-ex {
    min-width: 62px;
    padding: 4px 2px;
  }

  .cell-prog,
  .cell-count,
  .cell-repeats {
    font-size: 0.625rem;
  }
}
