/* =====================================================================
   Yestriva One · componentes da semana 1 · v0.1 · 20/11/2026 · design
   Depende de tokens.css (importar antes). Só usa variáveis --y-*.
   Prefixo .y- em tudo. Estados de demonstração: .is-pressed, .is-loading,
   .is-error, .is-disabled imitam :active, aria-busy, aria-invalid e
   :disabled; no app use os estados reais (o CSS cobre os dois).
   ===================================================================== */

/* ---------- Logo certo para o tema (segue o tema mais próximo) ---------- */
:root, [data-theme="light"] { --y-show-light: inline-block; --y-show-dark: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --y-show-light: none; --y-show-dark: inline-block; }
}
[data-theme="dark"] { --y-show-light: none; --y-show-dark: inline-block; }
.y-only-light { display: var(--y-show-light); }
.y-only-dark { display: var(--y-show-dark); }

/* ---------- Base de uma tela ---------- */
.y-app {
  background: var(--y-bg);
  color: var(--y-text);
  font-family: var(--y-font-text);
  font-size: var(--y-text-md);
  line-height: var(--y-leading-normal);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.y-app *, .y-app *::before, .y-app *::after { box-sizing: border-box; }
.y-app :focus-visible { outline: 3px solid var(--y-focus); outline-offset: 2px; }
.y-num { font-variant-numeric: var(--y-font-numeric); }
.y-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.y-icon { width: var(--y-icon-md); height: var(--y-icon-md); flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.y-icon--sm { width: var(--y-icon-sm); height: var(--y-icon-sm); }

.y-h1 { font: var(--y-weight-bold) var(--y-text-2xl)/var(--y-leading-tight) var(--y-font-display); letter-spacing: var(--y-tracking-display); margin: 0; }
.y-h2 { font: var(--y-weight-semibold) var(--y-text-lg)/1.3 var(--y-font-text); margin: 0; }
.y-section-label { font-size: var(--y-text-xs); font-weight: var(--y-weight-semibold); letter-spacing: var(--y-tracking-caps); text-transform: uppercase; color: var(--y-text-2); margin: var(--y-space-6) 0 var(--y-space-2); }
.y-muted { color: var(--y-text-2); }

/* ---------- Cabeçalho ---------- */
.y-header {
  min-height: var(--y-header-h);
  display: flex; align-items: center; gap: var(--y-space-1);
  padding: 0 var(--y-space-2);
  background: var(--y-bg);
}
.y-header__titles { flex: 1; min-width: 0; padding: 0 var(--y-space-2); }
.y-header__title { font: var(--y-weight-bold) var(--y-text-xl)/1.2 var(--y-font-display); letter-spacing: var(--y-tracking-display); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.y-header__sub { font-size: var(--y-text-sm); color: var(--y-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.y-header--large { flex-wrap: wrap; padding-top: var(--y-space-2); }
.y-header--large .y-header__title { font-size: var(--y-text-2xl); white-space: normal; }
.y-header__eyebrow { font-size: var(--y-text-sm); color: var(--y-text-2); font-weight: var(--y-weight-medium); }

.y-icon-btn {
  width: var(--y-touch-min); height: var(--y-touch-min); flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: var(--y-radius-md);
  background: transparent; color: inherit; cursor: pointer;
  transition: background var(--y-dur-fast);
}
.y-icon-btn:active, .y-icon-btn.is-pressed { background: var(--y-surface-2); }
.y-icon-btn--filled { background: var(--y-surface); }

/* ---------- Botões ---------- */
.y-btn {
  min-height: var(--y-touch-comfy); padding: 0 var(--y-space-5);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--y-space-2);
  border-radius: var(--y-radius-md); border: 1.5px solid transparent;
  font: var(--y-weight-semibold) 1.0625rem/1.2 var(--y-font-text);
  cursor: pointer; text-decoration: none; position: relative;
  transition: transform var(--y-dur-fast) var(--y-ease-out), background var(--y-dur-fast);
}
.y-btn:active, .y-btn.is-pressed { transform: scale(0.98); }
.y-btn--block { width: 100%; }
.y-btn--sm { min-height: var(--y-touch-min); padding: 0 var(--y-space-4); font-size: var(--y-text-md); }
.y-btn--primary { background: var(--y-primary-bg); color: var(--y-primary-text); }
.y-btn--primary:active, .y-btn--primary.is-pressed { background: var(--y-primary-bg-pressed); }
.y-btn--secondary { background: var(--y-secondary-bg); color: var(--y-secondary-text); border-color: var(--y-secondary-border); }
.y-btn--secondary:active, .y-btn--secondary.is-pressed { background: var(--y-secondary-bg-pressed); }
.y-btn--text { background: transparent; color: var(--y-text); text-decoration: underline; text-underline-offset: 3px; padding: 0 var(--y-space-3); min-height: var(--y-touch-min); }
.y-btn--text:active, .y-btn--text.is-pressed { background: var(--y-surface-2); }
.y-btn:disabled, .y-btn.is-disabled { background: var(--y-disabled-bg); color: var(--y-disabled-text); border-color: transparent; cursor: not-allowed; transform: none; }
.y-btn[aria-busy="true"], .y-btn.is-loading { color: transparent; pointer-events: none; }
.y-btn[aria-busy="true"]::after, .y-btn.is-loading::after {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--y-primary-text); border-right-color: transparent;
  animation: y-spin 0.8s linear infinite;
}
.y-btn--secondary.is-loading::after, .y-btn--secondary[aria-busy="true"]::after { border-color: var(--y-secondary-text); border-right-color: transparent; }

.y-spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: y-spin 0.8s linear infinite; flex: none; }
@keyframes y-spin { to { transform: rotate(360deg); } }

/* ---------- Campo de formulário ---------- */
.y-field { display: flex; flex-direction: column; gap: var(--y-space-2); }
.y-field__label { font-size: var(--y-text-sm); font-weight: var(--y-weight-semibold); }
.y-field__control { position: relative; display: flex; align-items: center; }
.y-input {
  width: 100%; min-height: var(--y-touch-comfy);
  padding: 0 var(--y-space-4);
  border: 1.5px solid var(--y-border-strong); border-radius: var(--y-radius-md);
  background: var(--y-bg); color: var(--y-text);
  font: var(--y-weight-regular) var(--y-text-md)/1.3 var(--y-font-text);  /* 16 px: o iPhone não dá zoom */
}
.y-input::placeholder { color: var(--y-text-2); opacity: 1; }
.y-input:focus { outline: 3px solid var(--y-focus); outline-offset: 1px; border-color: var(--y-text); }
.y-field__control .y-input:has(+ .y-icon-btn) { padding-right: 56px; }
.y-field__control .y-icon-btn { position: absolute; right: 4px; }
.y-field__hint { font-size: var(--y-text-sm); color: var(--y-text-2); }
.y-field__error { display: none; align-items: flex-start; gap: var(--y-space-2); font-size: var(--y-text-sm); font-weight: var(--y-weight-medium); color: var(--y-danger); }
.y-field.is-error .y-input, .y-input[aria-invalid="true"] { border: 2px solid var(--y-danger); }
.y-field.is-error .y-field__error { display: flex; }
.y-field.is-disabled .y-input, .y-input:disabled { background: var(--y-disabled-bg); color: var(--y-disabled-text); border-color: var(--y-disabled-bg); }
.y-field.is-disabled .y-field__label { color: var(--y-disabled-text); }

/* Busca */
.y-search { position: relative; }
.y-search .y-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--y-text-2); pointer-events: none; }
.y-search .y-input { min-height: var(--y-touch-min); padding-left: 46px; background: var(--y-surface); border-color: transparent; }

