/* ==========================================================================
   AutoBots Dev — AI Avatar Component
   Interactive glowing orb with animated blinking eyes, float & tap squish.
   Acts as the floating AI launcher for the Chatbot and in-modal AI identity.
   ========================================================================== */

.ai-avatar {
  --avatar-main: #0a8fb5;
  --avatar-light: #5dd4ff;
  --avatar-dark: #003d66;

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  isolation: isolate;
  overflow: visible;

  background: radial-gradient(
    circle at 36% 32%,
    #e0f7ff 0%,
    var(--avatar-light) 24%,
    var(--avatar-main) 60%,
    var(--avatar-dark) 100%
  );

  box-shadow:
    0 0 10px rgba(53, 213, 242, 0.5),
    0 8px 24px rgba(47, 123, 255, 0.35),
    inset 0 0 2px rgba(255, 255, 255, 0.7);

  animation: avatar-float 4s ease-in-out infinite;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

/* Color Themes: AutoBots Brand Royal Blue & Luminous Cyan */
.ai-avatar--blue {
  --avatar-dark: #081a3d;
  --avatar-main: #2F7BFF;
  --avatar-light: #35D5F2;
}

.ai-avatar--indigo {
  --avatar-dark: #2d157a;
  --avatar-main: #4f46e5;
  --avatar-light: #8b7eff;
}

/* Glass Reflection Highlight */
.ai-avatar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at 30% 24%,
    rgba(255, 255, 255, 0.75),
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
  pointer-events: none;
}

/* Deep Bottom Shadow Arc */
.ai-avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 65% 72%,
    rgba(0, 0, 0, 0.22),
    transparent 55%
  );
  pointer-events: none;
}

/* Blinking Eyes */
.ai-avatar__eyes {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 10px;
  align-items: center;
  transform: translateY(-2px);
  pointer-events: none;
}

.ai-avatar__eye {
  width: 6px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff, #d0f0ff);
  transform-origin: center;
  animation: avatar-blink 3.6s ease-in-out infinite;
  box-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
}

.ai-avatar__eye:nth-child(2) {
  animation-delay: 60ms;
}

/* Hover & Squish Physics */
.ai-avatar:hover {
  box-shadow:
    0 0 12px rgba(53, 213, 242, 0.65),
    0 8px 28px rgba(47, 123, 255, 0.45);
  transform: translateY(-2px) scale(1.08);
}

.ai-avatar.is-tapped {
  animation: avatar-squish 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Small Variant (Used in Chatbot Header & Badges) */
.ai-avatar--sm {
  width: 38px;
  height: 38px;
  animation: none;
  cursor: default;
  box-shadow: 0 2px 10px rgba(10, 143, 181, 0.35);
}

.ai-avatar--sm:hover {
  transform: none;
  box-shadow: 0 2px 10px rgba(10, 143, 181, 0.35);
}

.ai-avatar--sm .ai-avatar__eyes {
  gap: 7px;
  transform: translateY(-1.5px);
}

.ai-avatar--sm .ai-avatar__eye {
  width: 4.5px;
  height: 7.5px;
}

/* Large Variant */
.ai-avatar--lg {
  width: 68px;
  height: 68px;
}

.ai-avatar--lg .ai-avatar__eyes {
  gap: 13px;
}

.ai-avatar--lg .ai-avatar__eye {
  width: 7.5px;
  height: 13px;
}

/* Floating Chatbot Trigger Integration */
.chatbot-trigger.ai-avatar {
  position: fixed;
  bottom: calc(2rem + 60px + 14px);
  right: 2rem;
  z-index: 1000;
  width: 58px;
  height: 58px;
  outline: none;
}

.chatbot-trigger.ai-avatar span.chatbot-badge-pulse {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background-color: #10B981;
  border-radius: 50%;
  border: 2.5px solid #0d4d9a;
  z-index: 10;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.8);
  pointer-events: none;
}

.chatbot-trigger.ai-avatar span.chatbot-badge-pulse::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background-color: rgba(16, 185, 129, 0.7);
  animation: pulse-composited 2s infinite;
  z-index: -1;
  will-change: transform, opacity;
}

/* Mobile Responsive */
@media (max-width: 576px) {
  .chatbot-trigger.ai-avatar {
    bottom: calc(1.25rem + 48px + 10px) !important;
    right: 1.25rem !important;
    width: 48px !important;
    height: 48px !important;
  }

  .chatbot-trigger.ai-avatar .ai-avatar__eyes {
    gap: 8px;
  }

  .chatbot-trigger.ai-avatar .ai-avatar__eye {
    width: 5px;
    height: 8.5px;
  }

  .chatbot-trigger.ai-avatar span.chatbot-badge-pulse {
    top: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    border-width: 2px;
  }
}

/* Keyframes */
@keyframes avatar-blink {
  0%, 88%, 100% { transform: scaleY(1); }
  93%, 97% { transform: scaleY(0.07); }
}

@keyframes avatar-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes avatar-squish {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.18, 1.32); }
}

@keyframes pulse-composited {
  0% {
    transform: scale(1);
    opacity: 0.85;
  }
  70% {
    transform: scale(2.3);
    opacity: 0;
  }
  100% {
    transform: scale(2.3);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-avatar,
  .ai-avatar__eye,
  .chatbot-trigger.ai-avatar span.chatbot-badge-pulse::after {
    animation: none !important;
  }
  .ai-avatar {
    transition: none !important;
  }
}
