/* omnifit: area allenatore, pagina «Atleti» (js/coach.js, <dialog id="coachDlg">), fatta per il telefono.
   Come l'elenco delle chat di WhatsApp: in alto la ricerca e i filtri (sui telefoni i sette giorni su una riga loro, ogni
   tasto largo almeno 40 px anche a 320 px, senza scorrere di lato), sotto una riga per atleta: foto, nome e ora
   dell'ultimo messaggio, sotto la cosa più importante e i messaggi da leggere. Solo colori dei temi (chiaro e scuro). .co-av e .co-av-me servono anche alla scrivania del coach (desk.css). */

/* ---------- intestazione: resta in alto mentre l'elenco scorre ---------- */
#coachDlg > .co-head { position: sticky; top: 0; z-index: 3; }
.co-search {
  display: flex; align-items: center; gap: 8px; min-width: 0; height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted);
}
.co-search:focus-within { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.co-search svg { flex: none; width: 19px; height: 19px; }
.co-search input {
  flex: 1 1 auto; width: 100%; min-width: 0; height: 100%; padding: 0; border: 0; outline: none;
  background: transparent; color: var(--ink); font: 400 16px/1.2 var(--f-body); /* 16px: niente zoom automatico di iPhone */
}
.co-search input::placeholder { color: var(--muted); }

/* ---------- i filtri: «Tutti», «Da guardare» e i sette giorni del check, in una riga sola (sui telefoni i giorni sotto) ---------- */
.co-filters { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 6px; min-width: 0; }
.co-filters[hidden] { display: none; }
.co-fchip {
  position: relative; min-width: 0; min-height: 40px; padding: 0 12px; border: 0; border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 7%, var(--surface)); color: var(--ink);
  font: 600 13.5px/1 var(--f-body); white-space: nowrap; cursor: pointer;
}
/* «Da guardare» con qualcuno dentro: un pallino rosso nell'angolo (non allarga il tasto) */
.co-fchip.has-dot::after {
  content: ""; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--missed); box-shadow: 0 0 0 2px var(--surface);
}
/* i giorni: una striscia con sette tasti larghi uguali (Lu Ma Me …), oggi in arancione con un puntino sotto */
.co-days {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-width: 0; border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 7%, var(--surface));
}
.co-days button {
  position: relative; min-width: 0; min-height: 40px; padding: 0; border: 0; border-radius: 99px;
  background: transparent; color: var(--ink); font: 600 13.5px/1 var(--f-body); cursor: pointer;
}
.co-days button.is-today { color: var(--accent); font-weight: 800; }
.co-days button.is-today::after {
  content: ""; position: absolute; left: 50%; bottom: 6px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: currentColor;
}
.co-fchip[aria-pressed="true"], .co-days button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 20%, var(--surface)); color: color-mix(in srgb, var(--accent) 78%, var(--ink));
}
.co-days button.is-today[aria-pressed="true"] { color: var(--accent); }
.co-fchip:focus-visible, .co-days button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- l'elenco come le chat: righe da bordo a bordo, la linea comincia dopo la foto ---------- */
.co-chats { margin: 2px -20px 0; padding: 0; list-style: none; }
.co-crow { position: relative; display: flex; align-items: stretch; min-width: 0; }
.co-crow + .co-crow::before { content: ""; position: absolute; top: 0; left: 84px; right: 0; border-top: 1px solid var(--line); }
.co-crow:has(.co-copen:hover) { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.co-crow:has(.co-copen:active) { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.co-crow.is-busy { cursor: progress; }
.co-crow.is-busy .co-copen { opacity: .6; }

/* la foto: un tasto a parte (le info dell'atleta) */
.co-avb {
  display: grid; place-items: center; flex: none; width: 84px; min-height: 74px; padding: 0 12px 0 20px;
  border: 0; background: transparent; cursor: pointer;
}
.co-avb .co-av { width: 52px; height: 52px; font-size: 19px; }
.co-avb:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 50%; }

/* il resto della riga apre la chat */
.co-copen {
  display: flex; flex: 1 1 auto; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; min-height: 74px;
  padding: 10px 20px 10px 0; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.co-copen:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 12px; }
.co-l1, .co-l2 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.co-l1 .co-name { flex: 1 1 auto; }
.co-when { flex: none; font-size: 12.5px; line-height: 1.2; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.co-when.is-unread { font-weight: 700; color: var(--accent); }

/* la seconda riga: infortunio (rosso col triangolo), check (arancione), il perché, l'ultimo messaggio, i numeri */
.co-sub {
  display: flex; flex: 1 1 auto; align-items: center; gap: 5px; min-width: 0;
  font-size: 14px; line-height: 1.3; color: var(--muted); font-variant-numeric: tabular-nums;
}
.co-sub > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.co-sub.is-unread { color: var(--ink); }
.co-sub.is-hurt, .co-sub.is-why { font-weight: 600; color: var(--missed); }
.co-sub.is-check { font-weight: 600; color: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.co-tri { flex: none; width: 16px; height: 16px; }
.co-tri-x { stroke: var(--surface); }

/* messaggi da leggere: il numero in un cerchio arancione */
.co-badge {
  flex: none; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink);
  font: 700 12.5px/22px var(--f-body); text-align: center; font-variant-numeric: tabular-nums;
}

/* «Check» a destra della riga: da vedere (pieno) o già visto (solo l'icona, per rileggerlo) */
.co-ck {
  display: inline-flex; flex: none; align-self: center; align-items: center; justify-content: center; gap: 4px;
  min-width: 40px; min-height: 40px; margin-right: 16px; padding: 0 12px; border: 0; border-radius: 99px;
  background: var(--accent); color: var(--accent-ink); font: 700 13.5px/1 var(--f-body); white-space: nowrap; cursor: pointer;
}
.co-ck svg { flex: none; width: 17px; height: 17px; }
.co-ck.is-seen { padding: 0; background: color-mix(in srgb, var(--ink) 7%, var(--surface)); color: var(--muted); }
.co-ck:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.co-crow:has(.co-ck) .co-copen { padding-right: 10px; }

/* ---------- «Il mio calendario» e la scelta del giorno del check ---------- */
.co-list { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.co-list.co-solo { margin-top: 18px; }

.co-row { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; padding-right: 12px; }
.co-row + .co-row::before { content: ""; position: absolute; top: 0; left: 68px; right: 0; border-top: 1px solid var(--line); }
.co-row.is-cur { background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); }
.co-open {
  display: flex; flex: 1 1 auto; align-items: center; gap: 12px; min-width: 0; min-height: 66px; padding: 10px 0 10px 14px;
  border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.co-row:has(.co-open:hover) { background: color-mix(in srgb, var(--ink) 4%, var(--surface-2)); }
.co-row:has(.co-open:active) { background: color-mix(in srgb, var(--ink) 8%, var(--surface-2)); }
.co-open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 12px; }
.co-row.is-busy { cursor: progress; }
.co-row.is-busy .co-main { opacity: .6; }

.co-av {
  --av: var(--accent);
  position: relative; display: grid; place-items: center; flex: none; width: 42px; height: 42px; overflow: hidden; border-radius: 50%;
  background: color-mix(in srgb, var(--av) 17%, var(--surface)); color: color-mix(in srgb, var(--av) 82%, var(--ink));
  font: 700 17px/1 var(--f-display); letter-spacing: .03em;
}
.co-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface-2); }
.co-av img:not([src]) { visibility: hidden; }
.co-av svg { width: 21px; height: 21px; }
.co-av-me { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }

