/* TherapyFlow Help Bubble */
.tf-help-bubble-root {
  position: fixed;
  z-index: 1400;
  bottom: 1.25rem;
  inset-inline-end: 1.25rem;
  font-family: inherit;
}

.tf-help-fab {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 999px;
  border: 0;
  background: var(--primary, #0d9488);
  color: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tf-help-fab:hover,
.tf-help-fab.is-open {
  transform: scale(1.05);
}

.tf-help-fab-label {
  font-size: 0.75rem;
  font-weight: 700;
}

.tf-help-badge {
  position: absolute;
  top: -0.15rem;
  inset-inline-end: -0.15rem;
  min-width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
}

.tf-help-badge.hidden,
.tf-help-panel.hidden,
.tf-help-diag.hidden {
  display: none !important;
}

.tf-help-panel {
  position: absolute;
  bottom: 4.25rem;
  inset-inline-end: 0;
  width: min(380px, calc(100vw - 1.5rem));
  max-height: min(640px, calc(100vh - 6rem));
  background: var(--surface, #fff);
  color: inherit;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: tfHelpIn 0.18s ease-out;
}

@keyframes tfHelpIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tf-help-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  background: var(--primary, #0d9488);
  color: #fff;
}

.tf-help-panel-header h2 {
  margin: 0;
  font-size: 1rem;
}

.tf-help-close {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.tf-help-panel-body {
  padding: 0.85rem;
  overflow: auto;
  flex: 1;
}

.tf-help-form label,
.tf-help-reply {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
}

.tf-help-form input,
.tf-help-form textarea,
.tf-help-reply textarea {
  width: 100%;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  background: var(--input-bg, #fff);
  color: inherit;
}

.tf-help-drop {
  border: 1px dashed var(--border-color, #cbd5e1);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted, #64748b);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.tf-help-drop.drag {
  border-color: var(--primary, #0d9488);
  background: rgba(13, 148, 136, 0.08);
}

.tf-help-file-name {
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.tf-help-diag {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 0.45rem !important;
  font-size: 0.85rem;
}

.tf-help-thread {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 320px;
  overflow: auto;
  margin-bottom: 0.75rem;
}

.tf-help-bubble {
  max-width: 85%;
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-color, #e2e8f0);
  background: #fff;
}

.tf-help-bubble--user {
  align-self: flex-end;
  background: #ecfdf5;
}

.tf-help-bubble--support {
  align-self: flex-start;
}

.tf-help-bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
}

.tf-help-thanks {
  background: #f0fdfa;
  border-radius: 10px;
  padding: 0.7rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.tf-help-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.tf-help-list-item {
  text-align: start;
  border: 1px solid var(--border-color, #e2e8f0);
  background: transparent;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.tf-help-list-item span {
  color: var(--text-muted, #64748b);
  font-size: 0.8rem;
}

.tf-help-empty {
  color: var(--text-muted, #64748b);
}

html[data-theme="dark"] .tf-help-panel,
html[data-theme="dark"] .tf-help-bubble {
  background: var(--surface, #1f2326);
}

html[data-theme="dark"] .tf-help-bubble--user {
  background: rgba(13, 148, 136, 0.2);
}

@media (max-width: 640px) {
  .tf-help-panel {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-height: 95vh;
    border-radius: 16px 16px 0 0;
    bottom: 0;
  }
}

/* Sit above the CRM mobile bottom nav so Help does not cover "More" */
@media (max-width: 768px) {
  body:has(.mobile-bottom-bar) .tf-help-bubble-root {
    bottom: calc(var(--tf-mobile-fab-bottom-offset, 76px) + env(safe-area-inset-bottom, 0px));
    inset-inline-end: 1rem;
  }
}
