/* ===== HELP BOT ===== */
#help-bot {
  position: fixed;
  right: 18px;
  bottom: 14px;
  z-index: 400;
  font-family: 'Geist', -apple-system, sans-serif;
}
/* Hidden on public profile pages: that screen belongs to the page owner */
#profile-view.active ~ #help-bot { display: none; }

.hb-launch {
  position: relative;
  display: block;
  width: 128px;
  height: 128px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transition: transform 0.25s;
}
.hb-launch:hover { transform: translateY(-3px) scale(1.04); }
.hb-launch:focus-visible { outline: 2px solid #fff; outline-offset: -6px; }
.hb-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Flat robot until (or unless) the 3D model loads */
.hb-fallback {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(10,10,12,0.92);
  border: 1px solid rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.hb-fallback-tag {
  position: absolute;
  top: -10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff;
  color: #000;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
#help-bot.has-3d .hb-fallback { display: none; }

.hb-hint {
  position: absolute;
  right: 112px;
  bottom: 70px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 14px;
  border-radius: 14px 14px 4px 14px;
  background: #fff;
  color: #000;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  animation: hbPop 0.35s ease both;
  cursor: var(--cursor-hover);
}
.hb-hint[hidden] { display: none; }
.hb-hint-x {
  border: 0;
  background: transparent;
  color: rgba(0,0,0,0.5);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 4px;
}
.hb-hint-x:hover { color: #000; }
@keyframes hbPop { from { opacity: 0; transform: translateY(6px) scale(0.96); } to { opacity: 1; transform: none; } }

/* Panel */
.hb-panel {
  position: absolute;
  right: 6px;
  bottom: 126px;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: min(600px, calc(100vh - 170px));
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: rgba(10,10,12,0.97);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 30px 80px rgba(0,0,0,0.65);
  overflow: hidden;
  animation: hbPop 0.25s ease both;
  color: var(--text, #f5f5f7);
}
.hb-panel[hidden] { display: none; }
.hb-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 12px 16px;
}
.hb-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hb-avatar svg { width: 30px; height: 30px; }
.hb-title { flex: 1; min-width: 0; }
.hb-title strong { display: block; font-family: 'Geist', sans-serif; font-size: 1.02rem; }
.hb-title span { font-size: 0.8rem; color: var(--text-muted, rgba(255,255,255,0.6)); }
.hb-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: var(--text-muted, rgba(255,255,255,0.6));
  font-size: 1.2rem;
}
.hb-close:hover { color: #fff; border-color: rgba(255,255,255,0.25); }
.hb-modes { margin: 0 14px 10px; display: flex; }
.hb-modes button { flex: 1; }

.hb-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.hb-view[hidden] { display: none; }
.hb-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 14px 10px;
  scrollbar-width: thin;
}
.hb-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: hbPop 0.2s ease both;
}
.hb-bot { align-self: flex-start; background: rgba(255,255,255,0.07); border-bottom-left-radius: 4px; }
.hb-user { align-self: flex-end; background: #fff; color: #000; border-bottom-right-radius: 4px; }
.hb-note { align-self: center; max-width: 92%; background: transparent; color: var(--text-muted, rgba(255,255,255,0.6)); font-size: 0.82rem; text-align: center; padding: 4px 8px; }
.hb-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.hb-action, .hb-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.hb-action:hover, .hb-chip:hover { background: #fff; color: #000; }
.hb-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.hb-chips:empty { display: none; }
.hb-typing { display: flex; gap: 4px; padding: 13px 14px; }
.hb-typing span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.6); animation: hbDot 1s infinite ease-in-out; }
.hb-typing span:nth-child(2) { animation-delay: 0.15s; }
.hb-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes hbDot { 0%, 80%, 100% { opacity: 0.3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

.hb-compose {
  display: flex;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.hb-compose input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  outline: none;
}
.hb-compose input:focus { border-color: rgba(255,255,255,0.32); }
.hb-compose button {
  width: 42px;
  flex-shrink: 0;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ticket form */
.hb-ticket {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 14px 14px;
}
.hb-ticket[hidden], .hb-thread[hidden] { display: none; }
.hb-lead { font-size: 0.86rem; line-height: 1.5; color: var(--text-muted, rgba(255,255,255,0.6)); }
.hb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hb-ticket label { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; font-weight: 500; color: var(--text-muted, rgba(255,255,255,0.6)); }
.hb-ticket input, .hb-ticket select, .hb-ticket textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  resize: vertical;
}
.hb-ticket select option { background: #111; }
.hb-ticket input:focus, .hb-ticket select:focus, .hb-ticket textarea:focus { border-color: rgba(255,255,255,0.32); }
.hb-error { font-size: 0.82rem; color: var(--red, #f4b4b4); min-height: 1em; }
.hb-error:empty { display: none; }
.hb-ticket .btn { justify-content: center; }
.hb-thread { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.hb-ticket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 14px 10px;
}
.hb-ticket-head strong { display: block; font-size: 0.9rem; }
.hb-ticket-head span { font-size: 0.78rem; color: var(--text-muted, rgba(255,255,255,0.6)); }
.hb-status {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 0.8rem;
  color: var(--text-muted, rgba(255,255,255,0.6));
}
.hb-pulse { width: 8px; height: 8px; border-radius: 50%; background: #23a55a; animation: hbBlink 1.6s infinite; }
@keyframes hbBlink { 50% { opacity: 0.35; } }

.hb-credit {
  padding: 6px 14px 10px;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.35);
  text-align: center;
}
.hb-credit a { color: rgba(255,255,255,0.5); }

@media (max-width: 640px) {
  #help-bot { right: 6px; bottom: 6px; }
  .hb-launch { width: 78px; height: 78px; }
  .hb-panel { position: fixed; left: 8px; right: 8px; bottom: 88px; width: auto; max-width: none; height: min(560px, calc(100dvh - 104px)); }
  .hb-hint { right: 70px; bottom: 34px; }
  .hb-row { grid-template-columns: 1fr; }
}
/* Short landscape phones: let the panel use the height it has */
@media (max-height: 520px) {
  .hb-panel { height: calc(100dvh - 100px); bottom: 88px; }
  .hb-launch { width: 78px; height: 78px; }
}
@media (prefers-reduced-motion: reduce) {
  .hb-launch, .hb-msg, .hb-panel, .hb-hint { animation: none; transition: none; }
}
.hb-staff { font-size: 0.75rem; color: rgba(255,255,255,0.7); }

/* Drag to move */
.hb-launch { touch-action: none; }
#help-bot.hb-dragging .hb-launch { transform: scale(1.06); cursor: grabbing; transition: none; }
#help-bot.hb-dragging .hb-panel { display: none; }
#help-bot.hb-snapping { transition: left 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
#help-bot.hb-left .hb-hint { right: auto; left: 112px; border-radius: 14px 14px 14px 4px; }
#help-bot.hb-below .hb-hint { bottom: auto; top: 40px; }
@media (prefers-reduced-motion: reduce) { #help-bot.hb-snapping { transition: none; } }
