/* ===== ADVANCED ANIMATIONS & MICRO-INTERACTIONS ===== */

/* Global Animation Settings */
:root {
  --animation-duration-fast: 0.15s;
  --animation-duration-normal: 0.3s;
  --animation-duration-slow: 0.5s;
  --animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
  --animation-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --animation-easing-elastic: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 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;
  }
}

/* ===== LOADING ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInFromBottom {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInFromTop {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

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

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

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px var(--primary-color), 0 0 10px var(--primary-color), 0 0 15px var(--primary-color);
  }
  50% {
    box-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color), 0 0 30px var(--primary-color);
  }
}

@keyframes rainbow {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

@keyframes wiggle {
  0%, 7% { transform: rotateZ(0); }
  15% { transform: rotateZ(-15deg); }
  20% { transform: rotateZ(10deg); }
  25% { transform: rotateZ(-10deg); }
  30% { transform: rotateZ(6deg); }
  35% { transform: rotateZ(-4deg); }
  40%, 100% { transform: rotateZ(0); }
}

/* ===== MESSAGE ANIMATIONS ===== */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes messageBounceIn {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.3);
  }
  50% {
    opacity: 1;
    transform: translateY(-5px) scale(1.05);
  }
  70% {
    transform: translateY(2px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message {
  animation: messageSlideIn var(--animation-duration-normal) var(--animation-easing);
}

.message.bounce-in {
  animation: messageBounceIn var(--animation-duration-slow) var(--animation-easing-bounce);
}

.message.slide-out {
  animation: messageSlideOut var(--animation-duration-normal) var(--animation-easing);
}

/* ===== TYPING INDICATOR ANIMATIONS ===== */
@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.typing-indicator span {
  animation: typingDot 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

/* ===== BUTTON HOVER ANIMATIONS ===== */
.platform-btn, .control-btn, .action-btn, .input-btn, .send-btn, .start-btn {
  transition: all var(--animation-duration-fast) var(--animation-easing);
}

.platform-btn:hover {
  transform: translateY(-2px);
  animation: float 2s ease-in-out infinite;
}

.control-btn:hover, .action-btn:hover, .input-btn:hover {
  transform: scale(1.1) rotate(5deg);
}

.send-btn:hover {
  transform: scale(1.1);
  animation: pulse 1s infinite;
}

.send-btn:active {
  transform: scale(0.95);
  animation: none;
}

.start-btn:hover {
  transform: translateY(-3px) scale(1.05);
  animation: glow 2s ease-in-out infinite alternate;
}

/* ===== CARD HOVER ANIMATIONS ===== */
.feature-card, .platform-card {
  transition: all var(--animation-duration-normal) var(--animation-easing);
}

.feature-card:hover {
  transform: translateY(-8px) scale(1.02);
  animation: float 3s ease-in-out infinite;
}

.platform-card:hover {
  transform: translateY(-10px) scale(1.02);
  animation: glow 2s ease-in-out infinite alternate;
}

.platform-card:hover .platform-icon {
  animation: heartbeat 1s ease-in-out infinite;
}

/* ===== MODAL ANIMATIONS ===== */
.modal {
  animation: fadeIn var(--animation-duration-normal) var(--animation-easing);
}

.modal.closing {
  animation: fadeOut var(--animation-duration-normal) var(--animation-easing);
}

.modal-content {
  animation: scaleIn var(--animation-duration-normal) var(--animation-easing-bounce);
}

.modal.closing .modal-content {
  animation: scaleOut var(--animation-duration-normal) var(--animation-easing);
}

/* ===== SCREEN TRANSITION ANIMATIONS ===== */
.screen {
  transition: all var(--animation-duration-normal) var(--animation-easing);
}

.screen.slide-in-right {
  animation: slideInFromRight var(--animation-duration-normal) var(--animation-easing);
}

.screen.slide-in-left {
  animation: slideInFromLeft var(--animation-duration-normal) var(--animation-easing);
}

.screen.slide-in-bottom {
  animation: slideInFromBottom var(--animation-duration-normal) var(--animation-easing);
}

.screen.fade-in {
  animation: fadeIn var(--animation-duration-normal) var(--animation-easing);
}

/* ===== INPUT FOCUS ANIMATIONS ===== */
.message-input {
  transition: all var(--animation-duration-fast) var(--animation-easing);
}

.message-input:focus {
  transform: scale(1.02);
  animation: glow 2s ease-in-out infinite alternate;
}

/* ===== LOADING SPINNER ANIMATIONS ===== */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

.loading-spinner {
  animation: spin 1s linear infinite;
}

.loading-spinner.reverse {
  animation: spinReverse 1s linear infinite;
}

/* ===== NOTIFICATION ANIMATIONS ===== */
@keyframes slideInFromTopRight {
  from {
    opacity: 0;
    transform: translateX(100%) translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

@keyframes slideOutToTopRight {
  from {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%) translateY(-100%);
  }
}

.notification {
  animation: slideInFromTopRight var(--animation-duration-normal) var(--animation-easing-bounce);
}

.notification.closing {
  animation: slideOutToTopRight var(--animation-duration-normal) var(--animation-easing);
}

/* ===== REACTION ANIMATIONS ===== */
@keyframes reactionPop {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.2) rotate(-90deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes reactionFloat {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-5px) rotate(5deg);
  }
  75% {
    transform: translateY(-3px) rotate(-3deg);
  }
}

.reaction {
  animation: reactionPop var(--animation-duration-normal) var(--animation-easing-bounce);
}

.reaction:hover {
  animation: reactionFloat 0.6s ease-in-out infinite;
}

/* ===== STATUS INDICATOR ANIMATIONS ===== */
@keyframes statusPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.2);
  }
}

