/* ---------------- tela de login ---------------- */
#auth-screen {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 16%, rgba(228, 149, 249, 0.5) 0%, transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(76, 28, 212, 0.55) 0%, transparent 48%),
    linear-gradient(150deg, #9545f3 0%, #7c2ff0 38%, #4c1cd4 68%, #141221 100%);
  background-color: #141221;
  overflow: auto;
}
.auth-card {
  width: 100%;
  max-width: 480px;
  background: var(--modal);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 32px;
  animation: pop-in 0.25s ease;
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .logo {
  font-size: 30px; font-weight: 800; letter-spacing: 1px;
  color: var(--text-bright);
  display: inline-flex; align-items: center; gap: 10px;
}
.auth-brand .logo .mark {
  width: 48px; height: 48px;
  border-radius: 14px;
  box-shadow: 0 0 28px var(--brand-glow);
  display: block;
}
.auth-brand h1 { font-size: 24px; font-weight: 600; color: var(--text-bright); margin-top: 16px; }
.auth-brand p { color: var(--text-muted); font-size: 16px; margin-top: 8px; }

.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.02em;
}
.field label .req { color: var(--red); }
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--input-alt);
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 10px;
  color: var(--text-bright);
  font-size: 16px;
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); }
.field textarea { resize: vertical; min-height: 72px; font-family: inherit; }
.field .help { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.field.invalid label { color: var(--red); }
.field.invalid input { border-color: var(--red); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 16px;
  border-radius: 3px;
  background: var(--brand); color: #fff;
  font-size: 16px; font-weight: 500;
  transition: background 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.sm { height: 32px; font-size: 14px; padding: 0 12px; }
.btn.secondary { background: var(--input); color: var(--text-bright); }
.btn.secondary:hover { background: var(--hover); }
.btn.ghost { background: none; color: var(--text-bright); }
.btn.ghost:hover { text-decoration: underline; background: none; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-hover); }
.btn.green { background: var(--green); }
.btn.green:hover { filter: brightness(0.9); }

.auth-switch { margin-top: 8px; font-size: 14px; color: var(--text-muted); }
.auth-switch button { color: var(--link); font-size: 14px; }
.auth-switch button:hover { text-decoration: underline; }

.form-error {
  background: rgba(242, 63, 67, 0.1);
  border: 1px solid var(--red);
  border-radius: 4px;
  padding: 10px 12px;
  color: #f9a3a5;
  font-size: 14px;
  margin-bottom: 16px;
}

/* ---------------- modais ---------------- */
#modal-root {
  position: fixed; inset: 0;
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 24px;
  animation: fade-in 0.15s ease;
}
#modal-root.open { display: flex; }

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  background: var(--modal);
  border-radius: 8px;
  box-shadow: var(--shadow-high);
  display: flex; flex-direction: column;
  animation: pop-in 0.2s ease;
  overflow: hidden;
}
.modal.wide { max-width: 640px; }
.modal-head { padding: 24px 24px 8px; text-align: center; }
.modal-head.left { text-align: left; }
.modal-head h2 { font-size: 22px; font-weight: 700; color: var(--text-bright); }
.modal-head p { font-size: 15px; color: var(--text-muted); margin-top: 8px; }
.modal-body { padding: 16px 24px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 16px 24px;
  background: var(--modal-alt);
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
}
.modal-foot .spacer { flex: 1; }

.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 4px;
  display: grid; place-items: center;
  color: var(--text-muted);
}
.modal-close:hover { color: var(--text-bright); background: var(--hover); }
.modal { position: relative; }

.choice-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--modal-alt);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.choice-row:hover { background: var(--hover); }
.choice-row .icon { width: 40px; height: 40px; border-radius: 8px; background: var(--input); display: grid; place-items: center; color: var(--text-bright); flex: 0 0 40px; }
.choice-row .txt { flex: 1; min-width: 0; }
.choice-row .txt strong { display: block; color: var(--text-bright); font-size: 16px; font-weight: 600; }
.choice-row .txt span { font-size: 13px; color: var(--text-muted); }

.radio-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 4px; cursor: pointer;
}
.radio-row:hover { background: var(--hover); }
.radio-row input { accent-color: var(--brand); width: 18px; height: 18px; }

.copy-row { display: flex; gap: 8px; }
.copy-row input {
  flex: 1; background: var(--input-alt); border: 0; border-radius: 3px;
  padding: 10px; color: var(--text-bright); font-family: var(--mono); font-size: 14px;
}

