/* ============================================================
   LOFI DEX - Loading States & Smooth Transitions
   ============================================================ */

/* Global Transition Settings */
* {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); /* ease-out for natural feel */
}

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

/* ============================================================
   Loading States
   ============================================================ */

/* Skeleton Loading */
.skeleton-loader {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, 
    rgba(168, 184, 237, 0.1) 0%, 
    rgba(168, 184, 237, 0.2) 50%, 
    rgba(168, 184, 237, 0.1) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s ease-in-out infinite;
}

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

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

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

/* Spinner Loading */
.spinner-loader {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(168, 184, 237, 0.3);
  border-radius: 50%;
  border-top-color: #a8b8ed;
  animation: spin 0.8s linear infinite;
}

.spinner-loader.large {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

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

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

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

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

@keyframes dots-bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================================
   Button States & Transitions
   ============================================================ */

/* Base Button Transitions */
.button,
.btn,
button {
  transition: all 0.2s ease-out;
  transform: translateZ(0); /* Hardware acceleration */
  will-change: transform, box-shadow;
}

.button:hover,
.btn:hover,
button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(168, 184, 237, 0.2);
}

.button:active,
.btn:active,
button:active {
  transform: translateY(0);
  transition-duration: 0.1s;
}

/* Loading Button State */
.button.loading,
.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.button.loading::after,
.btn.loading::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

/* Success State */
.button.success,
.btn.success {
  background: #10b981 !important;
  animation: success-pulse 0.5s ease-out;
}

@keyframes success-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Error State */
.button.error,
.btn.error {
  background: #ef4444 !important;
  animation: error-shake 0.5s ease-out;
}

@keyframes error-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ============================================================
   Modal Transitions
   ============================================================ */

/* Modal Backdrop */
.lofi-wallet-modal {
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.lofi-wallet-modal.show {
  opacity: 1;
}

/* Modal Content */
.lofi-wallet-modal-content {
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lofi-wallet-modal.show .lofi-wallet-modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Modal Close Animation */
.lofi-wallet-modal.closing {
  opacity: 0;
}

.lofi-wallet-modal.closing .lofi-wallet-modal-content {
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  transition-duration: 0.2s;
}

/* ============================================================
   Input & Form Transitions
   ============================================================ */

/* Input Fields */
input[type="text"],
input[type="number"],
textarea,
select {
  transition: border-color 0.2s ease-out, box-shadow 0.2s ease-out;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  border-color: #a8b8ed;
  box-shadow: 0 0 0 3px rgba(168, 184, 237, 0.1);
}

/* Input Loading State */
.input-loading {
  position: relative;
}

.input-loading::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid rgba(168, 184, 237, 0.3);
  border-radius: 50%;
  border-top-color: #a8b8ed;
  animation: spin 0.8s linear infinite;
}

/* ============================================================
   Price & Value Transitions
   ============================================================ */

/* Price Updates */
.price-value {
  transition: color 0.3s ease-out, transform 0.3s ease-out;
}

.price-value.updating {
  transform: scale(1.05);
  color: #fbbf24;
}

.price-value.increased {
  color: #10b981;
  animation: price-bounce 0.4s ease-out;
}

.price-value.decreased {
  color: #ef4444;
  animation: price-shake 0.4s ease-out;
}

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

@keyframes price-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* ============================================================
   List & Item Transitions
   ============================================================ */

/* List Items */
.wallet-item,
.token-item {
  transition: all 0.2s ease-out;
}

.wallet-item:hover,
.token-item:hover {
  background: rgba(168, 184, 237, 0.1);
  transform: translateX(4px);
}

/* List Item Entry Animation */
.list-enter {
  opacity: 0;
  transform: translateY(10px);
  animation: list-enter 0.3s ease-out forwards;
}

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

/* Staggered List Animation */
.list-stagger .wallet-item,
.list-stagger .token-item {
  opacity: 0;
  transform: translateY(10px);
  animation: list-enter 0.3s ease-out forwards;
}

.list-stagger .wallet-item:nth-child(1) { animation-delay: 0.05s; }
.list-stagger .wallet-item:nth-child(2) { animation-delay: 0.1s; }
.list-stagger .wallet-item:nth-child(3) { animation-delay: 0.15s; }
.list-stagger .wallet-item:nth-child(4) { animation-delay: 0.2s; }
.list-stagger .wallet-item:nth-child(5) { animation-delay: 0.25s; }

/* ============================================================
   Notification Transitions
   ============================================================ */

/* Notification Entry */
.notification {
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.notification.show {
  transform: translateX(0);
  opacity: 1;
}

/* Notification Exit */
.notification.hiding {
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.2s ease-in;
}

/* ============================================================
   Swap Interface Transitions
   ============================================================ */

/* Token Swap Animation */
.swap-tokens-button {
  transition: transform 0.3s ease-out;
}

.swap-tokens-button:hover {
  transform: rotate(180deg);
}

.swap-tokens-button:active {
  transform: rotate(180deg) scale(0.9);
}

/* Swap Preview */
.swap-preview {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease-out;
}

.swap-preview.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   Progress Indicators
   ============================================================ */

/* Progress Bar */
.progress-bar {
  position: relative;
  height: 4px;
  background: rgba(168, 184, 237, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #a8b8ed;
  border-radius: 2px;
  transition: width 0.3s ease-out;
}

/* Indeterminate Progress */
.progress-bar.indeterminate .progress-bar-fill {
  width: 30%;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ============================================================
   Success Animations
   ============================================================ */

/* Checkmark Animation */
.success-checkmark {
  width: 60px;
  height: 60px;
  margin: 0 auto;
}

.success-checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 3;
  stroke: #10b981;
  fill: none;
  animation: checkmark-stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-checkmark-check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke: #10b981;
  fill: none;
  animation: checkmark-stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.4s forwards;
}

@keyframes checkmark-stroke {
  100% { stroke-dashoffset: 0; }
}

/* Confetti Animation */
@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: #a8b8ed;
  animation: confetti-fall 3s linear forwards;
}

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

/* Fade Transitions */
.fade-enter { opacity: 0; }
.fade-enter-active { opacity: 1; transition: opacity 0.3s ease-out; }
.fade-exit { opacity: 1; }
.fade-exit-active { opacity: 0; transition: opacity 0.2s ease-in; }

/* Slide Transitions */
.slide-up-enter { transform: translateY(20px); opacity: 0; }
.slide-up-enter-active { transform: translateY(0); opacity: 1; transition: all 0.3s ease-out; }
.slide-up-exit { transform: translateY(0); opacity: 1; }
.slide-up-exit-active { transform: translateY(-20px); opacity: 0; transition: all 0.2s ease-in; }

/* Scale Transitions */
.scale-enter { transform: scale(0.9); opacity: 0; }
.scale-enter-active { transform: scale(1); opacity: 1; transition: all 0.3s ease-out; }
.scale-exit { transform: scale(1); opacity: 1; }
.scale-exit-active { transform: scale(0.9); opacity: 0; transition: all 0.2s ease-in; }

/* Smooth Height Transitions */
.collapse {
  transition: height 0.3s ease-out;
  overflow: hidden;
}

/* No Transition Class */
.no-transition {
  transition: none !important;
}