/* ==================== RESET & BASE ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

/* ===== Paleta e tokens do tema (VERDE PADRÃO) ===== */
:root{
  /* Verdes base */
  --brand-900:#1a3b2b;        /* mais escuro */
  --brand-800:#224535;        /* header escuro */
  --brand-700:#28513e;        /* header gradiente */
  --brand-600:#2F6F4F;        /* botões principais */
  --brand-500:#3C8C6C;        /* hover / realce */
  --brand-300:#A8CABA;        /* scrollbars / divisores suaves */
  --brand-200:#CFE3DA;        /* bordas suaves */
  --brand-100:#E6F0EB;        /* fundos suaves */

  /* Superfícies e texto */
  --bg:#F3F7F4;               /* fundo geral */
  --surface:#FFFFFF;          /* cartões / caixas */
  --ink:#1e2a22;              /* texto principal */
  --ink-2:#314338;            /* texto secundário */
  --muted:#5d6d64;            /* legenda */

  /* Bordas, sombras e estados */
  --border:#d5e0da;
  --shadow:0 8px 24px rgba(0,0,0,.06);

  /* Semânticos */
  --danger:#c0392b;
  --ok:#2e7d32;

  /* Tipografia (ajuste leve no menu; bloco usuário 11px ajustado nas classes) */
  --menu-font-size:14.5px;
}

@media (prefers-color-scheme: dark){
  :root{
    --bg:#0f1713;
    --surface:#121c17;
    --ink:#e8f1ec;
    --ink-2:#cfe0d6;
    --muted:#9cb0a5;
    --border:#284237;
    --shadow:0 8px 24px rgba(0,0,0,.4);
  }
}

body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: Arial, sans-serif;
  min-height: 100vh;
  display: flex;
}

/* ==================== LOGIN ==================== */
body.login-page { justify-content: center; align-items: center; }
.container { display: flex; justify-content: center; align-items: center; height: 100vh; width: 100%; }
.container form {
  background-color: var(--surface);
  padding: 30px; border-radius: 10px; box-shadow: var(--shadow);
  width: 320px; text-align: center;
}
.container form h2 { margin-bottom: 20px; color: var(--brand-800); }
.container form input {
  width: 100%; padding: 10px 12px; margin: 8px 0;
  border: 1px solid var(--border); border-radius: 5px; font-size: 14px; box-sizing: border-box;
}
.container form button {
  width: 100%; padding: 10px; margin-top: 10px;
  background-color: var(--brand-600); border: none; border-radius: 5px; color: white; font-size: 16px; cursor: pointer; transition: background-color 0.3s;
}
.container form button:hover { background-color: var(--brand-500); }

/* ==================== TOPBAR ==================== */
.topbar {
  width: 100%;
  min-height: 56px;
  background: linear-gradient(0deg, var(--brand-700), var(--brand-800)); /* ESCURO (pedido) */
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  position: fixed; top: 0; left: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  color:#eaf5f0;
}
.topbar-titulo {
  color: #eaf5f0;
  font-size: 18px; font-weight: bold; letter-spacing: 1px;
}

