/* ZeraSync 2 — componentes. Sempre variáveis de base.css, nunca cor solta. */

/* ------------------------------------------------------------------ botões */
.btn {
  --b-bg: var(--zera-forte); --b-txt: #fff; --b-borda: transparent; --b-hover: #3c5570;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--raio);
  background: var(--b-bg); color: var(--b-txt); border: 1px solid var(--b-borda);
  font-weight: 600; font-size: 13.5px; white-space: nowrap; user-select: none;
  transition: background var(--t-rapido), box-shadow var(--t-rapido), transform var(--t-rapido), border-color var(--t-rapido);
}
.btn:hover { background: var(--b-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--anel-foco); }
.btn[disabled], .btn.ocupado { opacity: 0.55; pointer-events: none; }
.btn svg { flex: none; }
.btn-p { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--raio-p); }
.btn-g { height: 42px; padding: 0 18px; font-size: 14.5px; }
.btn-wa { --b-bg: var(--wa); --b-txt: var(--wa-tinta); --b-hover: #1fc35c; }
.btn-ia { --b-bg: var(--ia-grad); --b-txt: #fff; --b-hover: var(--ia-grad); box-shadow: 0 4px 14px rgba(124, 92, 255, 0.35); }
.btn-ia:hover { filter: brightness(1.06); }
.btn-sec { --b-bg: var(--sup); --b-txt: var(--txt); --b-borda: var(--linha-forte); --b-hover: var(--sup-2); }
.btn-fantasma { --b-bg: transparent; --b-txt: var(--txt-2); --b-hover: var(--hover); }
.btn-perigo { --b-bg: color-mix(in srgb, var(--erro) 86%, #000); --b-hover: color-mix(in srgb, var(--erro) 74%, #000); } /* branco 5,6:1 */
html[data-theme="dark"] .btn-perigo { --b-bg: color-mix(in srgb, var(--erro) 70%, #000); --b-hover: color-mix(in srgb, var(--erro) 60%, #000); } /* o --erro do escuro dava 3,0:1 */
.btn-perigo-sec { --b-bg: transparent; --b-txt: var(--erro-forte); --b-borda: var(--erro-bg); --b-hover: var(--erro-bg); }
.btn-icone { width: 36px; padding: 0; }
.btn-icone.btn-p { width: 30px; }
.btn-bloco { width: 100%; }
html[data-theme="dark"] .btn { --b-hover: #6c8cab; }
html[data-theme="dark"] .btn-sec { --b-hover: var(--sup-2); }
html[data-theme="dark"] .btn-fantasma { --b-hover: var(--hover); }

.botao-icone {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--raio);
  border: 0; background: transparent; color: var(--txt-2); transition: background var(--t-rapido), color var(--t-rapido);
}
.botao-icone:hover { background: var(--hover); color: var(--txt); }
.botao-icone.ativo { background: var(--ativo); color: var(--zera-txt); }

/* ------------------------------------------------------------------ campos */
.campo { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo > label, .rotulo { font-size: 12.5px; font-weight: 600; color: var(--txt-2); }
.campo .ajuda { font-size: 12px; color: var(--txt-3); }
.campo .erro-campo { font-size: 12px; color: var(--erro-forte); font-weight: 500; }
.entrada, .selecao, .area {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--raio);
  background: var(--sup); border: 1px solid var(--linha-forte); color: var(--txt);
  transition: border-color var(--t-rapido), box-shadow var(--t-rapido), background var(--t-rapido);
}
.area { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.entrada::placeholder, .area::placeholder { color: var(--txt-3); }
.entrada:hover, .selecao:hover, .area:hover { border-color: var(--txt-3); }
.entrada:focus, .selecao:focus, .area:focus { outline: none; border-color: var(--zera); box-shadow: var(--anel-foco); }
.entrada.invalida, .area.invalida { border-color: var(--erro); }
.entrada-p { height: 32px; font-size: 13px; border-radius: var(--raio-p); }
.selecao { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23677585' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }

.busca { position: relative; display: flex; align-items: center; }
.busca > svg { position: absolute; left: 11px; color: var(--txt-3); pointer-events: none; }
.busca > .entrada { padding-left: 34px; background: var(--afundado); border-color: transparent; }
.busca > .entrada:focus { background: var(--sup); border-color: var(--zera); }

/* interruptor */
.interruptor { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.interruptor input { position: absolute; opacity: 0; pointer-events: none; }
.interruptor .trilho-int { width: 36px; height: 20px; border-radius: 999px; background: var(--linha-forte); position: relative; transition: background var(--t-estado); flex: none; }
.interruptor .trilho-int::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--t-estado); }
.interruptor input:checked + .trilho-int { background: var(--wa-forte); }
.interruptor input:checked + .trilho-int::after { transform: translateX(16px); }
.interruptor input:focus-visible + .trilho-int { box-shadow: var(--anel-foco); }

/* ------------------------------------------------------------------ abas */
.abas { display: flex; gap: 2px; padding: 3px; background: var(--afundado); border-radius: 11px; overflow-x: auto; scrollbar-width: none; }
.abas::-webkit-scrollbar { display: none; }
.aba {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 8px;
  border: 0; background: transparent; color: var(--txt-2); font-weight: 600; font-size: 13px; white-space: nowrap;
  transition: background var(--t-rapido), color var(--t-rapido), box-shadow var(--t-rapido);
}
.aba:hover { color: var(--txt); }
.aba[aria-selected="true"] { background: var(--sup); color: var(--txt); box-shadow: var(--sombra-1); }
.aba .contador { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--zera-suave); color: var(--zera-txt); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
html[data-theme="dark"] .aba .contador:not(.verde):not(.violeta) { color: var(--zera); } /* o verde e o violeta mantêm o texto deles (o azul-aço sumia no verde) */
.aba .contador.verde { background: var(--wa); color: var(--wa-tinta); }
.aba .contador.violeta { background: var(--ia-suave); color: var(--ia-forte); }

/* abas sublinhadas (dentro de painel) */
.abas-linha { display: flex; gap: 18px; border-bottom: 1px solid var(--linha); }
.abas-linha .aba { background: none; border-radius: 0; padding: 0 2px; height: 38px; box-shadow: none; border-bottom: 2px solid transparent; }
.abas-linha .aba[aria-selected="true"] { border-bottom-color: var(--zera); box-shadow: none; }

/* ------------------------------------------------------------------ pílulas e chips */
.pilula {
  --p-cor: var(--zera); --p-bg: var(--zera-suave); --p-txt: var(--zera-forte);
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px 0 8px; border-radius: 999px;
  background: var(--p-bg); color: var(--p-txt); font-size: 12px; font-weight: 600; white-space: nowrap; max-width: 100%;
}
.pilula::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--p-cor); flex: none; }
.pilula.sem-ponto::before { display: none; }
.pilula .cortar { max-width: 140px; }
.pilula-p { height: 19px; font-size: 11px; padding: 0 7px; }
/* 12 cores de etiqueta: fundo suave + texto forte (AA) */
.cor-azul     { --p-cor: #3b82f6; --p-bg: rgba(59,130,246,.13);  --p-txt: #1d4ed8; }
.cor-verde    { --p-cor: #16a34a; --p-bg: rgba(22,163,74,.13);   --p-txt: #146c36; }
.cor-amarelo  { --p-cor: #eab308; --p-bg: rgba(234,179,8,.18);   --p-txt: #854d0e; }
.cor-laranja  { --p-cor: #f97316; --p-bg: rgba(249,115,22,.14);  --p-txt: #b4430c; }
.cor-vermelho { --p-cor: #ef4444; --p-bg: rgba(239,68,68,.13);   --p-txt: #b91c1c; }
.cor-rosa     { --p-cor: #ec4899; --p-bg: rgba(236,72,153,.13);  --p-txt: #be185d; }
.cor-roxo     { --p-cor: #a855f7; --p-bg: rgba(168,85,247,.13);  --p-txt: #7e22ce; }
.cor-violeta  { --p-cor: #7c5cff; --p-bg: rgba(124,92,255,.13);  --p-txt: #5b3fd6; }
.cor-ciano    { --p-cor: #06b6d4; --p-bg: rgba(6,182,212,.14);   --p-txt: #0e7490; }
.cor-teal     { --p-cor: #14b8a6; --p-bg: rgba(20,184,166,.14);  --p-txt: #0f766e; }
.cor-cinza    { --p-cor: #64748b; --p-bg: rgba(100,116,139,.14); --p-txt: #475569; }
.cor-marrom   { --p-cor: #a16207; --p-bg: rgba(161,98,7,.14);    --p-txt: #854d0e; }
html[data-theme="dark"] .pilula { --p-txt: color-mix(in srgb, var(--p-cor) 72%, white); --p-bg: color-mix(in srgb, var(--p-cor) 20%, transparent); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 7px;
  background: var(--afundado); color: var(--txt-2); font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.chip svg { width: 13px; height: 13px; }
.chip.botao { cursor: pointer; border-color: var(--linha); background: var(--sup); }
.chip.botao:hover { border-color: var(--linha-forte); }
.chip-ia { background: var(--ia-suave); color: var(--ia-forte); }
.chip-wa { background: var(--wa-suave); color: var(--wa-forte); }
.chip-alerta { background: var(--alerta-bg); color: var(--alerta-forte); }
.chip-erro { background: var(--erro-bg); color: var(--erro-forte); }
.chip-ok { background: var(--ok-bg); color: var(--ok-forte); }

/* cronômetro de espera (SLA) */
.espera { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums; background: var(--afundado); color: var(--txt-2); }
.espera svg { width: 12px; height: 12px; }
.espera.atencao { background: var(--alerta-bg); color: var(--alerta-forte); }
.espera.estourou { background: var(--erro-bg); color: var(--erro-forte); }

/* selo / contador redondo */
.selo { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--wa); color: var(--wa-tinta); }
.selo.cinza { background: var(--afundado); color: var(--txt-2); }
.selo.violeta { background: var(--ia); color: #fff; }

/* ------------------------------------------------------------------ avatar */
.avatar {
  --tam: 40px; position: relative; flex: none; width: var(--tam); height: var(--tam); border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 650; font-size: calc(var(--tam) * 0.36);
  letter-spacing: 0.01em; user-select: none; background: var(--zera);
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar .canal { position: absolute; right: -2px; bottom: -2px; width: calc(var(--tam) * 0.38); height: calc(var(--tam) * 0.38); min-width: 14px; min-height: 14px; border-radius: 50%; background: var(--wa); border: 2px solid var(--sup); display: grid; place-items: center; color: #fff; }
.avatar .canal svg { width: 60%; height: 60%; }
.avatar .presenca { position: absolute; right: 0; bottom: 0; width: 28%; height: 28%; min-width: 9px; min-height: 9px; border-radius: 50%; border: 2px solid var(--sup); background: var(--txt-3); }
.avatar .presenca.disponivel { background: var(--wa); }
.avatar .presenca.pausa { background: var(--alerta); }
.avatar .presenca.ausente { background: #9aa5b1; }
.avatar.ia-ativa { box-shadow: 0 0 0 2px var(--sup), 0 0 0 4px var(--ia); animation: pulso-ia 2.4s ease-in-out infinite; }
.pilha-avatares { display: inline-flex; }
.pilha-avatares .avatar { box-shadow: 0 0 0 2px var(--sup); }
.pilha-avatares .avatar + .avatar { margin-left: -8px; }

/* ------------------------------------------------------------------ cartão, painel */
.cartao { background: var(--sup); border: 1px solid var(--linha); border-radius: var(--raio-c); box-shadow: var(--sombra-1); }
.cartao-cab { display: flex; align-items: center; gap: 8px; padding: 14px 16px 0; }
.cartao-cab h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--txt-3); font-weight: 700; }
.cartao-corpo { padding: 12px 16px 16px; }
.par { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13.5px; }
.par > :first-child { color: var(--txt-3); }
.par > :last-child { font-weight: 600; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* KPI */
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .rotulo-kpi { font-size: 12px; color: var(--txt-3); font-weight: 600; }
.kpi .valor-kpi { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .detalhe-kpi { font-size: 12px; color: var(--txt-2); }
.kpi.alerta .valor-kpi { color: var(--alerta-forte); }
.kpi.erro .valor-kpi { color: var(--erro-forte); }

/* barra de carga (capacidade) */
.carga { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--txt-2); font-variant-numeric: tabular-nums; }
.carga .trilho-carga { flex: 1; height: 6px; border-radius: 999px; background: var(--linha); overflow: hidden; min-width: 40px; } /* --afundado sumia no tema escuro */
.carga .trilho-carga > i { display: block; height: 100%; border-radius: 999px; background: var(--wa-forte); transition: width var(--t-estado); }
.carga.media .trilho-carga > i { background: var(--alerta); }
.carga.cheia .trilho-carga > i { background: var(--erro); }

/* ------------------------------------------------------------------ menu suspenso / popover */
.menu {
  position: fixed; z-index: 85; min-width: 200px; /* acima de gaveta (75) e modal (80), abaixo de dica (90) e toast (100) */ max-width: 320px; max-height: min(420px, 70vh); overflow: auto;
  padding: 6px; background: var(--sup); border: 1px solid var(--linha); border-radius: 12px; box-shadow: var(--sombra-2);
  animation: surgir var(--t-entrada);
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px; border: 0; border-radius: 8px; background: none; text-align: left; color: var(--txt); font-size: 13.5px; }
.menu-item:hover, .menu-item.foco { background: var(--hover); }
.menu-item .atalho { margin-left: auto; color: var(--txt-3); font-size: 11.5px; }
.menu-item.perigo { color: var(--erro-forte); }
.menu-item[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--zera-txt); font-weight: 700; }
.menu-sep { height: 1px; background: var(--linha); margin: 5px 4px; }
.menu-titulo { padding: 6px 10px 4px; font-size: 11px; font-weight: 700; color: var(--txt-3); text-transform: uppercase; letter-spacing: 0.06em; }

/* tooltip (data-dica) */
[data-dica] { position: relative; }
.dica { position: fixed; z-index: 90; padding: 5px 9px; border-radius: 7px; background: #0f1720; color: #fff; font-size: 12px; font-weight: 500; pointer-events: none; white-space: nowrap; box-shadow: var(--sombra-2); animation: aparecer 120ms; }

/* ------------------------------------------------------------------ modal / gaveta */
.fundo-modal { position: fixed; inset: 0; z-index: 80; background: rgba(9, 14, 20, 0.48); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 20px; animation: aparecer 160ms; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--sup); border-radius: var(--raio-g); box-shadow: var(--sombra-3); animation: surgir var(--t-entrada); overflow: hidden; }
.modal.largo { width: min(760px, 100%); }
.modal.medio { width: min(600px, 100%); }
.modal-cab { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.modal-cab h2 { flex: 1; }
.modal-corpo { padding: 12px 20px 18px; overflow: auto; }
.modal-rodape { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--linha); background: var(--sup-2); }
.gaveta { position: fixed; top: 0; right: 0; bottom: 0; z-index: 75; width: min(460px, 100vw); background: var(--sup); box-shadow: var(--sombra-3); display: flex; flex-direction: column; animation: deslizar-gaveta var(--t-entrada); }
@keyframes deslizar-gaveta { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------------ toasts */
#toasts { position: fixed; z-index: 100; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
/* celular: o aviso fica acima da barra de baixo (60 px), sem cobrir os rótulos do menu */
@media (max-width: 767px) { #toasts { bottom: calc(60px + 12px + env(safe-area-inset-bottom)); } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; min-width: 260px; max-width: min(560px, calc(100vw - 32px)); padding: 11px 14px; border-radius: 12px; background: #16202b; color: #fff; box-shadow: var(--sombra-3); font-size: 13.5px; animation: surgir var(--t-entrada); }
.toast .acao-toast { margin-left: auto; border: 0; background: rgba(255,255,255,.12); color: #fff; font-weight: 700; height: 28px; padding: 0 10px; border-radius: 7px; }
.toast .acao-toast:hover { background: rgba(255,255,255,.2); }
.toast.ok { border-left: 4px solid var(--wa); }
.toast.erro { border-left: 4px solid var(--erro); }
.toast.alerta { border-left: 4px solid var(--alerta); }
.toast.ia { border-left: 4px solid var(--ia); }
html[data-theme="dark"] .toast { background: #233038; }

/* ------------------------------------------------------------------ estados */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--afundado) 0%, var(--sup-2) 50%, var(--afundado) 100%); background-size: 640px 100%; animation: brilho-skeleton 1.2s linear infinite; }
.vazio { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 48px 24px; color: var(--txt-2); }
.vazio .simbolo { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--zera-suave); color: var(--zera-txt); margin-bottom: 4px; }
html[data-theme="dark"] .vazio .simbolo { color: var(--zera); }
.vazio h3 { color: var(--txt); font-size: 16px; }
.vazio p { max-width: 380px; font-size: 13.5px; }
.estado-erro .simbolo { background: var(--erro-bg); color: var(--erro-forte); }

/* ------------------------------------------------------------------ tabela */
.tabela { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tabela th { text-align: left; font-size: 12px; font-weight: 700; color: var(--txt-3); padding: 10px 12px; border-bottom: 1px solid var(--linha); background: var(--sup-2); position: sticky; top: 0; z-index: 1; }
.tabela td { padding: 10px 12px; border-bottom: 1px solid var(--linha); vertical-align: middle; }
.tabela tbody tr:hover td { background: var(--hover); }
.tabela tbody tr.clicavel { cursor: pointer; }

/* teclas */
kbd { font-family: var(--fonte); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--linha-forte); border-bottom-width: 2px; background: var(--sup); color: var(--txt-2); }

/* paleta de comandos (Ctrl+K) */
.paleta { width: min(640px, 100%); align-self: start; margin-top: 12vh; }
.paleta .busca .entrada { height: 50px; font-size: 15px; border-radius: 0; background: transparent; border: 0; border-bottom: 1px solid var(--linha); box-shadow: none; padding-left: 44px; }
.paleta .busca > svg { left: 16px; }
.paleta .resultados { max-height: 52vh; overflow: auto; padding: 6px; }

/* ------------------------------------------------------------------ movimento dos componentes */
/* reflexo que passa no botão principal (a assinatura do login aprovado em junho) */
.btn, .btn-wa, .btn-ia { position: relative; overflow: hidden; isolation: isolate; }
.btn::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 40%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent); transform: translateX(-120%) skewX(-18deg); pointer-events: none; z-index: -1; }
.btn:hover::after { animation: brilho-passa 700ms ease; }
.btn-sec::after, .btn-fantasma::after, .btn-perigo-sec::after { display: none; }
.btn:not(.btn-sec):not(.btn-fantasma):not(.btn-perigo-sec):hover { box-shadow: 0 6px 18px -6px rgba(70, 97, 124, .55); }
.btn-wa:hover { box-shadow: 0 6px 18px -6px rgba(18, 140, 75, .55) !important; }
.btn-ia { background-size: 200% 200% !important; animation: degrade-vivo 6s ease infinite; }
/* cartões e itens clicáveis sobem um fio no hover */
.cartao.clicavel, .clicavel-sobe { transition: transform var(--t-estado), box-shadow var(--t-estado), border-color var(--t-estado); }
.cartao.clicavel:hover, .clicavel-sobe:hover { transform: translateY(-2px); box-shadow: var(--sombra-2); }
/* selo/contador que mudou dá um pulo */
.selo, .aba .contador { transition: transform var(--t-rapido); }
/* avatar com foto entra suave */
.avatar img { animation: aparecer 260ms ease-out; }
/* modal e gaveta: entrada com escala sutil */
.modal { animation: entrada-modal 300ms cubic-bezier(.16, 1, .3, 1); }
@keyframes entrada-modal { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

/* cabeçalho do menu do avatar: foto + nome, abre o perfil */
.menu-perfil { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px 10px; border: 0; background: none; text-align: left; border-radius: 10px; color: var(--txt); min-width: 0; }
.menu-perfil:hover { background: var(--hover); }
.menu-perfil b { display: block; font-size: 14px; }
