/* ══════════════════════════════════════════════════════════════════════════
   _help.css — Widget de Ajuda compartilhado (secretária / médico / gestor)
   Inspirado no HelpOrb do Portal do Paciente (app.jsx ~1438, ~8239) e nas
   classes .hbot-* de portal.css (~1247-1470). Reimplementado em vanilla CSS
   pra rodar sem build nos painéis Alpine.js.
   Tokens: var(--accent), var(--bg-elev), var(--fg), var(--border) com
   fallback hex. Dark mode via html.agm-dark e [data-theme="dark"].
   Alvos de toque ≥44px. z-index alto (acima de header/rail, abaixo de modais
   críticos — ajustar se o painel host usar z maior que 99990).
   ══════════════════════════════════════════════════════════════════════════ */

/* 🩹 E59 (19/09): .ahlp-orb não tinha width/height — como os dois filhos
   (blob + face) são `position:absolute`, eles não davam tamanho nenhum ao
   pai, e o orbe sumia (ficava 0×0, só o círculo branco do botão aparecia
   por trás). Tamanho explícito aqui + no host (.ahlp-fab .ahlp-orb /
   .ahlp-head .ahlp-orb abaixo) resolve os dois lugares onde o orbe aparece.
   Também trocado var(--accent) por var(--brand) — neste produto --accent
   já é reservado pro verde do WhatsApp (ver design/tokens.css), então um
   orbe "verde WhatsApp" confundia com indicador de canal; --brand é a cor
   oficial da marca (Cobalto #1B3FE8). */
.ahlp-orb { position: relative; display: inline-block; border-radius: 999px; width: 32px; height: 32px; flex-shrink: 0; }
.ahlp-orb__blob {
  position: absolute; inset: 0; border-radius: 999px;
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--brand, #1B3FE8) 70%, white 30%), var(--brand, #1B3FE8) 65%);
  animation: ahlp-float 3.6s ease-in-out infinite, ahlp-pulse 2.4s ease-in-out infinite;
}
.ahlp-orb__face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 22%; }
.ahlp-orb__face i { display: block; width: 14%; height: 14%; min-width: 4px; min-height: 4px; border-radius: 999px; background: #fff; opacity: .95; box-shadow: 0 0 0 1px rgba(0,0,0,.05); }
.ahlp-fab .ahlp-orb { width: 30px; height: 30px; }
@keyframes ahlp-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes ahlp-pulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.08); } }
@media (prefers-reduced-motion: reduce) {
  .ahlp-orb__blob { animation: none; }
}