.co-main { display: flex; flex: 1 1 auto; flex-direction: column; gap: 3px; min-width: 0; }
.co-name { min-width: 0; overflow: hidden; font-size: 16px; font-weight: 600; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; }
.co-ok { min-width: 0; overflow: hidden; font-size: 13.5px; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }

.co-chev { display: flex; flex: none; align-items: center; justify-content: center; width: 22px; color: var(--muted); }
.co-chev svg { width: 18px; height: 18px; }
.co-spin {
  width: 16px; height: 16px; border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent);
  border-radius: 50%; animation: co-spin .8s linear infinite;
}
@keyframes co-spin { to { transform: rotate(360deg); } }

/* in fondo: la scelta del giorno del check, fuori dai piedi */
.co-more {
  display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 48px; margin-top: 10px;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted); font: 600 14px/1.2 var(--f-body); cursor: pointer;
}
.co-more svg { width: 17px; height: 17px; }
.co-more:hover { color: var(--ink); }
.co-more:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- giorno del check di ogni atleta: sotto il nome i sette giorni ---------- */
.co-edhead { display: flex; align-items: center; gap: 10px; margin: 6px 2px 12px; }
.co-edhead p { flex: 1 1 auto; margin: 0; font-size: 14px; line-height: 1.35; color: var(--muted); }
.co-edhead .btn { flex: none; gap: 5px; }
.co-edhead .btn svg { width: 15px; height: 15px; }
.co-erow { align-items: flex-start; gap: 12px; padding: 12px 12px 12px 14px; }
.co-erow .co-main { gap: 8px; }
.co-pick { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 340px; }
.co-pick button {
  min-width: 0; min-height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); font: 600 13px/1 var(--f-body); cursor: pointer;
}
.co-pick button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.co-pick button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- avvisi ---------- */
.co-note {
  margin: 8px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--muted); font-size: 14px; line-height: 1.45;
}
.co-note .btn { margin-left: 4px; vertical-align: middle; }
.co-empty { margin: 14px 0 0; padding: 18px 12px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.45; }
.co-empty p { margin: 0 0 10px; }

/* ---------- telefono ---------- */
@media (max-width: 820px) {
  /* aperta da un tasto della barra in basso: il marchio prima del titolo, come le altre schede */
  #coachDlg[data-tab] .sh-mark { display: block; }
  /* .sh-body ha 14px ai lati: le righe arrivano ai bordi dello schermo */
  .co-chats { margin-inline: -14px; }
  .co-avb { width: 78px; padding-left: 14px; }
  .co-crow + .co-crow::before { left: 78px; }
  .co-copen { padding-right: 14px; }
  .co-ck { margin-right: 14px; }
}
/* telefoni: in una riga sola ai giorni resterebbero ~25 px a testa (sotto i 40 px di un dito). «Tutti» e «Da guardare»
   restano sopra, i sette giorni vanno sotto su tutta la larghezza: a 320 px 292 / 7 ≈ 41 px ciascuno */
@media (max-width: 520px) {
  .co-filters { row-gap: 6px; }
  .co-days { grid-column: 1 / -1; }
}
/* telefoni stretti: righe un po' più compatte */
@media (max-width: 360px) {
  .co-open { gap: 10px; padding-left: 12px; }
  .co-av { width: 38px; height: 38px; font-size: 15px; }
  .co-row + .co-row::before { left: 60px; }
  .co-avb { width: 72px; padding-right: 10px; }
  .co-avb .co-av { width: 48px; height: 48px; font-size: 17px; }
  .co-crow + .co-crow::before { left: 72px; }
  .co-ck { padding-inline: 10px; }
  .co-ck.is-seen { padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .co-spin { animation-duration: 2.4s; }
}
