:root {
  --verde-escuro: #075E54;
  --verde-header: #128C7E;
  --verde-bolha: #DCF8C6;
  --fundo-chat: #ECE5DD;
  --cinza-texto: #667781;
  --branco: #FFFFFF;
  --vermelho: #c0392b;
  --cinza-claro: #f0f0f0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
  background: #DAD3CC;
}

/* ===== Telas de autenticação (login/cadastro) ===== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--branco);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  overflow: hidden;
}

.auth-card .topo {
  background: var(--verde-escuro);
  color: var(--branco);
  padding: 24px 24px 18px;
  text-align: center;
}

.auth-card .topo .avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--branco);
  color: var(--verde-escuro);
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
}

.auth-card .topo h1 { font-size: 17px; margin: 0; }
.auth-card .topo p { font-size: 12.5px; opacity: 0.85; margin: 4px 0 0; }

.auth-card .corpo { padding: 22px 24px 26px; }

.campo { margin-bottom: 14px; }

.campo label {
  display: block;
  font-size: 12.5px;
  color: var(--cinza-texto);
  margin-bottom: 4px;
}

.campo input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d1d1;
  border-radius: 6px;
  font-size: 14.5px;
  font-family: inherit;
}

.campo input:focus {
  outline: none;
  border-color: var(--verde-header);
}

.btn {
  width: 100%;
  background: var(--verde-header);
  color: var(--branco);
  border: none;
  padding: 11px;
  border-radius: 6px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
}

.btn:disabled { background: #9bbfba; cursor: not-allowed; }
.btn.secundario { background: var(--cinza-claro); color: #333; }

.msg-erro {
  color: var(--vermelho);
  font-size: 12.5px;
  margin-top: 10px;
  display: none;
}

.msg-sucesso {
  color: #1e7e34;
  font-size: 12.5px;
  margin-top: 10px;
  display: none;
}

.rodape-link {
  text-align: center;
  font-size: 13px;
  color: var(--cinza-texto);
  margin-top: 16px;
}

.rodape-link a { color: var(--verde-header); text-decoration: none; font-weight: 600; }

/* ===== Barra superior (chat / admin) ===== */
.topbar {
  background: var(--verde-escuro);
  color: var(--branco);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--branco);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--verde-escuro);
  font-size: 15px;
  flex-shrink: 0;
}

.topbar .info { line-height: 1.3; overflow: hidden; flex: 1; }
.topbar .info .nome { font-weight: 600; font-size: 16px; }
.topbar .info .status { font-size: 12.5px; opacity: 0.85; }

.topbar .sair {
  background: rgba(255,255,255,0.15);
  border: none;
  color: var(--branco);
  padding: 7px 12px;
  border-radius: 16px;
  font-size: 12.5px;
  cursor: pointer;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.badge.aberto { background: #d4f5dc; color: #1e7e34; }
.badge.finalizado { background: #e2e2e2; color: #555; }

/* ===== Chat (imobiliária) ===== */
.app {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  max-height: 900px;
  background: var(--fundo-chat);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 24px rgba(0,0,0,0.25);
  position: relative;
  overflow: hidden;
  margin: 0 auto;
}

@media (min-width: 481px) {
  .app { height: 90vh; border-radius: 8px; margin: 20px auto; }
}

.sla-banner {
  background: #FFF3CD;
  color: #6b5300;
  font-size: 12.5px;
  text-align: center;
  padding: 8px 14px;
  border-bottom: 1px solid #e6d28a;
  flex-shrink: 0;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-image:
    linear-gradient(rgba(236,229,221,0.94), rgba(236,229,221,0.94)),
    repeating-linear-gradient(45deg, #ded6ca 0, #ded6ca 1px, transparent 1px, transparent 16px);
}

.bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.4;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.bubble.bot, .bubble.admin { background: var(--branco); align-self: flex-start; border-top-left-radius: 0; }
.bubble.user, .bubble.imobiliaria { background: var(--verde-bolha); align-self: flex-end; border-top-right-radius: 0; }

.bubble .hora {
  display: block;
  font-size: 10.5px;
  color: var(--cinza-texto);
  text-align: right;
  margin-top: 4px;
}

.bubble .check { color: #4fc3f7; margin-left: 3px; }

.input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #F0F0F0;
  flex-shrink: 0;
}

.input-bar textarea {
  flex: 1;
  resize: none;
  border: none;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14.5px;
  font-family: inherit;
  max-height: 90px;
  line-height: 1.3;
}

.input-bar textarea:focus { outline: none; }
.input-bar textarea:disabled { background: #e6e6e6; color: #888; }

.send-btn {
  background: var(--verde-header);
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn:disabled { background: #a9c9c4; cursor: not-allowed; }
.send-btn svg { width: 20px; height: 20px; fill: white; margin-left: 2px; }

.typing {
  align-self: flex-start;
  background: var(--branco);
  border-radius: 8px;
  border-top-left-radius: 0;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--cinza-texto);
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
}

.aviso-encerrado {
  text-align: center;
  font-size: 12.5px;
  color: #6b5300;
  background: #FFF3CD;
  padding: 8px 14px;
  margin: 6px auto;
  border-radius: 8px;
  max-width: 90%;
}

/* ===== Painel Admin ===== */
.admin-layout {
  display: flex;
  height: 100vh;
}

.admin-lista {
  width: 320px;
  flex-shrink: 0;
  background: var(--branco);
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.busca-protocolo {
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.busca-protocolo input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d1d1;
  border-radius: 16px;
  font-size: 13.5px;
  font-family: inherit;
}

.busca-protocolo input:focus {
  outline: none;
  border-color: var(--verde-header);
}

.ticket-item .protocolo {
  font-size: 11px;
  color: var(--cinza-texto);
  font-weight: 600;
}

.ticket-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ticket-item:hover { background: #f7f7f7; }
.ticket-item.ativo { background: #e8f5f2; }

.ticket-item .linha-topo {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ticket-item .nome-imob { font-weight: 600; font-size: 14px; }
.ticket-item .preview {
  font-size: 12.5px;
  color: var(--cinza-texto);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--fundo-chat);
}

.admin-thread .topbar .acoes { display: flex; gap: 8px; align-items: center; }

.btn-finalizar {
  background: var(--branco);
  color: var(--verde-escuro);
  border: 1px solid var(--branco);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.vazio-central {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cinza-texto);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-caixa {
  background: var(--branco);
  border-radius: 10px;
  padding: 20px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

.modal-caixa p {
  font-size: 14px;
  color: #333;
  margin: 0 0 16px;
  line-height: 1.4;
}

.modal-acoes {
  display: flex;
  gap: 10px;
}

.modal-acoes .btn { margin-top: 0; }

@media (max-width: 720px) {
  .admin-layout { flex-direction: column; }
  .admin-lista { width: 100%; height: 40vh; border-right: none; border-bottom: 1px solid #e0e0e0; }
  .admin-thread { height: 60vh; }
}