/* Bloco do usuário (CANTO DIREITO, EMPILHADO, 11px) */
.topbar-usuario {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
}
.topbar-matricula { color: #bfe3cf; font-size: 11px; letter-spacing: .3px; }
.topbar-nome { color: #ffffff; font-size: 11px; font-weight: 600; }
.topbar-localidade { color: #d6eee3; font-size: 11px; font-style: italic; }

/* ==================== CORPO (abaixo da topbar) ==================== */
.corpo { display: flex; margin-top: 56px; height: calc(100vh - 56px); width: 100%; }

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: 220px; height: 100%;
  background-color: #1f3b2d; /* um tom compatível com o header */
  padding: 20px 15px; display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto;
}

/* ==================== NAV MENU (links) ==================== */
.nav-menu { display: flex; flex-direction: column; gap: 5px; margin-bottom: 25px; }
.nav-link {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none; padding: 9px 12px; border-radius: 6px; font-size: var(--menu-font-size);
  transition: background-color 0.2s, color 0.2s;
}
.nav-link:hover { background-color: rgba(255, 255, 255, 0.10); color: #fff; }
.nav-link.ativo { background-color: var(--brand-600); color: #fff; font-weight: bold; }
.nav-logout { margin-top: auto; color: #ffb9b9; }
.nav-logout:hover { background-color: rgba(255, 107, 107, 0.12); color: #ffd6d6; }

/* ==================== SIDEBAR - LISTA DE USUÁRIOS ==================== */
.sidebar-usuarios { margin-top: 10px; }
.sidebar-usuarios h3 {
  color: rgba(255, 255, 255, 0.75); font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}
.sidebar-usuarios ul { list-style: none; }
.sidebar-usuarios li {
  color: rgba(255, 255, 255, 0.9); font-size: 13px; padding: 0; border-radius: 5px;
  display: flex; align-items: center; gap: 8px; transition: background-color 0.2s;
}
.link-usuario {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border-radius: 6px;
  text-decoration: none; color: rgba(255, 255, 255, 0.85); font-size: 13px; transition: background-color 0.2s, color 0.2s;
}
.link-usuario:hover { background-color: rgba(255, 255, 255, 0.10); color: #fff; }
.link-usuario.ativo { background-color: var(--brand-600); color: #fff; font-weight: 600; }
.usuario-nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usuario-localidade { font-size: 11px; opacity: 0.85; font-weight: normal; }
.usuario-ultima { font-size: 10px; color: rgba(255, 255, 255, 0.7); flex-shrink: 0; white-space: nowrap; }

/* ==================== BADGE DE MENSAGENS NÃO LIDAS ==================== */
.badge-nao-lida {
  background-color: #e53935; color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 10px;
  min-width: 18px; text-align: center; flex-shrink: 0; line-height: 1.3;
}
.link-usuario.ativo .badge-nao-lida { background-color: #c62828; }

/* ==================== POPUP DE NOTIFICAÇÃO ==================== */
.notificacao-popup {
  position: fixed; top: 70px; right: -350px; width: 320px;
  background: var(--surface); color: var(--ink);
  border-radius: 12px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 14px 16px; cursor: pointer;
  transition: right 0.3s ease, opacity 0.3s ease;
  opacity: 0; z-index: 500;
}
.notificacao-popup.show { right: 20px; opacity: 1; }
.notificacao-popup:hover { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); transform: translateY(-2px); }
.notif-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.notif-header strong { font-size: 14px; color: var(--ink); }
.notif-hora { font-size: 11px; color: var(--muted); }
.notif-reuniao { font-size: 11px; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }
.notif-corpo { font-size: 13px; color: var(--ink); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot.online { background-color: var(--ok); }
.status-dot.offline { background-color: #666; }

/* ==================== CHAT ==================== */
.chat { flex: 1; display: flex; flex-direction: column; height: 100%; padding: 20px; overflow: hidden; }
.messages {
  flex: 1; background-color: #f9f9f9; border-radius: 0 0 10px 10px;
  padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
}

/* ==================== CABEÇALHO DA CONVERSA PRIVADA ==================== */
.chat-header { padding: 12px 18px; background-color: var(--brand-800); border-radius: 10px 10px 0 0; flex-shrink: 0; color:#fff; }
.chat-header-info { display: flex; align-items: center; gap: 10px; }
.chat-header-info h2 { color: #fff; font-size: 16px; margin: 0; }
.chat-header-status { font-size: 11px; color: rgba(255,255,255,0.75); margin-left: auto; }

/* ==================== MENSAGENS — BOLHAS PRIVADAS ==================== */
.mensagem {
  background: var(--surface); padding: 9px 13px; border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  max-width: 72%; display: flex; flex-direction: column; gap: 2px; border:1px solid var(--border);
}
.mensagem.dele { align-self: flex-start; border-bottom-left-radius: 4px; background-color: #fff; }
.mensagem.minha { align-self: flex-end; border-bottom-right-radius: 4px; background-color: var(--brand-100); }
.mensagem b { color: var(--brand-800); font-size: 12px; }
.mensagem .hora { color: #999; font-size: 10px; align-self: flex-end; }
.mensagem.dele .hora { align-self: flex-start; }
.mensagem p { font-size: 14px; margin: 0; color: var(--ink); word-break: break-word; }

/* ==================== TELA VAZIA DO CHAT ==================== */
.chat-vazio { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: 12px; }
.chat-vazio-icone { font-size: 56px; }
.chat-vazio h2 { color: var(--ink); font-size: 22px; margin: 0; }
.chat-vazio p { font-size: 14px; max-width: 360px; margin: 0; line-height: 1.5; }

/* ==================== FORM DE MENSAGEM ==================== */
.form-mensagem { display: flex; gap: 10px; margin-top: 15px; align-items: flex-end; flex-wrap: wrap; }
.form-mensagem input[type="text"],
#campo-mensagem {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; transition: border-color 0.2s;
  min-height: 56px; max-height: 180px; resize: none; /* para o textarea do chat */
  background:#fff; color: var(--ink);
}
.form-mensagem input[type="text"]:focus,
#campo-mensagem:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(60,140,108,.15); }
.form-mensagem button,
.btn-enviar {
  padding: 10px 20px; background-color: var(--brand-600); color: white; border: none; border-radius: 10px; font-size: 14px; cursor: pointer; transition: background-color 0.3s; white-space: nowrap; flex-shrink: 0; font-weight: 600;
}
.form-mensagem button:hover,
.btn-enviar:hover { background-color: var(--brand-500); }

/* ==================== TOOLBAR DE ENTRADA ==================== */
.btn-toolbar { background: none; border: none; font-size: 20px; cursor: pointer; padding: 6px 4px; border-radius: 6px; transition: background-color 0.2s; flex-shrink: 0; line-height: 1; color: var(--brand-700); }
.btn-toolbar:hover { background-color: var(--brand-100); }
.btn-gravar.gravando { animation: pulsar 1s infinite; color: #e53935; }
@keyframes pulsar { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.preview-arquivo {
  display: flex; align-items: center; justify-content: space-between;
  background-color: var(--brand-100); border: 1px dashed var(--brand-200);
  border-radius: 8px; padding: 8px 12px; margin-top: 10px; font-size: 13px; color: var(--ink-2);
}
.btn-remover-preview { background: none; border: none; color: var(--danger); font-size: 16px; cursor: pointer; padding: 0 4px; line-height: 1; }
.btn-remover-preview:hover { opacity: 0.7; }

/* ==================== MENSAGEM — ARQUIVO/IMAGEM/ÁUDIO ==================== */
.mensagem-arquivo {
  margin-top: 8px; display: flex; align-items: center; gap: 10px;
  background-color: #f5fbf8; border: 1px solid var(--brand-200); border-radius: 8px; padding: 10px 12px;
}
.arquivo-icone { font-size: 28px; flex-shrink: 0; }
.arquivo-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.arquivo-nome { font-size: 13px; color: var(--ink); font-weight: 600; word-break: break-word; }
.link-download { font-size: 12px; color: var(--brand-600); text-decoration: none; font-weight: 600; transition: color 0.2s; }
.link-download:hover { color: var(--brand-500); text-decoration: underline; }

.mensagem-imagem { flex-direction: column; align-items: flex-start; gap: 6px; padding: 8px; }
.mensagem-imagem img { max-width: 280px; max-height: 220px; border-radius: 6px; object-fit: cover; cursor: pointer; }
.mensagem-imagem img:hover { opacity: 0.95; }

.mensagem-audio { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.mensagem-audio audio { max-width: 260px; height: 36px; }

/* ==================== MAIN CONTENT (CADASTRO) ==================== */
.main-content { flex: 1; padding: 25px 30px; overflow-y: auto; height: 100%; }

/* ==================== ALERTAS ==================== */
.alerta { padding: 12px 16px; border-radius: 7px; font-size: 14px; margin-bottom: 20px; }
.alerta.sucesso { background-color: #e6f9ee; color: #2e7d32; border: 1px solid #a5d6a7; }
.alerta.erro { background-color: #fdecea; color: #c62828; border: 1px solid #ef9a9a; }

/* ==================== SEÇÕES DE CADASTRO ==================== */
.cadastro-section { background-color: var(--surface); border-radius: 10px; padding: 25px; box-shadow: var(--shadow); margin-bottom: 30px; }
.cadastro-section h2 { color: var(--brand-800); font-size: 18px; margin-bottom: 18px; padding-bottom: 10px; border-bottom: 2px solid var(--brand-200); }

/* ==================== FORM GRID ==================== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-group { display: flex; flex-direction: column; }
.form-group label { font-size: 13px; color: #555; margin-bottom: 5px; font-weight: 600; }
.form-group input, .form-group select {
  padding: 9px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; outline: none; transition: border-color 0.2s; background-color: #fafafa;
}
.form-group input:focus, .form-group select:focus { border-color: var(--brand-500); background-color: #fff; }
.cadastro-section > .form-group { max-width: 400px; }
.cadastro-section button {
  margin-top: 20px; padding: 10px 24px; background-color: var(--brand-600); color: white;
  border: none; border-radius: 6px; font-size: 15px; cursor: pointer; transition: background-color 0.3s; width: auto; display: inline-block;
}
.cadastro-section button:hover { background-color: var(--brand-500); }

/* ==================== TABELAS ==================== */
.tabela-section { background-color: var(--surface); border-radius: 10px; padding: 25px; box-shadow: var(--shadow); margin-bottom: 30px; }
.tabela-section h2 { color: var(--brand-800); font-size: 18px; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid var(--brand-200); }
.tabela-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
table thead { background-color: var(--brand-800); color: #fff; }
table thead th { padding: 11px 14px; text-align: left; font-weight: 600; white-space: nowrap; }
table tbody tr { border-bottom: 1px solid #eee; transition: background-color 0.15s; }
table tbody tr:hover { background-color: var(--brand-100); }
table tbody td { padding: 10px 14px; color: #444; }
.sem-dados { text-align: center; color: #999; padding: 20px !important; font-style: italic; }

/* ==================== STATUS NA TABELA ==================== */
.status-online { color: #2e7d32; font-weight: 600; }
.status-offline { color: #757575; }

/* ==================== BOTÃO EDITAR NA TABELA ==================== */
.btn-editar {
  color: #fff; background-color: var(--brand-600); text-decoration: none; padding: 5px 12px; border-radius: 5px; font-size: 13px; transition: background-color 0.2s; white-space: nowrap;
}
.btn-editar:hover { background-color: var(--brand-500); }
.td-ações { display: flex; gap: 6px; align-items: center; }
.form-excluir { display: inline; }
.btn-excluir {
  color: #fff; background-color: #e53935; border: none; padding: 5px 12px; border-radius: 5px; font-size: 13px; cursor: pointer; transition: background-color 0.2s; white-space: nowrap; width: auto;
}
.btn-excluir:hover { background-color: #c62828; }
.sem-acao { color: #bbb; font-size: 18px; }

/* ==================== SEÇÃO DE EDIÇÃO ==================== */
.cadastro-editar { border: 2px solid var(--brand-600); background-color: #f6fbf8; }
.editar-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; padding-bottom: 10px; border-bottom: 2px solid var(--brand-200);
}
.editar-header h2 { margin: 0; border: none; padding: 0; }
.btn-cancelar { color: #fff; background-color: #e53935; text-decoration: none; padding: 6px 14px; border-radius: 5px; font-size: 13px; transition: background-color 0.2s; white-space: nowrap; }
.btn-cancelar:hover { background-color: #c62828; }
input:disabled { background-color: #e8e8e8; color: #888; cursor: not-allowed; }

/* ==================== SIDEBAR — REUNIÕES ==================== */
.btn-criar-reuniao {
  display: block; text-align: center; color: #fff; background-color: var(--brand-600); text-decoration: none; padding: 7px 10px; border-radius: 6px; font-size: 13px; margin-bottom: 10px; transition: background-color 0.2s; cursor: pointer; border: none;
}
.btn-criar-reuniao:hover { background-color: var(--brand-500); }
.link-reuniao {
  color: rgba(255, 255, 255, 0.85); text-decoration: none; font-size: 13px; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 5px; transition: background-color 0.2s, color 0.2s;
}
.link-reuniao:hover { background-color: rgba(255, 255, 255, 0.1); color: #fff; }
.link-reuniao.ativo { background-color: var(--brand-600); color: #fff; font-weight: 600; }
.sem-reuniao { color: rgba(255, 255, 255, 0.7); font-size: 12px; font-style: italic; padding: 4px 8px; }

/* ==================== REUNIÃO — CABEÇALHO ==================== */
.reuniao-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.reuniao-titulo h2 { color: var(--ink); font-size: 18px; margin: 0; }
.reuniao-participantes-count { color: var(--muted); font-size: 12px; margin-top: 2px; display: block; }
.form-excluir-reuniao { display: inline; }
.btn-excluir-reuniao { color: #fff; background-color: #e53935; border: none; padding: 5px 12px; border-radius: 5px; font-size: 13px; cursor: pointer; transition: background-color 0.2s; white-space: nowrap; width: auto; }
.btn-excluir-reuniao:hover { background-color: #c62828; }

/* ==================== REUNIÃO — PARTICIPANTES ==================== */
.reuniao-participantes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; padding: 10px 14px; background-color: rgba(255, 255, 255, 0.07); border-radius: 8px; }
.participante { display: flex; align-items: center; gap: 6px; color: rgba(255, 255, 255, 0.95); font-size: 13px; background-color: rgba(255, 255, 255, 0.12); padding: 4px 10px; border-radius: 20px; }

/* ==================== REUNIÃO — TELA VAZIA ==================== */
.reuniao-vazia { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: 12px; }
.reuniao-vazia-icone { font-size: 56px; }
.reuniao-vazia h2 { color: var(--ink); font-size: 22px; margin: 0; }
.reuniao-vazia p { font-size: 14px; max-width: 380px; margin: 0; }
.btn-criar-reuniao-centro { color: #fff; background-color: var(--brand-600); border: none; padding: 10px 24px; border-radius: 7px; font-size: 15px; cursor: pointer; transition: background-color 0.2s; margin-top: 8px; }
.btn-criar-reuniao-centro:hover { background-color: var(--brand-500); }

/* ==================== MENSAGENS DE SUCESSO E ERRO ==================== */
.msg-sucesso, .msg-erro { padding: 14px 18px; border-radius: 6px; margin-bottom: 20px; font-size: 14px; font-weight: 500; }
.msg-sucesso { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.msg-erro { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ==================== EMOJI PICKER ==================== */
.emoji-picker {
  position: fixed; bottom: 80px; left: 240px; width: 380px; max-height: 420px;
  background-color: var(--surface); border-radius: 12px; box-shadow: var(--shadow); z-index: 300;
  display: flex; flex-direction: column; overflow: hidden; border:1px solid var(--border);
}
.emoji-picker-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background-color: var(--brand-800); color: #fff; font-size: 14px; font-weight: 600; }
.emoji-fechar { font-size: 22px; cursor: pointer; color: rgba(255,255,255,0.85); transition: color 0.2s; }
.emoji-fechar:hover { color: #fff; }
.emoji-search { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.emoji-search input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; box-sizing: border-box;
}
.emoji-search input:focus { border-color: var(--brand-500); }
.emoji-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; padding: 10px 8px; overflow-y: auto; flex: 1; }
.emoji-btn { background: none; border: 1px solid var(--border); font-size: 20px; cursor: pointer; padding: 4px; border-radius: 5px; transition: background-color 0.15s; line-height: 1.2; text-align: center; background:#fff; }
.emoji-btn:hover { background-color: var(--brand-100); }

/* ==================== INPUTS DESABILITADOS ==================== */
input:disabled { background-color: #e8e8e8; color: #888; cursor: not-allowed; }