/* Advanced Animations and Micro-interactions */

/* Smooth page transitions */
* {
  scroll-behavior: smooth;
}

/* Enhanced loading animations */
@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.loading-shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

/* Product card entrance animations */
@keyframes slideInFromBottom {
  from {
    opacity: 0;
    transform: translateY(50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

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

/* Staggered animation for product cards */
.product-card {
  animation: slideInFromBottom 0.6s ease-out forwards;
  opacity: 0;
}

.product-card:nth-child(odd) {
  animation: slideInFromLeft 0.6s ease-out forwards;
}

.product-card:nth-child(even) {
  animation: slideInFromRight 0.6s ease-out forwards;
}

/* Enhanced hover effects */
.product-card {
  position: relative;
  overflow: hidden;
}

.product-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transition: left 0.5s;
}

.product-card:hover::after {
  left: 100%;
}

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

.product-card.featured {
  animation: float 3s ease-in-out infinite;
}

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

.btn::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%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::after {
  width: 300px;
  height: 300px;
}

/* Enhanced modal animations */
@keyframes modalBackdropFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(100px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal {
  animation: modalBackdropFadeIn 0.3s ease-out;
}

.modal-content {
  animation: modalSlideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Filter animation */
@keyframes filterSlideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filters {
  animation: filterSlideDown 0.5s ease-out;
}

/* Navigation button pulse */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
  }
}

.nav-btn:hover {
  animation: pulse 1.5s infinite;
}

/* Search input focus animation */
@keyframes inputFocus {
  from {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
  }
  to {
    box-shadow: 0 0 0 8px rgba(102, 126, 234, 0);
  }
}

.filter-input:focus {
  animation: inputFocus 0.6s ease-out;
}

/* Page number animation */
@keyframes pageNumberBounce {
  0%,
  20%,
  60%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  80% {
    transform: translateY(-5px);
  }
}

.page-number.active {
  animation: pageNumberBounce 0.8s ease-in-out;
}

/* Loading dots animation */
@keyframes loadingDots {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.loading-dots {
  display: inline-block;
}

.loading-dots::after {
  content: "...";
  animation: loadingDots 1.4s infinite ease-in-out both;
}

/* Notification slide animation */
@keyframes notificationSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes notificationSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.notification {
  animation: notificationSlideIn 0.3s ease-out;
}

.notification.hide {
  animation: notificationSlideOut 0.3s ease-in;
}

/* Price animation */
@keyframes priceHighlight {
  0%,
  100% {
    color: var(--primary-color);
    transform: scale(1);
  }
  50% {
    color: var(--accent-color);
    transform: scale(1.05);
  }
}

.product-price:hover {
  animation: priceHighlight 0.6s ease-in-out;
}

/* Header logo animation */
@keyframes logoSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.logo i:hover {
  animation: logoSpin 0.8s ease-in-out;
}

/* View toggle animation */
@keyframes viewToggle {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

.view-btn.active {
  animation: viewToggle 0.3s ease-in-out;
}

/* Scroll to top animation */
@keyframes scrollToTop {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.scroll-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-fast);
  animation: scrollToTop 0.3s ease-out;
  z-index: 100;
}

.scroll-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-5px);
}

/* Enhanced product image hover */
.product-image {
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.product-card:hover .product-image {
  transform: scale(1.1) rotate(2deg);
  filter: brightness(1.1) saturate(1.2);
}

/* Filter clear animation */
@keyframes filterClear {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

#clear-filters:active i {
  animation: filterClear 0.5s ease-in-out;
}

/* Pagination hover effects */
.page-btn:hover,
.page-number:hover {
  transform: translateY(-3px) scale(1.1);
  box-shadow: var(--shadow-lg);
}

/* Product actions slide up */
@keyframes actionsSlideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.product-card:hover .product-actions {
  animation: actionsSlideUp 0.3s ease-out;
}

/* Enhanced focus states */
.filter-input:focus,
.filter-select:focus {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

/* Micro-interaction for successful actions */
@keyframes successPulse {
  0% {
    transform: scale(1);
    background-color: var(--success-color);
  }
  50% {
    transform: scale(1.05);
    background-color: var(--primary-color);
  }
  100% {
    transform: scale(1);
    background-color: var(--success-color);
  }
}

.btn.success {
  animation: successPulse 0.6s ease-in-out;
}

/* Loading skeleton for product cards */
.product-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-2xl);
  height: 400px;
  margin-bottom: var(--spacing-6);
}

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

/* Dark mode animations (bonus feature) */
@media (prefers-color-scheme: dark) {
  .product-card::after {
    background: linear-gradient(
      90deg,
      transparent,
      rgba(255, 255, 255, 0.1),
      transparent
    );
  }

  .loading-shimmer {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
  }
}

/* Performance optimizations */
.product-card,
.btn,
.modal-content {
  will-change: transform;
}

.product-image {
  will-change: transform, filter;
}

/* Accessibility enhancements */
@media (prefers-reduced-motion: no-preference) {
  .product-card {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }
}

/* Custom scrollbar animations */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}
