/* terminais.css — a aba Terminais (js/terminais.js), o terminal na tela (js/terminal-vista.js) e o botão "Terminal" dos
   comandos que a sessão pede na conversa (js/conversa-modelo.js). O terminal é escuro nos dois temas, como a tela do CLI
   na página da sessão (--term-fundo, --term-tinta). */

/* O main sem margem e sem rolagem própria: a aba ocupa a altura toda (como o Explorar). */
main.com-terminais { grid-row: 4; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
/* No main em flex o margin: 0 auto de .sub-abas (app.css) as centraliza: margem fixa, no lugar da Fila (F2269-01). */
main.com-terminais > .sub-abas { margin: var(--respiro) var(--respiro) 12px; }
.vista-terminais { max-width: none; width: 100%; flex: 1; min-height: 0; display: flex; }

/* O <style> do xterm.js vira <estilo-xterm> (vendor/xterm/LEIA.md): o texto dele vai para uma folha construída. */
estilo-xterm { display: none !important; }

.tm { flex: 1; min-width: 0; min-height: 0; display: grid; grid-template-columns: 264px minmax(0, 1fr); background: var(--fundo); }

/* ── A lista ───────────────────────────────────────────────────────────────────────────────────────────────── */
.tm-lado { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--borda); background: var(--cartao); }
.tm-lado-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 8px 14px; }
.tm-lado-topo h2 { margin: 0; font-size: 15px; font-weight: 650; }
.tm-novo { padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.tm-lista { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 2px 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.tm-item {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 7px 8px;
  border-radius: 8px; color: var(--tinta); text-decoration: none;
}
.tm-item:hover { background: var(--linha-hover); }
.tm-item.atual { background: var(--marca-suave); }
.tm-item:focus-visible { outline: 2px solid var(--marca); outline-offset: -2px; }
.tm-item-texto { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.tm-item-nome { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-item-sub { font-size: 12px; color: var(--sutil); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-item-quando { font-size: 11.5px; color: var(--apagado); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tm-ponto { width: 8px; height: 8px; border-radius: 50%; background: var(--borda-forte); }
.tm-ponto.rodando { background: var(--bom); animation: tm-pulso 1.6s ease-in-out infinite; }
@keyframes tm-pulso { 50% { opacity: 0.35; } }
/* Os terminais das outras pessoas (desde 2026-10-07): o nome de cada uma em cima dos dela; o item, mais apagado. */
.tm-grupo {
  margin: 10px 8px 2px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.02em; color: var(--sutil);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tm-grupo:first-child { margin-top: 2px; }
.tm-item.alheio .tm-item-nome { font-weight: 500; color: var(--sutil); }
.tm-item.alheio.atual .tm-item-nome { color: var(--tinta); }
.tm-dica { margin: 6px 14px 14px; font-size: 12.5px; line-height: 1.45; }
.tm-dica[hidden] { display: none; }

/* ── O terminal escolhido ──────────────────────────────────────────────────────────────────────────────────── */
.tm-principal { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--term-fundo); }
.tm-topo {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; min-width: 0;
  background: var(--cartao); border-bottom: 1px solid var(--borda); color: var(--tinta);
}
.tm-topo[hidden], .tm-corpo[hidden], .tm-vazio[hidden] { display: none; }
.tm-voltar {
  display: none; align-items: center; justify-content: center; width: 34px; height: 34px; margin-left: -6px; flex: none;
  border-radius: 8px; color: var(--tinta); font-size: 26px; line-height: 1; text-decoration: none;
}
.tm-voltar:hover { background: var(--linha-hover); }
.tm-nome { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tm-titulo {
  max-width: 100%; padding: 0; border: 0; background: none; color: var(--tinta); font: inherit; font-size: 14px; font-weight: 650;
  text-align: left; cursor: text; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tm-titulo:hover { text-decoration: underline dotted; }
.tm-titulo:disabled { cursor: default; text-decoration: none; }
.tm-linha2 { display: flex; gap: 8px; min-width: 0; font-size: 12px; color: var(--sutil); }
.tm-situacao { white-space: nowrap; }
.tm-situacao.rodando { color: var(--bom-tinta); font-weight: 600; }
.tm-situacao.fim { color: var(--critico-tinta); font-weight: 600; }
.tm-pasta { min-width: 0; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-acoes { display: flex; align-items: center; gap: 2px; flex: none; }
.tm-acoes .botao.pequeno { padding: 4px 8px; }
.tm-acoes [aria-pressed="true"] { background: var(--marca-suave); color: var(--marca-texto); }
.tm-sessao[hidden], .tm-acoes [hidden] { display: none; }
/* A faixa do terminal de outra pessoa: de quem é e, para o dono e o gestor, o botão de passar a digitar. */
.tm-alheio {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 12px; min-width: 0;
  background: var(--info-fundo); border-bottom: 1px solid var(--borda); color: var(--info-tinta); font-size: 12.5px;
}
.tm-alheio[hidden], .tm-digitar[hidden] { display: none; }
.tm-alheio-texto { flex: 1; min-width: 0; line-height: 1.35; overflow-wrap: anywhere; }
.tm-digitar { flex: none; padding: 3px 9px; font-size: 12.5px; }
.tm-corpo { flex: 1; min-height: 0; min-width: 0; display: flex; }
.tm-vazio { flex: 1; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 24px; background: var(--fundo); color: var(--tinta); text-align: center; }
.tm-vazio h2 { margin: 0; font-size: 18px; }
.tm-vazio p { max-width: 480px; margin: 0; line-height: 1.5; }
.tm-vazio-icone { font: 700 36px/1 var(--mono); color: var(--apagado); }

/* Estreito (celular): a lista ou o terminal, um de cada vez. */
.tm.tm-estreito { grid-template-columns: minmax(0, 1fr); }
.tm.tm-estreito.tm-com-terminal .tm-lado { display: none; }
.tm.tm-estreito:not(.tm-com-terminal) .tm-principal { display: none; }
.tm.tm-estreito .tm-lado { border-right: 0; }
.tm.tm-estreito .tm-voltar { display: inline-flex; }
.tm.tm-estreito .tm-topo { gap: 6px; padding: 4px 4px 4px 10px; }
.tm.tm-estreito .tm-item { padding: 10px 8px; }

/* ── O terminal (xterm.js) ─────────────────────────────────────────────────────────────────────────────────── */
.tv { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--term-fundo); }
/* O espaço em volta fica no .xterm (o addon-fit desconta o padding dele, não o do pai): sem isso sobrava 1 px e aparecia uma
   barra de rolagem. A rolagem do pai só serve quando outro aparelho deixou o terminal maior que esta tela. */
.tv-tela { flex: 1; min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; }
.tv-tela .xterm { padding: 6px 0 0 8px; }
.tv-tela .xterm .xterm-viewport { background: var(--term-fundo) !important; }
/* Só olhar: o cursor do terminal não pisca nem convida a digitar. */
.tv-olhar .xterm { cursor: default; }
.tv-faixa {
  position: absolute; top: 10px; left: 50%; z-index: 4; transform: translateX(-50%); max-width: calc(100% - 24px);
  padding: 6px 14px; border-radius: 999px; background: rgba(38, 38, 37, 0.94); border: 1px solid #3a3a38; color: #e8e6df;
  font-size: 12.5px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); pointer-events: none;
}
.tv-faixa[hidden] { display: none; }
.tv-faixa[data-estado="fim"] { border-color: #b4505a; color: #ffd6d9; pointer-events: auto; }
.tv-teclas {
  display: flex; gap: 5px; padding: 6px 6px 4px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  background: #1d1d1c; border-top: 1px solid var(--term-borda);
}
.tv-teclas::-webkit-scrollbar { display: none; }
.tv-teclas[hidden], .tv-linha[hidden] { display: none; }
.tv-tecla {
  flex: none; min-width: 42px; height: 36px; padding: 0 10px; border: 1px solid #3a3a38; border-radius: 7px; background: #262624;
  color: #e8e6df; font: 600 13px var(--mono); cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.tv-tecla:active { background: #34342f; }
.tv-tecla[aria-pressed="true"] { background: var(--marca); border-color: var(--marca); color: #fff; }
.tv-linha { display: flex; gap: 6px; padding: 4px 6px calc(6px + env(safe-area-inset-bottom)); background: #1d1d1c; }
.tv-linha-campo {
  flex: 1; min-width: 0; height: 40px; padding: 0 10px; border: 1px solid #3a3a38; border-radius: 8px; background: #111110;
  color: #f0efea; font: 16px var(--mono);
}
.tv-linha-campo:focus { outline: 2px solid var(--marca); outline-offset: -1px; }
.tv-linha-enviar { flex: none; width: 48px; border: 0; border-radius: 8px; background: var(--marca); color: #fff; font-size: 20px; cursor: pointer; }
.tv-texto { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; background: var(--cartao); color: var(--tinta); }
.tv-texto-barra { display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--borda); }
.tv-espaco { flex: 1; }
.tv-texto-pre {
  flex: 1; min-height: 0; margin: 0; padding: 10px 12px; overflow: auto; font: 12.5px/1.45 var(--mono); white-space: pre-wrap;
  overflow-wrap: anywhere; user-select: text; -webkit-user-select: text;
}

/* ── "Terminal" na conversa da sessão: para quem está logado (html.pode-terminal), só no texto dela e só na sessão em que
   a pessoa age (a de outra pessoa, .sv-alheia, fica sem: o dev só olha) ── */
.cv-terminal-pre, .cv-terminal-cmd { display: none; }
.pode-terminal .cv-texto .cv-terminal-pre {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; margin: 6px 0 2px; padding: 0 10px 0 8px;
  border: 1px solid var(--cv-borda-2); border-radius: 7px; background: var(--cv-botao); color: var(--cv-texto-2);
  font: 600 12.5px var(--fonte); cursor: pointer;
}
.pode-terminal .cv-texto .cv-terminal-cmd {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 22px; margin-left: 3px; padding: 0;
  vertical-align: -5px; border: 1px solid var(--cv-borda-2); border-radius: 6px; background: var(--cv-botao); color: var(--cv-texto-2); cursor: pointer;
}
.pode-terminal .cv-texto .cv-terminal-pre:hover, .pode-terminal .cv-texto .cv-terminal-cmd:hover { background: var(--cv-cinza); color: var(--cv-texto); border-color: var(--cv-azul); }
.pode-terminal .cv-texto .cv-terminal-pre:disabled, .pode-terminal .cv-texto .cv-terminal-cmd:disabled { opacity: 0.55; cursor: progress; }
.pode-terminal .sv-alheia .cv-texto .cv-terminal-pre, .pode-terminal .sv-alheia .cv-texto .cv-terminal-cmd { display: none; }

@media (prefers-reduced-motion: reduce) {
  .tm-ponto.rodando { animation: none; }
}