/* Escolha entre opções (Yes / No, Active / All) */
.y-segmented { display: flex; gap: 4px; padding: 4px; background: var(--y-surface-2); border-radius: var(--y-radius-md); }
.y-segmented button {
  flex: 1; min-height: var(--y-touch-min); border: 0; border-radius: 9px;
  background: transparent; color: var(--y-text-2);
  font: var(--y-weight-semibold) var(--y-text-md) var(--y-font-text); cursor: pointer;
}
.y-segmented button[aria-pressed="true"], .y-segmented button[aria-selected="true"] { background: var(--y-selected-bg); color: var(--y-selected-text); }

/* Cartões de escolha (ofício) */
.y-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--y-space-2); }
.y-choice {
  min-height: 64px; padding: var(--y-space-3); text-align: left;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  border: 1.5px solid var(--y-border); border-radius: var(--y-radius-md);
  background: var(--y-bg); color: var(--y-text); font: var(--y-weight-semibold) var(--y-text-md) var(--y-font-text); cursor: pointer;
}
.y-choice small { font-size: var(--y-text-xs); font-weight: var(--y-weight-medium); color: var(--y-text-2); }
.y-choice[aria-checked="true"] { border: 2px solid var(--y-text); box-shadow: inset 0 0 0 1px var(--y-text); }
.y-choice:disabled { color: var(--y-disabled-text); cursor: not-allowed; }

