/* ===================================
   Advanced Animations & Micro-interactions
   =================================== */

/* ===================================
   Page Transition Animations
   =================================== */
.page-transition-enter {
  opacity: 0;
  transform: translateX(30px);
}

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

.page-transition-exit {
  opacity: 1;
  transform: translateX(0);
}

.page-transition-exit-active {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ===================================
   Loading States
   =================================== */
.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

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

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

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--primary-color);
  animation: loading-dots 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 loading-dots {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===================================
   Button Hover Effects
   =================================== */
.btn-glow:hover {
  box-shadow: 0 0 20px rgba(106, 13, 173, 0.4);
  transform: translateY(-2px);
}

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

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

.btn-ripple:active::before {
  width: 300px;
  height: 300px;
}

/* ===================================
   Card Hover Animations
   =================================== */
.card-hover {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.card-lift {
  transition: all 0.3s ease;
}

.card-lift:hover {
  transform: translateY(-12px);
  box-shadow: 0 25px 50px rgba(106, 13, 173, 0.2);
}

/* ===================================
   Form Input Animations
   =================================== */
.form-group {
  position: relative;
}

.floating-label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--white);
  padding: 0 4px;
  color: var(--gray-500);
  transition: all 0.2s ease;
  pointer-events: none;
}

.form-group input:focus + .floating-label,
.form-group input:not(:placeholder-shown) + .floating-label,
.form-group textarea:focus + .floating-label,
.form-group textarea:not(:placeholder-shown) + .floating-label {
  top: 0;
  font-size: 0.75rem;
  color: var(--primary-color);
}

.input-focus-effect {
  position: relative;
}

.input-focus-effect::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--primary-color);
  transform: translateX(-50%);
  transition: width 0.3s ease;
}

.input-focus-effect:focus::after {
  width: 100%;
}

/* ===================================
   Navigation Animations
   =================================== */
.nav-link {
  position: relative;
  overflow: hidden;
}

.nav-link::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--primary-color);
  transform: translateX(-50%);
  transition: width 0.3s ease;
}

.nav-link:hover::before,
.nav-link.active::before {
  width: 80%;
}

