/* =============================================================================
   help.css — Floating Help FAB + Help Documentation Page
   ============================================================================= */

/* ── Help FAB (Floating Action Button) ──────────────────────────────────────── */

.help-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--color-primary-500), var(--color-accent-500, #6366f1));
  color: white;
  border-radius: 50%;
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-semibold, 600);
  font-family: var(--font-family-base, inherit);
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35), 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  z-index: 200;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease,
              background 0.25s ease;
  border: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.help-fab:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.45), 0 4px 12px rgba(0, 0, 0, 0.2);
  text-decoration: none;
  color: white;
}

.help-fab:active {
  transform: translateY(-1px) scale(1.01);
}

.help-fab svg {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.help-fab:hover svg {
  transform: rotate(-10deg);
}

/* The label has been removed from the template, so media queries are no longer needed for it */

/* ── Help Page Layout ─────────────────────────────────────────────────────── */

.help-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-8, 2rem) var(--spacing-6, 1.5rem) var(--spacing-16, 4rem);
  position: relative;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.help-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-bg, #ffffff);
  padding-top: var(--spacing-6, 1.5rem);
  padding-bottom: var(--spacing-6, 1.5rem);
  border-bottom: 1px solid var(--color-border, rgba(255,255,255,0.1));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-6, 1.5rem);
  margin-bottom: var(--spacing-8, 2rem);
  flex-wrap: wrap;
}

.help-header__title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: var(--font-weight-bold, 700);
  margin-bottom: var(--spacing-2, 0.5rem);
  line-height: 1.15;
}

