:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --sidebar-w: 260px;
  --bg: #f5f6fa;
}

body { background: var(--bg); }

/* ---- Shell ---- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-content { padding: 1.5rem; }

/* ---- Sidebar ---- */
.app-sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid #e9ecef;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  /* O menu passou a ter mais itens (com os grupos), e sem isto ele
     transbordava os 100vh: a página inteira rolava para mostrar o fim da
     lista, o topo da barra saía da tela e a navbar fixa cobria o título do
     conteúdo. Rolando aqui dentro, o resto da tela fica parado. */
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Barra de rolagem discreta: a do sistema, escura e larga, dá peso demais a
   um menu que quase nunca precisa rolar. */
.app-sidebar { scrollbar-width: thin; scrollbar-color: #d8dae0 transparent; }
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: #d8dae0; border-radius: 3px; }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.15rem 1.25rem; font-weight: 700; font-size: 1.15rem;
  border-bottom: 1px solid #f0f0f5;
  /* A marca fica no lugar enquanto o menu rola por baixo. */
  position: sticky; top: 0; background: #fff; z-index: 1;
  flex-shrink: 0;
}
.brand-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--brand); color: #fff; font-size: 1.1rem;
}
.sidebar-nav {
  padding: .75rem; display: flex; flex-direction: column; gap: .15rem;
  padding-bottom: 1.5rem;  /* respiro no fim, para o último item não colar */
}
.sidebar-nav .nav-link {
  color: #495057; border-radius: 8px; padding: .6rem .8rem;
  display: flex; align-items: center; gap: .6rem; font-weight: 500;
}
.sidebar-nav .nav-link:hover { background: #f3f4f8; color: var(--brand-dark); }
.sidebar-nav .nav-link.active { background: var(--brand); color: #fff; }

/* ---- Navbar ---- */
.app-navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.5rem; background: #fff; border-bottom: 1px solid #e9ecef;
  position: sticky; top: 0; z-index: 10;
}

/* ---- Cards / page ---- */
.page-title { font-weight: 700; margin-bottom: 1.25rem; }
.card { border: 1px solid #ececf2; border-radius: 14px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 12px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 1.3rem;
  background: #eef0fb; color: var(--brand);
}

/* ---- Auth ---- */
.auth-body {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); padding: 1rem;
}
.auth-card { width: 100%; max-width: 420px; border: none; border-radius: 16px; }

/* ---- Onboarding ---- */
.onboarding-wrap { max-width: 640px; margin: 0 auto; }