/* -- botão flutuante -- */
.ahlp-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 99001;
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; padding: 0; border: 1px solid var(--border, #E3DED2);
  border-radius: 999px; background: var(--bg-elev, #FAF8F4);
  box-shadow: 0 10px 30px -8px rgba(19,18,16,.35), 0 2px 8px rgba(19,18,16,.12);
  cursor: pointer; transition: border-color .12s, transform .12s;
}
.ahlp-fab:hover { border-color: var(--brand, #1B3FE8); transform: translateY(-1px); }
.ahlp-fab:focus-visible { outline: 2px solid var(--brand, #1B3FE8); outline-offset: 2px; }
.ahlp-fab.is-open { background: var(--brand, #1B3FE8); border-color: var(--brand, #1B3FE8); }
.ahlp-fab__x { display: grid; place-items: center; width: 100%; height: 100%; color: #fff; font-size: 22px; line-height: 1; }
.ahlp-badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: #B4232C; color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg-elev, #FAF8F4);
}

/* -- painel -- */
.ahlp-panel {
  position: fixed; right: 24px; bottom: 92px; z-index: 99000;
  width: 380px; max-width: calc(100vw - 32px);
  max-height: min(600px, calc(100vh - 140px));
  display: flex; flex-direction: column;
  background: var(--bg-elev, #FAF8F4); border: 1px solid var(--border, #E3DED2);
  border-radius: 18px; box-shadow: 0 24px 60px -12px rgba(19,18,16,.4);
  overflow: hidden; animation: ahlp-rise .18s cubic-bezier(.16,1,.3,1);
}
@keyframes ahlp-rise { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .ahlp-panel { animation: none; } }

.ahlp-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px;
  border-bottom: 1px solid var(--border, #E3DED2);
  background: linear-gradient(120deg, color-mix(in srgb, var(--brand, #1B3FE8) 12%, transparent), var(--bg-elev, #FAF8F4) 72%);
}
.ahlp-head__t { flex: 1; min-width: 0; }
.ahlp-head__t b { display: block; font-size: 14.5px; font-weight: 700; color: var(--fg, #131210); letter-spacing: -0.01em; }
.ahlp-head__t span { display: block; font-size: 11px; color: var(--fg-soft, #8D897E); }
.ahlp-x {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; border: none;
  background: none; color: var(--fg-soft, #8D897E); cursor: pointer; font-size: 18px;
  display: grid; place-items: center;
}
.ahlp-x:hover { background: var(--bg, #F4F1EB); color: var(--fg, #131210); }

/* -- tabs -- */
.ahlp-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border, #E3DED2); background: var(--bg-elev, #FAF8F4); overflow-x: auto; }
.ahlp-tab {
  flex: 1; min-width: max-content; font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--fg-soft, #8D897E); background: none; border: none; border-radius: 10px;
  padding: 9px 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; white-space: nowrap;
}
.ahlp-tab:hover { background: var(--bg, #F4F1EB); color: var(--fg, #131210); }
.ahlp-tab.is-active { background: var(--brand, #1B3FE8); color: #fff; }
.ahlp-tab__badge {
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  background: #B4232C; color: #fff;
}
.ahlp-tab.is-active .ahlp-tab__badge { background: rgba(255,255,255,.3); }

/* -- corpo -- */
.ahlp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 16px; }

/* aba Ajuda */
.ahlp-search {
  width: 100%; font: inherit; font-size: 13.5px; padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid var(--border, #E3DED2); border-radius: 10px; background: var(--bg, #F4F1EB); color: var(--fg, #131210);
}
.ahlp-search:focus { outline: none; border-color: var(--brand, #1B3FE8); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand, #1B3FE8) 15%, transparent); }
.ahlp-art-list { display: flex; flex-direction: column; gap: 8px; }
.ahlp-art {
  border: 1px solid var(--border, #E3DED2); border-radius: 12px; background: var(--bg, #F4F1EB);
  overflow: hidden;
}
.ahlp-art__q {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 8px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--fg, #131210);
  background: none; border: none; cursor: pointer; padding: 11px 12px; min-height: 44px;
}
.ahlp-art__q:hover { color: var(--brand, #1B3FE8); }
.ahlp-art__q .ahlp-chev { margin-left: auto; transition: transform .12s; font-size: 11px; color: var(--fg-soft, #8D897E); }
.ahlp-art.is-open .ahlp-art__q .ahlp-chev { transform: rotate(90deg); }
.ahlp-art__a { padding: 0 12px 12px; font-size: 13px; line-height: 1.55; color: var(--fg-soft, #8D897E); white-space: pre-line; }
.ahlp-art__cta {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font: inherit; font-size: 12.5px; font-weight: 700;
  color: #fff; background: var(--brand, #1B3FE8); border: none; border-radius: 999px; padding: 9px 13px;
  min-height: 40px; cursor: pointer; text-decoration: none;
}
.ahlp-art__cta:hover { filter: brightness(.92); }
.ahlp-empty { padding: 24px 8px; text-align: center; font-size: 13px; color: var(--fg-soft, #8D897E); }

/* aba Chat da clínica (slot) */
.ahlp-slot { min-height: 120px; }

/* aba Primeiros passos */
.ahlp-progress-wrap { margin-bottom: 14px; }
.ahlp-progress-label { font-size: 12.5px; font-weight: 600; color: var(--fg, #131210); margin-bottom: 6px; }
.ahlp-progress-bar { height: 8px; border-radius: 999px; background: var(--border, #E3DED2); overflow: hidden; }
.ahlp-progress-fill { height: 100%; background: var(--brand, #1B3FE8); border-radius: 999px; transition: width .25s ease; }
/* V2.95 — 100% pronta: rótulo já vira "🎉 ...", aqui só a faixa some pro verde
   de sucesso (não é mais "progresso", é "chegou"). Sem animação — só cor. */
.ahlp-progress-wrap.is-complete .ahlp-progress-label { color: #2D6A4F; }
.ahlp-progress-wrap.is-complete .ahlp-progress-fill { background: #2D6A4F; }

/* V2.95 — separador da seção "Delegadas a mim" (mesma lista, tarefa de outra
   pessoa que caiu pra você resolver). */
.ahlp-section-h {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--fg-soft, #8D897E); margin: 16px 0 8px; padding-top: 10px;
  border-top: 1px solid var(--border, #E3DED2);
}
.ahlp-task-list:first-of-type { margin-top: 0; }
.ahlp-task-list { display: flex; flex-direction: column; gap: 8px; }
.ahlp-task-list + .ahlp-section-h { margin-top: 16px; }
.ahlp-task {
  border: 1px solid var(--border, #E3DED2); border-radius: 12px; background: var(--bg, #F4F1EB); padding: 11px 12px;
}
.ahlp-task[data-status="feito"] { opacity: .6; }
.ahlp-task__row { display: flex; align-items: flex-start; gap: 8px; }
.ahlp-task__dot { flex-shrink: 0; width: 9px; height: 9px; border-radius: 999px; margin-top: 5px; background: var(--fg-soft, #8D897E); }
.ahlp-task[data-status="feito"] .ahlp-task__dot { background: #2D6A4F; }
.ahlp-task[data-status="adiado"] .ahlp-task__dot { background: #7A5A0E; }
.ahlp-task[data-status="nao_se_aplica"] .ahlp-task__dot { background: var(--border, #E3DED2); }
.ahlp-task__t { flex: 1; min-width: 0; }
.ahlp-task__title { font-size: 13.5px; font-weight: 600; color: var(--fg, #131210); }
.ahlp-task__title.is-done { text-decoration: line-through; }
.ahlp-task__desc { font-size: 12px; color: var(--fg-soft, #8D897E); margin-top: 2px; line-height: 1.4; }
.ahlp-task__note { font-size: 11px; font-style: italic; color: var(--fg-soft, #8D897E); margin-top: 4px; }
.ahlp-task__assignee { font-size: 11px; color: var(--fg-soft, #8D897E); margin-top: 4px; }
.ahlp-task__acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.ahlp-task__btn {
  font: inherit; font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 7px 11px;
  min-height: 32px; cursor: pointer; border: 1px solid var(--border-strong, var(--border, #E3DED2));
  background: var(--bg-elev, #FAF8F4); color: var(--fg, #131210);
}
.ahlp-task__btn:hover { border-color: var(--brand, #1B3FE8); color: var(--brand, #1B3FE8); }
.ahlp-task__btn.primary { background: var(--brand, #1B3FE8); color: #fff; border-color: var(--brand, #1B3FE8); }
.ahlp-task__btn.primary:hover { filter: brightness(.92); }

/* V2.95 — formulário inline de "Delegar" (seletor de pessoa + prazo opcional).
   Fica dentro do próprio card da tarefa, sem modal — menos clique. */
.ahlp-delegate { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border, #E3DED2); display: flex; flex-direction: column; gap: 8px; }
.ahlp-delegate__select,
.ahlp-delegate__due {
  width: 100%; font: inherit; font-size: 13px; padding: 9px 10px; box-sizing: border-box;
  border: 1px solid var(--border, #E3DED2); border-radius: 10px; background: var(--bg-elev, #FAF8F4); color: var(--fg, #131210);
  min-height: 40px;
}
.ahlp-delegate__select:focus,
.ahlp-delegate__due:focus { outline: none; border-color: var(--brand, #1B3FE8); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand, #1B3FE8) 15%, transparent); }

/* mobile: sheet fullwidth */
@media (max-width: 480px) {
  .ahlp-fab { right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .ahlp-panel { right: 8px; left: 8px; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); width: auto; max-height: calc(100vh - 190px); }
}

/* ── Dark mode ── */
html.agm-dark .ahlp-fab,
[data-theme="dark"] .ahlp-fab { background: var(--bg-elev, #241F1A); border-color: var(--border, #3A342C); }
html.agm-dark .ahlp-panel,
[data-theme="dark"] .ahlp-panel { background: var(--bg-elev, #241F1A); border-color: var(--border, #3A342C); }
html.agm-dark .ahlp-head,
[data-theme="dark"] .ahlp-head { border-color: var(--border, #3A342C); background: linear-gradient(120deg, color-mix(in srgb, var(--brand-dark, #4C7CF0) 16%, transparent), var(--bg-elev, #241F1A) 72%); }
html.agm-dark .ahlp-head__t b,
[data-theme="dark"] .ahlp-head__t b { color: var(--fg, #ECE7DD); }
html.agm-dark .ahlp-tabs,
[data-theme="dark"] .ahlp-tabs { border-color: var(--border, #3A342C); background: var(--bg-elev, #241F1A); }
html.agm-dark .ahlp-tab.is-active,
[data-theme="dark"] .ahlp-tab.is-active { background: var(--brand-dark, #4C7CF0); }
html.agm-dark .ahlp-search,
[data-theme="dark"] .ahlp-search,
html.agm-dark .ahlp-art,
[data-theme="dark"] .ahlp-art,
html.agm-dark .ahlp-task,
[data-theme="dark"] .ahlp-task { background: var(--bg, #1A1612); border-color: var(--border, #3A342C); color: var(--fg, #ECE7DD); }
html.agm-dark .ahlp-art__q,
[data-theme="dark"] .ahlp-art__q,
html.agm-dark .ahlp-task__title,
[data-theme="dark"] .ahlp-task__title { color: var(--fg, #ECE7DD); }
html.agm-dark .ahlp-task__btn,
[data-theme="dark"] .ahlp-task__btn { background: var(--bg-elev, #241F1A); border-color: var(--border, #3A342C); color: var(--fg, #ECE7DD); }
html.agm-dark .ahlp-delegate__select,
[data-theme="dark"] .ahlp-delegate__select,
html.agm-dark .ahlp-delegate__due,
[data-theme="dark"] .ahlp-delegate__due { background: var(--bg, #1A1612); border-color: var(--border, #3A342C); color: var(--fg, #ECE7DD); }
html.agm-dark .ahlp-section-h,
[data-theme="dark"] .ahlp-section-h { border-color: var(--border, #3A342C); }
/* V2.95 (conserto C11) — o verde de sucesso `.is-complete` (#2D6A4F, linha
   ~141) foi escolhido pro fundo claro; no escuro fica quase ilegível em cima
   de `--bg-elev` (#241F1A). Mesmo tom mais claro já usado nos "ok" do produto
   em telas escuras (ACERTO — ver histórico de dark mode "estilo Claude"). */
html.agm-dark .ahlp-progress-wrap.is-complete .ahlp-progress-label,
[data-theme="dark"] .ahlp-progress-wrap.is-complete .ahlp-progress-label { color: #6FCF97; }

/* ══════════════════════════════════════════════════════════════════════════
   .onb-highlight — V2.95 (primeira entrada guiada)
   Anel Cobalto em volta do elemento-alvo de um passo do checklist quando a
   pessoa toca em "Fazer agora" e cai numa tela diferente (ex.: Gestão →
   Configuração). Aplicado pela ponte _onboarding-tasks.js via
   `[data-onb="<step_key>"]` — qualquer elemento da página pode ser o alvo,
   não só os do próprio widget de ajuda. Some sozinho depois de alguns
   segundos (ver _onboarding-tasks.js); aqui é só o visual.
   Respeita prefers-reduced-motion (sem pulso pra quem pediu menos movimento)
   e os dois seletores de dark mode do produto (html.agm-dark / data-theme).
   ══════════════════════════════════════════════════════════════════════════ */
.onb-highlight {
  position: relative;
  outline: 3px solid var(--brand, #1B3FE8);
  outline-offset: 3px;
  border-radius: 10px;
  animation: onb-highlight-pulse 1.6s ease-in-out 2;
}
@keyframes onb-highlight-pulse {
  0%, 100% { outline-color: var(--brand, #1B3FE8); box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand, #1B3FE8) 35%, transparent); }
  50% { outline-color: color-mix(in srgb, var(--brand, #1B3FE8) 70%, white 30%); box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand, #1B3FE8) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .onb-highlight { animation: none; }
}
html.agm-dark .onb-highlight,
[data-theme="dark"] .onb-highlight { outline-color: var(--brand-dark, #4C7CF0); }
@media (prefers-reduced-motion: no-preference) {
  html.agm-dark .onb-highlight,
  [data-theme="dark"] .onb-highlight { animation-name: onb-highlight-pulse-dark; }
}
@keyframes onb-highlight-pulse-dark {
  0%, 100% { outline-color: var(--brand-dark, #4C7CF0); box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand-dark, #4C7CF0) 35%, transparent); }
  50% { outline-color: color-mix(in srgb, var(--brand-dark, #4C7CF0) 70%, white 30%); box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand-dark, #4C7CF0) 0%, transparent); }
}