.help-header__subtitle {
  color: var(--color-text-secondary, #64748b);
  font-size: var(--font-size-base, 1rem);
  margin: 0;
}

.help-header__search {
  flex-shrink: 0;
  width: 280px;
}

@media (max-width: 640px) {
  .help-header__search {
    width: 100%;
  }
}

.help-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.help-search-icon {
  position: absolute;
  left: 12px;
  color: var(--color-text-muted, #94a3b8);
  pointer-events: none;
  flex-shrink: 0;
}

.help-search-input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: var(--color-bg-elevated, #1e293b);
  border: 1px solid var(--color-border, rgba(255,255,255,0.1));
  border-radius: var(--radius-full, 9999px);
  color: var(--color-text, #f1f5f9);
  font-size: var(--font-size-sm, 0.875rem);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.help-search-input:focus {
  border-color: var(--color-primary-500, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.help-search-input::placeholder {
  color: var(--color-text-muted, #94a3b8);
}

/* ── Body: Sidebar + Content ─────────────────────────────────────────────── */

.help-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--spacing-8, 2rem);
  align-items: start;
}

@media (max-width: 768px) {
  .help-body {
    grid-template-columns: 1fr;
  }
}

/* ── Table of Contents ───────────────────────────────────────────────────── */

.help-toc {
  position: sticky;
  top: 140px; /* Adjusted to stay below the sticky header */
  background: var(--color-bg-secondary, #0f172a);
  border: 1px solid var(--color-border, rgba(255,255,255,0.08));
  border-radius: var(--radius-xl, 0.75rem);
  padding: var(--spacing-4, 1rem);
  max-height: calc(100vh - 160px); /* Adjusted to fit the viewport with the new top position */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border, rgba(255,255,255,0.1)) transparent;
}

.help-toc__header {
  display: flex;
  align-items: center;
  gap: var(--spacing-2, 0.5rem);
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: var(--font-weight-semibold, 600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted, #94a3b8);
  margin-bottom: var(--spacing-3, 0.75rem);
  padding-bottom: var(--spacing-3, 0.75rem);
  border-bottom: 1px solid var(--color-border-subtle, rgba(255,255,255,0.05));
}

.help-toc__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.help-toc__item {
  display: block;
}

.help-toc__item--h3 {
  padding-left: var(--spacing-3, 0.75rem);
}

.help-toc__link {
  display: block;
  padding: 5px var(--spacing-2, 0.5rem);
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--color-text-secondary, #94a3b8);
  text-decoration: none;
  border-radius: var(--radius-md, 0.375rem);
  transition: color 0.15s ease, background 0.15s ease;
  line-height: 1.4;
}

.help-toc__link:hover {
  color: var(--color-text, #f1f5f9);
  background: var(--color-bg-tertiary, rgba(255,255,255,0.05));
  text-decoration: none;
}

.help-toc__link.active {
  color: var(--color-primary-400, #818cf8);
  background: rgba(99, 102, 241, 0.1);
  font-weight: var(--font-weight-medium, 500);
}

@media (max-width: 768px) {
  .help-toc {
    position: static;
    max-height: 200px;
  }
}

/* ── Loading & Error ─────────────────────────────────────────────────────── */

.help-loading:not([hidden]),
.help-error:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-4, 1rem);
  padding: var(--spacing-16, 4rem) var(--spacing-8, 2rem);
  color: var(--color-text-muted, #94a3b8);
  text-align: center;
}

.help-loading__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border, rgba(255,255,255,0.1));
  border-top-color: var(--color-primary-500, #6366f1);
  border-radius: 50%;
  animation: help-spin 0.8s linear infinite;
}

@keyframes help-spin {
  to { transform: rotate(360deg); }
}

.help-error svg {
  color: var(--color-warning, #f59e0b);
  opacity: 0.8;
}

/* ── Markdown Content ────────────────────────────────────────────────────── */

.help-markdown {
  min-height: 400px;
  animation: help-fadeIn 0.3s ease;
}

.help-search-meta:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-4, 1rem);
  margin-bottom: var(--spacing-5, 1.25rem);
  padding: var(--spacing-3, 0.75rem) var(--spacing-4, 1rem);
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.14);
  border-radius: var(--radius-lg, 0.5rem);
}

.help-search-meta__text {
  margin: 0;
  color: var(--color-text-secondary, #cbd5e1);
  line-height: 1.5;
}

.help-search-meta__clear,
.help-empty-state__clear {
  flex-shrink: 0;
  border: 1px solid var(--color-border, rgba(255,255,255,0.12));
  background: var(--color-bg-elevated, #1e293b);
  color: var(--color-text, #f1f5f9);
  border-radius: var(--radius-full, 9999px);
  padding: 0.5rem 0.875rem;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.help-search-meta__clear:hover,
.help-empty-state__clear:hover {
  color: var(--color-primary-300, #a5b4fc);
  border-color: var(--color-primary-500, #6366f1);
  transform: translateY(-1px);
}

.help-empty-state:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-4, 1rem);
  padding: var(--spacing-12, 3rem) var(--spacing-8, 2rem);
  text-align: center;
  border: 1px dashed var(--color-border, rgba(255,255,255,0.12));
  border-radius: var(--radius-xl, 0.75rem);
  background: rgba(15, 23, 42, 0.45);
}

.help-empty-state__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--color-primary-300, #a5b4fc);
}

.help-empty-state__title {
  margin: 0;
  color: var(--color-text, #f1f5f9);
  font-size: 1.125rem;
  font-weight: var(--font-weight-semibold, 600);
}

.help-empty-state__body {
  margin: 0;
  max-width: 32rem;
  color: var(--color-text-secondary, #94a3b8);
  line-height: 1.65;
}

@keyframes help-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Headings */
.help-markdown h1 {
  font-size: 1.875rem;
  font-weight: var(--font-weight-bold, 700);
  margin-bottom: var(--spacing-6, 1.5rem);
  padding-bottom: var(--spacing-4, 1rem);
  border-bottom: 2px solid var(--color-primary-500, #6366f1);
  background: linear-gradient(135deg, var(--color-primary-400, #818cf8), var(--color-accent-400, #a78bfa));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.help-markdown h2 {
  font-size: 1.375rem;
  font-weight: var(--font-weight-semibold, 600);
  margin-top: var(--spacing-10, 2.5rem);
  margin-bottom: var(--spacing-4, 1rem);
  padding-top: var(--spacing-6, 1.5rem);
  color: var(--color-text, #f1f5f9);
  border-top: 1px solid var(--color-border-subtle, rgba(255,255,255,0.06));
  display: flex;
  align-items: center;
  gap: var(--spacing-2, 0.5rem);
  scroll-margin-top: 100px;
}

.help-markdown h2:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.help-markdown h3 {
  font-size: 1.125rem;
  font-weight: var(--font-weight-semibold, 600);
  margin-top: var(--spacing-6, 1.5rem);
  margin-bottom: var(--spacing-3, 0.75rem);
  color: var(--color-primary-300, #a5b4fc);
  scroll-margin-top: 100px;
}

.help-markdown h4 {
  font-size: 1rem;
  font-weight: var(--font-weight-semibold, 600);
  margin-top: var(--spacing-4, 1rem);
  margin-bottom: var(--spacing-2, 0.5rem);
  color: var(--color-text, #f1f5f9);
  scroll-margin-top: 100px;
}

/* Heading anchor link */
.help-heading-anchor {
  display: inline-flex;
  align-items: center;
  margin-left: var(--spacing-2, 0.5rem);
  color: var(--color-text-muted, #94a3b8);
  opacity: 0;
  transition: opacity 0.2s ease;
  text-decoration: none;
  vertical-align: middle;
  flex-shrink: 0;
}

.help-markdown h2:hover .help-heading-anchor,
.help-markdown h3:hover .help-heading-anchor,
.help-markdown h4:hover .help-heading-anchor {
  opacity: 1;
}

/* Paragraphs */
.help-markdown p {
  color: var(--color-text-secondary, #94a3b8);
  line-height: 1.7;
  margin-bottom: var(--spacing-4, 1rem);
  font-size: var(--font-size-base, 1rem);
}

/* Lists */
.help-markdown ul,
.help-markdown ol {
  margin-bottom: var(--spacing-4, 1rem);
  padding-left: var(--spacing-6, 1.5rem);
}

.help-markdown li {
  color: var(--color-text-secondary, #94a3b8);
  line-height: 1.7;
  margin-bottom: var(--spacing-2, 0.5rem);
}

.help-markdown li::marker {
  color: var(--color-primary-400, #818cf8);
}

/* Tables */
.help-table-wrap {
  overflow-x: auto;
  margin-bottom: var(--spacing-6, 1.5rem);
  border-radius: var(--radius-lg, 0.5rem);
  border: 1px solid var(--color-border, rgba(255,255,255,0.08));
}

.help-markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm, 0.875rem);
  background: var(--color-bg-secondary, #0f172a);
}

.help-markdown thead tr {
  background: linear-gradient(90deg, rgba(99,102,241,0.15), rgba(139,92,246,0.1));
}

.help-markdown th {
  text-align: left;
  padding: var(--spacing-3, 0.75rem) var(--spacing-4, 1rem);
  font-weight: var(--font-weight-semibold, 600);
  color: var(--color-text, #f1f5f9);
  font-size: var(--font-size-xs, 0.75rem);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.help-markdown td {
  padding: var(--spacing-3, 0.75rem) var(--spacing-4, 1rem);
  color: var(--color-text-secondary, #94a3b8);
  border-top: 1px solid var(--color-border-subtle, rgba(255,255,255,0.05));
}

.help-markdown tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

/* Code Blocks */
.help-markdown pre {
  position: relative;
  background: var(--color-bg-tertiary, rgba(0,0,0,0.3));
  border: 1px solid var(--color-border, rgba(255,255,255,0.08));
  border-radius: var(--radius-lg, 0.5rem);
  padding: var(--spacing-4, 1rem) var(--spacing-5, 1.25rem);
  overflow-x: auto;
  margin-bottom: var(--spacing-4, 1rem);
  font-size: 0.875rem;
  line-height: 1.65;
}

.help-markdown code {
  font-family: var(--font-family-mono, 'Courier New', monospace);
  font-size: 0.875em;
  background: rgba(99, 102, 241, 0.12);
  color: var(--color-primary-300, #a5b4fc);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm, 0.25rem);
}

.help-markdown pre code {
  background: transparent;
  color: var(--color-text, #f1f5f9);
  padding: 0;
  font-size: inherit;
  border-radius: 0;
}

.help-code-lang {
  position: absolute;
  top: var(--spacing-3, 0.75rem);
  right: var(--spacing-3, 0.75rem);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted, #94a3b8);
  font-family: var(--font-family-mono, monospace);
  background: var(--color-bg-elevated, #1e293b);
  padding: 2px 6px;
  border-radius: var(--radius-sm, 0.25rem);
}

/* Blockquote */
.help-markdown blockquote {
  border-left: 3px solid var(--color-primary-500, #6366f1);
  margin: var(--spacing-4, 1rem) 0;
  padding: var(--spacing-3, 0.75rem) var(--spacing-5, 1.25rem);
  background: rgba(99, 102, 241, 0.07);
  border-radius: 0 var(--radius-md, 0.375rem) var(--radius-md, 0.375rem) 0;
  color: var(--color-text-secondary, #94a3b8);
  font-style: italic;
}

/* Horizontal Rule */
.help-markdown hr {
  border: none;
  border-top: 1px solid var(--color-border-subtle, rgba(255,255,255,0.06));
  margin: var(--spacing-10, 2.5rem) 0;
}

/* Links */
.help-markdown a:not(.help-heading-anchor) {
  color: var(--color-primary-400, #818cf8);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.help-markdown a:not(.help-heading-anchor):hover {
  color: var(--color-primary-300, #a5b4fc);
}

/* Strong */
.help-markdown strong {
  color: var(--color-text, #f1f5f9);
  font-weight: var(--font-weight-semibold, 600);
}

/* ── Back to Top ─────────────────────────────────────────────────────────── */

.help-back-to-top {
  position: fixed;
  bottom: 86px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: var(--color-bg-elevated, #1e293b);
  border: 1px solid var(--color-border, rgba(255,255,255,0.12));
  border-radius: 50%;
  color: var(--color-text-secondary, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 190;
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Hide the global cookie floating icon on the help page */
.cookie-floating-icon {
  display: none !important;
}

.help-back-to-top:hover {
  color: var(--color-primary-400, #818cf8);
  border-color: var(--color-primary-500, #6366f1);
  background: var(--color-bg-tertiary, rgba(255,255,255,0.05));
  transform: translateY(-2px);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .help-page {
    padding: var(--spacing-4, 1rem) var(--spacing-4, 1rem) var(--spacing-12, 3rem);
  }

  .help-header {
    flex-direction: column;
  }

  .help-search-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .help-markdown h1 { font-size: 1.5rem; }
  .help-markdown h2 { font-size: 1.25rem; }

  .help-back-to-top {
    bottom: 80px;
    right: 16px;
  }

  .help-fab {
    bottom: 16px;
    right: 16px;
  }
}