/* ---------- Etiquetas ---------- */
.y-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--y-radius-sm);
  font-size: 0.8125rem; font-weight: var(--y-weight-semibold); line-height: 1.4; white-space: nowrap;
  background: var(--y-surface-2); color: var(--y-text);
}
.y-chip--success { background: var(--y-success-bg); color: var(--y-success); }
.y-chip--warning { background: var(--y-warning-bg); color: var(--y-warning); }
.y-chip--danger { background: var(--y-danger-bg); color: var(--y-danger); }
.y-chip--next { background: var(--y-selected-bg); color: var(--y-selected-text); }

/* ---------- Cartões ---------- */
.y-card { background: var(--y-surface); border-radius: var(--y-radius-lg); padding: var(--y-space-4); }
.y-card--raised { background: var(--y-surface-raised); box-shadow: var(--y-shadow-md); }
.y-rows { display: flex; flex-direction: column; }
.y-row { display: flex; justify-content: space-between; gap: var(--y-space-3); padding: 10px 0; border-top: 1px solid var(--y-border); font-size: var(--y-text-md); }
.y-row:first-child { border-top: 0; }
.y-row > span:first-child { color: var(--y-text-2); }
.y-row > :last-child { font-weight: var(--y-weight-semibold); text-align: right; }

/* Cartão de job (toque abre o Workspace) */
.y-job {
  display: flex; align-items: center; gap: var(--y-space-3);
  width: 100%; min-height: 88px; padding: var(--y-space-3) var(--y-space-2) var(--y-space-3) var(--y-space-4);
  background: var(--y-surface); color: var(--y-text);
  border: 0; border-radius: var(--y-radius-lg); text-align: left; cursor: pointer;
  font: inherit; transition: background var(--y-dur-fast);
}
.y-job:active, .y-job.is-pressed { background: var(--y-surface-2); }
.y-job__time { flex: none; width: 56px; padding-right: var(--y-space-3); border-right: 3px solid var(--y-primary-bg); font-variant-numeric: var(--y-font-numeric); font-weight: var(--y-weight-bold); }
.y-job__time small { display: block; font-size: var(--y-text-xs); color: var(--y-text-2); font-weight: var(--y-weight-medium); }
.y-job__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.y-job__title { font-size: var(--y-text-lg); font-weight: var(--y-weight-semibold); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.y-job__meta { font-size: var(--y-text-sm); color: var(--y-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.y-job__foot { display: flex; align-items: center; gap: var(--y-space-2); margin-top: 2px; }
.y-job .y-icon { color: var(--y-text-2); }

/* Pendência com ação (Home · "Needs you") */
.y-todo { display: flex; align-items: center; gap: var(--y-space-3); min-height: 64px; padding: var(--y-space-2) var(--y-space-2) var(--y-space-2) var(--y-space-4); background: var(--y-surface); border-radius: var(--y-radius-lg); }
.y-todo__text { flex: 1; min-width: 0; font-size: var(--y-text-md); }
.y-todo__text small { display: block; font-size: var(--y-text-sm); color: var(--y-text-2); }
.y-todo .y-btn { flex: none; }

/* ---------- Barra de etapas ---------- */
.y-stages { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.y-stage { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.y-stage__bar { height: 6px; border-radius: 3px; background: var(--y-border); }
.y-stage__label { font-size: 0.6875rem; font-weight: var(--y-weight-medium); color: var(--y-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.y-stage--done .y-stage__bar { background: var(--y-text); }
.y-stage--current .y-stage__bar { height: 8px; margin-top: -1px; background: var(--y-primary-bg); box-shadow: inset 0 0 0 1.5px var(--y-text); }
.y-stage--current .y-stage__label { color: var(--y-text); font-weight: var(--y-weight-bold); }

/* ---------- Sub-abas do Workspace ---------- */
.y-subtabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--y-border); padding: 0 var(--y-space-2); }
.y-subtabs::-webkit-scrollbar { display: none; }
.y-subtab {
  min-height: var(--y-touch-min); padding: 0 var(--y-space-3); flex: none;
  border: 0; background: transparent; cursor: pointer;
  font: var(--y-weight-semibold) 0.9375rem var(--y-font-text); color: var(--y-text-2);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.y-subtab:active, .y-subtab.is-pressed { background: var(--y-surface-2); }
.y-subtab[aria-selected="true"] { color: var(--y-text); border-bottom-color: var(--y-text); }
.y-subtab .y-count { font-weight: var(--y-weight-medium); color: var(--y-text-2); margin-left: 4px; }

/* ---------- Lista (clientes) ---------- */
.y-list { list-style: none; margin: 0; padding: 0; }
.y-list-item {
  display: flex; align-items: center; gap: var(--y-space-3);
  width: 100%; min-height: 72px; padding: var(--y-space-2) var(--y-space-2) var(--y-space-2) var(--y-space-4);
  border: 0; border-bottom: 1px solid var(--y-border); background: transparent; color: inherit; text-align: left; font: inherit; cursor: pointer;
}
.y-list-item:active, .y-list-item.is-pressed { background: var(--y-surface-2); }
.y-list-item__body { flex: 1; min-width: 0; }
.y-list-item__title { display: block; font-weight: var(--y-weight-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.y-list-item__meta { display: block; font-size: var(--y-text-sm); color: var(--y-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.y-list-item > .y-icon { color: var(--y-text-2); }
.y-avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--y-surface-2); color: var(--y-text); font-weight: var(--y-weight-bold); font-size: var(--y-text-sm); }

/* ---------- Aviso de sincronização ---------- */
.y-sync {
  display: flex; align-items: center; gap: var(--y-space-3);
  min-height: var(--y-touch-min); padding: var(--y-space-2) var(--y-space-2) var(--y-space-2) var(--y-space-4);
  border-radius: var(--y-radius-md); font-size: var(--y-text-sm); font-weight: var(--y-weight-medium);
}
.y-sync__text { flex: 1; min-width: 0; }
.y-sync__text b { font-weight: var(--y-weight-semibold); }
.y-sync--ok { background: var(--y-success-bg); color: var(--y-success); }
.y-sync--syncing { background: var(--y-surface); color: var(--y-text-2); }
.y-sync--offline { background: var(--y-warning-bg); color: var(--y-warning); }
.y-sync--error { background: var(--y-danger-bg); color: var(--y-danger); }
.y-sync .y-btn { min-height: var(--y-touch-min); padding: 0 var(--y-space-3); font-size: var(--y-text-sm); background: transparent; color: inherit; border: 1.5px solid currentColor; }
/* versão discreta, no cabeçalho */
.y-sync-dot { display: inline-flex; align-items: center; gap: 6px; font-size: var(--y-text-xs); font-weight: var(--y-weight-semibold); color: var(--y-text-2); }
.y-sync-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--y-success); }
.y-sync-dot--offline::before { background: var(--y-warning); }

/* ---------- Vazio, erro, carregando ---------- */
.y-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--y-space-2); padding: var(--y-space-10) var(--y-space-6); }
.y-empty__icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--y-surface); color: var(--y-text); margin-bottom: var(--y-space-2); }
.y-empty__title { font: var(--y-weight-semibold) var(--y-text-lg)/1.3 var(--y-font-text); margin: 0; }
.y-empty__text { font-size: var(--y-text-md); color: var(--y-text-2); margin: 0 0 var(--y-space-3); max-width: 30ch; }
.y-empty--error .y-empty__icon { background: var(--y-danger-bg); color: var(--y-danger); }

.y-skeleton { background: var(--y-surface-2); border-radius: var(--y-radius-sm); position: relative; overflow: hidden; }
.y-skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent); animation: y-shimmer 1.4s infinite; }
[data-theme="dark"] .y-skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent); }
@keyframes y-shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .y-skeleton::after, .y-spinner, .y-btn.is-loading::after, .y-btn[aria-busy="true"]::after { animation-duration: 2.4s; } .y-skeleton::after { display: none; } }

