/* ============================================================
   Neurosia — B2B Qualification Chat Widget
   Floating FAB + qualification flow
   ============================================================ */

/* ── Floating Action Button (FAB) ────────────────────────── */
#b2b-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary, #FF5D17);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 93, 23, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--t-fast, 0.2s) ease, box-shadow var(--t-fast, 0.2s) ease, opacity var(--t-fast, 0.2s) ease;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

#b2b-chat-fab.b2b-chat-fab-visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

#b2b-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(255, 93, 23, 0.45);
}

#b2b-chat-fab:focus-visible {
  outline: 2px solid var(--primary-glow, rgba(255, 93, 23, 0.4));
  outline-offset: 3px;
}

#b2b-chat-fab svg {
  width: 26px;
  height: 26px;
  transition: transform 0.3s ease;
}

#b2b-chat-fab.b2b-chat-open svg {
  transform: rotate(90deg);
}

/* Pulse ring on FAB */
#b2b-chat-fab::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--primary, #FF5D17);
  opacity: 0;
  animation: b2b-pulse 2s ease-out infinite;
}

#b2b-chat-fab.b2b-chat-open::before {
  animation: none;
  opacity: 0;
}

@keyframes b2b-pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ── Chat Panel ───────────────────────────────────────────── */
#b2b-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9997;
  width: 380px;
  max-height: calc(100vh - 120px);
  background: var(--surface-1, #0d0d11);
  border: 1px solid var(--border, #222233);
  border-radius: var(--r-xl, 1rem);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  overflow: hidden;
  font-family: inherit;
}

#b2b-chat-panel.b2b-chat-panel-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* When chat is open, prevent page elements from intercepting clicks on the panel */
body.b2b-chat-open header,
body.b2b-chat-open main,
body.b2b-chat-open footer {
  pointer-events: none;
}

/* ── Panel Header ─────────────────────────────────────────── */
.b2b-chat-header {
  background: var(--primary, #FF5D17);
  padding: var(--sp-4, 1rem) var(--sp-5, 1.25rem);
  color: #fff;
  display: flex;
  align-items: center;
  gap: var(--sp-3, 0.75rem);
  flex-shrink: 0;
}

.b2b-chat-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.b2b-chat-header-icon svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.b2b-chat-header-text h3 {
  margin: 0;
  font-size: var(--text-base, 1rem);
  font-weight: 700;
  line-height: 1.3;
}

.b2b-chat-header-text p {
  margin: 0;
  font-size: var(--text-xs, 0.75rem);
  opacity: 0.9;
  line-height: 1.3;
}

.b2b-chat-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--r-md, 0.5rem);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast, 0.2s) ease;
}

.b2b-chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.b2b-chat-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.b2b-chat-close svg {
  width: 20px;
  height: 20px;
}

/* ── Panel Body ───────────────────────────────────────────── */
.b2b-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5, 1.25rem);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3, 0.75rem);
}

/* ── Step indicator ───────────────────────────────────────── */
.b2b-chat-steps {
  display: flex;
  gap: var(--sp-1, 0.25rem);
  margin-bottom: var(--sp-3, 0.75rem);
}

.b2b-chat-step-dot {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border, #222233);
  transition: background var(--t-fast, 0.2s) ease;
}

