/* ============================================================
   Help Widget - Posso ajudar? (Mini Chat de Pesquisa)
   Dashboard
   ============================================================ */

.help-widget-trigger {
  position: fixed;
  bottom: 24px;
  left: calc(var(--app-sidebar-width, 250px) + 24px);
  z-index: 99999;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #316AFF, #2555cc);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(49, 106, 255, 0.4);
  transition: all 0.3s ease;
}

.help-widget-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(49, 106, 255, 0.5);
}

.help-widget-trigger i {
  font-size: 18px;
}

.help-widget-card {
  position: fixed;
  bottom: 80px;
  left: calc(var(--app-sidebar-width, 250px) + 24px);
  width: 380px;
  max-width: calc(100vw - 48px);
  max-height: min(520px, calc(100vh - 120px));
  background: var(--bs-body-bg, #fff);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  z-index: 99998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--bs-border-color);
  animation: helpWidgetSlideUp 0.3s ease-out;
  isolation: isolate;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.help-widget-card.is-open {
  display: flex;
}

@keyframes helpWidgetSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.help-widget-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #316AFF, #2555cc);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.help-widget-header h6 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-widget-header h6 i {
  font-size: 18px;
}

.help-widget-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.help-widget-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.help-widget-search {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--bs-border-color);
  flex-shrink: 0;
  background: var(--bs-body-bg, #fff);
}

.help-widget-search-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--bs-secondary-color);
  line-height: 1.4;
}

.help-widget-search-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  font-family: inherit;
  background: var(--bs-light);
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
}

.help-widget-search .form-control {
  border-radius: 10px;
  padding: 10px 14px 10px 40px;
  font-size: 14px;
}

.help-widget-search .input-wrapper {
  position: relative;
}

.help-widget-search .input-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  font-size: 16px;
}

.help-widget-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  background: var(--bs-body-bg, #fff);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(49, 106, 255, 0.35) transparent;
}

.help-widget-body::-webkit-scrollbar {
  width: 6px;
}

.help-widget-body::-webkit-scrollbar-track {
  background: transparent;
}

.help-widget-body::-webkit-scrollbar-thumb {
  background: rgba(49, 106, 255, 0.28);
  border-radius: 999px;
}

.help-widget-body::-webkit-scrollbar-thumb:hover {
  background: rgba(49, 106, 255, 0.45);
}

/* Caso o SimpleBar seja aplicado em outro contexto, evita faixa branca */
.help-widget-body .simplebar-wrapper,
.help-widget-body .simplebar-mask,
.help-widget-body .simplebar-offset,
.help-widget-body .simplebar-content-wrapper,
.help-widget-body .simplebar-content,
.help-widget-body .simplebar-placeholder {
  background: var(--bs-body-bg, #fff);
}

.help-widget-welcome {
  padding: 16px;
  text-align: center;
}

.help-widget-welcome.is-hidden {
  display: none;
}

.help-widget-welcome i {
  font-size: 36px;
  color: var(--bs-primary);
  margin-bottom: 12px;
}

.help-widget-welcome p {
  margin: 0;
  font-size: 14px;
  color: var(--bs-secondary-color);
}

.help-widget-suggestions {
  margin-top: 12px;
}

.help-widget-suggestions-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
  margin-bottom: 8px;
  padding: 0 4px;
}

.help-widget-suggestion-chip {
  display: inline-block;
  padding: 6px 12px;
  margin: 4px 4px 4px 0;
  background: var(--bs-light);
  border-radius: 20px;
  font-size: 12px;
  color: var(--bs-body-color);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.help-widget-suggestion-chip:hover {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary);
}

/* Chat */
.help-widget-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px 8px;
}

.help-widget-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}

.help-widget-msg--user {
  justify-content: flex-end;
}

.help-widget-msg--assistant {
  justify-content: flex-start;
}

.help-widget-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(49, 106, 255, 0.12);
  color: #316AFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
}

.help-widget-msg-bubble {
  max-width: calc(100% - 36px);
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
}

.help-widget-msg--user .help-widget-msg-bubble {
  background: linear-gradient(135deg, #316AFF, #2555cc);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.help-widget-msg--user .help-widget-msg-bubble p {
  margin: 0;
  font-weight: 500;
}

.help-widget-msg--assistant .help-widget-msg-bubble {
  background: var(--bs-light);
  color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color);
  border-bottom-left-radius: 4px;
}

.help-widget-msg--status .help-widget-msg-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.help-widget-status-label {
  font-weight: 600;
  color: var(--bs-secondary-color);
}

.help-widget-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.help-widget-typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #316AFF;
  opacity: 0.35;
  animation: helpWidgetTyping 1.2s infinite ease-in-out;
}

.help-widget-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.help-widget-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes helpWidgetTyping {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.help-widget-msg-text {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--bs-body-color);
}

.help-widget-msg-text--error {
  color: var(--bs-danger);
  margin-bottom: 0;
}

.help-widget-chat-results {
  margin-top: 4px;
}

.help-widget-chat-results .help-widget-result-item {
  background: #fff;
  border: 1px solid rgba(12, 36, 60, 0.06);
}

.help-widget-chat-results .help-widget-result-item span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.help-widget-chat-results .help-widget-result-item strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--bs-body-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.help-widget-chat-results .help-widget-result-item em {
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #316AFF;
}

.help-widget-chat-results .help-widget-result-item small {
  font-size: 11px;
  color: var(--bs-secondary-color);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.help-widget-msg-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #316AFF;
  text-decoration: none;
}

.help-widget-msg-more:hover {
  color: #2555cc;
  text-decoration: underline;
}

.help-widget-results {
  display: none;
}

.help-widget-results.is-visible {
  display: block;
}

.help-widget-results-group {
  margin-bottom: 16px;
}

.help-widget-results-group:last-child {
  margin-bottom: 0;
}

.help-widget-results-category {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
  margin-bottom: 8px;
  padding: 0 4px;
}

.help-widget-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--bs-body-color);
  transition: background 0.2s;
  margin-bottom: 4px;
}

.help-widget-result-item:hover {
  background: var(--bs-light);
}

.help-widget-result-item i {
  font-size: 18px;
  color: var(--bs-primary);
  width: 24px;
  text-align: center;
}

.help-widget-result-item span {
  font-size: 14px;
  font-weight: 500;
}

.help-widget-empty {
  display: none;
  padding: 24px 16px;
  text-align: center;
}

.help-widget-empty.is-visible {
  display: block;
}

.help-widget-empty i {
  font-size: 40px;
  color: var(--bs-danger);
  margin-bottom: 12px;
}

.help-widget-empty p {
  margin: 0;
  font-size: 14px;
  color: var(--bs-secondary-color);
}

/* Portal: sem sidebar, botão no canto esquerdo */
.portal-body .help-widget-trigger,
.portal-body .help-widget-card {
  left: 24px;
}

.portal-body .help-widget-card,
.portal-body .help-widget-search,
.portal-body .help-widget-body {
  background: #fff;
}

/* Mobile: sidebar é overlay, botão no canto esquerdo */
@media (max-width: 1199.98px) {
  .help-widget-trigger {
    left: 24px;
  }

  .help-widget-card {
    left: 24px;
  }
}
