/* manual.css — estilos do modulo de Ajuda contextual
   PRD-TECNICA-0003 / TASK-0005 + TASK-0012
   Tokens herdaveis do app (tema CLARO); fallbacks claros — ver B#34. */

.help-modal,
.help-modal-backdrop,
.help-trigger,
.help-index {
  /* B#34 (22/05/2026) — reconciliacao com o tema CLARO do app.
     O app migrou de tema escuro para claro: a variavel `--bg-elev` foi
     descontinuada (as superficies hoje sao `--surface`/`--surface-2` no
     styles.css :root). Antes, `--manual-bg-elev` lia `var(--bg-elev, ...)`,
     caia no fallback dark `#1a1d24` e pintava o corpo do modal de preto.
     As pontes abaixo leem as variaveis reais do app; os fallbacks tambem
     sao claros para nunca recair no dark se a var do app faltar. */
  --manual-bg: var(--bg, #f5f5f5);
  --manual-bg-elev: var(--surface, #ffffff);
  --manual-text: var(--text, #333333);
  --manual-text-muted: var(--text-muted, #777777);
  --manual-accent: var(--accent, #337ab7);
  --manual-border: var(--border, #dddddd);
  /* B#34 — tons escurecidos: a legenda de frescor de screenshot agora vive
     sobre fundo claro; os ambar/vermelho claros antigos (#f0b94e/#e57373)
     batiam sub-AA em #fff. Estes passam a contraste AA em tema claro. */
  --manual-warn: #b8860b;
  --manual-stale: #c62828;
  --manual-radius: 8px;
  --manual-shadow: 0 18px 60px rgba(0,0,0,0.55);
}

/* Trigger (?) — colado no nome (sem espaço extra), nunca quebra linha */
.help-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin: 0 0 0 2px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--manual-accent);
  cursor: pointer;
  vertical-align: middle;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 120ms ease, border-color 120ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.help-trigger:hover,
.help-trigger:focus-visible {
  background: rgba(100, 181, 246, 0.12);
  border-color: var(--manual-accent);
  outline: none;
}
.help-trigger .help-icon { width: 14px; height: 14px; display: block; }

/* Backdrop + modal */
.help-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  opacity: 0;
  transition: opacity 200ms ease;
  z-index: 9998;
}
.help-modal-backdrop[data-open] { opacity: 1; }

.help-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, calc(-50% + 8px));
  width: 92vw; max-width: 720px;
  max-height: 85vh;
  background: var(--manual-bg-elev);
  color: var(--manual-text);
  border-radius: var(--manual-radius);
  border: 1px solid var(--manual-border);
  box-shadow: var(--manual-shadow);
  display: flex; flex-direction: column;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 9999;
  overflow: hidden;
}
.help-modal[data-open] {
  opacity: 1;
  transform: translate(-50%, -50%);
}
.help-modal:focus { outline: none; }

.help-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--manual-border);
  background: var(--manual-bg);
}
.help-modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}
.help-modal-header h2 .manual-version {
  margin-left: 8px;
  font-size: 0.7em;
  font-weight: 400;
  color: var(--manual-text-muted);
  vertical-align: baseline;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.help-modal-close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--manual-text-muted);
  font-size: 22px;
  line-height: 1;
  width: 32px; height: 32px;
  border-radius: 6px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.help-modal-close:hover,
.help-modal-close:focus-visible {
  background: rgba(0,0,0,0.05); /* B#34 — translucido escuro p/ tema claro */
  color: var(--manual-text);
  border-color: var(--manual-border);
  outline: none;
}

.help-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1 1 auto;
  font-size: 14px;
  line-height: 1.55;
}
.help-modal-body p { margin: 0 0 10px; }
.help-modal-body p:last-child { margin-bottom: 0; }
.help-modal-body code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(0,0,0,0.05); /* B#34 — translucido escuro p/ tema claro */
  padding: 1px 5px;
  border-radius: 3px;
}
.help-modal-body a { color: var(--manual-accent); }
.help-modal-body ul { padding-left: 18px; margin: 0 0 10px; }

.help-modal-figure {
  margin: 12px 0;
  border: 1px solid var(--manual-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--manual-bg);
}
.help-modal-screenshot { width: 100%; height: auto; display: block; }
.help-modal-aging {
  font-size: 12px;
  color: var(--manual-text-muted);
  padding: 6px 10px;
  border-top: 1px solid var(--manual-border);
}
.help-modal-figure.aging-warn .help-modal-aging { color: var(--manual-warn); }
.help-modal-figure.aging-stale .help-modal-aging { color: var(--manual-stale); }