/* ---------- Barra de 4 abas + WORK ---------- */
.y-tabbar {
  display: grid; grid-template-columns: 1fr 1fr 88px 1fr 1fr; align-items: end;
  min-height: var(--y-tabbar-h); padding: 0 var(--y-space-1) calc(6px + env(safe-area-inset-bottom));
  background: var(--y-tabbar-bg); border-top: 1px solid var(--y-tabbar-border);
}
.y-tab {
  min-height: 56px; min-width: var(--y-touch-min);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: transparent; color: var(--y-text-2); cursor: pointer;
  font: var(--y-weight-medium) var(--y-text-xs) var(--y-font-text); border-radius: var(--y-radius-md);
}
.y-tab:active, .y-tab.is-pressed { background: var(--y-surface-2); }
.y-tab[aria-current="page"] { color: var(--y-text); font-weight: var(--y-weight-bold); }
.y-tab[aria-current="page"] .y-icon { stroke-width: 2.5; }
.y-work {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; background: transparent; cursor: pointer; padding: 0; margin-top: -22px;
  font: var(--y-weight-bold) var(--y-text-xs) var(--y-font-text); letter-spacing: var(--y-tracking-caps); color: var(--y-text);
}
.y-work__btn {
  width: var(--y-work-size); height: var(--y-work-size); border-radius: 50%;
  display: grid; place-items: center;
  background: var(--y-primary-bg); color: var(--y-primary-text); box-shadow: var(--y-shadow-work);
  border: 4px solid var(--y-tabbar-bg);
  transition: transform var(--y-dur-fast) var(--y-ease-out), background var(--y-dur-fast);
}
.y-work__btn .y-icon { width: 30px; height: 30px; stroke-width: 2.6; }
.y-work:active .y-work__btn, .y-work.is-pressed .y-work__btn { transform: scale(0.94); background: var(--y-primary-bg-pressed); }

