/* Escritório — painel de chamada (public/js/escritorio/painel-chamada.js).
   Só variáveis do tema (claro/escuro). Navy fica com a barra inferior; amarelo não aparece; verde (--ok) marca quem fala. */

.cham {
  position: absolute;
  left: auto; top: auto; right: 12px; bottom: 12px;
  width: 360px; height: 240px;
  display: flex; flex-direction: column;
  background: var(--superficie);
  color: var(--tinta);
  border: 1px solid var(--linha);
  border-radius: 14px;
  box-shadow: var(--sombra-alta);
  z-index: 6;
  overflow: hidden;
  font-family: var(--texto);
  pointer-events: auto;
}
.cham[hidden] { display: none; }
/* maximizada: área grande (útil para tela compartilhada) */
.cham--max { left: 12px !important; top: 12px !important; right: 12px; bottom: 12px; width: auto !important; height: auto !important; }

/* bordas e cantos para redimensionar */
.cham__borda { position: absolute; z-index: 4; background: transparent; }
.cham__borda[data-borda="n"], .cham__borda[data-borda="s"] { left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.cham__borda[data-borda="e"], .cham__borda[data-borda="w"] { top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }
.cham__borda[data-borda="n"] { top: 0; } .cham__borda[data-borda="s"] { bottom: 0; }
.cham__borda[data-borda="e"] { right: 0; } .cham__borda[data-borda="w"] { left: 0; }
.cham__borda--canto { width: 12px; height: 12px; }
.cham__borda[data-borda="nw"] { left: 0; top: 0; cursor: nwse-resize; } .cham__borda[data-borda="se"] { right: 0; bottom: 0; cursor: nwse-resize; }
.cham__borda[data-borda="ne"] { right: 0; top: 0; cursor: nesw-resize; } .cham__borda[data-borda="sw"] { left: 0; bottom: 0; cursor: nesw-resize; }
.cham--max .cham__borda, .cham--min .cham__borda { display: none; }

.cham__topo { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 6px 4px 10px; flex: none; cursor: grab; user-select: none; touch-action: none; border-bottom: 1px solid var(--linha-suave); }
.cham--max .cham__topo { cursor: default; }
.cham__titulo { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono, 'Chivo Mono', monospace); font-size: 10px; letter-spacing: .04em; text-transform: uppercase; color: var(--tinta-2); }
.cham__titulo strong { font-weight: 600; }
.cham__bt-topo {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: transparent; color: var(--tinta); cursor: pointer;
}
.cham__bt-topo:hover { background: var(--superficie-2); }
.cham__acoes-topo { display: inline-flex; gap: 2px; }

/* aviso da minha tela: nunca o vídeo grande */
.cham__aviso-tela {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 8px 0; padding: 6px 8px;
  border: 1px solid var(--linha); border-radius: 10px; font-size: 12px; background: var(--superficie-2); flex: none;
}
.cham__aviso-tela[hidden] { display: none; }
.cham__aviso-texto { display: flex; align-items: center; gap: 10px; flex: 1 1 220px; min-width: 0; }
.cham__aviso-texto span { display: grid; gap: 2px; }
.cham__aviso-texto small { color: var(--tinta-2); font-size: 12px; line-height: 1.3; }
.cham__aviso-botoes { display: flex; gap: 6px; }
.cham__miniatura { width: 160px; aspect-ratio: 16 / 9; object-fit: contain; border-radius: 8px; background: var(--preto); border: 1px solid var(--linha); }
.cham__miniatura[hidden] { display: none; }

