/* Hriqo Reactive Form Companion — Kirby Avatar Guide System */

.hrms-avatar-companion {
  position: absolute;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px) scale(0.96);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              top 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              left 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 380px;
}

.hrms-avatar-companion.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.hrms-avatar-companion.is-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Free-Floating Avatar (NO circular border, transparent backdrop) */
.companion-avatar-bubble {
  width: 66px;
  height: 66px;
  border-radius: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible !important;
  position: relative;
  transition: transform 0.08s ease-out;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.65)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
  cursor: pointer;
}

.companion-avatar-bubble svg,
.companion-avatar-bubble span.bs-avatar {
  width: 100% !important;
  height: 100% !important;
  display: block;
  overflow: visible !important;
}

/* Eyes smooth gaze tracking via SVG group */
.companion-avatar-bubble svg g[clip-path] {
  transition: transform 0.08s ease-out;
  will-change: transform;
}

/* Typing bounce animation */
.companion-avatar-bubble.is-typing {
  animation: companion-typing-bounce 0.45s ease-in-out infinite alternate;
}

@keyframes companion-typing-bounce {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-3.5px) scale(1.02); }
}

/* Speech Bubble Card */
.companion-speech-bubble {
  position: relative;
  background: rgba(10, 15, 28, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.75rem 0.95rem;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(20px);
  color: #f1f5f9;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  min-width: 250px;
  max-width: 320px;
  transition: border-color 0.2s ease;
}

/* Bubble tail arrow */
.companion-speech-bubble::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: rgba(10, 15, 28, 0.95);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 1;
}

/* Right-aligned variant if flipped */
.hrms-avatar-companion.is-flipped {
  flex-direction: row-reverse;
}

.hrms-avatar-companion.is-flipped .companion-speech-bubble::before {
  left: auto;
  right: -7px;
  border-left: none;
  border-bottom: none;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* Bottom docked non-overlapping mode (For 2-column forms or narrower screens) */
.hrms-avatar-companion.is-bottom-docked {
  position: fixed !important;
  bottom: 1.25rem !important;
  left: 50% !important;
  transform: translateX(-50%) translateY(0) scale(1) !important;
  top: auto !important;
  max-width: 560px !important;
  width: min(560px, calc(100vw - 2rem)) !important;
  z-index: 9999 !important;
  justify-content: center !important;
  flex-direction: row !important;
}

.hrms-avatar-companion.is-bottom-docked .companion-speech-bubble {
  max-width: none !important;
  flex: 1 1 auto !important;
}

.hrms-avatar-companion.is-bottom-docked .companion-speech-bubble::before {
  left: -7px !important;
  right: auto !important;
  top: 50% !important;
}

/* Speech bubble header */
.companion-bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.companion-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #38bdf8;
  text-transform: uppercase;
}

.companion-hide-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.companion-hide-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f87171;
}

/* Message text */
.companion-message-text {
  font-size: 0.8rem;
  line-height: 1.45;
  color: #cbd5e1;
  margin: 0;
  word-break: break-word;
}

/* State highlights */
.companion-speech-bubble.state-valid {
  border-color: rgba(16, 185, 129, 0.4);
}
.companion-speech-bubble.state-valid .companion-tag {
  color: #34d399;
}

.companion-speech-bubble.state-invalid {
  border-color: rgba(239, 68, 68, 0.4);
}
.companion-speech-bubble.state-invalid .companion-tag {
  color: #f87171;
}

.companion-speech-bubble.state-privacy {
  border-color: rgba(168, 85, 247, 0.4);
}
.companion-speech-bubble.state-privacy .companion-tag {
  color: #c084fc;
}

.companion-speech-bubble.state-typing {
  border-color: rgba(56, 189, 248, 0.4);
}
.companion-speech-bubble.state-typing .companion-tag {
  color: #38bdf8;
}

/* Bubble Footer */
.companion-bubble-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.68rem;
}

.companion-status-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: #64748b;
}

.companion-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.companion-call-support-link {
  color: #94a3b8;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.companion-call-support-link:hover {
  color: #38bdf8;
}

/* Floating Summon Pill (Shown when user disables/mutes the avatar) */
.companion-summon-pill {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(10, 15, 28, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65), 0 0 12px rgba(56, 189, 248, 0.2);
  color: #e2e8f0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(16px);
}

.companion-summon-pill:hover {
  transform: translateY(-2px);
  background: rgba(15, 23, 42, 0.98);
  border-color: #38bdf8;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75), 0 0 16px rgba(56, 189, 248, 0.35);
  color: #ffffff;
}

.companion-summon-pill.is-hidden {
  display: none !important;
}

.companion-summon-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
  animation: companion-pulse 2s infinite ease-in-out;
}

@keyframes companion-pulse {
  0%, 100% { opacity: 0.6; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Mobile responsive adapt */
@media (max-width: 768px) {
  .hrms-avatar-companion {
    position: fixed !important;
    bottom: 1rem !important;
    left: 1rem !important;
    right: 1rem !important;
    top: auto !important;
    max-width: none !important;
    justify-content: center;
  }
  .companion-speech-bubble {
    max-width: calc(100vw - 110px);
  }
  .companion-speech-bubble::before {
    display: none;
  }
}
