@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);
}

.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; }

/* ---------- 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; }
}
