.tungtheme-product-gallery {
  padding: 0;
  background: none;
  border-radius: 12px;
  box-shadow: none;
}

.pg-filter {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.pg-filter select {
  padding: 10px 15px;
  border: none;
  border-radius: 8px;
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pg-filter select:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pg-grid {
  display: grid;
  gap: 20px;
  transition: all 0.3s ease;
}

/* Dynamic grid columns based on data-items attribute */
.tungtheme-product-gallery[data-items="1"] .pg-grid {
  grid-template-columns: repeat(1, 1fr);
}

.tungtheme-product-gallery[data-items="2"] .pg-grid {
  grid-template-columns: repeat(2, 1fr);
}

.tungtheme-product-gallery[data-items="3"] .pg-grid {
  grid-template-columns: repeat(3, 1fr);
}

.tungtheme-product-gallery[data-items="4"] .pg-grid {
  grid-template-columns: repeat(4, 1fr);
}

.tungtheme-product-gallery[data-items="5"] .pg-grid {
  grid-template-columns: repeat(5, 1fr);
}

.tungtheme-product-gallery[data-items="6"] .pg-grid {
  grid-template-columns: repeat(6, 1fr);
}

/* Fallback for invalid or missing data-items */
.tungtheme-product-gallery .pg-grid {
  grid-template-columns: repeat(3, 1fr); /* Default to 3 columns */
}

.pg-item {
  background: #fff;
  border: none;
  border-radius: 10px;
  padding: 15px;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 320px; /* Adjusted for discount */
}

.pg-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.pg-item img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  transition: transform 0.3s ease;
}

.pg-item:hover img {
  transform: scale(1.05);
}

.pg-item h3 {
  font-size: 18px;
  margin: 10px 0;
  color: #333; /* Controlled by Elementor title_color */
  flex-grow: 0;
  transition: color 0.3s ease, transform 0.3s ease;
}

.pg-item:hover h3 {
  transform: scale(1.03); /* Subtle scale effect on hover */
}

.price-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

.pg-item .price {
  font-weight: 600;
  font-size: 20px;
  color: #e67e22; /* Controlled by Elementor price_color */
  flex-grow: 0;
  transition: color 0.3s ease, transform 0.3s ease;
}

.pg-item .original-price {
  font-size: 16px;
  color: #7f8c8d;
  text-decoration: line-through;
  flex-grow: 0;
}

.pg-item .discount {
  font-size: 14px;
  font-weight: 600;
  color: #16a34a; /* Controlled by Elementor discount_color */
  background-color: #dcfce7; /* Controlled by Elementor discount_background_color */
  padding: 4px 8px;
  border-radius: 12px;
  flex-grow: 0;
  transition: transform 0.3s ease;
}

.pg-item:hover .price,
.pg-item:hover .original-price,
.pg-item:hover .discount {
  transform: scale(1.03); /* Subtle scale effect on hover */
}

.pg-item .category {
  display: block;
  font-size: 14px;
  color: #7f8c8d; /* Controlled by Elementor category_color */
  margin: 5px 0;
  flex-grow: 0;
  transition: color 0.3s ease, transform 0.3s ease;
}

.pg-item:hover .category {
  transform: scale(1.03); /* Subtle scale effect on hover */
}

.pg-item a {
  display: inline-block;
  text-decoration: none;
  color: #fff; /* Controlled by Elementor button_color */
  background-color: #3498db; /* Controlled by Elementor button_bg_color */
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  margin-top: auto; /* Pushes button to the bottom */
  transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

.pg-item a:hover {
  background-color: #2980b9; /* Controlled by Elementor button_bg_color_hover */
  color: #fff; /* Controlled by Elementor button_color_hover */
  transform: translateY(-2px); /* Lift button slightly on hover */
}

.pg-loading {
  text-align: center;
  font-size: 18px;
  color: #7f8c8d;
  display: none;
  animation: fade 1.5s infinite;
}

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

/* Pagination styles */
.pg-pagination {
  display: flex;
  justify-content: center;
  gap: 8px; /* Reduced gap for compactness */
  margin-top: 20px;
  flex-wrap: wrap;
}

.pg-page-btn {
  padding: 6px 12px; /* Reduced padding for compact buttons */
  border: none;
  border-radius: 6px; /* Slightly smaller border-radius */
  background-color: #3498db; /* Matches button_bg_color */
  color: #fff; /* Matches button_color */
  font-size: 13px; /* Smaller font size for compactness */
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease,
    box-shadow 0.3s ease;
}

.pg-page-btn:hover:not([disabled]) {
  background-color: #2980b9; /* Matches button_bg_color_hover */
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pg-page-btn.active {
  background-color: #e67e22; /* Matches price_color for active state */
  cursor: default;
  transform: none;
}

.pg-page-btn[disabled] {
  background-color: #7f8c8d; /* Matches category_color for disabled state */
  cursor: not-allowed;
  opacity: 0.6;
}

/* Single Product Page Styles */
.single-product-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px;
}

.single-product-container .pg-loading {
  display: none;
  text-align: center;
  padding: 2rem;
  font-size: 1.2rem;
  color: #7f8c8d; /* Fallback, can be overridden */
}

.single-product-container .loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #3498db; /* Controlled by Elementor button_bg_color */
  border-top: 3px solid #2980b9; /* Controlled by Elementor button_bg_color_hover */
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 10px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.product-content {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 40px;
}

.product-gallery {
  flex: 1 1 100%;
}

.product-gallery .main-image {
  max-width: 100%;
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 10px;
}

.product-thumbnails {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.product-thumbnails img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.3s ease;
}

.product-thumbnails img:hover {
  border-color: #2980b9; /* Controlled by Elementor button_bg_color_hover */
}

.product-info {
  flex: 1 1 100%;
}

.product-info h1 {
  font-size: 28px;
  margin: 0 0 10px;
  color: #333; /* Controlled by Elementor title_color */
  transition: color 0.3s ease;
}

.product-info:hover h1 {
  color: #e67e22; /* Controlled by Elementor title_color_hover */
}

.product-info p {
  margin: 10px 0;
  font-size: 16px;
}

.product-info .category {
  font-size: 14px;
  color: #7f8c8d; /* Controlled by Elementor category_color */
  transition: color 0.3s ease;
}

.product-info:hover .category {
  color: #3498db; /* Controlled by Elementor category_color_hover */
}

.product-info .price-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
  justify-content: flex-start;
}

.product-info .price {
  font-size: 24px;
  font-weight: 600;
  color: #e67e22; /* Controlled by Elementor price_color */
  transition: color 0.3s ease;
}

.product-info:hover .price {
  color: #d35400; /* Controlled by Elementor price_color_hover */
}

.product-info .original-price {
  font-size: 18px;
  color: #7f8c8d;
  text-decoration: line-through;
}

.product-info .discount {
  font-size: 16px;
  font-weight: 600;
  color: #16a34a; /* Controlled by Elementor discount_color */
  background-color: #dcfce7; /* Controlled by Elementor discount_background_color */
  padding: 4px 8px;
  border-radius: 12px;
}

.product-info .btn-add-cart {
  display: inline-block;
  text-decoration: none;
  color: #fff; /* Controlled by Elementor button_color */
  background-color: #3498db; /* Controlled by Elementor button_bg_color */
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

.product-info .btn-add-cart:hover {
  background-color: #2980b9; /* Controlled by Elementor button_bg_color_hover */
  color: #fff; /* Controlled by Elementor button_color_hover */
  transform: translateY(-2px);
}

.related-products {
  margin-top: 40px;
}

.related-products h2 {
  font-size: 24px;
  margin-bottom: 20px;
  color: #333; /* Controlled by Elementor title_color */
  transition: color 0.3s ease;
}

.related-products:hover h2 {
  color: #e67e22; /* Controlled by Elementor title_color_hover */
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.related-item {
  background: #fff;
  border-radius: 10px;
  padding: 15px;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.related-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.related-item img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 10px;
}

.related-item h3 {
  font-size: 18px;
  margin: 10px 0;
  color: #333; /* Controlled by Elementor title_color */
  transition: color 0.3s ease;
}

.related-item:hover h3 {
  color: #e67e22; /* Controlled by Elementor title_color_hover */
}

.related-item .price-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}

.related-item .price {
  font-weight: 600;
  font-size: 18px;
  color: #e67e22; /* Controlled by Elementor price_color */
  transition: color 0.3s ease;
}

.related-item:hover .price {
  color: #d35400; /* Controlled by Elementor price_color_hover */
}

.related-item .original-price {
  font-size: 14px;
  color: #7f8c8d;
  text-decoration: line-through;
}

.related-item .discount {
  font-size: 14px;
  font-weight: 600;
  color: #16a34a; /* Controlled by Elementor discount_color */
  background-color: #dcfce7; /* Controlled by Elementor discount_background_color */
  padding: 4px 8px;
  border-radius: 12px;
}

.related-item a {
  display: inline-block;
  text-decoration: none;
  color: #fff; /* Controlled by Elementor button_color */
  background-color: #3498db; /* Controlled by Elementor button_bg_color */
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

.related-item a:hover {
  background-color: #2980b9; /* Controlled by Elementor button_bg_color_hover */
  color: #fff; /* Controlled by Elementor button_color_hover */
  transform: translateY(-2px);
}

/* Responsive adjustments */
@media (max-width: 992px) {
  .tungtheme-product-gallery[data-items] .pg-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .related-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .tungtheme-product-gallery[data-items] .pg-grid {
    grid-template-columns: 1fr; /* 2 columns on smaller screens */
  }
  .related-grid {
    grid-template-columns: 1fr;
  }
  .product-content {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .tungtheme-product-gallery[data-items] .pg-grid {
    grid-template-columns: 1fr; /* 1 column on very small screens */
  }
  .related-grid {
    grid-template-columns: 1fr;
  }
}
