/* Enhanced Product Card Styles */

/* Dynamic product name styling */
.product-name {
  display: block;
  min-height: 2.5rem; /* Ensure consistent height */
  max-height: 2.5rem; /* Prevent overflow */
  overflow: hidden;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.25;
  transition: font-size 0.3s ease;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Ensure all product cards have the same height */
.product-card-container {
  height: 500px; /* Fixed height for all cards */
  display: flex;
  flex-direction: column;
}

/* Font size classes for different text lengths */
.product-name.size-large {
  font-size: 1.125rem; /* 18px - default size */
}

.product-name.size-medium {
  font-size: 1rem; /* 16px - for medium length names */
}

.product-name.size-small {
  font-size: 0.875rem; /* 14px - for long names */
}

.product-name.size-extra-small {
  font-size: 0.75rem; /* 12px - for very long names */
}

/* Product card height consistency */
.product-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Product info section should take remaining space */
.product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Smooth transitions for all interactive elements */
.product-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced hover effects */
.product-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Gradient text effects */
.gradient-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Custom scrollbar for product grids */
.product-grid::-webkit-scrollbar {
  width: 8px;
}

.product-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.product-grid::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.product-grid::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Loading animation for product cards */
@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.product-card-loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

/* Enhanced button styles */
.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  font-weight: 600;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

/* Badge animations */
.badge {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Image zoom effect */
.product-image {
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover .product-image {
  transform: scale(1.1);
}

/* Action buttons animation */
.action-buttons {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover .action-buttons {
  opacity: 1;
  transform: translateY(0);
}

/* Price highlight effect */
.price-current {
  position: relative;
  overflow: hidden;
}

.price-current::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(34, 197, 94, 0.2),
    transparent
  );
  animation: price-shine 3s infinite;
}

@keyframes price-shine {
  0% {
    left: -100%;
  }
  50% {
    left: 100%;
  }
  100% {
    left: 100%;
  }
}

/* Grid layout improvements */
#productGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  align-items: start;
}

/* Ensure all cards in grid have same height */
#productGrid .product-card-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .product-card-container {
    width: 100%;
    max-width: 300px;
    height: 450px; /* Slightly smaller for mobile */
  }

  #productGrid {
    grid-template-columns: 1fr;
    gap: 1rem;
    justify-items: center;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  #productGrid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .product-card-container {
    height: 480px; /* Medium height for tablets */
  }
}

@media (min-width: 1025px) {
  #productGrid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }

  .product-card-container {
    height: 500px; /* Full height for desktop */
  }
}

@media (min-width: 1280px) {
  #productGrid {
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
  }
}

/* Accessibility improvements */
.product-card:focus-within {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

.btn-primary:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .product-card {
    border: 2px solid #000;
  }

  .badge {
    border: 1px solid #000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .product-card,
  .product-image,
  .action-buttons,
  .btn-primary {
    transition: none;
    animation: none;
  }

  .product-card:hover {
    transform: none;
  }
}