.nav-indicator {
  position: absolute;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================================
   Chart Animations
   =================================== */
.chart-bar {
  animation: chart-bar-grow 1s ease-out forwards;
  transform-origin: bottom;
}

@keyframes chart-bar-grow {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

.chart-line {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: chart-line-draw 2s ease-out forwards;
}

@keyframes chart-line-draw {
  to {
    stroke-dashoffset: 0;
  }
}

.chart-pie {
  animation: chart-pie-rotate 1s ease-out;
  transform-origin: center;
}

@keyframes chart-pie-rotate {
  from {
    transform: rotate(-90deg) scale(0);
  }
  to {
    transform: rotate(0) scale(1);
  }
}

/* ===================================
   Number Counter Animations
   =================================== */
.counter {
  display: inline-block;
}

.counter-animate {
  animation: counter-pulse 0.3s ease;
}

@keyframes counter-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* ===================================
   Progress Bar Animations
   =================================== */
.progress-bar {
  position: relative;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
  border-radius: var(--radius-full);
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: progress-shimmer 2s infinite;
}

@keyframes progress-shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* ===================================
   Tooltip Animations
   =================================== */
.tooltip {
  position: absolute;
  background: var(--gray-900);
  color: var(--white);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s ease;
  z-index: var(--z-tooltip);
}

.tooltip::before {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid var(--gray-900);
}

.tooltip-trigger:hover .tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ===================================
   Modal Animations
   =================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: var(--z-modal-backdrop);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  max-width: 500px;
  width: 90%;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: var(--z-modal);
}

.modal.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* ===================================
   List Item Animations
   =================================== */
.list-item {
  opacity: 0;
  transform: translateX(-20px);
  animation: list-item-enter 0.4s ease forwards;
}

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

@keyframes list-item-enter {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.list-item-remove {
  animation: list-item-exit 0.3s ease forwards;
}

@keyframes list-item-exit {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ===================================
   Notification Animations
   =================================== */
.notification-slide {
  animation: notification-slide-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.notification-exit {
  animation: notification-slide-out 0.3s ease forwards;
}

@keyframes notification-slide-out {
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ===================================
   Pulse Animations
   =================================== */
.pulse {
  animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
  0% {
    box-shadow: 0 0 0 0 rgba(106, 13, 173, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(106, 13, 173, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(106, 13, 173, 0);
  }
}

.pulse-slow {
  animation: pulse-animation 3s infinite;
}

.pulse-fast {
  animation: pulse-animation 1s infinite;
}

/* ===================================
   Bounce Animations
   =================================== */
.bounce {
  animation: bounce-animation 1s infinite;
}

@keyframes bounce-animation {
  0%, 20%, 53%, 80%, 100% {
    transform: translateY(0);
  }
  40%, 43% {
    transform: translateY(-10px);
  }
  70% {
    transform: translateY(-5px);
  }
  90% {
    transform: translateY(-2px);
  }
}

.bounce-in {
  animation: bounce-in-animation 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounce-in-animation {
  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);
  }
}

/* ===================================
   Shake Animation
   =================================== */
.shake {
  animation: shake-animation 0.5s ease-in-out;
}

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

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

@keyframes fade-in-animation {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes fade-out-animation {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.fade-in-up {
  animation: fade-in-up-animation 0.5s ease forwards;
}

@keyframes fade-in-up-animation {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-down {
  animation: fade-in-down-animation 0.5s ease forwards;
}

@keyframes fade-in-down-animation {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===================================
   Slide Animations
   =================================== */
.slide-in-left {
  animation: slide-in-left-animation 0.5s ease forwards;
}

@keyframes slide-in-left-animation {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-right {
  animation: slide-in-right-animation 0.5s ease forwards;
}

@keyframes slide-in-right-animation {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-out-left {
  animation: slide-out-left-animation 0.5s ease forwards;
}

@keyframes slide-out-left-animation {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50px);
  }
}

.slide-out-right {
  animation: slide-out-right-animation 0.5s ease forwards;
}

@keyframes slide-out-right-animation {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(50px);
  }
}

/* ===================================
   Scale Animations
   =================================== */
.scale-in {
  animation: scale-in-animation 0.3s ease forwards;
}

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

.scale-out {
  animation: scale-out-animation 0.3s ease forwards;
}

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

/* ===================================
   Rotate Animations
   =================================== */
.rotate-in {
  animation: rotate-in-animation 0.5s ease forwards;
}

@keyframes rotate-in-animation {
  from {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

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

@keyframes rotate-out-animation {
  from {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
  to {
    opacity: 0;
    transform: rotate(180deg) scale(0.5);
  }
}

/* ===================================
   Flip Animations
   =================================== */
.flip-in-x {
  animation: flip-in-x-animation 0.6s ease forwards;
}

@keyframes flip-in-x-animation {
  from {
    opacity: 0;
    transform: perspective(400px) rotateX(90deg);
  }
  40% {
    transform: perspective(400px) rotateX(-10deg);
  }
  70% {
    transform: perspective(400px) rotateX(10deg);
  }
  to {
    opacity: 1;
    transform: perspective(400px) rotateX(0);
  }
}

.flip-in-y {
  animation: flip-in-y-animation 0.6s ease forwards;
}

@keyframes flip-in-y-animation {
  from {
    opacity: 0;
    transform: perspective(400px) rotateY(90deg);
  }
  40% {
    transform: perspective(400px) rotateY(-10deg);
  }
  70% {
    transform: perspective(400px) rotateY(10deg);
  }
  to {
    opacity: 1;
    transform: perspective(400px) rotateY(0);
  }
}

/* ===================================
   Stagger Animation Delays
   =================================== */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }
.stagger-7 { animation-delay: 0.7s; }
.stagger-8 { animation-delay: 0.8s; }
.stagger-9 { animation-delay: 0.9s; }
.stagger-10 { animation-delay: 1s; }

/* ===================================
   Responsive Animation Adjustments
   =================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===================================
   Performance Optimizations
   =================================== */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

/* ===================================
   Custom Scrollbar Animations
   =================================== */
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: var(--radius-full);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary-color), var(--primary-light));
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--primary-light), var(--primary-color));
}

/* ===================================
   Text Animations
   =================================== */
.text-gradient {
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light), var(--accent-color));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: text-gradient-animation 3s ease infinite;
}

@keyframes text-gradient-animation {
  0% {
    background-position: 0% center;
  }
  50% {
    background-position: 100% center;
  }
  100% {
    background-position: 0% center;
  }
}

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

@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

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