/* Estilos do Compartilhamento de Tela. Tema claro/escuro conforme o sistema. */

:root {
  color-scheme: light dark;
  --fundo: #f4f5f7;
  --superficie: #ffffff;
  --texto: #1d2129;
  --texto-suave: #5f6673;
  --borda: #d9dce1;
  --primaria: #2563eb;
  --primaria-hover: #1d4ed8;
  --erro: #b42318;
  --erro-fundo: #fef3f2;
  --sucesso: #067647;
  --sucesso-fundo: #ecfdf3;
  --alerta: #93370d;
  --alerta-fundo: #fffaeb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #121417;
    --superficie: #1c1f24;
    --texto: #e6e8eb;
    --texto-suave: #9aa1ad;
    --borda: #30353d;
    --primaria: #3b82f6;
    --primaria-hover: #60a5fa;
    --erro: #f97066;
    --erro-fundo: #2a1513;
    --sucesso: #47cd89;
    --sucesso-fundo: #0f2a1d;
    --alerta: #fdb022;
    --alerta-fundo: #2b2110;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
}

button {
  font: inherit;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--primaria);
  color: #fff;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--primaria-hover); }
button:disabled { opacity: 0.6; cursor: default; }
button.secundario {
  background: transparent;
  color: var(--texto);
  border-color: var(--borda);
}
button.secundario:hover:not(:disabled) { background: var(--borda); }
button.pequeno { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

/* Link com cara de botão */
a.botao {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 1px solid var(--borda);
  border-radius: 6px;
  color: var(--texto);
  text-decoration: none;
}
a.botao:hover { background: var(--borda); }

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

input {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--borda);
  border-radius: 6px;
  background: var(--fundo);
  color: var(--texto);
}
input:focus { outline: 2px solid var(--primaria); outline-offset: 1px; }

.sucesso {
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  background: var(--sucesso-fundo);
  color: var(--sucesso);
  font-size: 0.9rem;
}

.erro {
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  background: var(--erro-fundo);
  color: var(--erro);
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- login */

.pagina-login {
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.cartao-login {
  width: 100%;
  max-width: 360px;
  padding: 2rem;
  border: 1px solid var(--borda);
  border-radius: 10px;
  background: var(--superficie);
}
.cartao-login h1 { margin: 0 0 0.25rem; font-size: 1.35rem; }
.cartao-login .subtitulo { margin: 0 0 1.5rem; color: var(--texto-suave); }
.cartao-login form { display: flex; flex-direction: column; gap: 0.6rem; }
.cartao-login label { font-size: 0.9rem; font-weight: 600; }
.cartao-login button { margin-top: 0.5rem; }

/* ---------------------------------------------------------------- layout geral */

.cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--borda);
  background: var(--superficie);
}
.cabecalho-acoes { display: flex; align-items: center; gap: 0.75rem; }

.conteudo { flex: 1; padding: 1rem; }

.vazio { color: var(--texto-suave); text-align: center; margin-top: 4rem; }

/* ---------------------------------------------------------------- sala */

button.perigo { background: var(--erro); }
button.perigo:hover:not(:disabled) { background: var(--erro); filter: brightness(1.1); }

.acoes-sala { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

/* A sala ocupa exatamente a janela; a grade se ajusta ao espaço que sobra. */
.pagina-sala { height: 100vh; overflow: hidden; }
.sala { flex: 1; min-height: 0; display: flex; }
.conteudo-sala { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.dica-destaque {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--texto-suave);
  text-align: center;
}

/* Painel de participantes */
.participantes {
  width: 230px;
  flex-shrink: 0;
  padding: 1rem;
  border-left: 1px solid var(--borda);
  background: var(--superficie);
  overflow-y: auto;
}
.participantes h2 { margin: 0 0 0.75rem; font-size: 0.95rem; }
.participantes ul { list-style: none; margin: 0; padding: 0; }
.participantes li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--borda);
}
.participantes li:last-child { border-bottom: none; }
.nome-participante { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compartilhando {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--sucesso);
}
.compartilhando::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--sucesso);
}

.aviso-conexao {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0.5rem 1rem;
  background: var(--alerta-fundo);
  color: var(--alerta);
  font-size: 0.9rem;
}

.grade {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--colunas, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--linhas, 1), minmax(0, 1fr));
  gap: 0.5rem;
}

/* Destaque: a tela escolhida ocupa a linha de cima inteira; as outras viram
   miniaturas numa faixa embaixo. */