.color-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid transparent;
}
.color-swatch.active { border-color: var(--text-bright); }

/* ---------------- menu de contexto / popovers ---------------- */
.popover {
  position: fixed;
  z-index: 200;
  background: var(--modal-alt);
  border-radius: 4px;
  box-shadow: var(--shadow-high);
  padding: 6px 8px;
  min-width: 188px;
  animation: pop-in 0.12s ease;
}
.popover .item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 3px;
  font-size: 14px; font-weight: 500;
  color: var(--text);
  text-align: left;
}
.popover .item:hover { background: var(--brand); color: #fff; }
.popover .item.danger { color: var(--red); }
.popover .item.danger:hover { background: var(--danger); color: #fff; }
.popover .item .icon { margin-left: auto; opacity: 0.6; }
.popover .sep { height: 1px; background: var(--divider); margin: 4px 0; }
.popover .head { font-size: 11px; text-transform: uppercase; font-weight: 700; color: var(--text-muted); padding: 6px 8px 2px; }

/* ---------------- cartao de perfil ---------------- */
.profile-card {
  position: fixed;
  z-index: 200;
  width: 300px;
  background: var(--modal-alt);
  border-radius: 8px;
  box-shadow: var(--shadow-high);
  overflow: hidden;
  animation: pop-in 0.15s ease;
}
.profile-card .banner { height: 60px; }
.profile-card .inner { padding: 0 16px 16px; }
.profile-card .profile-avatar {
  position: relative;
  display: block;
  margin-top: -40px;
  margin-bottom: 12px;
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 6px solid var(--modal-alt);
  background: var(--modal-alt);
  box-sizing: content-box;
}
/* o avatarHtml traz o proprio .avatar-wrap: aqui ele so preenche a moldura */
.profile-card .profile-avatar .avatar-wrap { display: block; width: 100%; height: 100%; }
.profile-card .profile-avatar .avatar { width: 100%; height: 100%; font-size: 30px; }
.profile-card .profile-avatar .presence-dot {
  right: 2px; bottom: 2px;
  width: 16px; height: 16px;
  border-width: 4px;
}
.profile-card .card-body { background: var(--modal); border-radius: 8px; padding: 12px; }
.profile-card .tag { font-size: 20px; font-weight: 700; color: var(--text-bright); }
.profile-card .handle { font-size: 14px; color: var(--text-muted); }
.profile-card .section { margin-top: 12px; }
.profile-card .section h4 {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-bright); margin-bottom: 6px;
}
.profile-card .section p { font-size: 14px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.profile-card .actions { margin-top: 12px; display: flex; gap: 8px; }

/* ---------------- seletor de emoji ---------------- */
.emoji-picker {
  position: fixed;
  z-index: 200;
  width: 340px;
  height: 380px;
  background: var(--modal-alt);
  border-radius: 8px;
  box-shadow: var(--shadow-high);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop-in 0.12s ease;
}
.emoji-picker .search { padding: 12px; }
.emoji-picker .search input {
  width: 100%; height: 32px;
  background: var(--input-alt); border: 0; border-radius: 4px;
  padding: 0 10px; color: var(--text-bright); outline: none; font-size: 14px;
}
.emoji-picker .grid { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.emoji-picker .cat-name {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 4px 4px;
  position: sticky; top: 0; background: var(--modal-alt);
}
.emoji-picker .cat-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-picker .emoji {
  width: 100%; aspect-ratio: 1;
  font-size: 22px; border-radius: 4px;
  display: grid; place-items: center;
}
.emoji-picker .emoji:hover { background: var(--hover); }
.emoji-picker .empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ---------------- visualizador de imagem ---------------- */
#lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
  padding: 40px;
  animation: fade-in 0.15s ease;
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 100%; max-height: calc(100% - 48px); object-fit: contain; border-radius: 4px; }
#lightbox .lb-bar { display: flex; gap: 16px; font-size: 14px; }

/* ---------------- notificacoes ---------------- */
#toast-root {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--modal-alt);
  color: var(--text-bright);
  border-radius: 8px;
  box-shadow: var(--shadow-high);
  padding: 12px 20px;
  font-size: 14px;
  border-left: 4px solid var(--brand);
  animation: pop-in 0.2s ease;
  max-width: 90vw;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }

/* ---------------- configuracoes ---------------- */
#settings-screen {
  position: fixed; inset: 0; z-index: 150;
  background: var(--chat);
  display: none;
}
#settings-screen.open { display: flex; }
.settings-nav {
  width: 232px; flex: 0 0 232px;
  background: var(--sidebar);
  padding: 60px 6px 60px 20px;
  overflow-y: auto;
}
.settings-nav .group {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); padding: 16px 10px 6px;
}
.settings-nav .nav-item {
  display: block; width: 100%; text-align: left;
  padding: 6px 10px; margin-bottom: 2px;
  border-radius: 4px; font-size: 16px; color: var(--text-muted);
}
.settings-nav .nav-item:hover { background: var(--hover); color: var(--text); }
.settings-nav .nav-item.active { background: var(--active); color: var(--text-bright); }
.settings-nav .nav-item.danger { color: var(--red); }
.settings-main { flex: 1; padding: 60px 40px; overflow-y: auto; max-width: 740px; }
.settings-main h2 { font-size: 20px; font-weight: 700; color: var(--text-bright); margin-bottom: 20px; }
.settings-main h3 {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); margin: 24px 0 8px;
}
.settings-card { background: var(--input-alt); border-radius: 8px; padding: 16px; }
.settings-row {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row .grow { flex: 1; min-width: 0; }
.settings-row .label { font-size: 15px; color: var(--text-bright); font-weight: 500; }
.settings-row .desc { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.settings-close {
  position: absolute; top: 60px; right: 40px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--text-muted);
  color: var(--text-muted);
  display: grid; place-items: center;
}
.settings-close:hover { background: var(--hover); color: var(--text-bright); }

.switch { width: 40px; height: 24px; border-radius: 12px; background: var(--text-faint); position: relative; transition: background 0.15s ease; flex: 0 0 40px; }
.switch.on { background: var(--green); }
.switch::after {
  content: ""; position: absolute; top: 4px; left: 4px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform 0.15s ease;
}
.switch.on::after { transform: translateX(16px); }

/* ---------------- seletor de tela (aplicativo de desktop) ---------------- */
.grupo-fontes { margin-bottom: 16px; }
.grupo-fontes h4 {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.02em;
}
.grade-fontes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.fonte-tela {
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px; border-radius: 6px;
  background: var(--modal-alt);
  border: 2px solid transparent;
  text-align: left; width: 100%;
}
.fonte-tela:hover { background: var(--hover); }
.fonte-tela.ativa { border-color: var(--brand); background: var(--mention-bg); }
.fonte-tela .miniatura {
  display: block; width: 100%; aspect-ratio: 16 / 9;
  background: var(--input-alt); border-radius: 4px; overflow: hidden;
  display: grid; place-items: center;
}
.fonte-tela .miniatura img { width: 100%; height: 100%; object-fit: contain; }
.fonte-tela .miniatura .vazia { color: var(--text-faint); }
.fonte-tela .rotulo {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text); min-width: 0;
}
.fonte-tela.ativa .rotulo { color: var(--text-bright); font-weight: 500; }
.fonte-tela .icone-app { width: 16px; height: 16px; flex: 0 0 16px; border-radius: 3px; }