.help-modal-passos {
  padding-left: 22px;
  margin: 12px 0;
}
.help-modal-passos li { margin-bottom: 6px; }

.help-modal-relacionadas {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--manual-border);
  font-size: 13px;
  color: var(--manual-text-muted);
}
.help-modal-relacionadas a { color: var(--manual-accent); margin: 0 4px; }

.help-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 10px 18px;
  border-top: 1px solid var(--manual-border);
  background: var(--manual-bg);
}
.help-modal-link-indice {
  font-size: 13px;
  color: var(--manual-accent);
  text-decoration: none;
}
.help-modal-link-indice:hover { text-decoration: underline; }

body.manual-open { overflow: hidden; }

/* Indice */
.help-index {
  padding: 24px;
  color: var(--manual-text);
  font-size: 14px;
}
.help-index-header { margin-bottom: 16px; }
.help-index-header h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 12px;
}
.help-search-input {
  width: 100%;
  max-width: 480px;
  padding: 8px 12px;
  background: var(--manual-bg);
  color: var(--manual-text);
  border: 1px solid var(--manual-border);
  border-radius: 6px;
  font: inherit;
}
.help-search-input:focus {
  outline: 2px solid var(--manual-accent);
  outline-offset: 1px;
  border-color: var(--manual-accent);
}
.help-search-empty { padding: 16px 0; color: var(--manual-text-muted); }

.help-index-sections section {
  margin-top: 18px;
}
.help-index-sections h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--manual-text-muted);
  border-bottom: 1px solid var(--manual-border);
  padding-bottom: 6px;
  margin: 0 0 8px;
}
.help-index-sections ul { list-style: none; padding: 0; margin: 0; }
.help-index-sections li { margin: 4px 0; }
.help-index-sections li.hidden,
.help-index-sections section.hidden { display: none; }
.help-index-sections a {
  color: var(--manual-text);
  text-decoration: none;
  display: inline-block;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}
.help-index-sections a:hover { color: var(--manual-accent); border-bottom-color: var(--manual-accent); }
.help-index-vazio { color: var(--manual-text-muted); }

/* Mobile drawer */
@media (max-width: 767px) {
  .help-modal {
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; max-width: 100vw;
    max-height: 100vh; height: 100vh;
    border-radius: 0;
    transform: translateX(100%);
    transition: transform 280ms ease;
  }
  .help-modal[data-open] { transform: translateX(0); }
  .help-modal-backdrop { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .help-modal,
  .help-modal-backdrop {
    transition: none !important;
  }
}

/* ============================================================================
   UI#29 (10/05/2026) — Help tooltip (hover sintético)
   Tooltip flutuante que aparece no hover/focus de elementos [data-help].
   Coexiste com o botão (?) do UI#6-M — hover mostra resumo curto, click abre
   o manual completo.
   Glassmorphism alinhado DOC#9 (brand #337ab7).
   ========================================================================== */
.help-tooltip {
  position: fixed;
  /* Fundo escuro com backdrop-filter (Glass Banking DOC#9) */
  background: rgba(20, 30, 50, 0.92);
  color: #e8ecf3;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(51, 122, 183, 0.35);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 13px;
  line-height: 1.45;
  max-width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 10000;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease;
  pointer-events: none;
  /* Default position antes do JS posicionar — fica fora da tela */
  top: -9999px;
  left: -9999px;
}
.help-tooltip[data-open] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: none; /* nao captura clicks; mantem semantica de tooltip */
}
.help-tooltip-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: #64b5f6; /* var(--accent) */
  font-size: 13px;
}
.help-tooltip-body {
  font-size: 13px;
  color: #e8ecf3;
}
.help-tooltip-cta {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 6px;
  font-style: italic;
}

/* No reduced-motion sem transition */
@media (prefers-reduced-motion: reduce) {
  .help-tooltip {
    transition: opacity 0s !important;
    transform: none !important;
  }
}

/* ============================================================================
   UI#29 — Editor de hints (Gestão Dev → aba Hints)
   Tabela com lista de hints + textarea inline pra editar texto.
   ========================================================================== */
