/* ─────────────────────────────────────────────────────────────────────────
   Vetrda — componentes
   ───────────────────────────────────────────────────────────────────────── */

/* ═══ Botões ═════════════════════════════════════════════════════════════
   Todos os alvos têm pelo menos --tap (48px). As ações de campo usam
   --tap-lg (56px): o treinador marca com o polegar, à chuva, com pressa. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: 0 var(--s-5);
  border-radius: var(--r-full);
  font-size: var(--t-base);
  font-weight: var(--fw-semi);
  letter-spacing: -0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: transform var(--d-fast) var(--ease),
              background-color var(--d-fast) var(--ease),
              border-color var(--d-fast) var(--ease),
              opacity var(--d-fast) var(--ease);
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn--primary   { background: var(--c-primary); color: var(--c-primary-contrast); box-shadow: var(--sh-1); }
.btn--primary:hover { background: var(--c-primary-dark); }
.btn--secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.btn--secondary:hover { background: var(--c-surface-2); }
.btn--soft      { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.btn--ghost     { background: transparent; color: var(--c-text-2); }
.btn--ghost:hover { background: var(--c-surface-2); }
.btn--danger    { background: var(--c-danger); color: #fff; }
.btn--danger-soft { background: var(--c-danger-soft); color: var(--c-danger); }

.btn--lg { min-height: var(--tap-lg); padding: 0 var(--s-6); font-size: var(--t-md); }
.btn--xl { min-height: var(--tap-xl); padding: 0 var(--s-7); font-size: var(--t-md); width: 100%; }
.btn--sm { min-height: 36px; padding: 0 var(--s-4); font-size: var(--t-sm); }
.btn--block { width: 100%; }

/* Botão só com ícone: quadrado, alvo cheio, sem texto visível
   mas com rótulo para leitores de ecrã. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--r-full);
  color: var(--c-text-2);
  transition: background-color var(--d-fast) var(--ease);
}
.icon-btn:hover { background: var(--c-surface-2); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 22px; height: 22px; }

/* ═══ Cartões ═══════════════════════════════════════════════════════════ */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--sh-1);
}
.card--flat { box-shadow: none; }
.card--pad-0 { padding: 0; overflow: hidden; }
.card--accent { border-color: color-mix(in srgb, var(--c-primary) 35%, var(--c-border)); }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4);
  border-bottom: 1px solid var(--c-border);
}
.card__body { padding: var(--s-4); }
.card__foot {
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
}

/* ═══ Números de destaque ══════════════════════════════════════════════
   Os valores são o que o treinador lê de relance. Tipografia grande,
   tabular, e uma etiqueta curta por baixo. */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__value {
  font-size: var(--t-2xl);
  font-weight: var(--fw-bold);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat__label { font-size: var(--t-xs); color: var(--c-text-3); font-weight: var(--fw-medium); }
.stat--hero .stat__value { font-size: var(--t-3xl); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
}
@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }

.kpi {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
}

/* ═══ Etiquetas e pastilhas ════════════════════════════════════════════ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 var(--s-3);
  border-radius: var(--r-full);
  font-size: var(--t-xs);
  font-weight: var(--fw-semi);
  background: var(--c-neutral-soft);
  color: var(--c-neutral);
  white-space: nowrap;
}
.chip--ok     { background: var(--c-ok-soft);     color: var(--c-ok); }
.chip--warn   { background: var(--c-warn-soft);   color: var(--c-warn); }
.chip--danger { background: var(--c-danger-soft); color: var(--c-danger); }
.chip--info   { background: var(--c-info-soft);   color: var(--c-info); }
.chip--accent { background: var(--c-accent-soft); color: var(--c-accent-strong); }
.chip--primary{ background: var(--c-primary-soft);color: var(--c-primary-dark); }
.chip--bare   { background: transparent; border: 1px solid var(--c-border); color: var(--c-text-2); }

/* Chip de posição: monograma curto, largura fixa para alinhar em lista */
.pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.03em;
  background: var(--c-surface-3);
  color: var(--c-text-2);
  font-variant-numeric: tabular-nums;
}

