/**
 * AI Chat Animations
 * Additional animation effects for enhanced user experience
 */

/* ==================== Entrance Animations ==================== */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.slide-up {
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-down {
  animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.zoom-in {
  animation: zoomIn 0.3s ease-out;
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==================== Success Animation ==================== */
.success-checkmark {
  animation: successPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes successPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.success-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: successCircle 0.6s ease-out 0.2s forwards;
}

@keyframes successCircle {
  to {
    stroke-dashoffset: 0;
  }
}

.success-check {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: successCheck 0.3s ease-out 0.6s forwards;
}

@keyframes successCheck {
  to {
    stroke-dashoffset: 0;
  }
}

/* ==================== Loading Animations ==================== */
.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.bounce {
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Three-dot loading */
.loading-dots span {
  animation: loadingDots 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes loadingDots {
  0%, 80%, 100% {
    opacity: 0;
    transform: scale(0);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==================== Shake Animation (for errors) ==================== */
.shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }
  30%, 50%, 70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%, 60% {
    transform: translate3d(4px, 0, 0);
  }
}

/* ==================== Hover Grow ==================== */
.hover-grow {
  transition: transform 0.2s ease;
}

.hover-grow:hover {
  transform: scale(1.05);
}

/* ==================== Glow Effect ==================== */
.glow {
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    box-shadow: 0 0 5px rgba(255, 114, 0, 0.5);
  }
  to {
    box-shadow: 0 0 20px rgba(255, 114, 0, 0.8), 0 0 30px rgba(255, 114, 0, 0.6);
  }
}

/* ==================== Float Animation ==================== */
.float {
  animation: float 3s ease-in-out infinite;
}

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

/* ==================== Shimmer Effect (for loading states) ==================== */
.shimmer {
  background: linear-gradient(90deg,
    #f0f0f0 0%,
    #e0e0e0 20%,
    #f0f0f0 40%,
    #f0f0f0 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ==================== Wiggle (attention grabber) ==================== */
.wiggle {
  animation: wiggle 0.5s ease-in-out;
}

@keyframes wiggle {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-5deg);
  }
  75% {
    transform: rotate(5deg);
  }
}

/* ==================== Heartbeat ==================== */
.heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.1);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.1);
  }
  56% {
    transform: scale(1);
  }
}

/* ==================== Progress Bar Animation ==================== */
.progress-bar {
  position: relative;
  overflow: hidden;
  background: #e0e0e0;
  border-radius: 10px;
  height: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FF7200, #FF8C33);
  border-radius: 10px;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: progressShine 2s infinite;
}

@keyframes progressShine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ==================== Ripple Effect ==================== */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
  width: 300px;
  height: 300px;
}

/* ==================== Notification Badge Pulse ==================== */
.notification-pulse {
  animation: notificationPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes notificationPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

/* ==================== Card Flip Animation ==================== */
.card-flip {
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.card-flip.flipped {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  backface-visibility: hidden;
}

.card-back {
  transform: rotateY(180deg);
}

/* ==================== Typing Text Animation ==================== */
@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blink {
  50% {
    border-color: transparent;
  }
}

.typing-text {
  overflow: hidden;
  border-right: 2px solid var(--aj-orange);
  white-space: nowrap;
  animation: typing 3.5s steps(40) 1s forwards, blink 0.75s step-end infinite;
}

/* ==================== Scroll Reveal ==================== */
.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ==================== Stagger Animation ==================== */
.stagger-item {
  opacity: 0;
  animation: staggerFadeIn 0.5s ease forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }

@keyframes staggerFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== Attention Seeker ==================== */
.attention {
  animation: attention 1s ease-in-out 3;
}

@keyframes attention {
  0%, 100% {
    transform: scale(1);
  }
  10%, 20% {
    transform: scale(0.9) rotate(-3deg);
  }
  30%, 50%, 70%, 90% {
    transform: scale(1.1) rotate(3deg);
  }
  40%, 60%, 80% {
    transform: scale(1.1) rotate(-3deg);
  }
}

/* ==================== Confetti (Success celebration) ==================== */
@keyframes confetti-fall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--aj-orange);
  animation: confetti-fall 3s linear;
  pointer-events: none;
}

/* ==================== Mobile-Specific Animations ==================== */
@media (max-width: 768px) {
  /* Reduce animation intensity on mobile for performance */
  .float {
    animation: float 4s ease-in-out infinite;
  }

  .glow {
    animation: none;
    box-shadow: 0 0 10px rgba(255, 114, 0, 0.5);
  }
}

/* ==================== Reduced Motion Support ==================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .float,
  .pulse,
  .bounce,
  .spin,
  .glow,
  .shimmer,
  .wiggle,
  .heartbeat {
    animation: none !important;
  }
}
