/* Client-management dashboard components (trainer + client pages).
   Builds on theme.css tokens. Tailwind utilities do the layout. */

:root {
  /* WorkFit group classes vs one-to-one: classes are white, one-to-one is red. */
  --workfit: #E4E4E7;
  --workfit-soft: rgba(255, 255, 255, 0.1);
  --danger: #F2A3A3;
  --success: #6EE7A0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[id] {
  scroll-margin-top: 5rem;
}

/* ---------- buttons ---------- */

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.25rem;
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #FECACA;
  font-weight: 650;
  background: rgba(248, 113, 113, 0.12);
  transition: background 160ms ease, border-color 160ms ease;
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.55);
}

.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 2.25rem;
  padding: 0.375rem 0.875rem;
  border: 1px solid var(--field-line);
  border-radius: 0.25rem;
  color: var(--text-1);
  font-size: 0.8125rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
  white-space: nowrap;
}

.btn-sm:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-2);
}

.btn-sm.is-danger {
  color: #FECACA;
}

.btn-sm.is-danger:hover {
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.1);
}

.btn-sm:disabled,
.btn-ghost:disabled,
.btn-danger:disabled,
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-link {
  color: var(--red-text);
  font-weight: 600;
  text-underline-offset: 3px;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Two-state toggle (Attended / No-show) */
.seg {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--field-line);
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.03);
}

.seg button {
  min-height: 2rem;
  padding: 0.25rem 0.75rem;
  border-radius: 0.1875rem;
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease;
}

.seg button:hover {
  color: var(--text-1);
}

.seg button[aria-pressed="true"][data-value="attended"],
.seg button[aria-pressed="true"][data-value="completed"] {
  color: #0F2A1A;
  background: var(--success);
}

.seg button[aria-pressed="true"][data-value="no_show"] {
  color: #3A0F0F;
  background: var(--danger);
}

.seg button[aria-pressed="true"]:not([data-value="attended"]):not([data-value="completed"]):not([data-value="no_show"]) {
  color: #FFFFFF;
  background: var(--red-fill);
}

/* Filter pills */
.pill-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.375rem;
  background: var(--surface);
}

.pill-group button {
  min-height: 2.25rem;
  padding: 0.375rem 0.875rem;
  border-radius: 0.25rem;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 600;
}

.pill-group button:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.05);
}

.pill-group button[aria-pressed="true"] {
  color: #FFFFFF;
  background: var(--red-fill);
}

/* ---------- forms ---------- */

.field-sm {
  width: 100%;
  min-height: 2.5rem;
  border-radius: 0.25rem;
  border: 1px solid var(--field-line);
  background: var(--surface);
  padding: 0.5rem 0.75rem;
  color: var(--text-1);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease;
}

.field-sm:focus,
.field:focus-visible {
  border-color: var(--red);
  background: var(--surface-high);
}

.field-sm::placeholder {
  color: var(--text-3);
}

select.field,
select.field-sm {
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23C0C0C6'%3E%3Cpath d='M5.3 7.3a1 1 0 0 1 1.4 0L10 10.6l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

select option {
  background: #1C1C20;
  color: var(--text-1);
}

input[type="date"].field,
input[type="time"].field,
input[type="date"].field-sm,
input[type="time"].field-sm {
  min-width: 0;
}

.choice {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--field-line);
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  font-size: 0.875rem;
  transition: border-color 160ms ease, background 160ms ease;
}

.choice:hover {
  border-color: var(--text-2);
}

.choice:has(input:checked) {
  border-color: var(--red);
  background: rgba(245, 39, 46, 0.1);
}

.choice input {
  accent-color: var(--red-fill);
}

input[type="checkbox"],
input[type="radio"],
input[type="range"] {
  accent-color: var(--red-fill);
}

/* ---------- dialog ---------- */

.et-dialog {
  width: min(560px, calc(100vw - 1.5rem));
  max-height: min(92vh, 960px);
  margin: auto;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--red);
  border-radius: 0.375rem;
  color: var(--text-1);
  background: var(--surface-high);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overscroll-behavior: contain;
}

.et-dialog.is-wide {
  width: min(760px, calc(100vw - 1.5rem));
}

.et-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.et-dialog[open] {
  animation: et-in 200ms cubic-bezier(.2, .8, .2, 1);
}

@keyframes et-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
}

/* ---------- toasts ---------- */

.et-toasts {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(420px, calc(100vw - 2rem));
  transform: translateX(-50%);
  pointer-events: none;
}

.et-toast {
  padding: 0.75rem 1rem;
  border: 1px solid var(--field-line);
  border-radius: 0.25rem;
  color: var(--text-1);
  font-size: 0.875rem;
  background: var(--surface-higher);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: et-in 200ms cubic-bezier(.2, .8, .2, 1);
}

.et-toast.is-error {
  border-color: rgba(248, 113, 113, 0.5);
  background: #2A1616;
}

/* ---------- progress ---------- */

.et-progress {
  position: relative;
  height: 0.5rem;
  overflow: hidden;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.et-progress > span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #B5141A, #F5272E);
  transition: width 420ms cubic-bezier(.2, .8, .2, 1);
}

