/* ==========================================================================
   Wishy Animations & Effects
   Modern micro-interactions and animations
   ========================================================================== */

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */

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

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

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

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

@keyframes slideLeft {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideRight {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

@keyframes bounce {
  0%, 100% {
    transform: translateY(-5%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

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

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

@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

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

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

@keyframes wiggle {
  0%, 100% {
    transform: rotate(-3deg);
  }
  50% {
    transform: rotate(3deg);
  }
}

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

/* Gradient animation */
@keyframes gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ==========================================================================
   ANIMATION UTILITY CLASSES
   ========================================================================== */

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-fade-out {
  animation: fadeOut 0.3s ease-out;
}

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

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

.animate-slide-left {
  animation: slideLeft 0.4s ease-out;
}

.animate-slide-right {
  animation: slideRight 0.4s ease-out;
}

.animate-scale-in {
  animation: scaleIn 0.3s ease-out;
}

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

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

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

.animate-ping {
  animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.animate-shimmer {
  animation: shimmer 2s linear infinite;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  background-size: 1000px 100%;
}

.animate-shake {
  animation: shake 0.5s;
}

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

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

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

/* Delay utilities */
.animate-delay-100 {
  animation-delay: 100ms;
}

.animate-delay-200 {
  animation-delay: 200ms;
}

.animate-delay-300 {
  animation-delay: 300ms;
}

.animate-delay-500 {
  animation-delay: 500ms;
}

/* ==========================================================================
   HOVER EFFECTS
   ========================================================================== */

.hover-lift {
  transition: transform 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-2px);
}

.hover-grow {
  transition: transform 0.2s ease;
}

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

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

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.4);
}

.hover-shimmer {
  position: relative;
  overflow: hidden;
}

.hover-shimmer::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%
  );
  transition: left 0.5s ease;
}

.hover-shimmer:hover::before {
  left: 100%;
}

/* ==========================================================================
   TRANSITION UTILITIES
   ========================================================================== */

.transition-fast {
  transition: all 150ms ease;
}

.transition-base {
  transition: all 200ms ease;
}

.transition-slow {
  transition: all 300ms ease;
}

.transition-slower {
  transition: all 500ms ease;
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */

.loading-dots::after {
  content: '.';
  animation: loading-dots 1.5s steps(4, end) infinite;
}

@keyframes loading-dots {
  0%, 20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60% {
    content: '...';
  }
  80%, 100% {
    content: '';
  }
}

/* Skeleton Pulse */
.skeleton-pulse {
  animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  background: linear-gradient(
    90deg,
    var(--color-surface-sunken) 0%,
    var(--color-border-default) 50%,
    var(--color-surface-sunken) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

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

/* ==========================================================================
   STAGGER ANIMATIONS
   ========================================================================== */

.stagger-fade-in > * {
  opacity: 0;
  animation: fadeIn 0.5s ease-out forwards;
}

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

.stagger-slide-up > * {
  opacity: 0;
  animation: slideUp 0.5s ease-out forwards;
}

.stagger-slide-up > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-slide-up > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-slide-up > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-slide-up > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-slide-up > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-slide-up > *:nth-child(6) { animation-delay: 0.3s; }

/* ==========================================================================
   GLASSMORPHISM EFFECTS
   ========================================================================== */

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
}

.glass-panel {
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.dark .glass-panel {
  background: rgba(15, 23, 42, 0.5);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   GRADIENT BACKGROUNDS
   ========================================================================== */

.gradient-mesh {
  background: 
    radial-gradient(at 0% 0%, rgba(124, 58, 237, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 0% 100%, rgba(245, 158, 11, 0.15) 0px, transparent 50%);
}

.gradient-radial {
  background: radial-gradient(
    circle at center,
    var(--color-primary-50) 0%,
    transparent 70%
  );
}

/* ==========================================================================
   SCROLL ANIMATIONS
   ========================================================================== */

.scroll-fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   FOCUS ANIMATIONS
   ========================================================================== */

.focus-pulse:focus {
  animation: pulse 0.5s ease-out;
}

.focus-grow:focus {
  animation: scaleIn 0.2s ease-out;
}

/* ==========================================================================
   MAGIC IMPORT ANIMATIONS
   ========================================================================== */

@keyframes bg-pan {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* Outer wrapper: 2px gradient border via padding trick */
.magic-import-wrapper {
  position: relative;
  padding: 2px;
  border-radius: 22px;
  background: transparent;
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

.magic-import-wrapper.is-fetching {
  background: rgb(var(--primary-500));
  box-shadow: 0 10px 15px -3px rgb(var(--primary-500) / 0.2), 0 4px 6px -4px rgb(var(--primary-500) / 0.2);
}

.magic-import-wrapper.is-success {
  background: #10b981;
  box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.2), 0 4px 6px -4px rgba(16, 185, 129, 0.2);
}

.magic-import-wrapper.is-error {
  background: #f87171;
  box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.2), 0 4px 6px -4px rgba(239, 68, 68, 0.2);
  animation: shake 0.5s;
}

/* Inner card */
.magic-import-inner {
  padding: 1.5rem 2rem;
  background: white;
  border-radius: 20px;
  border: 1px solid rgb(var(--primary-100));
  transition: border-color 0.5s ease, background-color 0.5s ease;
}

.dark .magic-import-inner {
  background: rgb(15 23 42); /* slate-900 */
  border-color: rgb(var(--primary-800) / 0.5);
}

.magic-import-wrapper.is-fetching .magic-import-inner,
.magic-import-wrapper.is-success .magic-import-inner {
  border-color: transparent;
}

.magic-import-wrapper.is-error .magic-import-inner {
  border-color: rgb(254 202 202); /* red-200 */
}

.dark .magic-import-wrapper.is-error .magic-import-inner {
  border-color: rgba(153, 27, 27, 0.5); /* red-800/50 */
}

/* Icon badge */
.magic-import-icon {
  padding: 0.75rem;
  border-radius: 1rem;
  flex-shrink: 0;
  transition: background-color 0.4s ease, color 0.4s ease;
  background: rgb(var(--primary-50));
  color: rgb(var(--primary-600));
}

.dark .magic-import-icon {
  background: rgb(var(--primary-900) / 0.4);
  color: rgb(var(--primary-400));
}

.magic-import-wrapper.is-fetching .magic-import-icon {
  background: rgb(var(--primary-600));
  color: white;
}

.dark .magic-import-wrapper.is-fetching .magic-import-icon {
  background: rgb(var(--primary-700));
}

.magic-import-wrapper.is-success .magic-import-icon {
  background: rgb(209 250 229); /* emerald-100 */
  color: rgb(5 150 105);       /* emerald-600 */
  animation: none;
}

.dark .magic-import-wrapper.is-success .magic-import-icon {
  background: rgba(16, 185, 129, 0.2); /* emerald-900/40 */
  color: rgb(52 211 153);              /* emerald-400 */
}

.magic-import-wrapper.is-error .magic-import-icon {
  background: rgb(239 68 68); /* red-500 */
  color: white;
  animation: none;
}

.dark .magic-import-wrapper.is-error .magic-import-icon {
  background: rgb(185 28 28); /* red-700 */
}

/* Wand icon spin during fetch */
.magic-import-wrapper.is-fetching .magic-import-icon i {
  animation: spin 4s linear infinite;
}

.magic-import-wrapper.is-success .magic-import-icon i {
  transform: scale(1.1);
  transition: transform 0.3s ease;
}

/* Input success ring */
.magic-import-input.is-success {
  --tw-ring-color: rgb(16 185 129);
  box-shadow: var(--tw-ring-inset, ) 0 0 0 2px var(--tw-ring-color);
  background-color: rgba(16, 185, 129, 0.03);
}

/* Button states */
.magic-import-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  border-radius: 1rem;
  font-weight: 700;
  font-size: 1rem;
  color: white;
  white-space: nowrap;
  min-width: 140px;
  transition: all 0.2s ease;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  background: rgb(var(--primary-600));
}

.magic-import-btn:hover:not(:disabled) {
  background: rgb(var(--primary-700));
  transform: translateY(-2px);
}

.magic-import-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.magic-import-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.magic-import-btn.is-success {
  background: rgb(16 185 129); /* emerald-500 */
}

.magic-import-btn.is-success:hover:not(:disabled) {
  background: rgb(5 150 105); /* emerald-600 */
}
