@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #0e1a17;
  --surface: #142621;
  --surface-2: #1b322b;
  --surface-3: #233d34;
  --border: #274238;
  --accent: #3ddc97;
  --accent-dim: #2a8f66;
  --accent-warm: #f2a65a;
  --danger: #e5636b;
  --text: #eaf3ef;
  --text-muted: #8fa79e;
  --text-faint: #5f7d73;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 24px;
}
h2 {
  font-size: 16px;
  color: var(--text);
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Brand mark ---------- */

.marca {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.marca-ponto {
  position: relative;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.marca-ponto::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0.5;
  animation: pulso 2.4s ease-out infinite;
}

@keyframes pulso {
  0% {
    transform: scale(0.6);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

.marca-texto {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Auth pages (login / register) ---------- */

.pagina-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(
      circle at 15% 15%,
      rgba(61, 220, 151, 0.07),
      transparent 45%
    ),
    radial-gradient(
      circle at 85% 85%,
      rgba(242, 166, 90, 0.06),
      transparent 45%
    ),
    var(--bg);
}

.cartao {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
}

.cartao .marca {
  margin-bottom: 24px;
}

.subtitulo {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 24px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin: 16px 0 6px;
}

label:first-of-type {
  margin-top: 0;
}

input[type="email"],
input[type="password"],
input[type="text"],
select,
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-dim);
}

textarea {
  min-height: 90px;
  resize: vertical;
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-weight: 600;
  transition:
    background 0.15s ease,
    transform 0.05s ease;
}

button:active {
  transform: scale(0.98);
}

button[type="submit"],
.botao-primario,
#btnConectar,
#btnSalvarConfig {
  width: 100%;
  background: var(--accent);
  color: #06140f;
  margin-top: 20px;
}

button[type="submit"]:hover,
.botao-primario:hover,
#btnConectar:hover,
#btnSalvarConfig:hover {
  background: #4ee6a4;
}

.secundario {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.secundario:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- Botão Iniciar/Parar bot ---------- */

#btnIniciarBot {
  width: 100%;
  background: var(--accent);
  color: #06140f;
}

#btnIniciarBot:hover {
  background: #4ee6a4;
}

#btnIniciarBot.rodando {
  background: var(--danger);
  color: #2b0d0f;
}

#btnIniciarBot.rodando:hover {
  background: #ef7c82;
}

#btnIniciarBot:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* ---------- Indicador de estado do grupo ---------- */

.status-grupo {
  display: none;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin: 0 0 16px;
}

.status-grupo.fechado {
  display: block;
  background: rgba(242, 166, 90, 0.1);
  border: 1px solid rgba(242, 166, 90, 0.25);
  color: var(--accent-warm);
}

.status-grupo.aberto {
  display: block;
  background: rgba(61, 220, 151, 0.1);
  border: 1px solid rgba(61, 220, 151, 0.25);
  color: var(--accent);
}

/* ---------- Log de mensagens enviadas ---------- */