/* no aplicativo de desktop a barra de titulo e escondida: sobra espaco */
:root[data-desktop="sim"] .settings-nav { padding-top: 40px; }
:root[data-desktop="sim"] .settings-main { padding-top: 40px; }
:root[data-desktop="sim"] .settings-close { top: 40px; }

/* ---------------- chamada ---------------- */
.chamada-cartao {
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  padding: 16px 0 8px;
  text-align: center;
}
.chamada-cartao .avatar-wrap { animation: respirar 2.4s ease-in-out infinite; }
@keyframes respirar {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.chamada-nome { font-size: 22px; font-weight: 700; color: var(--text-bright); }
.chamada-estado {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; color: var(--text-muted);
}
.chamada-estado .ondas { display: inline-flex; gap: 3px; align-items: flex-end; height: 14px; }
.chamada-estado .ondas i {
  width: 3px; height: 6px; border-radius: 2px;
  background: var(--green);
  animation: onda 1s ease-in-out infinite;
}
.chamada-estado .ondas i:nth-child(2) { animation-delay: 0.15s; }
.chamada-estado .ondas i:nth-child(3) { animation-delay: 0.3s; }
@keyframes onda {
  0%, 100% { height: 5px; opacity: 0.5; }
  50% { height: 14px; opacity: 1; }
}

/* botao de ligar no cabecalho da conversa */
#chat-header .header-btn.ligando { color: var(--red); }
#chat-header .header-btn.ligando:hover { background: rgba(242, 63, 67, 0.12); color: var(--red); }

/* convite ja reconhecido: confirma sem poluir o formulario */
.convite-aplicado {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; margin-bottom: 20px;
  background: rgba(35, 165, 90, 0.1);
  border: 1px solid var(--green);
  border-radius: 4px;
  font-size: 14px; color: var(--text);
}
.convite-aplicado .marca { display: inline-flex; color: var(--green); }
.convite-aplicado .trocar {
  margin-left: auto; font-size: 13px; color: var(--text-muted);
  text-decoration: underline; background: none;
}
.convite-aplicado .trocar:hover { color: var(--text-bright); }

/* ---------------- controle de volume individual ---------------- */
.controle-volume { min-width: 230px; }
.controle-volume .linha-volume {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
}
.controle-volume .linha-volume .icone {
  color: var(--text-muted); display: inline-flex; cursor: pointer;
}
.controle-volume .linha-volume .icone:hover { color: var(--red); }
.controle-volume input[type="range"] {
  flex: 1; accent-color: var(--brand); cursor: pointer;
}
.controle-volume .valor {
  font-size: 12px; color: var(--text-muted);
  min-width: 38px; text-align: right; font-variant-numeric: tabular-nums;
}

/* ---------------- aviso de versao nova ---------------- */
/*
 * A posicao final e o padrao, e a entrada e so uma animacao por cima. Se o
 * aplicativo estiver minimizado quando o aviso aparecer, o navegador nao
 * desenha quadros e nenhuma animacao roda - mas a barra ja esta no lugar
 * certo, entao ela simplesmente aparece quando a janela volta.
 */
#barra-atualizacao {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 350;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px;
  background: var(--modal-alt);
  border: 1px solid var(--brand);
  border-radius: 10px;
  box-shadow: var(--shadow-high);
  font-size: 14px; color: var(--text);
  max-width: calc(100vw - 32px);
}
/* so entra com classe: em janela minimizada nenhum quadro e desenhado e a
   animacao ficaria travada no primeiro frame, fora da tela */
