/*
 * MileMinder Micro-Interactions
 * Smooth animations and interactions for a premium feel
 */

/* ====================
   Enhanced Button Interactions
   ==================== */

/* Button hover glow effect */
.btn-primary:hover::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: shimmer 0.6s ease-out;
  pointer-events: none;
  border-radius: inherit;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

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

.btn:active::after {
  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%);
  animation: ripple 0.6s ease-out;
}

@keyframes ripple {
  to {
    width: 300px;
    height: 300px;
    opacity: 0;
  }
}

/* Floating action button effect */
.btn-primary,
.btn-success,
.btn-danger {
  position: relative;
  z-index: 1;
}

.btn-primary:hover,
.btn-success:hover,
.btn-danger:hover {
  animation: float 0.3s ease-out forwards;
}

@keyframes float {
  to {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
  }
}

/* ====================
   Card Hover Animations
   ==================== */

/* Card entrance animation */
.card {
  animation: cardEntrance 0.4s ease-out;
}

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

/* Card content reveal on hover */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  transition: left 0.5s ease;
  z-index: 1;
  pointer-events: none;
}

.card:hover::before {
  left: 100%;
}

/* Card shadow transition */
.card {
  transition: all var(--transition-base) cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  transform: translateY(-4px) scale(1.01);
}

/* ====================
   Form Input Animations
   ==================== */

/* Input focus animation */
.form-control {
  position: relative;
  transition: all var(--transition-base) ease;
}

.form-control:focus {
  transform: scale(1.02);
  animation: inputFocus 0.3s ease-out;
}

@keyframes inputFocus {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.1);
  }
  100% {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }
}

/* Label animation on focus */
.form-label {
  transition: all var(--transition-fast) ease;
  transform-origin: left center;
}

.form-control:focus + .form-label,
.form-control:not(:placeholder-shown) + .form-label {
  transform: translateY(-8px) scale(0.85);
  color: var(--primary-600);
}

/* Input validation states */
.form-control.is-valid {
  border-color: var(--success-500);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
  animation: validPulse 0.5s ease-out;
}

.form-control.is-invalid {
  border-color: var(--error-500);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
  animation: invalidShake 0.5s ease-out;
}

@keyframes validPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
  }
}

@keyframes invalidShake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* ====================
   Table Row Animations
   ==================== */

/* Table row hover effect */
.table tbody tr {
  transition: all var(--transition-fast) cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.table tbody tr:hover {
  transform: translateX(4px);
}

.table tbody tr::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, var(--primary-100), transparent);
  transition: width var(--transition-base) ease;
  z-index: -1;
}

.table tbody tr:hover::before {
  width: 100%;
}

/* ====================
   Navigation Animations
   ==================== */

/* Navigation link hover effect */
.nav-link {
  position: relative;
  overflow: hidden;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary-600);
  transition: width var(--transition-base) ease;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* Dropdown animation */
.dropdown-menu {
  opacity: 0;
  transform: translateY(-10px);
  transition: all var(--transition-base) ease;
  pointer-events: none;
}

.dropdown-menu.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  animation: dropdownSlide 0.3s ease-out;
}

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

/* ====================
   Alert Animations
   ==================== */

/* Alert entrance animation */
.alert {
  animation: alertSlideIn 0.4s ease-out;
}

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

/* Alert dismissal animation */
.alert.fade {
  transition: all var(--transition-base) ease;
}

.alert.fade:not(.show) {
  opacity: 0;
  transform: translateX(20px);
}

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

/* Modal backdrop animation */
.modal.fade .modal-dialog {
  transform: scale(0.8) translateY(-50px);
  transition: all var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Modal content animation */
.modal-content {
  animation: modalContentSlide 0.4s ease-out;
}

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

/* ====================
   Badge Animations
   ==================== */

/* Badge hover effect */
.badge {
  transition: all var(--transition-fast) ease;
  cursor: default;
}

.badge:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-sm);
}

/* Badge notification pulse */
@keyframes badgePulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.badge.badge-notification {
  animation: badgePulse 2s infinite;
}

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

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

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* Table row loading skeleton */
.table tbody tr.loading {
  position: relative;
  pointer-events: none;
}

.table tbody tr.loading td {
  color: transparent;
  position: relative;
  overflow: hidden;
}

.table tbody tr.loading td::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: skeleton 1.5s infinite;
}

@keyframes skeleton {
  to {
    left: 100%;
  }
}

/* ====================
   Scroll Animations
   ==================== */

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Scroll-triggered fade-in */
.fade-in-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s ease-out;
}

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

/* ====================
   Progress Animations
   ==================== */

/* Progress bar animation */
.progress-bar {
  position: relative;
  overflow: hidden;
}

.progress-bar::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: progressShine 2s infinite;
}

@keyframes progressShine {
  to {
    left: 100%;
  }
}

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

/* Hover grow effect */
.hover-grow {
  transition: transform var(--transition-base) ease;
}

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

/* Hover glow effect */
.hover-glow {
  transition: box-shadow var(--transition-base) ease;
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

/* Smooth fade transitions */
.fade-transition {
  transition: opacity var(--transition-base) ease;
}

.fade-transition.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ====================
   Accessibility & Performance
   ==================== */

/* Respect user preferences for reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .fade-in-on-scroll {
    opacity: 1;
    transform: none;
  }
}