/* Ponto de estado: leitura instantânea, sem depender da cor do texto */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--c-neutral);
  flex: none;
}
.dot--ok     { background: var(--c-ok); }
.dot--warn   { background: var(--c-warn); }
.dot--danger { background: var(--c-danger); }
.dot--info   { background: var(--c-info); }

/* ═══ Avatar (iniciais) ════════════════════════════════════════════════
   A cor é derivada do nome, para a mesma pessoa ter sempre a mesma cor
   e a lista tornar-se reconhecível por padrão visual, não por leitura. */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  font-size: var(--t-sm);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  color: #fff;
  flex: none;
  user-select: none;
}
.avatar--lg { width: 56px; height: 56px; font-size: var(--t-md); }

/* ═══ Listas ═══════════════════════════════════════════════════════════ */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: var(--tap-lg);
  padding: var(--s-3) var(--s-4);
  text-align: left;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  transition: background-color var(--d-fast) var(--ease);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--c-surface-2); }
.list-row__main { flex: 1; min-width: 0; }
.list-row__title { font-size: var(--t-md); font-weight: var(--fw-medium); letter-spacing: -0.01em; }
.list-row__sub { font-size: var(--t-sm); color: var(--c-text-3); }

/* ═══ Formulário ═══════════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--t-sm); font-weight: var(--fw-semi); color: var(--c-text-2); }
.field__hint { font-size: var(--t-xs); color: var(--c-text-3); }
.field__error { font-size: var(--t-xs); color: var(--c-danger); font-weight: var(--fw-medium); }

.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s-3) var(--s-4);
  background: var(--c-surface);
  border: 1.5px solid var(--c-border-strong);
  border-radius: var(--r-md);
  font-size: var(--t-md); /* 17px: evita o zoom automático do iOS nos campos */
  color: var(--c-text);
  transition: border-color var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 18%, transparent);
}
.input::placeholder { color: var(--c-text-3); }
.textarea { min-height: 88px; resize: vertical; line-height: var(--lh-base); }
.select { appearance: none; background-image: none; padding-right: var(--s-6); }

/* Controlo segmentado: escolher entre poucas opções sem abrir menu */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--c-surface-2);
  border-radius: var(--r-full);
  border: 1px solid var(--c-border);
}
.segmented__opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 var(--s-4);
  border-radius: var(--r-full);
  font-size: var(--t-sm);
  font-weight: var(--fw-semi);
  color: var(--c-text-2);
  transition: background-color var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
.segmented__opt[aria-pressed='true'] {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--sh-1);
}

/* ═══ Folha inferior (bottom sheet) ════════════════════════════════════
   Padrão único para criar/editar. Evita ecrãs inteiros só para um
   formulário e mantém o contexto visível por trás. */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  background: rgba(9, 12, 16, 0.42);
  backdrop-filter: blur(2px);
  animation: fade-in var(--d-base) var(--ease);
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: calc(var(--z-sheet) + 1);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-4);
  padding-bottom: var(--safe-b);
  animation: sheet-up var(--d-slow) var(--ease-out);
}
@media (min-width: 640px) {
  .sheet {
    left: 50%;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, calc(100vw - 48px));
    max-height: 86dvh;
    border-radius: var(--r-xl);
    animation: pop-in var(--d-base) var(--ease-out);
  }
}
.sheet__grabber {
  width: 36px; height: 4px;
  margin: var(--s-3) auto var(--s-1);
  border-radius: var(--r-full);
  background: var(--c-border-strong);
  flex: none;
}
@media (min-width: 640px) { .sheet__grabber { display: none; } }
.sheet__head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border);
  flex: none;
}
.sheet__title { font-size: var(--t-md); font-weight: var(--fw-semi); flex: 1; }
.sheet__body { padding: var(--s-4); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet__foot {
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--c-border);
  display: flex;
  gap: var(--s-2);
  flex: none;
}
.sheet__foot .btn { flex: 1; }

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pop-in   { from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }

