/* ========================================
   Xblivian - Professional Animations
   ======================================== */

/* Keyframes */
@keyframes float-reaction {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  50% { transform: translateY(-8px) scale(1.1); opacity: 0.9; }
  100% { transform: translateY(-14px) scale(0.9); opacity: 0; }
}

.reaction-animate {
  animation: pop-react 250ms ease;
}

@keyframes pop-react {
  0% { transform: scale(0.9); }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Fade In Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade In Up Animation */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Down Animation */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Left Animation */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade In Right Animation */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale In Animation */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide In Up Animation */
@keyframes slideInUp {
  from {
    transform: translateY(100%);
    visibility: visible;
  }
  to {
    transform: translateY(0);
  }
}

/* Bounce Animation */
@keyframes bounce {
  0%, 20%, 53%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    transform: translateY(0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    transform: translateY(-15px);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    transform: translateY(-8px);
  }
  80% {
    transform: translateY(0);
  }
  90% {
    transform: translateY(-3px);
  }
}

/* Pulse Animation */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

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

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

/* Glow Animation */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(148, 163, 184, 0.28);
  }
  50% {
    box-shadow: 0 0 20px rgba(148, 163, 184, 0.5), 0 0 30px rgba(75, 85, 99, 0.35);
  }
}

/* Shimmer Loading Animation */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

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

/* Ripple Animation */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

/* Stagger Children Animation */
@keyframes staggerFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   Animation Utility Classes
   ======================================== */

.animate-fadeIn {
  animation: fadeIn 0.4s ease-out forwards;
}

.animate-fadeInUp {
  animation: fadeInUp 0.5s ease-out forwards;
}

.animate-fadeInDown {
  animation: fadeInDown 0.5s ease-out forwards;
}

.animate-fadeInLeft {
  animation: fadeInLeft 0.5s ease-out forwards;
}

.animate-fadeInRight {
  animation: fadeInRight 0.5s ease-out forwards;
}

.animate-scaleIn {
  animation: scaleIn 0.4s ease-out forwards;
}

.animate-bounce {
  animation: bounce 1s ease infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

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

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

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

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, 
    rgba(200, 200, 200, 0.2) 25%, 
    rgba(200, 200, 200, 0.5) 50%, 
    rgba(200, 200, 200, 0.2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--border-radius-sm, 8px);
}

body.dark-mode .skeleton {
  background: linear-gradient(90deg, 
    rgba(48, 54, 61, 0.5) 25%, 
    rgba(48, 54, 61, 0.8) 50%, 
    rgba(48, 54, 61, 0.5) 75%
  );
  background-size: 200% 100%;
}

/* Staggered animations for lists */
.stagger-animate > * {
  opacity: 0;
  animation: staggerFadeIn 0.4s ease-out forwards;
}

.stagger-animate > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-animate > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-animate > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-animate > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-animate > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-animate > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-animate > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-animate > *:nth-child(8) { animation-delay: 0.4s; }
.stagger-animate > *:nth-child(9) { animation-delay: 0.45s; }
.stagger-animate > *:nth-child(10) { animation-delay: 0.5s; }

/* Hover Animations */
.hover-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

body.dark-mode .hover-lift:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.hover-scale {
  transition: transform 0.3s ease;
}

.hover-scale:hover {
  transform: scale(1.03);
}

.hover-glow {
  transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 25px rgba(148, 163, 184, 0.28);
}

/* Button ripple effect */
.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.3) 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 0.5s;
}

.btn-ripple:active::after {
  transform: scale(0, 0);
  opacity: 0.3;
  transition: 0s;
}

/* Page transition */
.page-enter {
  opacity: 0;
  transform: translateY(20px);
}

.page-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Card reveal on scroll */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* Icon animations */
.icon-bounce:hover i,
.icon-bounce:focus i {
  animation: bounce 0.6s ease;
}

.icon-spin:hover i,
.icon-spin:focus i {
  animation: spin 0.5s ease;
}

.icon-pulse:hover i,
.icon-pulse:focus i {
  animation: pulse 0.4s ease;
}

/* Loading dots */
.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  animation: bounce 1.4s ease-in-out infinite both;
}

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

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

/* Tooltip animations */
.tooltip-animated {
  animation: fadeInUp 0.2s ease-out;
}

/* Modal animations */
.modal.fade .modal-dialog {
  transform: scale(0.95) translateY(-20px);
  transition: transform 0.3s ease-out;
}

.modal.show .modal-dialog {
  transform: scale(1) translateY(0);
}

/* Dropdown animations */
.dropdown-menu {
  animation: fadeInDown 0.2s ease-out;
}

/* Alert animations */
.alert {
  animation: fadeInDown 0.3s ease-out;
}

/* Toast animations */
.toast {
  animation: slideInUp 0.3s ease-out;
}

/* Progress bar animation */
.progress-animated .progress-bar {
  animation: fadeInLeft 0.6s ease-out;
}

/* Notification badge pulse */
.notification-badge {
  animation: pulse 2s ease-in-out infinite;
}

/* Chat message animations */
.chat-message {
  animation: fadeInUp 0.3s ease-out;
}

/* Smooth accordion */
.accordion-collapse {
  transition: height 0.35s ease;
}

/* Tab transition */
.tab-content > .tab-pane {
  transition: opacity 0.15s linear;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .reveal-on-scroll {
    opacity: 1;
    transform: none;
  }
}

/* AI processing status for summarize/rewrite */
@keyframes blinkGray {
  0%, 50%, 100% {
    opacity: 1;
  }
  25%, 75% {
    opacity: 0.45;
  }
}

.ai-processing-blink {
  animation: blinkGray 1s ease-in-out infinite !important;
  color: #5f6670 !important;
  font-weight: 500;
}

body.dark-mode .ai-processing-blink,
html[data-bs-theme="dark"] .ai-processing-blink,
body[data-bs-theme="dark"] .ai-processing-blink {
  color: #c6cbd2 !important;
}