.hints-editor-table {
  width: 100%;
  border-collapse: collapse;
  /* B#34 — `--bg-elev` nao existe mais; usa a surface real do tema claro. */
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #dddddd);
  border-radius: 8px;
  overflow: hidden;
}
.hints-editor-table th,
.hints-editor-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border, #dddddd);
  font-size: 13px;
  vertical-align: top;
}
.hints-editor-table thead th {
  background: rgba(51, 122, 183, 0.08);
  font-weight: 600;
  color: var(--accent, #337ab7);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.hints-editor-table tbody tr:hover {
  background: rgba(100, 181, 246, 0.04);
}
.hints-editor-table .hint-key {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted, #777777);
}
.hints-editor-table .hint-title {
  font-weight: 600;
  color: var(--text, #333333);
}
.hints-editor-table .hint-preview {
  color: var(--text-muted, #777777);
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hints-editor-row-edit {
  background: rgba(51, 122, 183, 0.06);
}
.hints-editor-row-edit textarea {
  width: 100%;
  min-height: 70px;
  padding: 8px 10px;
  background: var(--bg, #f5f5f5);
  color: var(--text, #333333);
  border: 1px solid var(--accent, #337ab7);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.45;
  resize: vertical;
}
.hints-editor-row-edit .hints-editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}
.hints-editor-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.hints-editor-toolbar .text-muted {
  font-size: 12px;
}

/* ============================================================ */
/* Modal AMPLIADO — PRD-0027 / TASK-0007                        */
/* Layout: 95% viewport por padrão · 100% quando fullscreen      */
/* ============================================================ */

.help-modal-ampliado.help-modal {
  /* sobrescreve dimensões do modal pequeno antigo */
  width: min(95vw, 1700px);
  height: 92vh;
  max-width: none;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0; /* zera padding antigo do modal pequeno */
  border-radius: 18px;
}

.help-modal-ampliado.help-modal[data-fullscreen] {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  top: 0;
  left: 0;
  transform: none;
}

/* Backdrop não escurece tanto quando em fullscreen */
.help-modal-backdrop[data-fullscreen] {
  background: rgba(15, 23, 42, 0.92);
}

/* Topbar (header do modal ampliado) */
.help-modal-ampliado .help-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  flex-shrink: 0;
}

.help-modal-ampliado .help-modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink-1, #0f172a);
  letter-spacing: -0.3px;
}

.help-modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.help-modal-action-btn {
  background: #f1f5f9;
  color: var(--ink-2, #334155);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 7px;
  padding: 7px 13px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  line-height: 1;
}
.help-modal-action-btn:hover {
  background: #e2e8f0;
}
.help-modal-ampliado .help-modal-close {
  background: #dc2626;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.help-modal-ampliado .help-modal-close:hover {
  background: #b91c1c;
}

/* Body: grid sidebar 240px + conteúdo flex */
.help-modal-ampliado .help-modal-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0; /* permite o flex:1 funcionar */
}

/* Sidebar interna */
.help-modal-sidebar {
  background: #f8fafc;
  border-right: 1px solid var(--line, #e2e8f0);
  padding: 18px 14px;
  overflow-y: auto;
  font-size: 13px;
}

.help-modal-sidebar h2,
.help-modal-sidebar h3 {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--ink-3, #64748b);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 700;
}

.help-modal-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.help-modal-sidebar li {
  margin: 0;
}

.help-modal-sidebar li a {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink-2, #334155);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}
.help-modal-sidebar li a:hover {
  background: #eaf3fb;
}
.help-modal-sidebar li a.active {
  background: var(--brand, #1f4e7a);
  color: #fff;
}

/* Conteúdo principal */
.help-modal-ampliado .help-modal-content {
  padding: 32px 40px;
  overflow-y: auto;
  background: #fff;
}

/* Scoping do conteúdo HTML do cap (vem do extrator com prefixo .help-modal-content) */
.help-modal-content .chapter {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

/* Loading / error states */
.help-modal-loading,
.help-modal-error {
  padding: 40px;
  text-align: center;
  color: var(--ink-3, #64748b);
  font-style: italic;
  font-size: 14px;
}
.help-modal-error {
  color: #b91c1c;
  background: #fef2f2;
  border-radius: 10px;
}

/* Responsivo: mobile força fullscreen + esconde sidebar */
@media (max-width: 767px) {
  .help-modal-ampliado.help-modal {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .help-modal-ampliado .help-modal-body {
    grid-template-columns: 1fr;
  }
  .help-modal-sidebar {
    display: none;
  }
  .help-modal-ampliado .help-modal-content {
    padding: 20px 18px;
  }
}

/* Hidden: garantir override do display:flex/grid (regra dura 14 CLAUDE.md) */
.help-modal-ampliado[hidden],
.help-modal-sidebar[hidden],
.help-modal-body[hidden] {
  display: none !important;
}

