/* ============================================================
   Goora Fitness — design tokens & styles
   Kierunek: Nike "Volt" na czerni, wysoki kontrast, SF.
   Sygnatura: liczby treningowe jak tablica wyników (tabular-nums, limonka).
   ============================================================ */

:root {
  /* kolor */
  --volt:        #CCFF00;
  --volt-press:  #B4E600;
  --bg:          #0A0A0B;
  --surface:     #151517;
  --surface-2:   #1E1E22;
  --line:        #2A2A2F;
  --text:        #F4F4F5;
  --muted:       #8A8A93;
  --danger:      #FF6B6B;

  /* typografia */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fw-thin: 200;   /* ExtraLight — tresc, etykiety */
  --fw-strong: 400; /* Regular — nazwiska i wazne naglowki */
  --fw-medium: 500; /* Medium — tekst przyciskow (troche grubszy niz reszta) */
  --fw-bold: 700;   /* Bold — kluczowe liczby (np. liczba powtorzen) */

  /* metryka */
  --r:   14px;    /* promien kart */
  --r-s: 10px;    /* promien mniejszych elementow */
  --gap: 16px;
  --pad: 16px;
  --maxw: 520px;

  /* insety bezpieczne (viewport-fit=cover) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: var(--fw-thin);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

button { font-family: inherit; font-weight: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* linki: bez podkreslenia, kolor dziedziczony (nadpisywany przez konkretne klasy) */
a { text-decoration: none; color: inherit; }

/* Nazwiska i wazne naglowki -> Regular 400 (var(--fw-strong)).
   Reszta (etykiety, przyciski, dane liczbowe, chipy) -> ExtraLight 200 (var(--fw-thin)).
   Wagi ustawione bezposrednio przy kazdym selektorze nizej w pliku. */

/* numery = tablica wynikow */
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---------- uklad/kontener ---------- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- naglowek ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10,10,11,0.82);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: calc(var(--sat) + 12px) var(--pad) 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}
.topbar__logo { color: var(--volt); height: 20px; display: block; }
.topbar__logo svg { height: 20px; width: auto; display: block; }
.topbar__title {
  font-size: 17px;
  font-weight: var(--fw-strong);
  letter-spacing: -0.01em;
  margin: 0;
}
.topbar__spacer { flex: 1; }

.iconbtn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .06s ease, background .15s ease;
}
.iconbtn:active { transform: scale(0.94); background: var(--surface-2); }

/* ---------- tresc ---------- */
.content {
  flex: 1;
  padding: var(--pad);
  padding-bottom: calc(var(--sab) + 96px); /* miejsce na pasek akcji */
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.eyebrow {
  font-size: 11px;
  font-weight: var(--fw-thin);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 4px 0 0;
}

.h-display {
  font-size: 30px;
  font-weight: var(--fw-strong);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 2px 0 0;
}

/* ---------- karty ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--pad);
}
.card--tap { transition: transform .06s ease, border-color .15s ease; }
.card--tap:active { transform: scale(0.99); border-color: #35353b; }

/* lista podopiecznych */
.client {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r);
  padding: 14px var(--pad);
}
.client__avatar {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--volt);
  display: grid; place-items: center;
  font-weight: var(--fw-strong); font-size: 18px;
  flex: none;
  letter-spacing: -0.02em;
}
.client__main { flex: 1; min-width: 0; }
.client__name { font-weight: var(--fw-strong); font-size: 16px; }
.client__meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.client__weight { text-align: right; flex: none; }
.client__weight b { font-size: 18px; font-weight: var(--fw-thin); }
.client__weight span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.client__chev { color: var(--muted); font-size: 20px; flex: none; }

/* ---------- przyciski ---------- */
.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: var(--fw-medium);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .06s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--volt); color: #0A0A0B; }
.btn--primary:active { background: var(--volt-press); }
.btn--ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn--ghost:active { background: var(--surface-2); }
.btn--danger { background: transparent; color: var(--danger); border: 1px solid #40292b; }
.btn--block { width: 100%; }
.btn--sm { padding: 9px 12px; font-size: 14px; border-radius: 10px; }

/* pasek akcji na dole */
.actionbar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 20;
  padding: 12px var(--pad) calc(var(--sab) + 12px);
  background: linear-gradient(to top, var(--bg) 55%, rgba(10,10,11,0));
  display: flex;
  gap: 10px;
  max-width: var(--maxw);
  margin: 0 auto;
}
.actionbar .btn { flex: 1; }

/* ---------- pola formularza ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 12px; font-weight: var(--fw-thin);
  color: var(--muted);
  letter-spacing: .04em; text-transform: uppercase;
}
.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-s);
  padding: 12px 12px;
  font-size: 16px; /* >=16px: iOS nie zoomuje */
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--volt);
  box-shadow: 0 0 0 3px rgba(204,255,0,0.18);
}
.textarea { resize: vertical; min-height: 64px; line-height: 1.4; }

/* iOS Safari renderuje input[type=date/time/datetime-local] ze swoja wlasna
   "piguzka" tekstowa, ktora bez dodatkowej wysokosci potrafi wystawac poza
   nasz stylizowany box (nachodzenie na sasiedni element). Wiecej wysokosci
   + reset appearance eliminuje ten glitch. */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 50px;
}

/* natywna ikonka kalendarza nie jest w pelni stylowalna kolorem na iOS —
   chowamy ja (input i tak jest tappable w calosci) i rysujemy wlasna,
   zolto-zielona, w kontenerze .datefield nizej */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  opacity: 0;
}
.datefield { position: relative; }
.datefield .input { padding-right: 40px; }
.datefield__icon {
  position: absolute;
  right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--volt); font-size: 16px;
  pointer-events: none; /* tap przechodzi na pole pod ikonka */
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%238A8A93' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }

