/**
 * leihradar Payment Animations
 * Micro-interactions for payment flows
 * 
 * Stripe-inspired smooth animations
 */

/* ===================================
   Button Animations
   =================================== */

/* Button Press Effect */
.btn-primary:active,
.btn-destructive:active,
.btn-secondary:active {
  transform: scale(0.98);
  transition: transform 0.1s ease;
}

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

.btn-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: button-spinner 0.6s linear infinite;
}

@keyframes button-spinner {
  to { transform: rotate(360deg); }
}

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

/* Checkmark Animation */
.success-checkmark {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: block;
  stroke-width: 3;
  stroke: #10b981;
  stroke-miterlimit: 10;
  box-shadow: inset 0 0 0 #10b981;
  animation: checkmark-fill 0.4s ease-in-out 0.4s forwards, checkmark-scale 0.3s ease-in-out 0.9s both;
  margin: 0 auto;
}

.success-checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 3;
  stroke-miterlimit: 10;
  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;
  animation: checkmark-stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

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

@keyframes checkmark-scale {
  0%, 100% {
    transform: none;
  }
  50% {
    transform: scale3d(1.1, 1.1, 1);
  }
}

@keyframes checkmark-fill {
  100% {
    box-shadow: inset 0 0 0 30px #10b981;
  }
}

/* Success Message Slide In */
.success-message {
  animation: slide-up 0.4s ease-out;
}

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

/* ===================================
   Error Animations
   =================================== */

/* Shake Animation for Errors */
.error-shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

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

/* Error Message Fade In */
.error-message {
  animation: fade-in 0.3s ease-out;
}

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

/* Error Icon Pulse */
.error-icon {
  animation: error-pulse 2s ease-in-out infinite;
}

@keyframes error-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* ===================================
   Loading Animations
   =================================== */

/* Spinner */
.spinner {
  animation: spin 0.8s linear infinite;
}

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

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

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

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

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

/* Progress Bar Animation */
.progress-bar {
  position: relative;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 4px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #635bff, #8b83ff);
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: progress-shimmer 1.5s infinite;
}

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

/* ===================================
   Form Field Animations
   =================================== */

/* Focus Ring Animation */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  animation: focus-ring 0.3s ease-out;
}

@keyframes focus-ring {
  from {
    box-shadow: 0 0 0 0 rgba(99, 91, 255, 0.4);
  }
  to {
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.1);
  }
}

/* Label Float Animation */
.form-group-floating {
  position: relative;
}

.form-label-floating {
  position: absolute;
  left: 14px;
  top: 14px;
  color: #9ca3af;
  transition: all 0.2s ease;
  pointer-events: none;
}

.form-input:focus ~ .form-label-floating,
.form-input:not(:placeholder-shown) ~ .form-label-floating {
  top: -8px;
  left: 10px;
  font-size: 0.75rem;
  color: #635bff;
  background: white;
  padding: 0 4px;
}

/* ===================================
   Card Selection Animation
   =================================== */

/* Payment Method Tab Selection */
.payment-method-tab {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.payment-method-tab:hover {
  transform: translateY(-2px);
}

.payment-method-tab.active {
  animation: tab-select 0.3s ease-out;
}

@keyframes tab-select {
  0% {
    transform: scale(0.95);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

/* ===================================
   Amount Display Animations
   =================================== */

/* Number Counter Animation */
.amount-counter {
  animation: count-up 0.6s ease-out;
}

@keyframes count-up {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Currency Symbol Pop */
.currency-symbol {
  display: inline-block;
  animation: currency-pop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.2s both;
}

@keyframes currency-pop {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

/* ===================================
   Modal Animations
   =================================== */

/* Modal Overlay Fade In */
.modal-overlay {
  animation: overlay-fade-in 0.2s ease-out;
}

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

/* Modal Content Slide Up */
.modal-content {
  animation: modal-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ===================================
   Notification Toast Animations
   =================================== */

/* Toast Slide In from Right */
.toast-notification {
  animation: toast-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Toast Slide Out */
.toast-notification.removing {
  animation: toast-slide-out 0.2s ease-in forwards;
}

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

/* ===================================
   Hover Effects
   =================================== */

/* Subtle Lift on Hover */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Glow Effect on Hover */
.hover-glow {
  position: relative;
  transition: box-shadow 0.3s ease;
}

.hover-glow::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(45deg, #635bff, #8b83ff);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
  filter: blur(8px);
}

.hover-glow:hover::before {
  opacity: 0.6;
}

/* ===================================
   List Item Stagger Animation
   =================================== */

.stagger-list > * {
  animation: fade-in-up 0.4s ease-out backwards;
}

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

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

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

/* ===================================
   Performance Optimizations
   =================================== */

/* Use GPU acceleration for animations */
.btn-primary,
.btn-destructive,
.payment-method-tab,
.hover-lift {
  will-change: transform;
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Remove will-change after animation */
.animation-complete {
  will-change: auto;
}

/* Map Page Specific Styles */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Custom Range Slider Styling (Stripe-inspired) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #635bff;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: #5144e1;
  box-shadow: 0 4px 8px rgba(99, 91, 255, 0.3);
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #635bff;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
  background: #5144e1;
  box-shadow: 0 4px 8px rgba(99, 91, 255, 0.3);
  transform: scale(1.1);
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: linear-gradient(to right, #635bff 0%, #635bff var(--range-progress, 50%), #e3e8ee var(--range-progress, 50%), #e3e8ee 100%);
  border-radius: 8px;
}

input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  background: #e3e8ee;
  border-radius: 8px;
}

input[type="range"]::-moz-range-progress {
  background: #635bff;
  height: 6px;
  border-radius: 8px;
}

/* Leaflet Custom Marker Styles */
.user-location-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #635bff;
  filter: drop-shadow(0 2px 4px rgba(99, 91, 255, 0.3));
}

.item-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(239, 68, 68, 0.3));
}

.marker-cluster-custom {
  background: linear-gradient(135deg, #635bff 0%, #5144e1 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(99, 91, 255, 0.4);
}

/* Leaflet Popup Styling */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  padding: 0 !important;
}

.item-popup {
  padding: 1rem;
}

.item-popup h3 {
  color: #0a2540;
  margin: 0 0 0.5rem 0;
}

.item-popup p {
  margin: 0.25rem 0;
  color: #425466;
}

/* Backdrop Blur Support */
@supports (backdrop-filter: blur(4px)) {
  .backdrop-blur {
    backdrop-filter: blur(4px);
  }
}

/* Responsive Map Container */
@media (max-width: 768px) {
  .payment-container {
    margin: 1rem;
    padding: 1.5rem;
  }
}