.status-indicator.online {
  animation: statusPulse 2s ease-in-out infinite;
}

.status-indicator.typing {
  animation: pulse 1s ease-in-out infinite;
}

/* ===== THEME TRANSITION ANIMATIONS ===== */
.theme-transition {
  transition: all var(--animation-duration-slow) var(--animation-easing);
}

/* ===== SCROLL ANIMATIONS ===== */
@keyframes scrollFade {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scroll-animate {
  animation: scrollFade var(--animation-duration-normal) var(--animation-easing);
}

/* ===== INTERACTIVE ELEMENT ANIMATIONS ===== */
.interactive-element {
  transition: all var(--animation-duration-fast) var(--animation-easing);
  cursor: pointer;
}

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

.interactive-element:active {
  transform: scale(0.95);
}

/* ===== RIPPLE EFFECT ANIMATION ===== */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple-effect {
  position: relative;
  overflow: hidden;
}

.ripple-effect::before {
  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-effect:active::before {
  width: 300px;
  height: 300px;
  animation: ripple 0.6s ease-out;
}

/* ===== PARALLAX ANIMATIONS ===== */
@keyframes parallaxFloat {
  0%, 100% {
    transform: translateY(0px) translateX(0px);
  }
  25% {
    transform: translateY(-10px) translateX(5px);
  }
  50% {
    transform: translateY(-5px) translateX(-5px);
  }
  75% {
    transform: translateY(-15px) translateX(3px);
  }
}

.parallax-element {
  animation: parallaxFloat 6s ease-in-out infinite;
}

.parallax-element:nth-child(2n) {
  animation-delay: 1s;
  animation-duration: 8s;
}

.parallax-element:nth-child(3n) {
  animation-delay: 2s;
  animation-duration: 10s;
}

/* ===== GRADIENT ANIMATIONS ===== */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.animated-gradient {
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
}

/* ===== TEXT ANIMATIONS ===== */
@keyframes typewriter {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blinkCursor {
  from, to {
    border-color: transparent;
  }
  50% {
    border-color: var(--primary-color);
  }
}

.typewriter-text {
  overflow: hidden;
  border-right: 2px solid var(--primary-color);
  white-space: nowrap;
  animation: typewriter 3s steps(40, end), blinkCursor 0.75s step-end infinite;
}

/* ===== MICRO-INTERACTIONS ===== */
.micro-bounce:hover {
  animation: bounceIn var(--animation-duration-fast) var(--animation-easing-bounce);
}

.micro-shake:hover {
  animation: shake 0.5s ease-in-out;
}

.micro-wiggle:hover {
  animation: wiggle 0.8s ease-in-out;
}

.micro-pulse:hover {
  animation: pulse 1s ease-in-out infinite;
}

.micro-glow:hover {
  animation: glow 1s ease-in-out infinite alternate;
}

.micro-float:hover {
  animation: float 2s ease-in-out infinite;
}

.micro-heartbeat:hover {
  animation: heartbeat 1s ease-in-out infinite;
}

/* ===== STAGGER ANIMATIONS ===== */
.stagger-animation > * {
  animation: fadeIn var(--animation-duration-normal) var(--animation-easing);
}

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

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform, opacity;
}

.smooth-scroll {
  scroll-behavior: smooth;
}

/* ===== ACCESSIBILITY ANIMATIONS ===== */
@media (prefers-reduced-motion: reduce) {
  .respect-motion-preference {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== CUSTOM EASING FUNCTIONS ===== */
.ease-in-out-back {
  transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ease-in-out-circ {
  transition-timing-function: cubic-bezier(0.785, 0.135, 0.15, 0.86);
}

.ease-in-out-expo {
  transition-timing-function: cubic-bezier(1, 0, 0, 1);
}

.ease-in-out-sine {
  transition-timing-function: cubic-bezier(0.445, 0.05, 0.55, 0.95);
}

