/* =====================================================================
   Docefy — Central de Ajuda (widget flutuante do app)
   Usa os tokens de docefy.css. Marcação em Views/Shared/_HelpChat.cshtml,
   listas montadas por wwwroot/js/help-chat.js.
   ===================================================================== */

.help-chat-widget {
  font-family: var(--ds-font);
  color: var(--ds-ink);
}

/* Botão flutuante */
.help-chat-toggle {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 1045;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: var(--ds-r-pill);
  background: var(--ds-ink);
  color: #fff;
  font-size: 1.4rem;
  box-shadow: 0 10px 24px -12px rgba(23, 22, 28, 0.45);
  transition: background-color 0.15s ease, transform 0.2s var(--ds-ease);
}
.help-chat-toggle:hover { background: var(--ds-ink-2); }
.help-chat-toggle:active { transform: scale(0.96); }
.help-chat-toggle:focus-visible { outline: 2px solid var(--ds-brand-500); outline-offset: 3px; }
.help-chat-toggle[aria-expanded="true"] { display: none; }

/* Painel */
.help-chat-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1060;
  display: none;
  flex-direction: column;
  width: min(400px, calc(100vw - 2rem));
  height: min(680px, calc(100dvh - 2rem));
  overflow: hidden;
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-r-lg);
  background: var(--ds-surface);
  box-shadow: 0 24px 48px -20px rgba(23, 22, 28, 0.3), 0 2px 8px rgba(23, 22, 28, 0.06);
}
.help-chat-panel[hidden] { display: none !important; }

.help-chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1055;
  display: none;
  background: rgba(23, 22, 28, 0.25);
}
.help-chat-backdrop[hidden] { display: none !important; }

.help-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--ds-line);
}
.help-chat-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.help-chat-title i { display: none; }
.help-chat-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.875rem;
  color: var(--ds-ink-3);
}
.help-chat-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--ds-r-pill);
  background: var(--ds-fill);
  color: var(--ds-ink-2);
}
.help-chat-close:hover { background: var(--ds-fill-2); color: var(--ds-ink); }

.help-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* Busca */
.help-chat-search { padding: 1rem 1.25rem 0.5rem; }
.help-chat-body.is-detail-view .help-chat-search { display: none; }
.help-chat-search-field {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  border-radius: var(--ds-r-pill);
  background: var(--ds-canvas);
}
.help-chat-search-field:focus-within { box-shadow: 0 0 0 1.5px var(--ds-ink-2); }
.help-chat-search-icon {
  display: grid;
  place-items: center;
  width: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ds-ink-3);
}
.help-chat-search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 2.5rem 0 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ds-ink);
  font-family: var(--ds-font);
  font-size: 0.9375rem;
}
/* O anel de foco é o da pílula (:focus-within); o seletor precisa vencer o body.app-body :focus-visible. */
.help-chat-search-field .help-chat-search-input:focus { outline: none; box-shadow: none; background: transparent; }
.help-chat-search-input::placeholder { color: var(--ds-ink-4); }
.help-chat-search-clear {
  position: absolute;
  right: 6px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--ds-r-pill);
  background: transparent;
  color: var(--ds-ink-3);
}
.help-chat-search-clear:hover { background: var(--ds-fill-2); color: var(--ds-ink); }
.help-chat-search-results-count {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--ds-ink-3);
}

/* Conteúdo */
.help-chat-content,
.help-chat-detail {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.5rem 1.25rem 1.5rem;
}
.help-chat-content[hidden],
.help-chat-detail[hidden],
.help-chat-section[hidden],
.help-chat-loading[hidden],
.help-chat-category-topics[hidden] { display: none !important; }

.help-chat-section + .help-chat-section { margin-top: 1.5rem; }
.help-chat-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ds-ink-3);
}
.help-chat-section-title i { display: none; }

/* Categorias (acordeão) */
.help-chat-categories {
  display: grid;
  gap: 0.25rem;
}
.help-chat-category {
  border-radius: var(--ds-r-md);
  background: var(--ds-canvas);
}
.help-chat-category-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 52px;
  padding: 0.6rem 0.875rem;
  border: 0;
  border-radius: var(--ds-r-md);
  background: transparent;
  color: var(--ds-ink);
  font-family: var(--ds-font);
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: left;
}
.help-chat-category-header > span:first-of-type { flex: 1 1 auto; }
.help-chat-category-header:hover { background: var(--ds-fill); }
.help-chat-category-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: var(--ds-r-pill);
  background: var(--ds-surface);
  color: var(--ds-ink-2);
  font-size: 0.95rem;
}
.help-chat-category-count {
  min-width: 24px;
  padding: 0.1rem 0.45rem;
  border-radius: var(--ds-r-pill);
  background: var(--ds-surface);
  color: var(--ds-ink-3);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}
.help-chat-category-header > .bi-chevron-down {
  color: var(--ds-ink-3);
  font-size: 0.85rem;
  transition: transform 0.2s var(--ds-ease);
}
.help-chat-category-header.is-expanded > .bi-chevron-down { transform: rotate(180deg); }
.help-chat-category-topics { padding: 0 0.5rem 0.5rem; }

