/* Tema escuro único (sala de videoconferência). Contrastes AA conferidos sobre --fundo e --botao. */
:root {
  --fundo: #202124; --superficie: #2d2e31; --botao: #3c4043; --botao-hover: #4a4e52; --borda: #5f6368;
  --texto: #e8eaed; --suave: #bdc1c6; --foco: #8ab4f8; --primaria: #8ab4f8; --texto-primaria: #202124;
  --perigo: #c5221f; --ok: #81c995; --alerta: #fdd663; --erro: #f28b82; --anfitriao: #c2410c; --prof: #1967d2;
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fundo); color: var(--texto); }
body[data-papel] { overflow: hidden; }
h1 { font-size: 1.3rem; margin: 8px 0; }
h2 { font-size: 1rem; margin: 0; }
.nota, .rodape { color: var(--suave); font-size: .9rem; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.cheio { fill: currentColor; stroke: none; }
:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; }
body:not([data-papel="professor"]) .so-professor { display: none !important; }
[hidden] { display: none !important; }

/* ---------- campos e botões comuns ---------- */
input, select, button { font: inherit; color: var(--texto); }
input, select { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--borda); background: var(--fundo); min-height: 44px; }
button { cursor: pointer; border: 0; border-radius: 8px; padding: 10px 14px; background: var(--botao); font-weight: 600; }
button:hover { background: var(--botao-hover); }
.primario { background: var(--primaria); color: var(--texto-primaria); }
.primario:hover { background: #aecbfa; }
.perigo { background: var(--perigo); color: #fff; }
.perigo:hover { background: #a50e0e; }
button:disabled { opacity: .6; cursor: default; }

/* ---------- entrada e fim ---------- */
.cartao-pagina { max-width: 480px; margin: 24px auto; padding: 20px; background: var(--superficie); border-radius: 16px; }
.marca { margin: 0 0 8px; font-weight: 800; font-size: 1.1rem; }
.marca span { font-weight: 400; color: var(--suave); font-size: .9rem; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: .95rem; }
@media (max-width: 520px) { .cartao-pagina { margin: 0; border-radius: 0; min-height: 100dvh; } }

/* ---------- aviso (toast) ---------- */
.aviso:empty { display: none; }
.aviso { position: fixed; z-index: 30; top: 64px; left: 50%; transform: translateX(-50%); max-width: min(92vw, 520px);
  margin: 0; background: var(--texto); color: var(--fundo); padding: 10px 16px; border-radius: 8px; font-weight: 600; box-shadow: 0 4px 16px #0008; }

/* ---------- sala ---------- */
.sala { position: fixed; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--fundo); }
.sala-topo { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 16px; min-height: 56px; }
.topo-esq, .topo-dir { display: flex; align-items: center; gap: 12px; min-width: 0; }
#hora { font-size: 1rem; }
.divisor { width: 1px; height: 20px; background: var(--borda); }
#sala-codigo { font-size: 1rem; letter-spacing: .02em; }
.selo-rede { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--suave); white-space: nowrap; }
.selo-rede .ponto { width: 8px; height: 8px; border-radius: 50%; background: var(--suave); }
.selo-rede[data-estado="conectado"] .ponto { background: var(--ok); }
.selo-rede[data-estado="reconectando"] .ponto { background: var(--alerta); }
.selo-rede[data-estado="desconectado"] .ponto { background: var(--erro); }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--botao); font-weight: 600; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--anfitriao); color: #fff; font-size: .85rem; font-weight: 700; }

.redondo { width: 44px; height: 44px; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; position: relative; flex: none; }
.redondo.leve { background: transparent; }
.redondo.leve:hover { background: var(--botao); }
.sala-topo .redondo { width: 40px; height: 40px; }