.grade.modo-destaque {
  grid-template-columns: repeat(var(--miniaturas, 1), minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr) 130px;
}
.grade.modo-destaque .tile.destacado { grid-column: 1 / -1; grid-row: 1; }

.tile {
  position: relative;
  margin: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
  border: 1px solid var(--borda);
  cursor: pointer;
}
.tile.local { border-color: var(--primaria); }
.tile.destacado { cursor: zoom-out; }

.botao-tela-cheia {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  padding: 0.35rem;
  border-radius: 6px;
  background: rgb(0 0 0 / 0.6);
  opacity: 0;
  transition: opacity 0.15s;
}
.botao-tela-cheia:hover:not(:disabled) { background: rgb(0 0 0 / 0.85); }
.tile:hover .botao-tela-cheia,
.botao-tela-cheia:focus-visible { opacity: 1; }
.botao-tela-cheia svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (hover: none) { .botao-tela-cheia { opacity: 1; } }

.tile:fullscreen { border: none; border-radius: 0; cursor: default; }
.tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.tile figcaption {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  max-width: calc(100% - 1rem);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tela estreita (celular): uma tela por linha, com rolagem. */
@media (max-width: 700px) {
  .pagina-sala { height: auto; overflow: auto; }
  .sala { flex-direction: column; }
  .grade,
  .grade.modo-destaque { display: flex; flex-direction: column; }
  .tile { aspect-ratio: 16 / 9; }
  .tile.destacado { order: -1; }
  .participantes { width: auto; border-left: none; border-top: 1px solid var(--borda); }
  .cabecalho { flex-wrap: wrap; }
}

/* ---------------------------------------------------------------- admin */

.barra-titulo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.barra-titulo h1 { margin: 0; font-size: 1.3rem; }
.barra-acoes { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.barra-acoes input { width: 260px; max-width: 100%; }

/* Notificação flutuante: não empurra a tabela (evita clique na linha errada). */
.aviso {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  margin: 0;
  padding: 0.6rem 1rem;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.25);
  border-radius: 6px;
  background: var(--sucesso-fundo);
  color: var(--sucesso);
}
.aviso.erro { background: var(--erro-fundo); color: var(--erro); }

.tabela-rolagem { overflow-x: auto; }

.tabela {
  width: 100%;
  border-collapse: collapse;
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 8px;
}
.tabela th,
.tabela td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--borda);
  white-space: nowrap;
}
.tabela th { font-size: 0.8rem; text-transform: uppercase; color: var(--texto-suave); }
.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tr.inativo td { color: var(--texto-suave); }
.tabela .acoes { text-align: right; width: 1%; }
.voce { color: var(--texto-suave); font-size: 0.85rem; }

.etiqueta {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--borda);
}
.etiqueta.destaque { border-color: var(--primaria); color: var(--primaria); }
.etiqueta.sucesso { border-color: var(--sucesso); color: var(--sucesso); }
.etiqueta.apagada { color: var(--texto-suave); }
.etiqueta.perigo { border-color: var(--erro); color: var(--erro); }

/* Abas do admin */
.abas {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--borda);
}
.abas .aba {
  background: transparent;
  color: var(--texto-suave);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 0.9rem;
}
.abas .aba:hover:not(:disabled) { background: transparent; color: var(--texto); }
.abas .aba.ativa { color: var(--texto); border-bottom-color: var(--primaria); font-weight: 600; }

/* Auditoria: o detalhe pode ser longo e quebra linha; o resto não. */
.tabela-auditoria td.detalhe { white-space: normal; min-width: 280px; word-break: break-word; }
.tabela-auditoria td { font-size: 0.9rem; }
.carregar-mais { display: flex; justify-content: center; margin-top: 1rem; }
select {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--borda);
  border-radius: 6px;
  background: var(--fundo);
  color: var(--texto);
}

/* ---------------------------------------------------------------- diálogos */

dialog {
  width: min(420px, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--borda);
  border-radius: 10px;
  background: var(--superficie);
  color: var(--texto);
}
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog h2 { margin: 0 0 1rem; font-size: 1.15rem; }
dialog form { display: flex; flex-direction: column; gap: 0.5rem; }
dialog label { font-size: 0.9rem; font-weight: 600; }
dialog label.opcao { display: flex; align-items: center; gap: 0.5rem; font-weight: normal; }
dialog label.opcao input { width: auto; }
.dica { margin: -0.2rem 0 0.3rem; font-size: 0.8rem; color: var(--texto-suave); }
.dialogo-botoes { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.75rem; }

.rodape {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--texto-suave);
  text-align: right;
}
