/* ============================================================================
   IRON FORGED — coach dashboard components (Phase 2)
   ============================================================================ */

/* mobile nav (sidenav hides <=860px; coach must be fully usable on a phone) */
.mobilenav { display: none; }
/* inside a client, drop the app-level nav — it's all about that client (back btn returns) */
.viewing-client .mobilenav { display: none !important; }
@media (max-width: 860px) {
  .mobilenav {
    display: flex; gap: var(--s-2); overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--line-soft);
    position: sticky; top: 0; z-index: 39; background: rgba(11,11,15,0.92);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  }
  .mobilenav a { flex: none; padding: 8px 14px; border-radius: var(--r-pill);
    border: 1px solid var(--line); color: var(--text-secondary);
    font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
  .mobilenav a.active { color: var(--ember); border-color: var(--ember-deep); background: var(--ember-glow-soft); }
}

/* ---------- roster ---------- */
/* min(100%, Npx) so a fixed minimum can never force sideways overflow on phones */
.roster { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.rcard { display: block; cursor: pointer; }
.rcard__top { display: flex; align-items: center; gap: var(--s-4); margin-bottom: var(--s-4); }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700;
  font-size: 1rem; letter-spacing: 0.05em; color: var(--text-secondary);
  background: var(--steel-300); border: 1px solid var(--line-strong);
  box-shadow: var(--inset-top);
}
.rcard__who { min-width: 0; }
.rcard__name { font-weight: 700; font-size: var(--t-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcard__meta { font-size: var(--t-xs); color: var(--text-muted); }
.rcard__mid { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); }
.rcard__weight { line-height: 1; }
.rcard__weight .num { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rcard__weight .unit { font-size: var(--t-xs); color: var(--text-muted); }
.rcard__trend { font-size: var(--t-xs); color: var(--text-secondary); margin-top: 4px; font-variant-numeric: tabular-nums; }
.rcard__chips { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.spark { display: block; }
.spark polyline { fill: none; stroke: var(--text-secondary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.9; }
.spark .dot { fill: var(--ember); }
.spark .base { stroke: var(--line); stroke-width: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: var(--r-pill); font-size: var(--t-xs); font-weight: 700;
  letter-spacing: 0.04em; border: 1px solid var(--line); color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: none; }
.chip--ok    { color: var(--ok);     border-color: rgba(127,169,138,0.35); } .chip--ok i    { background: var(--ok); }
.chip--warn  { color: var(--warn);   border-color: rgba(201,154,78,0.4); }  .chip--warn i  { background: var(--warn); }
.chip--danger{ color: var(--danger); border-color: rgba(195,106,80,0.4); }  .chip--danger i{ background: var(--danger); }
.chip--muted { color: var(--text-muted); }

/* ---------- client detail ---------- */
.detailhead { display: flex; align-items: center; gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap; }
.backbtn { width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center;
  background: var(--steel-100); border: 1px solid var(--line); color: var(--text-secondary); flex: none; }
.backbtn:hover { color: var(--text-primary); border-color: var(--line-strong); }
.detailhead .avatar { width: 54px; height: 54px; }
.detailhead h1 { font-size: var(--t-lg); }
.detailhead .sub { font-size: var(--t-xs); color: var(--text-muted); }

.tabs { display: flex; gap: var(--s-1); overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--line-soft); margin-bottom: var(--s-6); }
.tabs a { flex: none; padding: 10px 14px; font-size: var(--t-sm); font-weight: 700;
  color: var(--text-muted); border-bottom: 2px solid transparent; letter-spacing: 0.03em; }
.tabs a:hover { color: var(--text-secondary); }
.tabs a.active { color: var(--ember); border-bottom-color: var(--ember); }

/* weight chart */
.chartwrap { position: relative; }
.chartwrap svg { display: block; width: 100%; height: auto; }
.wline { fill: none; stroke: var(--text-secondary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.warea { fill: url(#wfade); opacity: 0.5; }
.wgrid { stroke: var(--line-soft); stroke-width: 1; }
.wdot { fill: var(--ember); stroke: var(--steel-100); stroke-width: 2; }
.whover { fill: transparent; }
.wcross { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.charttip {
  position: absolute; pointer-events: none; padding: 6px 10px; border-radius: var(--r-xs);
  background: var(--steel-300); border: 1px solid var(--line-strong); box-shadow: var(--shadow-md);
  font-size: var(--t-xs); font-variant-numeric: tabular-nums; white-space: nowrap;
  transform: translate(-50%, -130%); display: none; z-index: 5;
}
.axislab { font-size: 0.62rem; fill: var(--text-faint); font-family: var(--font-ui); }

/* activity feed */
.activity { display: flex; flex-direction: column; }
.activity li { display: flex; gap: var(--s-3); align-items: baseline; padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line-soft); list-style: none; font-size: var(--t-sm); }
.activity li:last-child { border-bottom: 0; }
.activity .when { color: var(--text-muted); font-size: var(--t-xs); flex: none; width: 64px; font-variant-numeric: tabular-nums; }

/* ---------- program preview (default face of the Program tab) ---------- */
.pday { padding: var(--s-5); }
.pday__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3);
  margin-bottom: var(--s-3); padding-bottom: var(--s-3); border-bottom: 1px solid var(--line-soft); }
.pday__label { font-family: var(--font-display); font-weight: 700; text-transform: uppercase;
  letter-spacing: var(--tracking-display); font-size: var(--t-base); }
.pday__count { font-size: var(--t-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pxrow { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--line-soft); }
.pxrow:last-child { border-bottom: 0; padding-bottom: 0; }
.pxrow__main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pxrow__name { font-weight: 600; font-size: var(--t-sm); }
.pxrow__sub { font-size: var(--t-xs); color: var(--text-muted); }
.pxrow__rx { flex: none; font-size: var(--t-sm); color: var(--text-secondary);
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.pxrow__rx b { color: var(--ember); font-weight: 700; }

/* ---------- program builder ---------- */
.progbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-5); }
.progbar select { height: 40px; }
.daygrid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
.daycard { padding: var(--s-4); }
.daycard__head { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); }
.daycard__head .input--inline { font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 700; font-size: var(--t-base); }

.exrow { display: grid; grid-template-columns: 1fr auto; gap: var(--s-2); padding: var(--s-3) 0;
  border-top: 1px solid var(--line-soft); }
.exrow__main { min-width: 0; }
.exrow__nums { display: flex; gap: var(--s-2); margin-top: var(--s-2); flex-wrap: wrap; align-items: center; }
.exrow__nums .nfield { display: flex; flex-direction: column; gap: 2px; }
.exrow__nums .nfield span { font-size: 0.58rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); }
.exrow__side { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

.input--sm { height: 34px; padding: 0 8px; border-radius: var(--r-xs); font-size: var(--t-sm);
  background: var(--steel-400); border: 1px solid var(--line); color: var(--text-primary);
  font-variant-numeric: tabular-nums; }
.input--sm:focus { border-color: var(--ember); box-shadow: 0 0 0 2px var(--ember-glow-soft); }
.input--sm.w-sets { width: 52px; } .input--sm.w-reps { width: 64px; }
.input--sm.w-kg { width: 70px; } .input--sm.w-rest { width: 60px; }
.input--note { width: 100%; margin-top: var(--s-2); }

.input--inline { background: transparent; border: 1px solid transparent; border-radius: var(--r-xs);
  color: var(--text-primary); padding: 4px 6px; width: 100%; min-width: 0; font-size: var(--t-sm); }
.input--inline:hover { border-color: var(--line); }
.input--inline:focus { background: var(--steel-400); border-color: var(--ember); }

select.input--sm, select.input { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239C9CA8' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 26px; }

.rowbtn { width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--r-xs);
  background: transparent; border: 1px solid transparent; color: var(--text-faint); font-size: 13px; line-height: 1; }
.rowbtn:hover { color: var(--text-secondary); border-color: var(--line); background: var(--steel-300); }
.rowbtn--del:hover { color: var(--danger); border-color: rgba(195,106,80,0.4); }

.dayfoot { display: flex; gap: var(--s-2); margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--line-soft); }
.dayfoot select { flex: 1; min-width: 0; }

.btn--sm { height: 36px; padding: 0 var(--s-4); font-size: var(--t-xs); }

/* ---------- exercise library ---------- */
.libtools { display: flex; gap: var(--s-3); margin-bottom: var(--s-5); flex-wrap: wrap; }
.libtools .input { flex: 1; min-width: 200px; height: 44px; }
.libgrid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.libcard { cursor: pointer; }
.libcard:active { transform: scale(0.99); }
.libcard__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2); margin-bottom: var(--s-2); }
.libcard__name { font-weight: 700; }
.libcard__edit { flex: none; font-size: var(--t-xs); font-weight: 700; color: var(--ember);
  letter-spacing: 0.06em; opacity: 0.85; }

/* PersonalOS-style side-by-side selects in the exercise editor */
.selrow { display: flex; gap: var(--s-2); }
.selrow select { flex: 1; min-width: 0; }
.libcard__cues { font-size: var(--t-xs); color: var(--text-muted); margin-top: var(--s-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.libcard__foot { display: flex; gap: var(--s-2); align-items: center; margin-top: var(--s-3); flex-wrap: wrap; }

/* ---------- logs ---------- */
.sess { margin-bottom: var(--s-4); }
.sess__head { display: flex; align-items: baseline; gap: var(--s-3); margin-bottom: var(--s-2); flex-wrap: wrap; }
.sess__date { font-weight: 700; font-variant-numeric: tabular-nums; }
.setline { display: flex; gap: var(--s-3); font-size: var(--t-sm); padding: 6px 0;
  border-top: 1px solid var(--line-soft); align-items: baseline; }
.setline .ex { flex: 1; min-width: 0; }
.setline .nums { color: var(--text-secondary); font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- add client ---------- */
.addwrap { max-width: 480px; }
.pwrow { display: flex; gap: var(--s-2); }
.pwrow .input { flex: 1; }
.credbox { padding: var(--s-4); border-radius: var(--r-sm); background: var(--steel-400);
  border: 1px solid var(--line-strong); font-variant-numeric: tabular-nums;
  font-size: var(--t-sm); line-height: 1.9; user-select: all; -webkit-user-select: all;
  overflow-wrap: anywhere; white-space: pre-wrap; }

/* ---------- builder: per-set rows (PersonalOS model) ---------- */
.bex { padding: var(--s-3) 0; border-top: 1px solid var(--line-soft); }
.bex__head { display: flex; align-items: center; gap: var(--s-2); }
.bex__name { font-weight: 700; flex: 1; min-width: 0; font-size: var(--t-sm); }
.settable { margin-top: var(--s-2); }
.setrow { display: grid; grid-template-columns: 38px 1fr 1fr 38px; gap: var(--s-2); align-items: center; padding: 3px 0; }
.setrow input { width: 100%; }
.setrow__n { color: var(--text-muted); font-size: var(--t-xs); font-variant-numeric: tabular-nums; text-align: center; }
.setrow--head { padding: 0 0 2px; }
.setrow--head span { font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-faint); }
.setrow--head span:not(.setrow__n) { padding-left: 2px; }
.addset { width: 100%; margin-top: 4px; height: 34px; border-radius: var(--r-xs);
  background: transparent; border: 1px dashed var(--line); color: var(--text-muted);
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.06em; }
.addset:hover { color: var(--text-secondary); border-color: var(--line-strong); }
.bex__meta { display: flex; gap: var(--s-2); margin-top: var(--s-3); align-items: flex-end; }
/* PersonalOS .ex-note: borderless note straight under the exercise name */
.bexnote { width: 100%; background: transparent; border: none; outline: none;
  color: var(--text-secondary); font-size: var(--t-sm); line-height: 1.4; padding: 2px 0 0; }
.bexnote::placeholder { color: var(--text-faint); }
.restrow { display: flex; gap: var(--s-2); }

/* ---------- exercise picker sheet (mirrors PersonalOS "Add exercise") ---------- */
.sheet-scrim { position: fixed; inset: 0; z-index: 80; background: rgba(8,8,11,0.72);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fadein var(--dur) var(--ease); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 81; max-height: 84dvh;
  display: flex; flex-direction: column; background: var(--steel-100);
  border-top: 1px solid var(--line-strong); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding-bottom: var(--safe-b); box-shadow: var(--shadow-lg); animation: sheetup 320ms var(--ease-out); }
@media (min-width: 861px) { .sheet { left: 50%; right: auto; transform: translateX(-50%); width: 520px; } }
@keyframes sheetup { from { transform: translateY(30%); opacity: 0.3; } }
.sheet__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5) var(--s-5) var(--s-3); }
.sheet__title { flex: 1; font-weight: 800; font-size: var(--t-lg); }
.sheet__search { padding: 0 var(--s-5) var(--s-3); }
.sheet__search .input { width: 100%; }
.sheet__body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 var(--s-5) var(--s-6); }
.pcat { display: flex; justify-content: space-between; align-items: center; width: 100%;
  padding: var(--s-4) 0 var(--s-2); background: none; border: 0; cursor: pointer;
  font-size: var(--t-xs); font-weight: 700; letter-spacing: var(--tracking-label);
  text-transform: uppercase; color: var(--text-muted); }
