/* agenda-mk — vocabulário do cbnethub/DESIGN.md (§3 cor, §4 espaço/raio/elevação,
   §5 tipografia, §6 movimento, §7 layout). Tokens copiados do DESIGN.md, nunca
   de outro módulo. */

/* ── Fonte vendorada (§5): só 500 e 600, nunca CDN (CSP font-src 'self'). ── */
@font-face {
  font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('vendor/poppins-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('vendor/poppins-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Cor (§3) ── */
:root, [data-theme="dark"] {
  --bg:            #061423;
  --surface:       rgba(255,255,255,.045);
  --surface-2:     rgba(255,255,255,.03);
  --border:        rgba(255,255,255,.10);
  --text:          #eaf2f8;
  --text-muted:    #93a7ba;
  --accent:        #2fd15a;
  --accent-text:   #2fd15a;
  --on-accent:     #061423;
  --danger:        #ff6b7a;
  --warning:       #ffb020;
  --on-danger:     #061423;
  --on-warning:    #061423;
  --warning-text:  #ffb020;
  --focus-ring:    color-mix(in srgb, var(--accent) 55%, transparent);
  --elev-1: 0 1px 2px rgba(0,0,0,.30);
  --elev-2: 0 20px 46px rgba(0,0,0,.50);
}
[data-theme="light"] {
  --bg:            #eaeff6;
  --surface:       #ffffff;
  --surface-2:     #dde5ef;
  --border:        #ccd7e4;
  --text:          #0f1c2b;
  --text-muted:    #54637a;
  --accent:        #22a847;
  --accent-text:   #147233;
  --on-accent:     #061423;
  --danger:        #b3352f;
  --warning:       #b7791f;
  --on-danger:     #ffffff;
  --on-warning:    #061423;
  --warning-text:  #8a5a12;
  --focus-ring:    color-mix(in srgb, var(--accent) 55%, transparent);
  --elev-1: 0 1px 2px rgba(15,28,43,.05), 0 1px 1px rgba(15,28,43,.04);
  --elev-2: 0 18px 42px rgba(15,28,43,.16);
}

/* Widgets nativos acompanham o tema (§3.2 item 1). */
:root { color-scheme: dark }
[data-theme="light"] { color-scheme: light }

/* ── Espaço, raio, movimento, medida (§4, §6, §7) ── */
:root {
  --s-1: .25rem;  --s-2: .5rem;  --s-3: .75rem;  --s-4: 1rem;
  --s-5: 1.5rem;  --s-6: 2rem;   --s-7: 3rem;    --s-8: 4rem;
  --r-campo: 10px;
  --r-card:  14px;
  --r-pill:  999px;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --t-press: 120ms;
  --t-hover: 160ms;
  --t-enter: 240ms;
  /* Módulo de tabela densa (agenda do técnico, lista de atendimentos): 72rem. */
  --medida: 72rem;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box }
html, body { margin: 0 }
body {
  min-height: 100vh;
  min-height: 100dvh;          /* iOS: 100vh conta a barra recolhida e sobra rolagem vazia */
  display: flex;               /* MODULE_CONTRACT §5 */
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.55;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
strong, b { font-weight: 600 }
h1, h2, h3, p { margin: 0 }
h1, h2, h3 { font-weight: 600 }  /* o padrão do navegador é 700: negrito sintético (§5) */
/* O `display: flex` do .cartao venceria o `display: none` que o navegador dá
   ao atributo `hidden` — e o "Carregando…" ficava na tela junto da saudação. */
[hidden] { display: none !important }

/* Barras de rolagem tematizadas (§3.1). */
* { scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--text-muted) 45%, transparent) transparent }
::-webkit-scrollbar { width: 8px; height: 8px }
::-webkit-scrollbar-track { background: transparent }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-muted) 45%, transparent);
                            border-radius: var(--r-pill) }

/* Widgets nativos: fundo opaco na cor da página (§3.2 itens 2 e 4). */
select, select option, select optgroup { background-color: var(--bg); color: var(--text) }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent) }

:focus-visible { outline: 2px solid var(--foco-visivel, var(--focus-ring)); outline-offset: 2px }
/* No claro o --focus-ring dá 1,72:1 sobre o fundo (WCAG 1.4.11 pede 3:1). */
[data-theme="light"] { --foco-visivel: var(--accent-text) }