.b2b-chat-step-dot.b2b-chat-step-active {
  background: var(--primary, #FF5D17);
}

.b2b-chat-step-dot.b2b-chat-step-done {
  background: var(--primary-dim, #cc4a12);
}

/* ── Step content ─────────────────────────────────────────── */
.b2b-chat-step {
  display: none;
  flex-direction: column;
  gap: var(--sp-3, 0.75rem);
  animation: b2b-fade-in 0.3s ease;
}

.b2b-chat-step.b2b-chat-step-current {
  display: flex;
}

@keyframes b2b-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.b2b-chat-question {
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  color: var(--text, #e8e8ed);
  margin: 0;
  line-height: 1.4;
}

.b2b-chat-subtitle {
  font-size: var(--text-sm, 0.875rem);
  color: var(--text-3, #888);
  margin: 0;
  line-height: 1.4;
}

/* ── Option cards ─────────────────────────────────────────── */
.b2b-chat-options {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2, 0.5rem);
}

.b2b-chat-option {
  background: var(--surface-2, #161622);
  border: 1px solid var(--border, #222233);
  border-radius: var(--r-lg, 0.75rem);
  padding: var(--sp-3, 0.75rem) var(--sp-4, 1rem);
  cursor: pointer;
  transition: border-color var(--t-fast, 0.2s) ease, background var(--t-fast, 0.2s) ease, transform var(--t-fast, 0.2s) ease;
  text-align: left;
  color: var(--text, #e8e8ed);
  font-size: var(--text-sm, 0.875rem);
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: var(--sp-2, 0.5rem);
}

.b2b-chat-option:hover {
  border-color: var(--primary, #FF5D17);
  background: rgba(255, 93, 23, 0.08);
  transform: translateX(4px);
}

.b2b-chat-option:focus-visible {
  outline: 2px solid var(--primary, #FF5D17);
  outline-offset: 2px;
}

.b2b-chat-option-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Text input ──────────────────────────────────────────── */
.b2b-chat-input-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2, 0.5rem);
}

.b2b-chat-input {
  background: var(--surface-2, #161622);
  border: 1px solid var(--border, #222233);
  border-radius: var(--r-md, 0.5rem);
  padding: var(--sp-3, 0.75rem) var(--sp-4, 1rem);
  color: var(--text, #e8e8ed);
  font-size: var(--text-sm, 0.875rem);
  font-family: inherit;
  transition: border-color var(--t-fast, 0.2s) ease;
}

.b2b-chat-input:focus {
  outline: none;
  border-color: var(--primary, #FF5D17);
}

.b2b-chat-input::placeholder {
  color: var(--text-3, #888);
}

/* ── Navigation buttons ───────────────────────────────────── */
.b2b-chat-actions {
  display: flex;
  gap: var(--sp-2, 0.5rem);
  margin-top: var(--sp-2, 0.5rem);
}

.b2b-chat-btn {
  padding: var(--sp-2, 0.5rem) var(--sp-4, 1rem);
  border-radius: var(--r-md, 0.5rem);
  font-size: var(--text-sm, 0.875rem);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast, 0.2s) ease, transform var(--t-fast, 0.2s) ease;
  border: none;
  font-family: inherit;
}

.b2b-chat-btn-primary {
  background: var(--primary, #FF5D17);
  color: #fff;
}

.b2b-chat-btn-primary:hover {
  background: var(--primary-dim, #cc4a12);
  transform: translateY(-1px);
}

.b2b-chat-btn-primary:focus-visible {
  outline: 2px solid var(--primary-glow, rgba(255, 93, 23, 0.4));
  outline-offset: 2px;
}

.b2b-chat-btn-secondary {
  background: transparent;
  color: var(--text-3, #888);
  border: 1px solid var(--border, #222233);
}

.b2b-chat-btn-secondary:hover {
  color: var(--text, #e8e8ed);
  border-color: var(--text-3, #888);
}

/* ── Result screen ────────────────────────────────────────── */
.b2b-chat-result {
  text-align: center;
  padding: var(--sp-4, 1rem) 0;
}

.b2b-chat-result-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--sp-4, 1rem);
  border-radius: 50%;
  background: rgba(255, 93, 23, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.b2b-chat-result-icon svg {
  width: 32px;
  height: 32px;
  fill: var(--primary, #FF5D17);
}

.b2b-chat-result h4 {
  color: var(--text, #e8e8ed);
  font-size: var(--text-base, 1rem);
  margin: 0 0 var(--sp-2, 0.5rem) 0;
}

.b2b-chat-result p {
  color: var(--text-3, #888);
  font-size: var(--text-sm, 0.875rem);
  margin: 0 0 var(--sp-4, 1rem) 0;
  line-height: 1.5;
}

.b2b-chat-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2, 0.5rem);
  padding: var(--sp-3, 0.75rem) var(--sp-5, 1.25rem);
  background: #25D366;
  color: #fff;
  border-radius: var(--r-lg, 0.75rem);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--text-sm, 0.875rem);
  transition: background var(--t-fast, 0.2s) ease, transform var(--t-fast, 0.2s) ease;
}

.b2b-chat-cta:hover {
  background: #1fb856;
  transform: translateY(-1px);
  color: #fff;
}

.b2b-chat-cta svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.b2b-chat-cta--contact {
  background: var(--primary, #FF5D17);
}

.b2b-chat-cta--contact:hover {
  background: var(--primary-dim, #cc4a12);
}

.b2b-chat-result-links {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2, 0.5rem);
  margin-top: var(--sp-3, 0.75rem);
}

/* ── Back button ──────────────────────────────────────────── */
.b2b-chat-back {
  background: none;
  border: none;
  color: var(--text-3, #888);
  cursor: pointer;
  font-size: var(--text-sm, 0.875rem);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: var(--sp-1, 0.25rem);
  padding: 0;
  transition: color var(--t-fast, 0.2s) ease;
}

.b2b-chat-back:hover {
  color: var(--text, #e8e8ed);
}

.b2b-chat-back svg {
  width: 16px;
  height: 16px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
  #b2b-chat-panel {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 80px;
    max-height: calc(100vh - 96px);
  }

  #b2b-chat-fab {
    bottom: 16px;
    right: 16px;
  }
}

@media (min-width: 481px) and (max-width: 767px) {
  #b2b-chat-panel {
    width: calc(100vw - 48px);
    max-width: 400px;
  }
}

/* ── Accessibility: reduced motion ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #b2b-chat-fab,
  #b2b-chat-panel,
  .b2b-chat-option,
  .b2b-chat-btn,
  .b2b-chat-cta {
    transition: none;
  }

  .b2b-chat-step {
    animation: none;
  }

  #b2b-chat-fab::before {
    animation: none;
  }
}