:root {
  --bg: #F7F9F8;
  --surface: #FFFFFF;
  --surface-2: #F1F4F2;
  --border: #E3E8E5;
  --text: #0C1210;
  --text-2: #4A5652;
  --brand: #059669;
  --brand-hover: #047857;
  --brand-soft: rgba(5, 150, 105, .09);
}

:root[data-theme="dark"] {
  --bg: #080B0A;
  --surface: #101514;
  --surface-2: #161E1C;
  --border: #1F2A27;
  --text: #ECF2EF;
  --text-2: #9BA8A3;
  --brand: #10B981;
  --brand-hover: #34D399;
  --brand-soft: rgba(16, 185, 129, .12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080B0A;
    --surface: #101514;
    --surface-2: #161E1C;
    --border: #1F2A27;
    --text: #ECF2EF;
    --text-2: #9BA8A3;
    --brand: #10B981;
    --brand-hover: #34D399;
    --brand-soft: rgba(16, 185, 129, .12);
  }
}

* { box-sizing: border-box; }

[x-cloak] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .titulo {
  letter-spacing: -0.02em;
  font-weight: 700;
}

a { color: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.transicao, button, input, select, textarea, .card, .chip {
  transition: background-color 180ms cubic-bezier(0,0,.2,1), border-color 180ms cubic-bezier(0,0,.2,1),
    color 180ms cubic-bezier(0,0,.2,1), box-shadow 180ms cubic-bezier(0,0,.2,1), transform 180ms cubic-bezier(0,0,.2,1);
}

/* ── Layout ────────────────────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
}

.sidebar-icone {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.ativo { background: var(--brand-soft); color: var(--brand); }
.nav-item i { width: 18px; text-align: center; }

.sidebar-rodape {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conteudo {
  margin-left: 220px;
  flex: 1;
  min-width: 0;
  padding: 24px 28px 80px;
}

/* ── Indicador de conexão ──────────────────────────────────────────────── */

.indicador-conexao {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  padding: 6px 10px;
  border-radius: 9999px;
  background: var(--surface-2);
}

.bolinha {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-2);
  flex-shrink: 0;
}

.bolinha.online {
  background: var(--brand);
  box-shadow: 0 0 0 0 var(--brand-soft);
  animation: pulso 2s infinite;
}

@keyframes pulso {
  0% { box-shadow: 0 0 0 0 var(--brand-soft); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ── Banner de agente parado ──────────────────────────────────────────── */

.banner-agente {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.banner-agente .icone {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}

/* ── Cards, inputs, botões ─────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

button { font-family: inherit; cursor: pointer; }

.btn {
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover { background: var(--surface-2); }

.btn-primario {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-primario:hover { background: var(--brand-hover); border-color: var(--brand-hover); }

.btn-primario:disabled, .btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn-perigo { color: #DC2626; border-color: #FCA5A5; }
.btn-perigo:hover { background: rgba(220,38,38,.08); }

.btn-icone {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2);
}
.btn-icone:hover { color: var(--text); background: var(--surface-2); }

/* ── Chips & pills ─────────────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chip.ativo { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip:hover:not(.ativo) { background: var(--surface-2); }

.pill {
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ── Interruptor (toggle) ──────────────────────────────────────────────── */

.interruptor {
  position: relative;
  width: 40px; height: 22px;
  border-radius: 9999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.interruptor::after {
  content: "";
  position: absolute;
  top: 1px; left: 1px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 180ms cubic-bezier(0,0,.2,1), background-color 180ms;
}
.interruptor.ativo { background: var(--brand); border-color: var(--brand); }
.interruptor.ativo::after { transform: translateX(18px); background: #fff; }

/* ── Labels e densidade de tabela ──────────────────────────────────────── */

.label-mini {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-2);
  font-weight: 700;
}

table.tabela-leads { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tabela-leads th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-2);
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tabela-leads td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.tabela-leads tbody tr:hover { background: var(--surface-2); cursor: pointer; }

/* ── Estado vazio ──────────────────────────────────────────────────────── */

.estado-vazio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  color: var(--text-2);
  text-align: center;
}
.estado-vazio i { font-size: 28px; color: var(--text-2); opacity: .6; }

/* ── Skeleton ──────────────────────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: brilho 1.4s ease infinite;
  border-radius: 8px;
}

@keyframes brilho {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ── Toasts ────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}
.toast.sucesso i { color: var(--brand); }
.toast.erro i { color: #DC2626; }

/* ── Drawer lateral ────────────────────────────────────────────────────── */

.drawer-fundo {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 60;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 61;
  overflow-y: auto;
}

/* ── Slider ────────────────────────────────────────────────────────────── */

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 9999px;
  padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--brand);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--brand);
}

/* ── Mapa de busca ─────────────────────────────────────────────────────── */

.pin-busca {
  width: 16px; height: 16px; border-radius: 50%;
  background: #10B981;
  border: 3px solid #fff;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, .55);
  animation: pulso-pin 2s infinite;
}

@keyframes pulso-pin {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); }
  70% { box-shadow: 0 0 0 14px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.barra-progresso {
  height: 6px;
  border-radius: 9999px;
  background: var(--surface-2);
  overflow: hidden;
}

.barra-progresso > div {
  height: 100%;
  background: var(--brand);
  border-radius: 9999px;
  transition: width .3s ease;
}

/* ── Responsivo ────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: 60px;
    top: auto;
    bottom: 0;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .sidebar-icone { display: none; }
  .sidebar-nav { flex-direction: row; padding: 6px; }
  .nav-item { flex-direction: column; font-size: 10px; padding: 6px; gap: 3px; }
  .nav-item span { white-space: nowrap; }
  .sidebar-rodape { display: none; }
  .conteudo { margin-left: 0; padding: 16px 16px 90px; }
  table.tabela-leads, table.tabela-leads thead { display: none; }
  .drawer { width: 100%; }
}