/* natywne inputy (zwlaszcza typu date/datetime-local) maja wlasna minimalna
   szerokosc i domyslnie NIE chca sie skurczyc do wielkosci komorki grida —
   to powodowalo nachodzenie sasiednich pol. min-width:0 wymusza respektowanie
   szerokosci kolumny. */
.row2 > .field,
.row3 > .field {
  min-width: 0;
}

/* ---------- sekcje ---------- */
.section__head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 4px;
}
.section__title { font-size: 13px; font-weight: var(--fw-thin); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* ---------- trening: karta + "tablica wynikow" ---------- */
.workout { display: flex; flex-direction: column; gap: 12px; }
.workout__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.workout__title { font-weight: var(--fw-strong); font-size: 16px; letter-spacing: -0.01em; }
.workout__date { color: var(--muted); font-size: 13px; white-space: nowrap; }
.workout__note { color: var(--muted); font-size: 13px; line-height: 1.4; }

.ex { border-top: 1px solid var(--line); padding-top: 12px; }
.ex:first-child { border-top: none; padding-top: 0; }
.ex__top { display: flex; align-items: center; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px 4px 6px;
  font-size: 12px; font-weight: var(--fw-thin);
  white-space: nowrap;
}
.chip__ico {
  width: 16px; height: 16px; color: var(--volt);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; flex: none;
}
.ex__name { font-weight: var(--fw-strong); font-size: 15px; flex: 1; min-width: 0; }
.ex__note { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.4; }

/* serie = duze cyfry limonkowe */
.sets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.set {
  background: #0f0f11;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 8px 12px;
  min-width: 64px;
}
.set__main { font-size: 20px; font-weight: var(--fw-bold); letter-spacing: -0.02em; color: var(--volt); line-height: 1; }
.set__sub { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .08em; }

/* ---------- edytor serii (formularz) ---------- */
.seteditor { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.setrow {
  display: grid;
  grid-template-columns: 24px 1fr 1fr 1fr 34px;
  gap: 6px;
  align-items: center;
}
.setrow__idx { color: var(--muted); font-size: 13px; text-align: center; font-weight: var(--fw-thin); }
.setrow .input { padding: 9px 8px; text-align: center; }
.exblock {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}

/* ---------- wykres wagi ---------- */
.chartcard { padding: var(--pad); }
.detail-top { display: flex; flex-direction: column; gap: var(--gap); }
.detail-side { display: flex; flex-direction: column; gap: var(--gap); }
.chart__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.chart__now { font-size: 30px; font-weight: var(--fw-strong); letter-spacing: -0.02em; }
.chart__now u { text-decoration: none; color: var(--muted); font-size: 15px; font-weight: var(--fw-thin); margin-left: 4px; }
.chart__delta { font-size: 13px; font-weight: var(--fw-thin); }
.chart__delta.down { color: var(--volt); }
.chart__delta.up { color: var(--danger); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }

/* ---------- pomiary lista ---------- */
.measure { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.measure:first-child { border-top: none; }
.measure__date { color: var(--muted); font-size: 14px; }
.measure__val { font-weight: var(--fw-thin); font-size: 17px; }

/* ---------- puste stany ---------- */
.empty {
  border: 1px dashed var(--line);
  border-radius: var(--r);
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}
.empty h3 { color: var(--text); font-size: 16px; margin: 0 0 6px; font-weight: var(--fw-strong); }
.empty p { margin: 0 0 14px; font-size: 14px; line-height: 1.4; }

/* ---------- drobne ---------- */
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-s { display: flex; flex-direction: column; gap: 10px; }
.exercises-stack { display: flex; flex-direction: column; gap: 10px; } /* jak .stack-s, ale nigdy nie staje sie grid — to formularz */
.hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.link { color: var(--volt); background: none; border: none; padding: 0; font-size: 14px; font-weight: var(--fw-thin); letter-spacing: 0.01em; }
.link i { margin-right: 5px; font-size: 0.8em; }

/* przelacznik sortowania listy podopiecznych */
.sorttoggle {
  display: inline-flex; gap: 2px; flex: none;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px;
}
.sortbtn {
  appearance: none; border: none; background: none;
  color: var(--muted); font-size: 12px; font-weight: var(--fw-thin);
  padding: 7px 12px; border-radius: 999px;
  transition: background .15s ease, color .15s ease;
  white-space: nowrap;
}
.sortbtn.is-active { background: var(--volt); color: #0A0A0B; font-weight: var(--fw-strong); }

/* dostepnosc: widoczny focus + reduced motion */
:focus-visible { outline: 2px solid var(--volt); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   Tablet (iPad mini i wieksze, >=680px): szerszy uklad,
   listy kart w 2 kolumnach, formularze zostaja wazkie i czytelne.
   ============================================================ */
@media (min-width: 680px) {
  :root { --maxw: 900px; }

  .card { padding: 20px; }
  .content { padding-left: 20px; padding-right: 20px; padding-top: 20px; }

  /* listy podopiecznych i treningow -> 2 kolumny */
  .stack-s { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
  .stack-s > .empty { grid-column: 1 / -1; }         /* puste stany zawsze na cala szerokosc */

  /* widok szczegolow podopiecznego: wykres + (profil/cel/pomiary) obok siebie —
     lepiej wypelnia szerszy ekran, niz waska wyspa na srodku */
  .detail-top { display: grid; grid-template-columns: 1.3fr 1fr; align-items: start; }

  /* formularze (dodaj/edytuj podopiecznego, trening, pomiar): waskie i czytelne */
  .formwrap { max-width: 640px; margin: 0 auto; }
}