/* Tópicos (linhas) */
.help-chat-topics { display: grid; }
.help-chat-topic-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.7rem 0.5rem;
  border: 0;
  border-radius: var(--ds-r-sm);
  background: transparent;
  color: var(--ds-ink);
  font-family: var(--ds-font);
  text-align: left;
}
.help-chat-topic-item + .help-chat-topic-item { box-shadow: 0 -1px 0 var(--ds-line); }
.help-chat-topic-item:hover { background: var(--ds-surface); }
.help-chat-topics .help-chat-topic-item:hover { background: var(--ds-canvas); }
.help-chat-topic-item > .bi-chevron-right { color: var(--ds-ink-4); font-size: 0.85rem; }
.help-chat-topic-content {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1 1 auto;
  min-width: 0;
}
.help-chat-topic-title {
  font-size: 0.9063rem;
  font-weight: 500;
  line-height: 1.35;
}
.help-chat-topic-title mark {
  padding: 0 0.1em;
  border-radius: 3px;
  background: var(--ds-warning-100);
  color: inherit;
}
.help-chat-topic-category {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--ds-ink-3);
}
.help-chat-category .help-chat-topic-category { display: none; }
.help-chat-topic-favorite {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--ds-r-pill);
  background: transparent;
  color: var(--ds-ink-4);
}
.help-chat-topic-favorite:hover { background: var(--ds-fill); color: var(--ds-ink-2); }
.help-chat-topic-favorite.is-favorite { color: var(--ds-warning-500); }

/* Contato */
.help-chat-contact-options { display: grid; gap: 0.25rem; }
.help-chat-contact-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.875rem;
  border-radius: var(--ds-r-md);
  background: var(--ds-canvas);
  color: var(--ds-ink);
  text-decoration: none;
}
.help-chat-contact-item:hover { background: var(--ds-fill); color: var(--ds-ink); }
.help-chat-contact-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: var(--ds-r-pill);
  background: var(--ds-surface);
  color: var(--ds-ink-2);
}
.help-chat-contact-content { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.help-chat-contact-title { font-size: 0.9063rem; font-weight: 600; }
.help-chat-contact-description {
  overflow: hidden;
  font-size: 0.8125rem;
  color: var(--ds-ink-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.help-chat-contact-arrow { color: var(--ds-ink-4); font-size: 0.85rem; }

/* Carregando */
.help-chat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
  color: var(--ds-ink-3);
}
.help-chat-loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--ds-fill-2);
  border-top-color: var(--ds-ink);
  border-radius: 50%;
  animation: help-spin 0.8s linear infinite;
}
.help-chat-loading-text { margin: 0; font-size: 0.875rem; }
@keyframes help-spin { to { transform: rotate(360deg); } }
.help-chat-skeleton-item {
  height: 52px;
  margin-bottom: 0.25rem;
  border-radius: var(--ds-r-md);
  background: var(--ds-canvas);
  animation: help-pulse 1.4s ease-in-out infinite;
}
@keyframes help-pulse { 50% { opacity: 0.55; } }

/* Vazio */
.help-chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 2rem 1rem;
  text-align: center;
}
.help-chat-empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 0.25rem;
  border-radius: var(--ds-r-pill);
  background: var(--ds-fill);
  color: var(--ds-ink-3);
  font-size: 1.15rem;
}
.help-chat-empty-title { font-weight: 600; }
.help-chat-empty-text { max-width: 28ch; font-size: 0.875rem; color: var(--ds-ink-3); }

/* Detalhe do tópico */
.help-chat-detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0 1rem;
}
.help-chat-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0.35rem 0.85rem 0.35rem 0.65rem;
  border: 0;
  border-radius: var(--ds-r-pill);
  background: var(--ds-fill);
  color: var(--ds-ink);
  font-family: var(--ds-font);
  font-size: 0.875rem;
  font-weight: 600;
}
.help-chat-detail-back:hover { background: var(--ds-fill-2); }
.help-chat-detail-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  overflow: hidden;
  font-size: 0.8125rem;
  color: var(--ds-ink-3);
  white-space: nowrap;
}
.help-chat-detail-breadcrumb-item { overflow: hidden; text-overflow: ellipsis; }
.help-chat-detail-breadcrumb-separator { color: var(--ds-ink-4); }
.help-chat-detail-title {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}
.help-chat-detail-body {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ds-ink-2);
}
.help-chat-detail-body > :first-child { margin-top: 0; }
.help-chat-detail-body p,
.help-chat-detail-body ul,
.help-chat-detail-body ol { margin: 0 0 0.875rem; }
.help-chat-detail-body ul,
.help-chat-detail-body ol { padding-left: 1.25rem; }
.help-chat-detail-body li + li { margin-top: 0.35rem; }
.help-chat-detail-body :is(h3, h4, h5, h6) {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  font-style: normal;
  color: var(--ds-ink);
}
.help-chat-detail-body strong { color: var(--ds-ink); font-weight: 600; }
.help-chat-detail-body em { font-style: normal; font-weight: 600; color: var(--ds-ink); }
.help-chat-detail-body a { color: var(--ds-ink); font-weight: 600; text-decoration: underline; }
.help-chat-detail-body code {
  padding: 0.1rem 0.35rem;
  border-radius: var(--ds-r-xs);
  background: var(--ds-fill);
  color: var(--ds-ink);
  font-size: 0.85em;
}
.help-chat-detail-related {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ds-line);
}
.help-chat-detail-related-title {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ds-ink-3);
}

/* Celular: painel ocupa a tela e o botão sobe acima das abas */
@media (max-width: 1024.98px) {
  .help-chat-toggle {
    right: 1rem;
    bottom: calc(var(--ds-tabbar-h, 64px) + env(safe-area-inset-bottom) + 0.875rem);
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }
}
@media (max-width: 575.98px) {
  .help-chat-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .help-chat-toggle,
  .help-chat-category-header > .bi-chevron-down { transition: none; }
  .help-chat-loading-spinner,
  .help-chat-skeleton-item { animation: none; }
}
