/* =====================================================================
   TFNL design system  |  shared by the client app and coach dashboard
   Source of truth: TFNL Brand Guidelines v1.0
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@800;900&family=Hanken+Grotesk:wght@400;500;600;700;800&family=Kaushan+Script&display=swap');

:root {
  /* Brand palette (exact values from the guidelines) */
  --ink:   #0B0B0D;   /* Ink Black: base / backgrounds */
  --paper: #FFFFFF;   /* Paper White */
  --cyan:  #0CC0DF;   /* Electric Cyan: everyday UI accent ("Default") */
  --pink:  #FF6BC2;   /* Bold Pink: coach actions, calls to action ("Hype") */

  /* Surfaces built up from Ink */
  --surface:     #141417;
  --raised:      #1C1C21;
  --line:        #2A2A31;
  --line-strong: #3B3B44;

  /* Text */
  --text:       #F4F4F6;
  --text-muted: #A4A4AE;
  --text-faint: #6F6F7A;
  --on-accent:  #0B0B0D; /* brand rule: text on a neon goes black */

  /* Status (small indicators only, never as brand colour) */
  --good: #3DD68C;
  --warn: #F5A524;
  --bad:  #FF5C5C;

  /* Type */
  --font-display: 'Archivo', 'Arial Black', system-ui, sans-serif;
  --font-body:    'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-script:  'Kaushan Script', 'Brush Script MT', cursive;

  /* Spacing and shape (kept modest: the manual asks for no bubbly UI) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --radius-sm: 6px;
  --radius:    10px;
  --tap: 48px; /* minimum touch target */
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
img { max-width: 100%; display: block; }
a { color: var(--cyan); text-underline-offset: 3px; }
a:hover { color: var(--paper); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
::selection { background: var(--cyan); color: var(--on-accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Type ---------- */
.display, h1, h2 {
  font-family: var(--font-display);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 0.95;
  margin: 0;
}
h1 { font-size: clamp(2rem, 7vw, 3rem); }
h2 { font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; margin: 0; }
p  { margin: 0; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 0.875rem; }
.script { font-family: var(--font-script); color: var(--pink); font-size: 1.35rem; line-height: 1.2; }
.num { font-family: var(--font-display); font-weight: 900; letter-spacing: -0.02em; }

/* Signature brush bar: one key word per screen, single colour, never neat */
.brush { position: relative; display: inline-block; padding: 0 0.18em; color: var(--on-accent); isolation: isolate; }
.brush::before {
  content: ''; position: absolute; inset: -0.04em -0.06em; z-index: -1;
  background: var(--cyan); transform: rotate(-1.5deg);
  clip-path: polygon(0 9%, 7% 0, 21% 6%, 37% 1%, 55% 7%, 71% 0, 88% 5%, 100% 1%, 98% 48%, 100% 97%,
                     85% 100%, 66% 94%, 49% 100%, 31% 95%, 13% 100%, 1% 94%, 3% 52%);
}
.brush--pink::before { background: var(--pink); }

/* ---------- Layout ---------- */
.stack > * + * { margin-top: var(--s4); }
.stack-lg > * + * { margin-top: var(--s6); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row--between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s5);
}

/* ---------- Forms ---------- */
.field { display: block; }
.field > span { display: block; font-size: 0.875rem; font-weight: 600; color: var(--text-muted); margin-bottom: var(--s2); }
.input {
  width: 100%; min-height: var(--tap);
  padding: var(--s3) var(--s4);
  background: var(--ink); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 16px; /* 16px stops iOS zooming in */
}
.input:focus { border-color: var(--cyan); outline: none; box-shadow: 0 0 0 3px rgb(12 192 223 / 0.25); }
.input::placeholder { color: var(--text-faint); }

.check { display: flex; gap: var(--s3); align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--cyan); flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s5);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 800; font-size: 1rem; cursor: pointer; text-decoration: none;
  background: var(--cyan); color: var(--on-accent);
}
.btn:hover { filter: brightness(1.08); color: var(--on-accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn--block { width: 100%; }
.btn--pink { background: var(--pink); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn--ghost:hover { border-color: var(--text-muted); color: var(--text); }
.btn--text { background: none; color: var(--text-muted); padding: 0; min-height: 40px; font-weight: 600; text-align: left; justify-content: flex-start; }
.btn--text:hover { color: var(--text); }

/* ---------- Feedback ---------- */
.notice { padding: var(--s3) var(--s4); border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--raised); font-size: 0.95rem; }
.notice--error { border-color: rgb(255 92 92 / 0.5); background: rgb(255 92 92 / 0.08); }
.notice--ok { border-color: rgb(12 192 223 / 0.5); background: rgb(12 192 223 / 0.08); }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
.tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.tag--good::before { background: var(--good); }
.tag--warn::before { background: var(--warn); }
.tag--bad::before  { background: var(--bad); }
.tag--cyan::before { background: var(--cyan); }

/* ---------- Data tables (coach dashboard) ---------- */
.table-wrap { overflow-x: auto; }
.data { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
.data th {
  text-align: left; font-weight: 700; color: var(--text-muted); font-size: 0.8rem;
  padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
.data td { padding: var(--s3); border-bottom: 1px solid var(--line); }
.data tr:hover td { background: var(--raised); }

/* ---------- Loading ---------- */
.loading { color: var(--text-faint); padding: var(--s7) 0; text-align: center; }

/* ---------- Coach dashboard shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  height: 64px; padding: 0 var(--s6);
  background: var(--ink); border-bottom: 1px solid var(--line);
}
.topbar img { height: 30px; width: auto; }
.nav { display: flex; gap: var(--s2); }
.nav__link {
  color: var(--text-muted); text-decoration: none; font-weight: 700;
  padding: var(--s2) var(--s3); border-radius: var(--radius-sm);
}
.nav__link:hover { color: var(--text); background: var(--raised); }
.nav__link.is-active { color: var(--text); background: var(--raised); box-shadow: inset 0 -2px 0 var(--cyan); }
.main { max-width: 1280px; margin: 0 auto; padding: var(--s6); }

.toolbar { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.toolbar .input { width: auto; min-height: 40px; padding: var(--s2) var(--s3); }
.select {
  min-height: 40px; padding: var(--s2) var(--s3);
  background: var(--ink); color: var(--text); font: inherit;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.pill { display: inline-block; min-width: 22px; text-align: center; padding: 1px 7px; border-radius: 4px; font-size: 0.8rem; font-weight: 800; background: var(--raised); color: var(--text-muted); }
.pill--A { background: var(--cyan); color: var(--on-accent); }
.pill--B { background: var(--line-strong); color: var(--text); }

/* ---------- Editing (coach) ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0.55); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(460px, 100vw); overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--line-strong);
  padding: var(--s5);
}
.drawer h2 { font-size: 1.4rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
.input--sm, .select--sm {
  min-height: 34px; padding: 4px 8px; font-size: 0.9rem; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--text); border: 1px solid var(--line-strong); font-family: inherit;
}
.input--sm:focus, .select--sm:focus { border-color: var(--cyan); outline: none; }
.num-in { width: 52px; text-align: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--line-strong); color: var(--text-muted);
  font: inherit; font-size: 0.9rem; cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-muted); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn--danger:hover { color: var(--bad); border-color: var(--bad); }
.btn--sm { min-height: 36px; padding: 0 var(--s4); font-size: 0.9rem; }
.save-state { font-size: 0.85rem; color: var(--text-faint); min-width: 90px; text-align: right; }
.save-state.is-error { color: var(--bad); }
tr.is-clickable { cursor: pointer; }

/* ---------- Chat (client app and coach dashboard) ---------- */
.chat-day { text-align: center; color: var(--text-faint); font-size: 0.78rem; font-weight: 700; margin: var(--s4) 0 var(--s2); }
.chat-empty { text-align: center; color: var(--text-faint); padding: var(--s6) 0; }
.chat-note { font-size: 0.82rem; color: var(--text-faint); text-align: center; padding: var(--s2) var(--s3); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 6px; }
.msg.is-mine { align-items: flex-end; }
.msg-name { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); margin: 8px 0 3px 4px; }
.coach-badge { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--pink); color: var(--on-accent); font-size: 0.68rem; font-weight: 800; vertical-align: 1px; }
.msg-bubble {
  max-width: min(78%, 560px); padding: 9px 13px; border-radius: 16px 16px 16px 4px;
  background: var(--raised); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4;
}
.msg.is-coach .msg-bubble { border: 1px solid rgb(255 107 194 / 0.45); }
.msg.is-mine .msg-bubble { background: var(--cyan); color: var(--on-accent); border: 0; border-radius: 16px 16px 4px 16px; }
.msg-meta { font-size: 0.7rem; color: var(--text-faint); margin: 2px 6px 0; }
.msg-deleted { color: var(--text-faint); }
.msg.is-mine .msg-deleted { color: rgb(11 11 13 / .6); }
.msg-del { background: none; border: 0; padding: 0; color: var(--text-faint); font: inherit; text-decoration: underline; cursor: pointer; }
.composer { display: flex; gap: var(--s2); align-items: flex-end; }
.composer textarea {
  flex: 1; min-height: 46px; max-height: 140px; resize: none; padding: 11px 14px; border-radius: 22px;
  background: var(--ink); color: var(--text); border: 1px solid var(--line-strong); font: inherit; font-size: 16px; line-height: 1.35;
}
.composer textarea:focus { outline: none; border-color: var(--cyan); }
.composer .btn { min-height: 46px; border-radius: 23px; padding: 0 18px; }
.count-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--pink); color: var(--on-accent); font-size: 0.72rem; font-weight: 800; text-align: center; line-height: 18px; margin-left: 6px; }
