/* ===============================
   Categories Page Styles
================================= */

/* Make categories page 90% width */
.page-categories .container {
  max-width: none;
  width: 90%;
  margin: 0 auto;
}

/* Product Grid */
.prod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 30px;
}

.prod-card {
  background: var(--white);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  border: 1px solid rgba(46, 125, 50, 0.1);
  text-align: center;
  padding: 30px 20px;
}

.prod-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(46, 125, 50, 0.15);
}

.prod-card h3 {
  font-size: 1.2rem;
  margin-bottom: 20px;
  color: var(--jungle-dark);
}

.prod-card .btn {
  margin-top: 15px;
}

.categories-layout {
  display: flex;
  gap: 30px;
  margin-top: 20px;
}

.categories-sidebar {
  width: 280px;
  background: var(--white);
  border-radius: 15px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  height: fit-content;
  position: sticky;
  top: 100px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
}

.categories-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--jungle-dark);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  transition: background-color 0.3s ease;
}

.subcategory-link {
  display: block;
  padding: 6px 12px 6px 24px;
  border-radius: 6px;
  color: var(--jungle-dark);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: background-color 0.3s ease;
}

.category-link.active,
.subcategory-link.active {
  background-color: var(--jungle-green);
  color: var(--white);
}

.category-link:hover,
.subcategory-link:hover {
  background-color: var(--jungle-light);
  color: var(--white);
}

.products-content {
  flex: 1;
}

.products-header {
  margin-bottom: 20px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  /* Optimized hardware acceleration to prevent flickering */
  will-change: transform;
  backface-visibility: hidden;
  /* Add hardware acceleration for smooth animations */
  transform: translateZ(0);
  /* Safari-specific prefixes */
  -webkit-backface-visibility: hidden;
  -webkit-transform: translateZ(0);
  /* Prevent grid reflow */
  grid-auto-rows: 1fr;
  align-items: start;
}

.product-card {
  background: var(--white);
  border-radius: 15px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid rgba(46, 125, 50, 0.1);
  /* Optimized hardware acceleration */
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  -webkit-transform: translateZ(0);
  /* Flexible height instead of fixed */
  min-height: 450px;
  max-height: 550px;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(46, 125, 50, 0.15);
}

.product-image {
  width: 100%;
  height: 350px;
  background: var(--gray-light);
  position: relative;
  overflow: hidden;
}

.product-image img {
  width: 100%;
  height: 350px;
  object-fit: cover;
  /* Prevent flicker during image loading */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  transform: translateZ(0);
  backface-visibility: hidden;
  /* Add loading state */
  opacity: 0;
  transition: opacity 0.3s ease;
  position: absolute;
  top: 0;
  left: 0;
}

.product-image img.loaded {
  opacity: 1;
}

/* Loading skeleton */
.product-image::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 350px;
  background: linear-gradient(90deg, var(--gray-light) 25%, var(--gray-lighter) 50%, var(--gray-light) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  z-index: 1;
}

.product-image img.loaded::before {
  display: none;
}

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

.product-info {
  padding: 10px 15px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-info h3 {
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--jungle-dark);
  line-height: 1.3;
}

.product-description {
  font-size: 0.8rem;
  color: var(--gray-dark);
  margin-bottom: 10px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  /* Standard property for better cross-browser compatibility */
  line-clamp: 2;
  overflow: hidden;
}

.product-price {
  margin-bottom: 10px;
  font-weight: 700;
  color: var(--jungle-green);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.wholesale-price {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--gray);
}

.product-actions {
  margin-top: 15px;
  padding: 0 15px 15px;
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: center;
}

.product-actions .btn {
  flex: 1;
  padding: 12px 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(46, 125, 50, 0.2);
}

.product-actions .btn.add-to-cart {
  background: var(--jungle-green);
  color: var(--white);
}

.product-actions .btn.add-to-cart:hover {
  background: var(--jungle-dark);
}

.product-actions .btn.secondary {
  background: var(--white);
  color: var(--jungle-green);
  border: 2px solid var(--jungle-green);
}

.product-actions .btn.secondary:hover {
  background: var(--jungle-light);
  color: var(--white);
}

.no-products {
  text-align: center;
  padding: 40px 20px;
  background: var(--soft-beige);
  border-radius: 15px;
  box-shadow: var(--shadow-sm);
  color: var(--jungle-dark);
  font-weight: 600;
  font-size: 1.1rem;
}

.welcome-message {
  text-align: center;
  padding: 60px 20px;
  color: var(--jungle-dark);
  font-weight: 600;
  font-size: 1.3rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .categories-layout {
    flex-direction: column;
  }

  .categories-sidebar {
    width: 100%;
    position: relative;
    top: auto;
    max-height: none;
  }

  .products-content {
    width: 100%;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .prod-grid {
    grid-template-columns: 1fr;
  }

  .prod-card {
    max-width: 300px;
    margin: 0 auto;
  }

  .product-actions .btn {
    padding: 8px 0;
    font-size: 0.9rem;
  }
}