/* ═══ Faixa de aviso ═══════════════════════════════════════════════════ */
.banner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  font-size: var(--t-sm);
  font-weight: var(--fw-medium);
  background: var(--c-info-soft);
  color: var(--c-info);
}
.banner--warn   { background: var(--c-warn-soft);   color: var(--c-warn); }
.banner--danger { background: var(--c-danger-soft); color: var(--c-danger); }
.banner--ok     { background: var(--c-ok-soft);     color: var(--c-ok); }
.banner__action { margin-left: auto; font-weight: var(--fw-semi); text-decoration: underline; }

/* ═══ Toasts ═══════════════════════════════════════════════════════════
   Regra que evita confusão: "guardado" e "enviado" são SEMPRE mensagens
   distintas. Reutilizar o mesmo texto para as duas deixa o utilizador
   sem saber se o trabalho saiu do telemóvel. */
.toasts {
  position: fixed;
  left: var(--s-4);
  right: var(--s-4);
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--s-4));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}
@media (min-width: 900px) {
  .toasts { left: auto; right: var(--s-5); bottom: var(--s-5); width: 340px; }
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--c-text);
  color: var(--c-bg);
  font-size: var(--t-sm);
  font-weight: var(--fw-medium);
  box-shadow: var(--sh-3);
  pointer-events: auto;
  animation: toast-in var(--d-base) var(--ease-out);
}
.toast--ok     { background: var(--c-ok);     color: #fff; }
.toast--warn   { background: var(--c-warn);   color: #fff; }
.toast--danger { background: var(--c-danger); color: #fff; }
.toast__action { margin-left: auto; font-weight: var(--fw-bold); text-decoration: underline; color: inherit; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ═══ Estado vazio ═════════════════════════════════════════════════════ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-8) var(--s-5);
  text-align: center;
}
.empty__icon {
  display: flex; align-items: center; justify-content: center;
  width: 64px; height: 64px;
  border-radius: var(--r-full);
  background: var(--c-surface-2);
  color: var(--c-text-3);
}
.empty__icon svg { width: 28px; height: 28px; }
.empty__title { font-size: var(--t-md); font-weight: var(--fw-semi); }
.empty__text { font-size: var(--t-sm); color: var(--c-text-3); max-width: 34ch; }

/* ═══ Barra de progresso ═══════════════════════════════════════════════ */
.meter {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--c-surface-3);
  overflow: hidden;
}
.meter__fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--c-primary);
  transition: width var(--d-slow) var(--ease);
}
.meter__fill--warn   { background: var(--c-warn); }
.meter__fill--danger { background: var(--c-danger); }

/* ═══ Esqueleto de carregamento ═══════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg,
    var(--c-surface-2) 25%, var(--c-surface-3) 37%, var(--c-surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ═══ Botão flutuante ══════════════════════════════════════════════════ */
.fab {
  position: fixed;
  right: var(--s-4);
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--s-4));
  z-index: calc(var(--z-nav) - 1);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: var(--tap-lg);
  padding: 0 var(--s-5);
  border-radius: var(--r-full);
  background: var(--c-primary);
  color: var(--c-primary-contrast);
  font-size: var(--t-base);
  font-weight: var(--fw-semi);
  box-shadow: var(--sh-3);
}
.fab:active { transform: scale(0.96); }
.fab svg { width: 20px; height: 20px; }
@media (min-width: 900px) {
  .fab { bottom: var(--s-5); right: var(--s-5); }
}

/* Caixa de aviso para navegador sem JS */
.noscript { max-width: 44ch; margin: 20vh auto; padding: var(--s-5); text-align: center; }