/* ---- Simulador (chat) ---- */
.chat-window {
  max-width: 460px; margin: 0 auto; background: #e5ddd5;
  border-radius: 16px; overflow: hidden; border: 1px solid #d6cfc7;
}
.chat-header {
  background: #075e54; color: #fff; padding: .75rem 1rem;
  display: flex; align-items: center; gap: .6rem;
}
.chat-body { height: 460px; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.chat-bubble { max-width: 78%; padding: .5rem .75rem; border-radius: 10px; font-size: .92rem; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.chat-bubble.from-user { align-self: flex-end; background: #dcf8c6; }
.chat-bubble.from-bot { align-self: flex-start; background: #fff; }
.chat-bubble.not-delivered { border: 1px solid #dc3545; }
.chat-footer { padding: .6rem; background: #f0f0f0; display: flex; gap: .5rem; }
.chat-hint { font-size: .78rem; }

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

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 1040;
}

@media (max-width: 768px) {
  /* `top: 0` explícito: como fixed tira do fluxo, sem isto a barra abria na
     altura em que a página estava rolada, cortada no topo. */
  .app-sidebar { position: fixed; top: 0; left: -100%; z-index: 1050; transition: left .2s; }
  .app-sidebar.is-open { left: 0; }
}

/* ---- Página pública (ver PROJECT_SPEC.md, seção 23) ---- */
.public-body { background: #fff; }
.public-wrap { max-width: 980px; margin: 0 auto; padding: 0 1rem; }
.public-section { padding: 3.5rem 0; }

.public-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.25rem; border-bottom: 1px solid #ececf2;
  position: sticky; top: 0; background: #fff; z-index: 10;
}
.public-brand {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 700; font-size: 1.15rem; color: inherit; text-decoration: none;
}

.public-hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff; text-align: center; padding: 4rem 0 4.5rem;
}
.public-hero h1 { font-weight: 800; font-size: clamp(1.7rem, 4vw, 2.6rem); margin-bottom: 1rem; }
.public-hero .lead { max-width: 620px; margin: 0 auto 1.75rem; opacity: .93; }

.public-steps { padding-left: 1.1rem; }
.public-steps li { margin-bottom: .85rem; }

.public-cta {
  background: #0f172a; color: #fff; text-align: center; padding: 3rem 0;
}

.public-footer {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  max-width: 980px; margin: 0 auto; padding: 1.5rem 1rem;
  border-top: 1px solid #ececf2; color: #6c757d; font-size: .9rem;
}

/* --- Perguntas e respostas: lista editável e reordenável --- */

.faq-item { transition: background-color .4s ease; }
/* min-width:0 é o que permite o texto truncar dentro de um flex — sem isso o
   item cresce e empurra os botões para fora da tela no celular. */
.min-w-0 { min-width: 0; }

.faq-alca { cursor: grab; padding-top: .15rem; }
.faq-alca:active { cursor: grabbing; }
.faq-arrastando { opacity: .45; background: #eef2ff; }

/* Duas linhas de resposta bastam para reconhecer o item; o resto vem na edição. */
.text-truncate-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.faq-item-pendente { border-left: 3px solid #ffc107; }

/* Confirmação de que salvou, sem mensagem no topo que obrigue a procurar o
   que mudou: a própria linha pisca por um instante. */
.faq-item[data-salvou] { animation: faq-salvou 1.4s ease; }
@keyframes faq-salvou {
  0%   { background-color: #d1e7dd; }
  100% { background-color: transparent; }
}

@media (max-width: 575.98px) {
  /* No celular a alça não serve (o dedo rola a página), e os botões precisam
     de espaço: as setas viram o caminho de reordenar. */
  .faq-alca { display: none; }
  .faq-item .btn-group { margin-top: .5rem; }
  .faq-item > .d-flex { flex-wrap: wrap; }
}

/* --- Primeiros passos --- */

.setup-hero {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem 1.5rem; border-radius: .75rem;
}
.setup-hero-ok { background: linear-gradient(135deg, #157347 0%, #0f5132 100%); color: #fff; }

.setup-list { display: flex; flex-direction: column; gap: .75rem; }

.setup-step {
  display: flex; align-items: center; gap: 1rem;
  background: #fff; border: 1px solid #ececf2; border-radius: .75rem;
  padding: 1rem 1.25rem;
}
/* O passo da vez ganha destaque: numa lista de quatro itens iguais, o leigo
   pergunta "por onde começo?" — a resposta tem que estar na tela. */
.setup-step-agora { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.setup-step-ok { background: #f8f9fa; }

.setup-step-marca {
  flex-shrink: 0; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; background: #eef2ff; color: #4f46e5;
}
.setup-step-ok .setup-step-marca { background: #d1e7dd; color: #0f5132; }

@media (max-width: 575.98px) {
  .setup-step { flex-wrap: wrap; }
  .setup-step > .flex-shrink-0 { width: 100%; }
  .setup-step > .flex-shrink-0 .btn { width: 100%; }
  .setup-hero { flex-wrap: wrap; }
}

/* Títulos das seções do menu. Separam o caminho de configuração do resto —
   sem eles são treze links iguais e o leigo não sabe por onde começar. */
.sidebar-group {
  display: block; padding: 1.1rem 1rem .35rem;
  font-size: .7rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #9aa0ae;
}
.sidebar-group:first-of-type { padding-top: .6rem; }

/* Rodapé de avanço: fecha as telas do caminho de configuração, que antes
   terminavam sem dizer o que vinha depois. */
.avancar-card { border-color: #c7d2fe; background: #f8f9ff; }

/* Separa os quatro passos do caminho dos ajustes opcionais, no guia. */
.guide-secao {
  margin: 2rem 0 1rem; font-size: .75rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: #9aa0ae;
}

/* Marca das perguntas que viram opção numerada do menu. */
.faq-badge-menu {
  background: #eef2ff; color: #4f46e5; font-weight: 600;
  font-size: .68rem; vertical-align: middle;
}
