/* ============================================================
   Help Panel — assistente de ajuda do produto.
   Estilos isolados (prefixo .help-*) pra não colidir com nada existente.
   ============================================================ */

/* Slideout container — desliza da direita */
.help-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 100vw;
  height: 100vh;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease-out, width 0.2s ease-out;
}

.help-panel.open {
  transform: translateX(0);
}

/* Modo ampliado — botão ⛶ no header alterna pra ~80vw */
.help-panel.expanded {
  width: min(80vw, 1100px);
}

/* Backdrop opcional (overlay claro) */
.help-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.help-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Header do painel */
.help-header {
  flex-shrink: 0;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.help-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.help-icon-btn,
.help-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #64748b;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}

.help-icon-btn:hover,
.help-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0f172a;
}

/* Tabs internas (Manual | Pergunte à IA) */
.help-tabs {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  background: #fff;
}

.help-tab {
  flex: 1;
  padding: 10px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.help-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  font-weight: 600;
}

.help-tab:hover:not(.active) {
  background: #f1f5f9;
}

/* Conteúdo (rolável) */
.help-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Caixa de busca textual */
.help-search-box {
  position: sticky;
  top: 0;
  background: #fff;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 12px;
  z-index: 1;
}

.help-search-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.help-search-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.help-search-stats {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

/* Render do markdown */
.help-markdown {
  font-size: 13px;
  line-height: 1.6;
  color: #1e293b;
}

.help-markdown h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 12px 0 6px;
  color: #0f172a;
}

.help-markdown h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 16px 0 6px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
  color: #0f172a;
  scroll-margin-top: 60px;
}

.help-markdown h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 12px 0 4px;
  color: #1e293b;
  scroll-margin-top: 60px;
}

.help-markdown h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 10px 0 4px;
  color: #334155;
}

.help-markdown p {
  margin: 6px 0;
}

.help-markdown ul, .help-markdown ol {
  margin: 6px 0 6px 20px;
  padding: 0;
}

.help-markdown li {
  margin: 2px 0;
}

.help-markdown code {
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  color: #be123c;
}

.help-markdown pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
}

.help-markdown pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.help-markdown a {
  color: #2563eb;
  text-decoration: none;
}

.help-markdown a:hover {
  text-decoration: underline;
}

.help-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
}

.help-markdown th, .help-markdown td {
  border: 1px solid #e2e8f0;
  padding: 4px 6px;
  text-align: left;
}

.help-markdown th {
  background: #f8fafc;
  font-weight: 600;
}

.help-markdown blockquote {
  border-left: 3px solid #2563eb;
  margin: 8px 0;
  padding: 4px 12px;
  background: #f0f9ff;
  color: #1e293b;
  font-style: italic;
}

/* Highlight de busca */
.help-markdown mark.help-hit {
  background: #fde68a;
  padding: 0 2px;
  border-radius: 2px;
}

/* Imagens (prints do manual) — fit no container */
.help-markdown img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 8px 0;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Tab "Pergunte à IA" — layout vertical: toolbar topo, mensagens scrolláveis, form fixo embaixo */
.help-content[data-content="ai"] {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.help-ai-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}

.help-ai-toolbar-btn {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  font-size: 11px;
  padding: 4px 10px;
  color: #64748b;
  cursor: pointer;
}

.help-ai-toolbar-btn:hover {
  background: #fff;
  color: #0f172a;
}

.help-ai-result {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafbfc;
}

.help-ai-msg {
  max-width: 92%;
  font-size: 13px;
  line-height: 1.55;
}

.help-ai-msg-user {
  align-self: flex-end;
}

.help-ai-msg-assistant {
  align-self: flex-start;
  width: 100%;
}

.help-ai-question {
  background: #2563eb;
  color: #fff;
  padding: 8px 12px;
  border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.help-ai-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.help-ai-textarea {
  width: 100%;
  min-height: 70px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
}

.help-ai-textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.help-ai-submit {
  align-self: flex-end;
  padding: 7px 16px;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.help-ai-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.help-ai-loading {
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  padding: 12px 0;
}

.help-ai-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
}

.help-ai-answer {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #2563eb;
  padding: 10px 14px;
  border-radius: 4px 10px 10px 10px;
  font-size: 13px;
  line-height: 1.65;
  color: #1e293b;
}

/* Tipografia da resposta — força espaçamento e bullets visíveis */
.help-ai-answer p { margin: 0 0 8px; }
.help-ai-answer p:last-child { margin-bottom: 0; }
.help-ai-answer ul, .help-ai-answer ol {
  margin: 6px 0 8px 22px;
  padding: 0;
}
.help-ai-answer ul { list-style: disc outside; }
.help-ai-answer ol { list-style: decimal outside; }
.help-ai-answer li { margin: 2px 0; }
.help-ai-answer li > p { margin: 0; }
.help-ai-answer h1, .help-ai-answer h2, .help-ai-answer h3, .help-ai-answer h4 {
  font-weight: 700;
  margin: 10px 0 4px;
  color: #0f172a;
}
.help-ai-answer h3 { font-size: 14px; }
.help-ai-answer h4 { font-size: 13px; color: #334155; }
.help-ai-answer code {
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  color: #be123c;
}
.help-ai-answer pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 8px 10px;
  border-radius: 5px;
  overflow-x: auto;
  font-size: 12px;
  margin: 6px 0;
}
.help-ai-answer pre code { background: none; color: inherit; padding: 0; }
.help-ai-answer strong { color: #0f172a; }
.help-ai-answer a { color: #2563eb; text-decoration: none; }
.help-ai-answer a:hover { text-decoration: underline; }

.help-ai-answer-meta {
  margin-top: 8px;
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Botão "?" inline (sidebar) — herda estilo do `.nav-item` da própria página */

/* Botão "?" flutuante (FAB) — pra páginas SEM sidebar (dashboards, share, etc) */
.help-trigger-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.help-trigger-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
}

.help-trigger-fab:active {
  transform: translateY(0);
}

/* Responsivo */
@media (max-width: 720px) {
  .help-panel {
    width: 100vw;
  }
}