.cham__chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; min-height: 32px;
  border: 1px solid var(--linha); border-radius: var(--r-pilula, 999px); background: var(--superficie);
  color: var(--tinta); font: 600 12px/1 var(--texto); cursor: pointer;
}
.cham__chip:hover { background: var(--superficie-2); }
.cham__chip--on { border-color: var(--ok); color: var(--ok); }
.cham__chip--perigo { color: #B3261E; border-color: currentColor; }
[data-tema="escuro"] .cham__chip--perigo { color: #FF8F86; }
.cham__chip[hidden] { display: none; }

/* corpo: grade ou palco + faixa */
.cham__corpo { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding: 6px 8px 0; }
.cham__palco {
  position: relative; flex: 1 1 auto; min-height: 0; border-radius: 16px; overflow: hidden;
  background: var(--preto); display: grid; place-items: center;
}
.cham__palco[hidden] { display: none; }
.cham__palco-video { width: 100%; height: 100%; object-fit: contain; background: var(--preto); }
.cham__palco-video--cam { object-fit: cover; }
.cham__palco-video--espelho { transform: scaleX(-1); }
.cham__palco-rotulo {
  position: absolute; left: 12px; bottom: 12px; padding: 3px 10px; border-radius: var(--r-pilula, 999px);
  background: rgba(14, 14, 16, .72); color: var(--papel); font: 600 12px/18px var(--texto); pointer-events: none;
}
.cham__bt-flutuante {
  position: absolute; right: 12px; bottom: 12px; width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(14, 14, 16, .72); color: var(--papel); cursor: pointer;
}
.cham__bt-flutuante:hover { background: rgba(14, 14, 16, .9); }
.cham__palco-escolha { position: absolute; left: 12px; top: 12px; right: 12px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 2; }
.cham__palco-escolha[hidden] { display: none; }
.cham__palco:fullscreen { border-radius: 0; }

.cham__grade {
  flex: 1 1 auto; min-height: 0; display: grid; gap: 6px; overflow-y: auto; align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
}
.cham__grade[data-n="1"], .cham__grade[data-n="2"] { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.cham--max .cham__grade { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.cham--max .cham__controles { padding: 10px 14px 14px; }
.cham--max .cham__ctl { height: 40px; min-width: 40px; }
/* com palco, os participantes ficam numa faixa embaixo */
.cham--max .cham__grade--faixa .cham__tile { flex-basis: 168px; width: 168px; }
.cham__grade--faixa { flex: none; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 6px; align-content: stretch; }
.cham__grade--faixa .cham__tile { flex: 0 0 96px; width: 96px; aspect-ratio: 16 / 9; }

.cham__tile {
  position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; cursor: default;
  background: var(--superficie-2); border: 2px solid transparent;
  display: grid; place-items: center;
  transition: border-color var(--t-rapido) var(--ease), box-shadow var(--t-rapido) var(--ease);
}
.cham__tile[data-fixavel="1"] { cursor: pointer; }
.cham__tile:focus-visible { outline: 2px solid var(--foco); outline-offset: 2px; }
.cham__tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--superficie-2); display: none; }
.cham__tile--video video { display: block; }
.cham__tile--espelho video { transform: scaleX(-1); }
.cham__tile-avatar { display: grid; place-items: center; transform: scale(.7); }
.cham--max .cham__tile-avatar { transform: none; }
.cham__tile--video .cham__tile-avatar { display: none; }
.cham__tile--falando { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-fundo); }
.cham__tile--fixado { outline: 2px solid var(--tinta-2); outline-offset: -2px; }
.cham__grade--faixa .cham__tile-avatar { transform: scale(.5); }
.cham--max .cham__grade--faixa .cham__tile-avatar { transform: scale(.75); }

.cham__tile-nome {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 52px); padding: 1px 8px; border-radius: var(--r-pilula, 999px);
  background: rgba(14, 14, 16, .72); color: var(--papel); font: 600 11px/17px var(--texto);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.cham__tile-selo {
  position: absolute; top: 8px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  background: rgba(14, 14, 16, .72); color: var(--papel); pointer-events: none;
}
.cham__tile-selo[hidden] { display: none; }
.cham__tile-selo--mudo { right: 8px; }
.cham__tile-selo--tela { left: 8px; }
.cham__tile-selo--fixo { right: 36px; }
.cham__tile-volume {
  position: absolute; right: 6px; bottom: 6px; display: none; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: var(--r-pilula, 999px); background: rgba(14, 14, 16, .78); color: var(--papel);
}
.cham__tile-volume[hidden] { display: none !important; }
.cham__tile:hover .cham__tile-volume, .cham__tile:focus-within .cham__tile-volume { display: inline-flex; }
.cham__tile-volume input { width: 70px; accent-color: var(--papel); }
.cham__grade--faixa .cham__tile-volume { display: none !important; }
.cham__grade--faixa .cham__tile:hover .cham__tile-nome { max-width: calc(100% - 16px); }

/* controles compactos */
.cham__controles { flex: none; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px 8px; }
.cham__ctl {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--linha); border-radius: var(--r-pilula, 999px); background: var(--superficie-2); color: var(--tinta);
  font: 600 12px/1 var(--texto); cursor: pointer;
  transition: background var(--t-rapido) var(--ease);
}
.cham__ctl svg { width: 16px; height: 16px; }
.cham__ctl:hover:not(:disabled) { background: var(--linha); }
.cham__ctl:disabled { opacity: .5; cursor: progress; }
.cham__ctl--off { background: transparent; color: var(--tinta-2); }
.cham__ctl--on { border-color: var(--ok); color: var(--ok); }
.cham__ctl--sair { background: transparent; border-color: #B3261E; color: #B3261E; margin-left: 4px; }
.cham__ctl--sair:hover:not(:disabled) { background: #B3261E; color: #fff; }
[data-tema="escuro"] .cham__ctl--sair { color: #FF8F86; border-color: #FF8F86; }
.cham__ctl--mini { min-width: 28px; height: 28px; padding: 0 6px; }

/* minimizada: pílula pequena e arrastável */
.cham--min { right: auto; bottom: auto; width: auto !important; height: auto !important; border-radius: var(--r-pilula, 999px); cursor: grab; }
.cham--min > :not(.cham__barra) { display: none !important; }
.cham__barra { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; user-select: none; touch-action: none; }
.cham__barra[hidden] { display: none; }
.cham__barra-texto { display: inline-flex; align-items: center; gap: 5px; font: 600 12px/1 var(--texto); white-space: nowrap; }
.cham__barra--falando { box-shadow: inset 0 0 0 2px var(--ok); border-radius: var(--r-pilula, 999px); }
.cham--saiu .cham__barra-texto { color: var(--tinta-2); }

/* tela nova de outra pessoa: só destaca (não maximiza) */
.cham--destaque { animation: cham-destaque 1.2s ease-in-out infinite; }
@keyframes cham-destaque { 0%, 100% { box-shadow: var(--sombra-alta); } 50% { box-shadow: 0 0 0 3px var(--ok), var(--sombra-alta); } }

/* celular: simples (tela cheia; pílula fixa) */
.modo-movel .cham:not(.cham--min) {
  position: fixed; inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0; border: 0; z-index: 90;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.modo-movel .cham--min { position: fixed; top: calc(56px + 8px); right: 8px; left: auto !important; z-index: 90; }
.modo-movel .cham__borda { display: none; }
.modo-movel .cham__grade { grid-template-columns: 1fr 1fr; }
.modo-movel .cham__grade[data-n="1"] { grid-template-columns: 1fr; }
.modo-movel .cham__tile-volume { display: none !important; }
.modo-movel .cham__ctl { height: 40px; min-width: 40px; }
.modo-movel .cham__miniatura { width: 112px; }
.modo-movel .cham__topo { cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .cham__tile, .cham__ctl, .cham--destaque { transition: none; animation: none; }
}