.et-progress.is-done > span {
  background: linear-gradient(90deg, #22C55E, #6EE7A0);
}

/* ---------- sticky in-page nav ---------- */

.subnav {
  position: sticky;
  top: 0;
  z-index: 30;
  margin-inline: -1.25rem;
  padding: 0.625rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 14, 16, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.subnav ul {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.subnav ul::-webkit-scrollbar {
  display: none;
}

.subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.375rem 0.875rem;
  border-radius: 0.25rem;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.subnav a:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.05);
}

.subnav a[aria-current="true"] {
  color: #FFFFFF;
  background: var(--red-fill);
}

/* ---------- stats ---------- */

.stat {
  padding: 1rem 1.125rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.375rem;
  background: var(--surface);
}

.stat-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}

.stat-value {
  margin-top: 0.25rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.625rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  margin-top: 0.125rem;
  font-size: 0.75rem;
  color: var(--text-3);
}

.tnum {
  font-variant-numeric: tabular-nums;
}

/* ---------- data table ---------- */

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.data-table th {
  position: sticky;
  top: 0;
  padding: 0.75rem 0.625rem;
  border-bottom: 1px solid var(--line-strong);
  color: var(--text-3);
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--surface);
}

.data-table th:first-child,
.data-table td:first-child {
  padding-left: 1.125rem;
}

.data-table td {
  padding: 0.875rem 0.625rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 140ms ease;
}

.data-table tbody tr:hover,
.data-table tbody tr:focus-within {
  background: rgba(255, 255, 255, 0.035);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------- calendar ---------- */

.et-cal {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
}

.et-cal-head {
  padding: 0.25rem 0;
  color: var(--text-3);
  font-size: 0.6875rem;
  font-weight: 650;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.et-cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.125rem;
  min-width: 0;
  min-height: 3rem;
  padding: 0.25rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-1);
  text-align: left;
}

button.et-cal-cell {
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

button.et-cal-cell:hover {
  border-color: var(--text-3);
  background: rgba(255, 255, 255, 0.05);
}

.et-cal-cell.is-blank {
  border-color: transparent;
  background: transparent;
}

.et-cal-cell.is-past .et-cal-num {
  color: var(--text-3);
}

.et-cal-cell.is-today {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px rgba(245, 39, 46, 0.35);
}

.et-cal-cell.is-today .et-cal-num {
  color: var(--red-text);
}

.et-cal-cell.is-selected {
  border-color: var(--text-1);
  background: rgba(245, 39, 46, 0.12);
}

.et-cal-num {
  font-size: 0.75rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.et-cal-pills {
  display: none;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.et-cal-pill {
  display: block;
  overflow: hidden;
  padding: 0.0625rem 0.3125rem;
  border-radius: 0.125rem;
  font-size: 0.6875rem;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.et-cal-pill.is-session {
  color: #FFD9DA;
  background: rgba(245, 39, 46, 0.24);
}

.et-cal-pill.is-class {
  color: #F5F5F5;
  background: var(--workfit-soft);
}

.et-cal-pill.is-noshow {
  color: #FECACA;
  background: rgba(248, 113, 113, 0.16);
}

.et-cal-pill.is-cancelled {
  color: var(--text-3);
  background: rgba(255, 255, 255, 0.04);
  text-decoration: line-through;
}

.et-cal-more {
  padding-left: 0.3125rem;
  color: var(--text-3);
  font-size: 0.625rem;
}

.et-cal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: auto;
}

.et-cal-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  flex: none;
}

.et-cal-dot.is-session {
  background: var(--red);
}

.et-cal-dot.is-class {
  background: var(--workfit);
}

.et-cal-dot.is-noshow {
  background: #F87171;
}

.et-cal-dot.is-cancelled {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--text-3);
}

@media (min-width: 640px) {
  .et-cal {
    gap: 0.375rem;
  }

  .et-cal-cell {
    min-height: 5.75rem;
    padding: 0.375rem;
  }

  .et-cal-pills {
    display: flex;
  }

  .et-cal-dots {
    display: none;
  }
}

/* In a narrow calendar the pills show just the time; the day panel has the rest. */
@container (max-width: 680px) {
  .et-cal-pill-title {
    display: none;
  }
}

/* ---------- misc ---------- */

.hairline {
  height: 1px;
  background: var(--line);
}

.kv dt {
  color: var(--text-3);
  font-size: 0.75rem;
  font-weight: 600;
}

.kv dd {
  margin-top: 0.125rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.skeleton {
  border-radius: 0.25rem;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  background-size: 200% 100%;
  animation: et-shimmer 1.4s linear infinite;
}

@keyframes et-shimmer {
  to {
    background-position: -200% 0;
  }
}

details.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  width: fit-content;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 600;
}

details.disclosure > summary:hover {
  color: var(--text-1);
}

details.disclosure > summary::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 160ms ease;
}

details.disclosure[open] > summary::before {
  transform: rotate(45deg);
}
