:root {
  --wa-dark: #075E54;
  --wa-teal: #128C7E;
  --wa-green: #25D366;
  --wa-bg: #F7F8FA;
  --wa-chat-bg: #E9E3DA;
  --wa-surface: #FFFFFF;
  --wa-surface-alt: #F0FAF6;
  --wa-text: #111B21;
  --wa-text-muted: #667781;
  --wa-divider: #E9EDEF;
  --wa-danger: #FF3B30;
  --wa-bubble-out: #DCF8C6;
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Garante que [hidden] sempre vence, mesmo com display:flex definido nas
   classes específicas de tela abaixo (sem isso, telas ficam sobrepostas). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--wa-text);
  background: var(--wa-bg);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.tela { height: 100vh; width: 100vw; }

/* Transição suave entre telas - reforça sensação de app nativo */
.tela:not([hidden]) { animation: tela-entra 0.18s ease-out; }
@keyframes tela-entra { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tela:not([hidden]) { animation: none; } }

button { font-family: inherit; }
button { transition: transform 0.08s ease-out, opacity 0.08s ease-out; }
button:active { transform: scale(0.97); }
@media (prefers-reduced-motion: reduce) { button:active { transform: none; } }

/* ===== LANDING ===== */
.tela-landing {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: radial-gradient(circle at 30% 20%, #1a2f2b 0%, #0a1210 55%, #050807 100%);
  color: #fff;
  padding: 40px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.landing-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(37,211,102,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,211,102,0.06) 1px, transparent 1px);
  background-size: 32px 32px;
}
.landing-glow {
  position: absolute; width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37,211,102,0.35) 0%, transparent 70%);
  top: 80px; left: 55px; filter: blur(10px);
}
.landing-hero { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 14px; }
.landing-icone {
  width: 88px; height: 88px; border-radius: 24px; background: rgba(255,255,255,0.06);
  border: 1px solid rgba(37,211,102,0.4); display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); box-shadow: 0 0 40px rgba(37,211,102,0.25);
}
.landing-badge {
  display: inline-block; background: rgba(37,211,102,0.12); border: 1px solid rgba(37,211,102,0.35); color: #6ee7a8;
  font-size: 0.7rem; font-weight: 700; padding: 5px 12px; border-radius: 20px; letter-spacing: 0.06em; text-transform: uppercase;
}
.landing-hero h1 { font-size: 2rem; font-weight: 800; margin: 8px 0 0; letter-spacing: -0.02em; color: #fff; }
.landing-sub { position: relative; font-size: 0.9rem; line-height: 1.55; color: rgba(255,255,255,0.65); max-width: 300px; margin: 6px 0 26px; }
.landing-botoes { position: relative; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 300px; }

.btn-primario {
  background: var(--wa-dark);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.tela-landing .btn-primario {
  background: linear-gradient(135deg, #25D366, #128C7E); color: #04211a; font-weight: 800;
  box-shadow: 0 8px 24px rgba(37,211,102,0.35); border-radius: 14px; padding: 15px;
}
.btn-secundario {
  background: var(--wa-surface);
  color: var(--wa-dark);
  border: 1.5px solid var(--wa-divider);
  padding: 13px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
}
.tela-landing .btn-secundario { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.15); color: #fff; backdrop-filter: blur(8px); border-radius: 14px; padding: 14px; }
.landing-rodape { position: relative; font-size: 0.75rem; color: rgba(255,255,255,0.4); }
.landing-rodape a { color: rgba(255,255,255,0.4); }

/* ===== FORMULÁRIOS (cadastro/login/config) ===== */
.tela-form {
  background: var(--wa-bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  padding: env(safe-area-inset-top, 0px) 0 40px;
}

.btn-voltar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  margin: 12px 0 0 12px;
  background: var(--wa-surface);
  border: 1px solid var(--wa-divider);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1.1rem;
  color: var(--wa-text);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.form-card {
  max-width: 420px;
  margin: 8px auto 0;
  padding: 12px 24px 24px;
}
.form-card-larga { max-width: 480px; }

.form-card h2 { font-size: 1.3rem; font-weight: 800; margin: 4px 0 4px; color: var(--wa-dark); }
.form-sub { font-size: 0.85rem; color: var(--wa-text-muted); margin: 0 0 20px; line-height: 1.45; }

.campo { margin-bottom: 15px; text-align: left; }
.campo label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wa-text-muted);
  margin-bottom: 6px;
}
.campo input, .campo select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--wa-divider);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  background: var(--wa-surface);
  color: var(--wa-text);
}
.campo input:focus, .campo select:focus { border-color: var(--wa-teal); box-shadow: 0 0 0 3px rgba(15, 122, 102, 0.12); }
.campo input:disabled { opacity: 0.6; }

.campo-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--wa-text-muted);
  margin-bottom: 18px;
  line-height: 1.4;
  cursor: pointer;
}
.campo-checkbox input { margin-top: 3px; flex-shrink: 0; }
.campo-checkbox a { color: var(--wa-teal); font-weight: 600; }