/* ---------- Folha do WORK ---------- */
.y-sheet { background: var(--y-surface-raised); border-radius: var(--y-radius-xl) var(--y-radius-xl) 0 0; padding: var(--y-space-2) var(--y-space-4) var(--y-space-6); box-shadow: var(--y-shadow-lg); }
.y-sheet__grip { width: 40px; height: 5px; border-radius: 3px; background: var(--y-border); margin: 4px auto var(--y-space-3); }
.y-sheet__title { font: var(--y-weight-bold) var(--y-text-lg)/1.3 var(--y-font-display); margin: 0 0 var(--y-space-3); }
.y-action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--y-space-2); }
.y-action {
  min-height: 88px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: var(--y-space-2);
  padding: var(--y-space-3) var(--y-space-4); border: 0; border-radius: var(--y-radius-lg);
  background: var(--y-surface); color: var(--y-text); font: var(--y-weight-semibold) var(--y-text-md) var(--y-font-text); cursor: pointer; text-align: left;
}
.y-action:active, .y-action.is-pressed { background: var(--y-surface-2); }
/* Dentro da folha, os botões ficam um nível acima (no escuro a folha já é --y-surface) */
.y-sheet .y-action { background: var(--y-surface-2); }
.y-sheet .y-action:active, .y-sheet .y-action.is-pressed { background: var(--y-border); }