.lista-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.log-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.log-data {
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.log-texto {
  color: var(--text);
  flex: 1;
  min-width: 120px;
  overflow-wrap: anywhere;
}

.log-reacao {
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}

.erro {
  display: none;
  background: rgba(229, 99, 107, 0.1);
  border: 1px solid rgba(229, 99, 107, 0.3);
  color: var(--danger);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
}

.link-rodape {
  text-align: center;
  margin-top: 22px;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* ---------- App shell (dashboard) ---------- */

.app-shell {
  min-height: 100vh;
  display: flex;
}

/* Sidebar (desktop) / drawer (mobile) */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.18s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.btn-recolher {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-recolher:hover {
  color: var(--text);
  border-color: var(--text-faint);
}
.btn-recolher svg {
  transition: transform 0.18s ease;
}

.abas-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  flex: 1;
}

.aba-botao {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  text-align: left;
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
}

.aba-botao svg {
  flex-shrink: 0;
  width: 19px;
  height: 19px;
}

.aba-botao:hover {
  background: var(--surface-2);
  color: var(--text);
}

.aba-botao.ativa {
  background: var(--surface-3);
  color: var(--accent);
}

.aba-botao .rotulo {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-rodape {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.sidebar-rodape .secundario {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  margin: 0;
  justify-content: flex-start;
}

.sidebar-rodape .secundario svg {
  flex-shrink: 0;
  width: 19px;
  height: 19px;
}

/* Collapsed (icon rail) state — desktop only */

.sidebar.recolhida {
  width: var(--sidebar-w-collapsed);
}
.sidebar.recolhida .marca-texto,
.sidebar.recolhida .rotulo,
.sidebar.recolhida .sidebar-rodape .secundario span {
  display: none;
}
.sidebar.recolhida .sidebar-cabecalho {
  justify-content: center;
}
.sidebar.recolhida .btn-recolher svg {
  transform: rotate(180deg);
}
.sidebar.recolhida .aba-botao,
.sidebar.recolhida .sidebar-rodape .secundario {
  justify-content: center;
}

/* Main column */

.coluna-principal {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(14, 26, 23, 0.85);
  backdrop-filter: blur(6px);
  z-index: 30;
}

.topbar-esquerda {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.btn-menu {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar-titulo {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-badge.conectado {
  background: rgba(61, 220, 151, 0.12);
  color: var(--accent);
}
.status-badge.conectado::before {
  background: var(--accent);
}

.status-badge.desconectado {
  background: rgba(229, 99, 107, 0.1);
  color: var(--danger);
}
.status-badge.desconectado::before {
  background: var(--danger);
}

.status-badge.pendente {
  background: rgba(242, 166, 90, 0.12);
  color: var(--accent-warm);
}
.status-badge.pendente::before {
  background: var(--accent-warm);
  animation: pulso-badge 1.1s ease-in-out infinite;
}

@keyframes pulso-badge {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.conteudo {
  flex: 1;
  padding: 24px 20px 48px;
  max-width: 720px;
  width: 100%;
}

.aba-painel {
  display: none;
}
.aba-painel.ativa {
  display: block;
}

.painel-cabecalho {
  margin-bottom: 20px;
}
.painel-cabecalho p {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-top: 4px;
}

.bloco {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
}

/* ---------- Connection tab / QR ---------- */

.estado-conexao {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 8px 4px;
}

.icone-estado {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-faint);
}

.icone-estado.conectado {
  color: var(--accent);
  border-color: rgba(61, 220, 151, 0.35);
}

.estado-conexao h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 17px;
  margin-bottom: 4px;
}

.estado-conexao p {
  color: var(--text-muted);
  font-size: 13.5px;
  max-width: 300px;
  margin-bottom: 20px;
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.qr-moldura {
  background: #fff;
  padding: 14px;
  border-radius: var(--radius);
  width: 208px;
  height: 208px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-moldura img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-barra {
  width: 208px;
  height: 3px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.qr-barra-preenchimento {
  height: 100%;
  width: 100%;
  background: var(--accent-warm);
  transform-origin: left;
  animation: contagem-regressiva linear forwards;
}

@keyframes contagem-regressiva {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.qr-tentativas {
  font-size: 12px;
  color: var(--text-faint);
}

.aviso-tempo-esgotado {
  display: none;
  font-size: 13px;
  color: var(--accent-warm);
  background: rgba(242, 166, 90, 0.1);
  border: 1px solid rgba(242, 166, 90, 0.25);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

/* ---------- Table (Cobranças) ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 12px;
  text-transform: none;
}

tbody tr:last-child td {
  border-bottom: none;
}

.tabela-scroll {
  overflow-x: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

/* ---------- Drawer backdrop (mobile) ---------- */

.fundo-drawer {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 35;
}

.fundo-drawer.visivel {
  display: block;
}

/* ---------- Cards de resumo do Financeiro ---------- */

.grade-financeiro {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.cartao-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  flex: 1 1 170px;
  min-width: 150px;
}

.rotulo-stat {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.valor-stat {
  font-size: 26px;
  font-weight: 700;
}

.valor-stat-texto {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-warm);
  line-height: 1.4;
  text-transform: capitalize;
}

.cartao-pagar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cartao-pagar button {
  width: 100%;
  background: var(--accent);
  color: #06140f;
}

.cartao-pagar button:hover {
  background: #4ee6a4;
}

/* ---------- Modal de bloqueio por falta de pagamento ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-caixa {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--danger);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.modal-caixa p {
  font-size: 13.5px;
  line-height: 1.5;
}

/* ---------- Bot Premium: banner + toggle ---------- */

.banner-premium {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, rgba(61, 220, 151, 0.16), rgba(242, 166, 90, 0.1));
  border: 1px solid rgba(61, 220, 151, 0.3);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.banner-premium-texto {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.banner-premium-texto strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 16px;
  color: var(--text);
}

/* Banner promocional (usuário ainda não é premium) — mais discreto,
   com contorno tracejado, pra não parecer que o recurso já está ativo. */
.banner-premium-promo {
  background: var(--surface);
  border: 1px dashed var(--border);
}

.banner-premium-promo .banner-premium-texto span {
  color: var(--text-muted);
}

/* Estado "ligado": precisa chamar bem mais atenção do que o normal, pra
   lembrar a pessoa de deixar o WhatsApp aberto e monitorado. */
.banner-premium-ligado {
  background: linear-gradient(135deg, rgba(61, 220, 151, 0.28), rgba(242, 166, 90, 0.22));
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(61, 220, 151, 0.15);
}

.banner-premium-ligado .banner-premium-texto strong {
  color: var(--accent);
}

.banner-premium-ligado .banner-premium-texto span {
  color: var(--text);
  font-weight: 600;
}

.toggle {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-trilho {
  width: 46px;
  height: 26px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-block;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.toggle-bolinha {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.18s ease, background 0.18s ease;
}

.toggle input:checked + .toggle-trilho {
  background: rgba(61, 220, 151, 0.25);
  border-color: var(--accent-dim);
}

.toggle input:checked + .toggle-trilho .toggle-bolinha {
  transform: translateX(20px);
  background: var(--accent);
}

/* ---------- Bot Premium: prévia da mensagem ---------- */

.preview-mensagem {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 13px;
}

.preview-mensagem-rotulo {
  font-size: 11.5px;
  color: var(--text-faint);
}

/* ---------- Bot Premium: linhas de rota ---------- */

.linha-rota {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.linha-rota .rota-cidade {
  flex: 1;
  min-width: 0;
}

.linha-rota .rota-bairro {
  flex: 1;
  min-width: 0;
}

.botao-remover-rota {
  flex-shrink: 0;
  width: 42px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.botao-remover-rota:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- Planos ---------- */

.grade-planos {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.cartao-plano-v2 {
  position: relative;
  flex: 1 1 220px;
  min-width: 220px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.15s ease;
}

.cartao-plano-v2.selecionado {
  border-color: var(--accent-dim);
}

.cartao-plano-cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cartao-plano-cabecalho h4 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 16px;
}

.etiqueta-plano-atual {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(61, 220, 151, 0.12);
  border: 1px solid rgba(61, 220, 151, 0.3);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.etiqueta-recomendado {
  position: absolute;
  top: -10px;
  right: 16px;
  font-size: 11px;
  font-weight: 600;
  color: #06140f;
  background: var(--accent-warm);
  border-radius: 999px;
  padding: 3px 10px;
}

.cartao-plano-preco {
  font-family: "Space Grotesk", sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin: 12px 0 14px;
}

.cartao-plano-preco-mes {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.cartao-plano-preco-detalhe {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  margin-top: 2px;
}

.cartao-plano-lista {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cartao-plano-lista li {
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 20px;
  position: relative;
}

.cartao-plano-lista li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Responsive: mobile ---------- */

@media (max-width: 780px) {
  .btn-recolher {
    display: none;
  }
  .btn-menu {
    display: flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 250px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.35);
  }

  .sidebar.aberta {
    transform: translateX(0);
  }
  .sidebar.recolhida {
    width: 250px;
  }
  .sidebar.recolhida .marca-texto,
  .sidebar.recolhida .rotulo,
  .sidebar.recolhida .sidebar-rodape .secundario span {
    display: inline;
  }
  .sidebar.recolhida .aba-botao,
  .sidebar.recolhida .sidebar-rodape .secundario {
    justify-content: flex-start;
  }

  .conteudo {
    padding: 18px 16px 40px;
  }
  .topbar {
    padding: 0 14px;
  }
  .banner-premium {
    flex-wrap: wrap;
  }
  .grade-planos {
    flex-direction: column;
  }
}