.form-msg {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 8px;
  margin: -4px 0 14px;
  border: 1px solid transparent;
}
.form-msg.erro { background: #FBEAE7; color: var(--wa-danger); border-color: #F0CFC8; }
.form-msg.ok { background: #E9F5F0; color: var(--wa-green); border-color: #CDE9DE; }

form button[type="submit"] {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: var(--wa-dark);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
form button[type="submit"]:disabled { opacity: 0.6; }

.btn-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--wa-teal);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 12px 0 0;
  cursor: pointer;
  text-align: center;
}

/* ===== Telas de conta (cadastro/login/esqueci senha) - visual dark tech,
   igual à landing. Escopado só nessas 3 telas (não afeta Config/Instalar,
   que continuam com o fundo claro de sempre). ===== */
.tela-form-dark {
  background: radial-gradient(circle at 30% 0%, #1a2f2b 0%, #0a1210 55%, #050807 100%) !important;
}
.tela-form-dark .btn-voltar {
  position: relative;
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.15);
  color: #fff;
  backdrop-filter: blur(8px);
  box-shadow: none;
  z-index: 1;
}
.tela-form-dark .form-card { position: relative; z-index: 1; }
.tela-form-dark .form-card h2 { color: #fff; }
.tela-form-dark .form-sub { color: rgba(255,255,255,0.55); }
.tela-form-dark .campo label { color: #6ee7a8; }
.tela-form-dark .campo input,
.tela-form-dark .campo select {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  backdrop-filter: blur(8px);
}
.tela-form-dark .campo input::placeholder { color: rgba(255,255,255,0.3); }
.tela-form-dark .campo input:focus,
.tela-form-dark .campo select:focus { border-color: rgba(37,211,102,0.6); box-shadow: 0 0 0 3px rgba(37,211,102,0.12); }
.tela-form-dark .campo-checkbox { color: rgba(255,255,255,0.55); }
.tela-form-dark .campo-checkbox a { color: #6ee7a8; }
.tela-form-dark form button[type="submit"] {
  background: linear-gradient(135deg, #25D366, #128C7E);
  color: #04211a;
  font-weight: 800;
  border-radius: 14px;
  padding: 15px;
  box-shadow: 0 8px 24px rgba(37,211,102,0.3);
}
.tela-form-dark .btn-link { color: #6ee7a8; }
.tela-form-dark .btn-link:last-of-type { color: rgba(255,255,255,0.4); }

/* 🆕 O aviso de sucesso/erro (.form-msg) não tinha ajuste pro tema escuro -
   ficava com o fundo claro padrão (quase branco), destoando muito do resto
   da tela escura. Usa o mesmo verde translúcido já usado em outros elementos
   dessas telas (badge da landing, links, etc.). */
.tela-form-dark .form-msg.ok { background: rgba(37,211,102,0.12); color: #6ee7a8; border-color: rgba(37,211,102,0.3); }
.tela-form-dark .form-msg.erro { background: rgba(255,59,48,0.12); color: #ff8a80; border-color: rgba(255,59,48,0.35); }

/* ===== CHAT ===== */
.tela-app {
  display: flex;
  flex-direction: column;
  background: var(--wa-chat-bg);
}

.app-bar {
  background: var(--wa-dark);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.app-bar-titulo { display: flex; flex-direction: column; }
.app-bar-nome { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.005em; }
.app-bar-usuario { font-size: 0.7rem; opacity: 0.75; display: flex; align-items: center; gap: 5px; }
.pulso-conectado {
  width: 6px; height: 6px; border-radius: 50%; background: var(--wa-green);
  box-shadow: 0 0 0 0 rgba(30, 138, 110, 0.5);
  animation: pulso 2.4s infinite;
  flex-shrink: 0;
}
@keyframes pulso {
  0% { box-shadow: 0 0 0 0 rgba(30, 138, 110, 0.4); }
  70% { box-shadow: 0 0 0 5px rgba(30, 138, 110, 0); }
  100% { box-shadow: 0 0 0 0 rgba(30, 138, 110, 0); }
}
@media (prefers-reduced-motion: reduce) { .pulso-conectado { animation: none; } }
.icon-btn { background: transparent; border: none; color: #fff; padding: 8px; border-radius: 50%; cursor: pointer; }
.icon-btn:active { background: rgba(255,255,255,0.12); }

.lista-mensagens { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 14px; }

.banner-onboarding {
  background: #FFF8E1;
  border-bottom: 1px solid #F5E0A3;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.banner-onboarding p { margin: 0; font-size: 0.82rem; color: #7A5B00; font-weight: 600; flex: 1; }
.banner-onboarding-botoes { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.btn-primario-mini {
  background: var(--wa-dark);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-fechar-mini { background: transparent; border: none; color: #7A5B00; font-size: 0.9rem; cursor: pointer; padding: 4px; opacity: 0.7; }
.ul-mensagens { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.bolha {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
  position: relative;
  animation: bolha-chega 0.15s ease-out;
}
@keyframes bolha-chega { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bolha { animation: none; } }
.bolha-recebida { align-self: flex-end; background: var(--wa-bubble-out); border-top-right-radius: 2px; }
.bolha-enviada { align-self: flex-start; background: var(--wa-surface); border-top-left-radius: 2px; }
.bolha-recebida::after {
  content: ''; position: absolute; top: 0; right: -7px; width: 10px; height: 12px;
  background: var(--wa-bubble-out); clip-path: polygon(0 0, 0% 100%, 100% 0);
}
.bolha-enviada::after {
  content: ''; position: absolute; top: 0; left: -7px; width: 10px; height: 12px;
  background: var(--wa-surface); clip-path: polygon(100% 0, 0% 0, 100% 100%);
}
.bolha-hora { display: flex; align-items: center; justify-content: flex-end; gap: 3px; font-size: 0.65rem; color: var(--wa-text-muted); margin-top: 3px; }
.bolha-check { color: var(--wa-teal); }

.estado-vazio { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; color: var(--wa-text-muted); padding: 40px; gap: 4px; }
.estado-vazio p { font-weight: 600; color: var(--wa-text); margin: 0; }
.estado-vazio span { font-size: 0.82rem; max-width: 240px; }

#overlay-flash {
  position: fixed;
  inset: 0;
  background: var(--wa-danger);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
}
#overlay-flash.ativo { animation: flash-tela 0.5s steps(1) 6; }
@keyframes flash-tela { 0%, 100% { opacity: 0; } 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { #overlay-flash.ativo { animation: none; } }

/* Barra de resposta: campo de texto ocupa quase toda a largura, botão de
   enviar pequeno e discreto no canto direito - igual ao WhatsApp. As regras
   abaixo são propositalmente explícitas (flex-grow/shrink/basis) pra NUNCA
   deixar o botão esticar, seja qual for o navegador/tela. */
.btn-reconhecer-alarme {
  flex-shrink: 0;
  margin: 0 12px 10px;
  padding: 13px 16px;
  background: var(--wa-danger);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  animation: pisca-alarme 1.1s infinite;
  box-shadow: 0 2px 10px rgba(255, 59, 48, 0.35);
}
@keyframes pisca-alarme {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(0.98); }
}
@media (prefers-reduced-motion: reduce) { .btn-reconhecer-alarme { animation: none; } }

.barra-resposta {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--wa-bg);
  border-top: 1px solid var(--wa-divider);
  flex-shrink: 0;
  width: 100%;
}
.barra-resposta input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 16px;
  border-radius: 24px;
  border: 1.5px solid var(--wa-divider);
  background: var(--wa-surface);
  font-size: 0.92rem;
  outline: none;
}
.barra-resposta input:focus { border-color: var(--wa-teal); }
.btn-enviar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  max-width: 44px;
  background: var(--wa-dark);
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ===== CONFIGURAÇÕES ===== */
.secao-config { margin-bottom: 28px; padding-bottom: 22px; border-bottom: 1px solid var(--wa-divider); }
.secao-config h3 { font-size: 0.92rem; font-weight: 800; margin: 0 0 14px; color: var(--wa-dark); }
.secao-perigo .btn-secundario, .secao-perigo .btn-perigo { width: 100%; margin-bottom: 8px; border-radius: 10px; padding: 12px; font-weight: 700; cursor: pointer; font-size: 0.9rem; }
.secao-perigo .btn-secundario { background: var(--wa-surface); border: 1.5px solid var(--wa-divider); color: var(--wa-text); }
.btn-perigo { background: #FBEAE7; color: var(--wa-danger); border: 1.5px solid #F0CFC8; }
.texto-explicativo { font-size: 0.8rem; color: var(--wa-text-muted); line-height: 1.45; margin: 6px 0 12px; }

.lista-sons { display: flex; flex-direction: column; gap: 8px; }
.opcao-som {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1.5px solid var(--wa-divider);
  border-radius: 10px;
  cursor: pointer;
  background: var(--wa-surface);
}
.opcao-som.selecionado { border-color: var(--wa-teal); background: var(--wa-surface-alt); }
.opcao-som-nome { font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 10px; color: var(--wa-text); }
.opcao-som button { background: none; border: 1px solid var(--wa-divider); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--wa-teal); }

.link-rodape { display: block; text-align: center; font-size: 0.8rem; color: var(--wa-text-muted); margin-top: 8px; }

/* Tela "Como instalar" */
#instalar-conteudo { text-align: left; font-size: 0.88rem; line-height: 1.6; }
#instalar-conteudo ol { padding-left: 20px; }
#instalar-conteudo li { margin-bottom: 10px; }
#instalar-conteudo .aviso-instalar { background: var(--wa-surface-alt); color: var(--wa-dark); border: 1px solid var(--wa-divider); padding: 10px 12px; border-radius: 8px; font-size: 0.82rem; margin-bottom: 16px; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--wa-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  z-index: 999;
  max-width: 85vw;
  text-align: center;
}

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