/* Inbox: linhas de WhatsApp conectadas (régua + lista). Tokens: --m-* no celular V2, --ib-* no desktop, hex como último recurso
 * (a folha do app pode ficar fora de ambos). A cor nunca está sozinha: o marcador muda de forma (cheio, pulsando, vazado) e o
 * estado vem sempre por extenso. */

.wa-linhas,
.wa-linhas-pop,
.wa-linhas-corpo {
  --wl-ink: var(--m-ink, var(--ib-ink, #14213d));
  --wl-muted: var(--m-ink-3, var(--ib-muted, #56657a));
  --wl-line: var(--m-line, var(--ib-line, #e3e8ef));
  --wl-line-strong: var(--m-line-strong, #c9d2e0);
  --wl-surface: var(--m-bg, #fff);
  --wl-hover: var(--m-surface, var(--ib-hover, #edf1f7));
  --wl-accent: var(--m-accent, var(--ib-blue, var(--navy,#003DA5)));
  --wl-on: var(--m-ok, var(--ib-green, #15803d));
  --wl-pend: var(--m-warn, var(--ib-warn, #8a4b06));
  --wl-pend-dot: #d97706;
  --wl-off: var(--m-danger, var(--ib-late, #a51d24));
  --wl-nil: var(--m-ink-3, var(--ib-faint, #6b7a90));
}

.wa-linhas { margin-top: 6px; min-width: 0; }
.wa-linhas[hidden] { display: none; }

/* Com mais de uma linha a régua é o status: a faixa antiga só fala quando há problema. */
#wa-inbox.wa-tem-linhas #wa-inbox-status[data-state="on"] { display: none; }

.wa-linhas-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  min-height: 28px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--wl-line);
  border-radius: 999px;
  background: transparent;
  color: var(--wl-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color .18s var(--ib-ease, ease), border-color .18s var(--ib-ease, ease);
}

.wa-linhas-btn:hover { background: var(--wl-hover); border-color: var(--wl-line-strong); }
.wa-linhas-btn:focus-visible { outline: 2px solid var(--wl-accent); outline-offset: 2px; }
.wa-linhas-btn[aria-expanded="true"] { background: var(--wl-hover); border-color: var(--wl-line-strong); }

.wa-linhas-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }

.wa-linhas-seta { flex: none; color: var(--wl-muted); transition: transform .2s var(--ib-ease, ease); }
.wa-linhas-btn[aria-expanded="true"] .wa-linhas-seta { transform: rotate(180deg); }

/* A régua: um segmento por linha, na mesma ordem da lista cadastrada. */
.wa-linhas-regua {
  display: inline-flex;
  flex: none;
  gap: 2px;
  max-width: 96px;
}

.wa-linhas-regua .wa-seg {
  display: block;
  flex: 0 1 16px;
  min-width: 4px;
  height: 6px;
  border-radius: 2px;
  background: var(--wl-nil);
  opacity: .45;
}

.wa-seg[data-tom="on"] { background: var(--wl-on); opacity: 1; }
.wa-seg[data-tom="pend"] { background: var(--wl-pend-dot); opacity: 1; animation: waLinhaPulso 1.4s ease-in-out infinite; }
.wa-seg[data-tom="off"] { background: var(--wl-off); opacity: 1; }

.wa-linhas-regua.is-larga { display: flex; max-width: none; gap: 3px; margin-top: 12px; }
.wa-linhas-regua.is-larga .wa-seg { flex: 1 1 0; height: 8px; border-radius: 3px; }

@keyframes waLinhaPulso { 50% { opacity: .35; } }

/* Balão ancorado (desktop). A folha do app leva o mesmo corpo no celular. */
.wa-linhas-pop {
  position: fixed;
  z-index: 95;
  overflow-y: auto;
  padding: 14px 16px 12px;
  border: 1px solid var(--wl-line);
  border-radius: 14px;
  background: var(--wl-surface);
  color: var(--wl-ink);
  box-shadow: 0 18px 40px -14px rgba(13, 31, 78, .3), 0 2px 8px rgba(13, 31, 78, .08);
  outline: none;
  overscroll-behavior: contain;
}

.wa-linhas-pop-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.wa-linhas-pop-head + .wa-linhas-regua { display: flex; }
.wa-linhas-pop-head h3 { margin: 0; font-size: 15px; font-weight: 750; letter-spacing: -.01em; }
.wa-linhas-pop-head p { margin: 2px 0 0; font-size: 12px; font-weight: 600; color: var(--wl-muted); font-variant-numeric: tabular-nums; }

.wa-linhas-fechar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin: -4px -6px 0 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--wl-muted);
  cursor: pointer;
}

.wa-linhas-fechar:hover { background: var(--wl-hover); color: var(--wl-ink); }
.wa-linhas-fechar:focus-visible { outline: 2px solid var(--wl-accent); outline-offset: 1px; }

.wa-linhas-lista { list-style: none; margin: 8px 0 0; padding: 0; }

.wa-linha {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--wl-line);
}

.wa-linha:first-child { border-top: 0; }

.wa-linha-marca {
  box-sizing: border-box;
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--wl-nil);
}

.wa-linha[data-tom="on"] .wa-linha-marca { background: var(--wl-on); box-shadow: 0 0 0 3px color-mix(in srgb, var(--wl-on) 20%, transparent); }
.wa-linha[data-tom="pend"] .wa-linha-marca { background: var(--wl-pend-dot); animation: waLinhaPulso 1.4s ease-in-out infinite; }
.wa-linha[data-tom="off"] .wa-linha-marca { background: transparent; border: 2px solid var(--wl-off); }
.wa-linha[data-tom="nil"] .wa-linha-marca { background: transparent; border: 2px dotted var(--wl-nil); }

.wa-linha-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wa-linha-info strong { font-size: 14px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.wa-linha-num { font-size: 13px; line-height: 1.3; color: var(--wl-muted); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.wa-linha-num.is-vazio { font-style: normal; opacity: .85; }

.wa-linha-estado { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 12px; font-weight: 700; line-height: 1.3; text-align: right; color: var(--wl-nil); }
.wa-linha-estado small { font-size: 11px; font-weight: 600; color: var(--wl-muted); }
.wa-linha[data-tom="on"] .wa-linha-estado { color: var(--wl-on); }
.wa-linha[data-tom="pend"] .wa-linha-estado { color: var(--wl-pend); }
.wa-linha[data-tom="off"] .wa-linha-estado { color: var(--wl-off); }

.wa-linhas-rodape { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--wl-line); }
.wa-linhas-rodape p { margin: 0; font-size: 12px; line-height: 1.45; color: var(--wl-muted); text-wrap: pretty; }
.wa-linhas-rodape:empty { display: none; }

.wa-linhas-atualizar {
  align-self: flex-start;
  min-height: 32px;
  padding: 6px 14px;
  border: 1px solid var(--wl-line-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--wl-accent);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.wa-linhas-atualizar:hover:not(:disabled) { background: var(--wl-hover); }
.wa-linhas-atualizar:focus-visible { outline: 2px solid var(--wl-accent); outline-offset: 2px; }
.wa-linhas-atualizar:disabled { cursor: progress; color: var(--wl-muted); }

/* O único movimento autoral: as linhas sobem em sequência ao abrir. */
.wa-linhas-pop.is-vista .wa-linha,
.wa-app-sheet.is-on .wa-linhas-corpo .wa-linha {
  animation: waLinhaEntra .42s var(--ib-ease, cubic-bezier(.16, 1, .3, 1)) both;
  animation-delay: calc(var(--wl-i, 0) * 38ms);
}

@keyframes waLinhaEntra { from { opacity: 0; transform: translateY(8px); } }

/* Folha do app (celular): a lista em cartão, sem moldura própria. */
.wa-linhas-corpo.is-folha { padding: 2px 6px 6px; background: var(--wl-surface); border-radius: 14px; }
.wa-linhas-corpo.is-folha .wa-linha { padding: 13px 8px; }
.wa-linhas-corpo.is-folha .wa-linhas-rodape { padding: 12px 8px 4px; }

/* Celular V2: o botão fica sob o título, com alvo de toque confortável. */
html.inbox-m2 .wa-linhas { margin-top: 2px; }
html.inbox-m2 .wa-linhas-btn { min-height: 32px; padding-block: 5px; font-size: 13px; }
html.inbox-m2 #wa-inbox.wa-tem-linhas #wa-inbox-status.m-status[data-state="on"] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .wa-seg[data-tom="pend"],
  .wa-linha[data-tom="pend"] .wa-linha-marca { animation: none; }
  .wa-linhas-pop.is-vista .wa-linha,
  .wa-app-sheet.is-on .wa-linhas-corpo .wa-linha { animation: none; }
  .wa-linhas-seta { transition: none; }
}
