/* MindFlux IA — identidade visual (brandbook): azul elétrico #2563EB, roxo neural #7C3AED, azul-escuro #0F172A,
   ciano-fluxo #06B6D4, cinza-neblina #F3F4F6. Títulos em Montserrat, texto em Inter. */
:root {
  --bg: #0F172A;
  --bg-deep: #0A1020;
  --panel: rgba(21, 32, 58, .78);
  --panel-solid: #15203A;
  --panel2: #1B2A4A;
  --line: #27395F;
  --text: #EAF0FC;
  --muted: #93A4C8;
  --primary: #2563EB;
  --primary-h: #1D4ED8;
  --violet: #7C3AED;
  --accent: #06B6D4;
  --grad: linear-gradient(135deg, #2563EB 0%, #7C3AED 100%);
  --grad-soft: linear-gradient(135deg, rgba(37, 99, 235, .22), rgba(124, 58, 237, .22));
  --glow: 0 0 0 1px rgba(124, 58, 237, .25), 0 8px 30px rgba(37, 99, 235, .25);
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 14px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-title: Montserrat, Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg-deep); color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
/* luzes de fundo: o "fluxo" azul → roxo, fixas atrás de tudo */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(900px 600px at 8% -10%, rgba(37, 99, 235, .28), transparent 60%),
    radial-gradient(800px 600px at 100% 10%, rgba(124, 58, 237, .22), transparent 60%),
    radial-gradient(700px 500px at 50% 120%, rgba(6, 182, 212, .14), transparent 60%),
    linear-gradient(180deg, #0F172A 0%, #0A1020 100%);
}
h1, h2, h3 { margin: 0 0 12px; font-family: var(--font-title); letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; } h2 { font-size: 19px; font-weight: 700; } h3 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
::selection { background: rgba(124, 58, 237, .45); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #38507f; }

/* Layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: linear-gradient(180deg, rgba(21, 32, 58, .92), rgba(15, 23, 42, .92));
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { font-family: var(--font-title); font-weight: 800; font-size: 20px; padding: 4px 10px 16px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-logo { display: block; height: 30px; width: auto; margin: 4px 8px 18px; filter: drop-shadow(0 0 14px rgba(37, 99, 235, .35)); }
.nav button {
  width: 100%; text-align: left; background: none; border: 0; color: var(--muted); padding: 10px 12px; border-radius: 10px;
  cursor: pointer; font: inherit; font-weight: 500; transition: background .18s, color .18s, transform .18s, box-shadow .18s;
}
.nav button:hover { background: rgba(124, 58, 237, .14); color: var(--text); transform: translateX(2px); }
.nav button.active { background: var(--grad); color: #fff; box-shadow: var(--glow); }
.side .spacer { flex: 1; }
.main { padding: 28px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }

/* entrada suave das telas */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
#view > * { animation: rise .45s cubic-bezier(.2, .7, .2, 1) both; }
#view > *:nth-child(2) { animation-delay: .05s; } #view > *:nth-child(3) { animation-delay: .1s; } #view > *:nth-child(4) { animation-delay: .15s; }

/* Components */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  backdrop-filter: blur(8px); box-shadow: 0 6px 24px rgba(2, 6, 23, .35);
  transition: border-color .2s, box-shadow .25s, transform .2s;
}
.card:hover { border-color: rgba(124, 58, 237, .45); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.grid > .card { transform-style: preserve-3d; will-change: transform; }
.grid > .card.tilting { box-shadow: 0 18px 44px rgba(37, 99, 235, .28), 0 0 0 1px rgba(124, 58, 237, .4); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; background: rgba(10, 16, 32, .7); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font: inherit; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #5f7199; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .28); }
textarea { min-height: 150px; resize: vertical; }
button.btn {
  background: var(--grad); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px;
  font: inherit; font-weight: 600; cursor: pointer; position: relative;
  transition: transform .15s, box-shadow .2s, filter .2s;
}
button.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(37, 99, 235, .4); filter: brightness(1.08); }
button.btn:active { transform: translateY(0); }
button.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
button.btn.ghost { background: rgba(10, 16, 32, .35); border: 1px solid var(--line); color: var(--text); }
button.btn.ghost:hover { background: rgba(124, 58, 237, .16); border-color: rgba(124, 58, 237, .5); box-shadow: none; }
button.btn.danger { background: transparent; border: 1px solid var(--bad); color: #fca5a5; }
button.btn.danger:hover { background: var(--bad); color: #fff; box-shadow: none; }
.badge { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line); }
.badge.connected { color: var(--ok); border-color: rgba(34, 197, 94, .6); background: rgba(34, 197, 94, .08); }
.badge.connecting, .badge.qr { color: var(--warn); border-color: rgba(245, 158, 11, .6); background: rgba(245, 158, 11, .08); }
.badge.disconnected { color: var(--muted); }
.switch { display: flex; gap: 8px; align-items: center; cursor: pointer; color: var(--text); font-size: 14px; margin: 0; }
.switch input { width: auto; accent-color: var(--primary); }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

/* QR do WhatsApp com moldura de fluxo animada */
@property --a { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
.qr-box { background: #fff; border-radius: 14px; padding: 8px; width: fit-content; position: relative; isolation: isolate; }
.qr-box::before {
  content: ''; position: absolute; inset: -3px; border-radius: 17px; z-index: -1;
  background: conic-gradient(from var(--a), #2563EB, #7C3AED, #06B6D4, #2563EB);
  animation: spin 4s linear infinite; filter: blur(.3px);
}
.qr-box::after { content: ''; position: absolute; inset: 0; border-radius: 14px; background: #fff; z-index: -1; }
@keyframes spin { to { --a: 360deg; } }
.qr-box img { display: block; width: 240px; height: 240px; position: relative; }

/* Auth / página inicial */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; }
.auth-card { width: 100%; max-width: 400px; position: relative; z-index: 1; background: rgba(17, 27, 50, .72); backdrop-filter: blur(14px); box-shadow: 0 20px 60px rgba(2, 6, 23, .55), 0 0 0 1px rgba(124, 58, 237, .2); }
.auth-card h2 { margin: 0; font-size: 21px; }
.auth-card .brand-logo { height: 34px; margin: 0 0 4px; }
.auth-card .auth-brand { display: none; }
.auth-wrap.landing { grid-template-columns: minmax(0, 540px) minmax(0, 400px); gap: 64px; justify-content: center; align-items: center; }
.hero { position: relative; z-index: 1; }
.hero > *:not(.hero-3d) { position: relative; z-index: 1; }
.hero .brand-logo { height: 40px; margin: 0 0 22px; }
.hero h1 { font-size: 36px; line-height: 1.12; margin: 8px 0 14px; font-weight: 800; }
.hero h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-list { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 11px; }
.hero-list li { padding-left: 28px; position: relative; color: var(--text); animation: rise .6s both; }
.hero-list li:nth-child(1) { animation-delay: .15s; } .hero-list li:nth-child(2) { animation-delay: .25s; } .hero-list li:nth-child(3) { animation-delay: .35s; } .hero-list li:nth-child(4) { animation-delay: .45s; } .hero-list li:nth-child(5) { animation-delay: .55s; }
.hero-list li::before { content: ''; position: absolute; left: 4px; top: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(6, 182, 212, .18), 0 0 14px var(--accent); }
/* o "M" 3D fica no centro da tela, atrás dos dois blocos; o cartão de entrada (vidro) desfoca o que passa atrás dele */
.hero-3d { position: fixed; left: 50%; top: 52%; transform: translate(-50%, -50%); width: min(82vh, 780px); height: min(82vh, 780px); opacity: .55; pointer-events: none; z-index: 0; }
.hero-3d canvas { width: 100% !important; height: 100% !important; display: block; }
#flow { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.notice { padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.notice.ok { background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .4); }
.notice.bad { background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .4); }
label.switch.small { display: flex; gap: 8px; align-items: flex-start; }

/* Chats */
.chats { display: grid; grid-template-columns: 300px 1fr; gap: 14px; height: calc(100vh - 150px); min-height: 420px; }
.chat-list { overflow-y: auto; padding: 6px; }
.chat-item { padding: 10px; border-radius: 10px; cursor: pointer; border-bottom: 1px solid transparent; transition: background .15s; }
.chat-item:hover { background: rgba(124, 58, 237, .12); }
.chat-item.active { background: var(--grad-soft); outline: 1px solid rgba(124, 58, 237, .6); }
.chat-item .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-pane { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 75%; padding: 8px 13px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; background: var(--panel2); align-self: flex-start; animation: rise .25s both; }
.bubble.assistant { background: var(--grad); align-self: flex-end; box-shadow: 0 4px 14px rgba(37, 99, 235, .3); }
.bubble.human { background: #3b2a8f; align-self: flex-end; }
.bubble .who { display: block; font-size: 11px; opacity: .75; margin-bottom: 2px; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.toast { background: var(--panel-solid); border: 1px solid var(--line); border-left: 4px solid var(--primary); padding: 10px 14px; border-radius: 10px; max-width: 340px; box-shadow: 0 10px 30px rgba(2, 6, 23, .5); animation: rise .3s both; }
.toast.error { border-left-color: var(--bad); }

/* carregamento inicial: o símbolo da marca pulsando dentro de um anel de fluxo */
#boot { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg-deep); transition: opacity .5s, visibility .5s; }
#boot.done { opacity: 0; visibility: hidden; }
#boot .orb { position: relative; width: 120px; height: 120px; display: grid; place-items: center; }
#boot .orb::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from var(--a), #2563EB, #7C3AED, #06B6D4, #2563EB); animation: spin 2.4s linear infinite; -webkit-mask: radial-gradient(circle, transparent 54px, #000 55px); mask: radial-gradient(circle, transparent 54px, #000 55px); }
#boot img { width: 64px; height: 64px; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px rgba(37, 99, 235, .4)); } 50% { transform: scale(1.08); filter: drop-shadow(0 0 18px rgba(124, 58, 237, .7)); } }

@media (max-width: 900px) {
  .auth-wrap.landing { grid-template-columns: minmax(0, 420px); gap: 28px; }
  .hero h1 { font-size: 28px; }
  .hero-3d { display: none; }
  .auth-card .auth-brand { display: block; }
}
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; padding-top: calc(10px + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 20; height: auto; overflow: visible; }
  .brand-logo { margin: 0 10px 0 0; height: 24px; }
  .side .spacer { display: none; }
  /* menu em uma faixa que rola para o lado, com botões fáceis de tocar */
  .nav { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; width: 100%; order: 3; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { width: auto; flex: none; white-space: nowrap; min-height: 40px; }
  .nav button:hover { transform: none; }
  .chats { grid-template-columns: 1fr; height: auto; }
  .chat-list { max-height: 200px; }
  .chat-pane { height: 70vh; }
  .main { padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  input, select, textarea { font-size: 16px; } /* evita o zoom automático do iPhone ao digitar */
  table { display: block; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Conversas: alternador Lista | Kanban, quadro e termômetro */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: none; border: 0; color: var(--muted); padding: 8px 14px; cursor: pointer; font: inherit; font-weight: 500; }
.seg button.on { background: var(--grad); color: #fff; }
.chat-item .meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.stage-tag { color: var(--muted); font-size: 12px; }
.temp { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.temp.quente { background: rgba(239, 68, 68, .16); border-color: rgba(239, 68, 68, .5); color: #fecaca; }
.temp.morno { background: rgba(245, 158, 11, .14); border-color: rgba(245, 158, 11, .45); color: #fde68a; }
.temp.frio { background: rgba(56, 189, 248, .12); border-color: rgba(56, 189, 248, .4); color: #bae6fd; }
.temp.fechado { background: rgba(34, 197, 94, .14); border-color: rgba(34, 197, 94, .45); color: #bbf7d0; }

.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; min-height: 420px; -webkit-overflow-scrolling: touch; }
.col { flex: 0 0 262px; background: rgba(21, 32, 58, .55); border: 1px solid var(--line); border-top: 3px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 190px); transition: background .15s, outline-color .15s; outline: 2px solid transparent; }
.col.over { background: rgba(124, 58, 237, .16); outline-color: rgba(124, 58, 237, .7); }
.col.stage-novo { border-top-color: #38bdf8; } .col.stage-conversando { border-top-color: #2563EB; } .col.stage-montando { border-top-color: #7C3AED; }
.col.stage-pagamento { border-top-color: #f59e0b; } .col.stage-agendado { border-top-color: #22c55e; } .col.stage-precisa { border-top-color: #ef4444; }
.col.stage-sumiu { border-top-color: #64748b; } .col.stage-perdido { border-top-color: #475569; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 6px; }
.col-head .count { background: rgba(255, 255, 255, .08); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.col-body { padding: 4px 10px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.empty-col { text-align: center; padding: 14px 0; }
.kcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: transform .15s, border-color .15s; }
.kcard:hover { border-color: rgba(124, 58, 237, .6); transform: translateY(-1px); }
.kcard.drag { opacity: .45; }
.kcard .ktop { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.kcard .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kcard .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kcard .kfoot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.kcard select.move { margin-left: auto; width: auto; max-width: 112px; padding: 2px 6px; font-size: 12px; }
@media (max-width: 800px) {
  .col { flex-basis: 78vw; max-height: none; }
  .kcard select.move { font-size: 16px; }
}