/* ── Layout: uma coluna, uma largura (§7) ── */
.app {
  width: 100%;
  max-width: var(--medida);
  margin-inline: auto;
  padding: var(--s-5) var(--s-5) var(--s-8);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.cabecalho { display: flex; flex-direction: column; gap: var(--s-1) }
.cabecalho h1 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.021em;
}
.sub, .muted {
  color: var(--text-muted);
  font-size: .8125rem;
  line-height: 1.5;
  letter-spacing: .005em;
}

/* ── Cartão ── */
.cartao {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--elev-1);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  overflow-wrap: anywhere;
}
.titulo-cartao {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.006em;
  overflow-wrap: anywhere;     /* o nome vem do hub-auth: sem espaço, estouraria (P-032) */
}
/* Estado de tela cheia: moldura, então centrada (§7). */
.estado { align-items: center; text-align: center; gap: var(--s-4) }

/* ── Botão ── */
.botao {
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-campo);
  border: 1px solid var(--border);
  background-color: var(--bg);
  background-image: linear-gradient(var(--surface-2), var(--surface-2));
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out);
  touch-action: manipulation;
}
.botao:active { transform: scale(.97) }
.botao.primario {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
}
/* Hover sem transição: só transform e opacity animam (§6); o clareado é
   imediato, e o retorno ao toque continua sendo o scale do :active. */
@media (hover: hover) and (pointer: fine) {
  .botao:hover { filter: brightness(1.08) }
}
/* Alvo de toque só no toque, nunca na regra base (P-031 regra 1). */
@media (hover: none) and (pointer: coarse) {
  .botao, .aba, .segmento, .campo { min-height: 44px }
  .opcao { min-height: 44px }
  .resumo-filtro { min-height: 44px; display: flex; align-items: center }
  /* iOS dá zoom ao focar campo com fonte < 16px (P-031 regra 2). */
  .campo { font-size: 16px }
}

/* ── Painel e abas ── */
.painel { display: flex; flex-direction: column; gap: var(--s-4) }
.tela { display: flex; flex-direction: column; gap: var(--s-3) }
/* Abas de primeiro nível (Fila | Agenda): sublinhado, para não se confundir
   com a escolha de visão, que é pílula. */
.abas { display: flex; gap: var(--s-4); border-bottom: 1px solid var(--border) }
.aba {
  padding: var(--s-2) 0;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.aba[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent-text) }
@media (hover: hover) and (pointer: fine) {
  .aba:hover { color: var(--text) }
}
/* Controle segmentado (Semana | Dia): largura automática (§7, exceção legítima). */
.segmentado {
  display: inline-flex;
  align-self: flex-start;
  gap: var(--s-1);
  padding: var(--s-1);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background-color: var(--bg);
  background-image: linear-gradient(var(--surface-2), var(--surface-2));
}
.segmento {
  padding: var(--s-2) var(--s-4);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out);
  touch-action: manipulation;
}
.segmento:active { transform: scale(.97) }
.segmento[aria-pressed="true"] { background: var(--accent); color: var(--on-accent) }