#barra-atualizacao.animar { animation: subir-barra 0.28s cubic-bezier(.2,.8,.3,1); }
@keyframes subir-barra {
  from { transform: translate(-50%, 140%); opacity: 0; }
  to { transform: translateX(-50%); opacity: 1; }
}
#barra-atualizacao .texto { display: flex; align-items: center; gap: 8px; }
#barra-atualizacao .texto svg { color: var(--brand-soft); flex: 0 0 auto; }
#barra-atualizacao .depois {
  width: 28px; height: 28px; border-radius: 4px;
  display: grid; place-items: center; color: var(--text-muted);
}
#barra-atualizacao .depois:hover { background: var(--hover); color: var(--text-bright); }

/* ---- ajustes do servidor: abas e cargos ---- */
.settings-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 18px;
}
.settings-tabs .tab-item {
  background: none; border: none; cursor: pointer;
  padding: 8px 4px; margin-right: 16px;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}
.settings-tabs .tab-item:hover { color: var(--text-bright); }
.settings-tabs .tab-item.active { color: var(--text-bright); border-bottom-color: var(--brand); }

/* paragrafo de ajuda solto, fora de um .field */
p.help { font-size: 12px; color: var(--text-muted); margin: 0 0 14px; }

.cargos-lista { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.cargo-linha {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--input); cursor: pointer;
}
.cargo-linha:hover { background: var(--hover); }
.cargo-cor { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.cargo-nome { color: var(--text-bright); font-weight: 500; }
.cargo-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 8px;
  background: var(--brand-soft); color: var(--brand);
}
.cargo-seta { margin-left: auto; color: var(--text-muted); }

.cargo-form .switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px; cursor: pointer;
  font-size: 14px; color: var(--text-bright);
}
.cargo-form > [data-voltar-cargos] { margin-bottom: 14px; }

.cargo-membros {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--divider); border-radius: var(--radius);
  padding: 6px;
}
.cargo-membro {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 4px;
  font-size: 14px; color: var(--text-bright);
  cursor: pointer;
}
.cargo-membro:hover { background: var(--hover); }
.cargo-membro input[type="checkbox"] { flex: none; }