/* palco: um tile grande */
.palco { display: flex; padding: 0 16px; min-height: 0; }
.tile { position: relative; flex: 1; margin: 0; border-radius: 16px; background: var(--botao); overflow: hidden; display: grid; place-items: center; }
#slide, #video-prof { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile:not([data-modo="slide"]) #slide { display: none; }
.espera { display: grid; justify-items: center; gap: 16px; padding: 16px; text-align: center; }
.tile:not([data-modo="avatar"]) .espera { display: none; }
.avatar-grande { width: clamp(96px, 20vmin, 168px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  background: var(--prof); color: #fff; font-size: clamp(2.5rem, 8vmin, 4.5rem); font-weight: 600; }
#slide-vazio { margin: 0; color: var(--suave); }
/* Slide no palco + vídeo do professor em miniatura no canto */
.tile[data-modo="slide"] #video-prof { inset: auto 16px 56px auto; width: min(26%, 256px); height: auto; aspect-ratio: 16 / 9;
  border-radius: 10px; border: 2px solid var(--borda); }
.nome { position: absolute; left: 16px; bottom: 14px; margin: 0; color: #fff; font-weight: 600; text-shadow: 0 1px 3px #000, 0 0 8px #000; }
.selo-video { display: none; margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: #000a; font-size: .75rem; text-shadow: none; }
.tile[data-video="ligado"] .selo-video { display: inline; }
.contador { position: absolute; top: 12px; right: 12px; padding: 2px 8px; border-radius: 6px; background: #000b; color: #fff; font-size: .8rem; }
.contador:empty { display: none; }
.nav-slides { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.nav-slides .redondo { background: #000b; }
.tile:not([data-modo="slide"]) .nav-slides { display: none; }

.maos { position: absolute; top: 12px; left: 12px; max-width: min(320px, 70%); background: var(--superficie); border-radius: 12px;
  padding: 10px 12px; box-shadow: 0 4px 16px #0008; }
.maos ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.maos li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.maos li button { padding: 6px 10px; min-height: 36px; }

.reacoes { position: absolute; left: 16px; bottom: 48px; display: flex; flex-direction: column-reverse; gap: 4px; pointer-events: none; }
.reacao { font-size: 2.25rem; animation: subir 3s ease-out forwards; }
@keyframes subir { from { transform: translateY(0); opacity: 1; } 80% { opacity: 1; } to { transform: translateY(-80px); opacity: 0; } }

/* barra inferior: três grupos */
.sala-base { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 12px 16px 16px; }
.base-centro { display: flex; align-items: center; gap: 8px; }
.base-dir { justify-self: end; display: flex; gap: 4px; }
.ia { display: flex; align-items: center; gap: 6px; max-width: 360px; padding: 4px; border-radius: 999px; background: var(--superficie); }
.ia-campo { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; background: transparent; font-weight: 400; color: var(--suave); border-radius: 999px; }
.ia-texto { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ia-selo { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--botao); font-size: .75rem; white-space: nowrap; }
.ia-selo svg { width: 16px; height: 16px; }
.alterna .risco { display: none; }
.alterna[aria-pressed="false"], .alterna[aria-disabled="true"] { background: var(--perigo); color: #fff; }
.alterna[aria-pressed="false"] .risco, .alterna[aria-disabled="true"] .risco { display: inline; }
.alterna[aria-disabled="true"] { background: var(--botao); color: var(--suave); }
.alterna-mao[aria-pressed="true"] { background: var(--primaria); color: var(--texto-primaria); }
.desligar { width: 64px; height: 44px; padding: 0; border-radius: 22px; background: var(--perigo); color: #fff; display: inline-grid; place-items: center; }
.desligar:hover { background: #a50e0e; }
[aria-disabled="true"] { cursor: not-allowed; }
[aria-disabled="true"] svg { opacity: .75; }
[aria-expanded="true"] { background: var(--botao-hover); }
.contador-bolha { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--primaria); color: var(--texto-primaria); font-size: .75rem; display: grid; place-items: center; }

/* dica no foco/hover dos botões da barra inferior (texto vem do data-dica) */
/* No toque (celular) a dica sai pelo aviso ao tocar: o hover "gruda" e a bolha sairia da tela. */
@media (hover: hover) and (min-width: 641px) { .sala-base [data-dica]:is(:hover, :focus-visible)::after {
  content: attr(data-dica); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; padding: 6px 10px; border-radius: 6px; background: var(--texto); color: var(--fundo);
  font-size: .8rem; font-weight: 600; pointer-events: none; z-index: 5;
}
.sala-base .base-esq [data-dica]:is(:hover, :focus-visible)::after { left: 0; transform: none; }
.sala-base .base-dir [data-dica]:is(:hover, :focus-visible)::after { left: auto; right: 0; transform: none; } }
.ia-campo { position: relative; }

/* painéis */
.painel { position: fixed; z-index: 20; right: 16px; bottom: 84px; width: min(360px, calc(100vw - 32px)); max-height: calc(100dvh - 160px);
  overflow: auto; padding: 16px; border-radius: 16px; background: var(--superficie); box-shadow: 0 8px 24px #000a; display: grid; gap: 12px; align-content: start; }
.painel-topo { display: flex; justify-content: space-between; align-items: center; }
.painel p { margin: 0; }
.painel label { font-weight: 600; }
.linha { display: flex; gap: 8px; }
.linha input { flex: 1; min-width: 0; }
.convite { display: grid; gap: 6px; }
.medidor .mb { font-size: 1.5rem; }
.medidor dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 12px; margin: 12px 0 0; }
.medidor dt { color: var(--suave); font-size: .8rem; }
.medidor dd { margin: 0; }
#conexao[data-estado="conectado"] { color: var(--ok); }
#conexao[data-estado="reconectando"] { color: var(--alerta); }
#conexao[data-estado="desconectado"] { color: var(--erro); }
.lista-mais { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lista-mais button { width: 100%; text-align: left; background: transparent; font-weight: 400; min-height: 44px; }
.lista-mais button:hover { background: var(--botao); }
.lista-mais [aria-disabled="true"] { color: var(--suave); }
.opcoes-reacao { display: flex; flex-wrap: wrap; gap: 8px; }
.opcoes-reacao button { font-size: 1.6rem; width: 52px; height: 52px; padding: 0; border-radius: 50%; }

dialog { background: var(--superficie); color: var(--texto); border: 0; border-radius: 16px; padding: 20px; max-width: min(92vw, 400px); }
dialog::backdrop { background: #000a; }
dialog p { color: var(--suave); }
.fim-linha { justify-content: flex-end; }

/* celular em pé: barra compacta (microfone, câmera, mão, ⋮, sair + "…") */
@media (max-width: 640px) {
  .sala-topo { padding: 6px 8px; gap: 8px; }
  .topo-esq, .topo-dir { gap: 8px; }
  #hora, .divisor { display: none; }
  .palco { padding: 0 8px; }
  .tile { border-radius: 12px; }
  .sala-base { grid-template-columns: 1fr; justify-items: center; padding: 8px 8px 12px; }
  .base-esq, .base-dir, .vai-pro-mais { display: none !important; }
  .base-centro { gap: 6px; }
  .desligar { width: 56px; }
  .painel { left: 8px; right: 8px; width: auto; bottom: 72px; }
  .tile[data-modo="slide"] #video-prof { width: 34%; bottom: 48px; right: 8px; }
}
@media (max-width: 360px) { .selo-rede { display: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