/* ── Filtros ── */
.filtros { gap: var(--s-3) }
.linha-filtros { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) }
.campo {
  min-width: 0;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-campo);
  border: 1px solid color-mix(in srgb, var(--text-muted) 55%, transparent);
  background-color: var(--bg);
  background-image: linear-gradient(var(--surface-2), var(--surface-2));
  color: var(--text);
  font: inherit;
  font-size: 1rem;   /* iOS dá zoom com < 16px (P-031 r.2): explícito, não por herança */
}
input.campo { width: 9rem }
.filtro-sub { flex: 1 1 18rem; min-width: 0 }
.resumo-filtro { cursor: pointer; padding: var(--s-2) 0; overflow-wrap: anywhere }
.lista-marcar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: var(--s-1) var(--s-3);
  max-height: 16rem;
  overflow-y: auto;
  padding: var(--s-2) 0;
}
.filtro-status { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); border: 0; margin: 0; padding: 0 }
.filtro-status legend { font-size: .8125rem; color: var(--text-muted); padding: 0; margin-bottom: var(--s-1) }
.opcao { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; overflow-wrap: anywhere }
.contagem { font-size: .8125rem }
.periodo { font-weight: 600; padding: 0 var(--s-2) }
.linha-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); min-height: 1.5rem; overflow-wrap: anywhere }
/* Erro com cara de erro: --danger dá 6:1 sobre o fundo nos dois temas. */
.erro { color: var(--danger); font-weight: 600 }
/* Enquanto busca: o que está na tela é antigo — mais apagado (opacity anima, §6). */
.buscando { opacity: .55; transition: opacity var(--t-hover) var(--ease-out) }
.nota-acao { font-size: .8125rem; letter-spacing: .005em }
.botao.pequeno { padding: var(--s-1) var(--s-3); font-size: .8125rem }
.botao:disabled { opacity: .55; cursor: not-allowed; transform: none }
.aviso { color: var(--warning-text); font-size: .8125rem; line-height: 1.5; letter-spacing: .005em }
.selo {
  display: inline-block;
  padding: 0 var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: .75rem;
  letter-spacing: .005em;
  color: var(--text-muted);
}

/* ── Fila ── */
.lista { display: flex; flex-direction: column; gap: var(--s-3) }
.atendimento { gap: var(--s-1) }
.lista-os { list-style: none; margin: var(--s-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2) }
.os {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-campo);
}
.os-cabeca { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); overflow-wrap: anywhere }
.os-acoes { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--s-2) }

/* ── Agenda ── */
.quadro-rolavel { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-card) }
.grade { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 78rem }
.grade th, .grade td { border-bottom: 1px solid var(--border); padding: var(--s-2); vertical-align: top; text-align: left }
.grade thead th {
  font-weight: 600;
  font-size: .6875rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.grade th[scope="row"], .grade thead th:first-child { width: 11rem }
.grade thead th.hoje { color: var(--accent-text) }
.grade .hoje { background-image: linear-gradient(color-mix(in srgb, var(--accent) 8%, transparent), color-mix(in srgb, var(--accent) 8%, transparent)) }
.grade td { display: table-cell }
.grade td > * + * { margin-top: var(--s-1) }
.nome-tecnico { font-size: .8125rem; font-weight: 600; overflow-wrap: anywhere }
.lista-dias { display: flex; flex-direction: column; gap: var(--s-3) }
.dia { gap: var(--s-2) }
.bloco-tecnico { display: flex; flex-direction: column; gap: var(--s-1) }
.compromisso {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-2);
  border-radius: var(--r-campo);
  border-left: 3px solid var(--accent);
  background-color: var(--bg);
  background-image: linear-gradient(var(--surface-2), var(--surface-2));
  font-size: .8125rem;
  line-height: 1.45;
  letter-spacing: .005em;
  overflow-wrap: anywhere;
}
.compromisso.interno { border-left-color: var(--text-muted) }
.compromisso .quando { font-weight: 600 }

/* ── Aviso de versão nova (P-050) ──
   Persistente: some quando a pessoa clicar em Atualizar. Fica no fluxo, no
   topo, com a mesma largura dos outros blocos (§7) — não flutua sobre botões. */
.avisos:empty { display: none }
.avisos { display: flex; flex-direction: column; gap: var(--s-2) }
.aviso-versao {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-card);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background-color: var(--bg);
  background-image: linear-gradient(var(--surface), var(--surface));
  box-shadow: var(--elev-1);
  transition: opacity var(--t-enter) var(--ease-out), transform var(--t-enter) var(--ease-out);
}
/* Entrada (ocasional → animação padrão, §6): vem de onde fica, sem pular. */
@starting-style {
  .aviso-versao { opacity: 0; transform: translateY(-4px) }
}

/* ── Celular ── */
@media (max-width: 40rem) {
  .app { padding: var(--s-4) var(--s-4) var(--s-7) }
  .cartao { padding: var(--s-4) }
  .aviso-versao { flex-wrap: wrap }
  .aviso-versao .botao { margin-left: auto }   /* quebrou de linha: o botão fica à direita */
}

/* Movimento reduzido (§6): sem deslocamento, retorno continua. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important }
}