.prow { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3);
  padding: 13px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.prow:active { background: var(--steel-200); }
.prow__name { font-size: var(--t-md); min-width: 0; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: rgba(8,8,11,0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: var(--s-5); animation: fadein var(--dur) var(--ease); }
.modal__card { width: 100%; max-width: 440px; padding: var(--s-6) var(--s-5) var(--s-5);
  animation: rise var(--dur) var(--ease-out); max-height: 88dvh; overflow-y: auto; }
.modal__title { font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: var(--tracking-display); font-size: var(--t-md); margin-bottom: var(--s-5); }
.modal__foot { display: flex; gap: var(--s-3); margin-top: var(--s-5); }
.modal__foot .btn { flex: 1; }
@keyframes fadein { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* ---------- phone pass ---------- */
@media (max-width: 860px) {
  /* iOS Safari zooms the whole page when focusing any form control under 16px,
     and never zooms back out — the "have to zoom out" bug. 16px kills it. */
  .input, .input--sm, .input--inline, .bexnote, select, textarea { font-size: 16px !important; }
  .input--sm { height: 40px; }
  .input--sm.w-sets { width: 58px; } .input--sm.w-reps { width: 72px; }
  .input--sm.w-kg { width: 76px; } .input--sm.w-rest { width: 66px; }
  /* fingers, not cursors */
  .rowbtn { width: 34px; height: 34px; font-size: 15px; }
  .tabs a { padding: 12px 14px; }
  /* program bar: controls go full-width rows instead of cramping */
  .progbar select, .progbar .input--inline { max-width: none !important; flex: 1 1 100%; }
}

/* ---------- toast ---------- */
.toast { position: fixed; bottom: calc(var(--s-5) + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(20px);
  padding: 10px 18px; border-radius: var(--r-pill); background: var(--steel-300);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-md); font-size: var(--t-sm);
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); z-index: 90; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .tick { color: var(--ember); }
