/* ===================================
   PRODUCT CARD STYLING
   Used in carousels and product loops
   =================================== */

/* Product Card Container */
.product-carousel,
.product-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background-color: #fff;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--primary-color);
}

/* Section 1: Product Image */
.product-card-image-section {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--primary-color);
  flex-shrink: 0;
}

.product-card-image-section a {
  display: block;
  width: 100%;
  height: 100%;
}

.product-card-image-section img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 1;
  min-height: 200px;
  background-color: #f8f9fa;
}

.product-carousel:hover .product-card-image-section img,
.product-card:hover .product-card-image-section img {
  transform: scale(1.05);
}

/* Sale Badge */
.sale-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background-color: #dc3545;
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

/* Section 2: Product Name */
.product-card-name-section {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px 12px;
  min-height: 70px;
  border-bottom: 1.5px solid var(--primary-color, #175f53);
}

.product-card-name-section .card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-color, #333);
}

.product-card-name-section .card-title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.product-card-name-section .card-title a:hover {
  color: var(--primary-color, #175f53);
}

/* Section 3: Action Button with Price */
.product-card-action-section {
  flex-shrink: 0;
  padding: 0;
  background-color: transparent;
}

.product-action-btn {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  margin: 0;
  border: none;
  background: var(--primary-color);
  color: #fff !important;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.product-action-btn:hover {
  background-color: var(--active-link);
  color: #fff !important;
  text-decoration: none;
}

.product-action-btn:active {
  transform: translateY(0);
}

/* Button Content Styling */
.product-action-btn .action-text {
  font-weight: 700;
  white-space: nowrap;
}

.product-action-btn .separator {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 400;
}

.product-action-btn .price-text {
  font-weight: 700;
  direction: ltr;
}

/* Price Styling - Regular and Sale Prices */
.product-action-btn .price-text .price {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.product-action-btn .price-text del {
  font-size: 0.85em;
  opacity: 0.7;
  text-decoration: line-through;
  font-weight: 400;
}

.product-action-btn .price-text ins {
  text-decoration: none;
  font-weight: 700;
}

/* Loading State for AJAX Add to Cart */
.product-action-btn.loading {
  background-color: var(--notification-color) !important;
  color: var(--text-color) !important;
  pointer-events: none;
  position: relative;
  cursor: wait;
}

.product-action-btn.loading .action-text,
.product-action-btn.loading .separator,
.product-action-btn.loading .price-text {
  color: var(--text-color) !important;
}

.product-action-btn.loading .action-text::after {
  content: "...";
  animation: dots 1.5s steps(4, end) infinite;
}

.product-action-btn.loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes dots {
  0%,
  20% {
    content: ".";
  }
  40% {
    content: "..";
  }
  60%,
  100% {
    content: "...";
  }
}

/* Added to Cart State */
.product-action-btn.added {
  background-color: var(--active-link) !important;
  color: #fff !important;
}

.product-action-btn.added .action-text,
.product-action-btn.added .separator,
.product-action-btn.added .price-text {
  color: #fff !important;
}

/* Prevent WooCommerce from adding "View cart" text */
.product-action-btn.added::before {
  content: none !important;
}

/* Ensure button maintains its structure after AJAX add-to-cart */
.product-action-btn.added_to_cart,
.product-action-btn[data-added_to_cart] {
  background-color: var(--active-link) !important;
  color: #fff !important;
}

.product-action-btn.added_to_cart .action-text,
.product-action-btn.added_to_cart .separator,
.product-action-btn.added_to_cart .price-text {
  color: #fff !important;
}

/* Hide any WooCommerce-generated text nodes */
.product-action-btn::after {
  content: none !important;
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
  .product-carousel,
  .product-card {
    min-height: 400px;
  }
}

@media (max-width: 768px) {
  .product-carousel,
  .product-card {
    min-height: 380px;
  }

  .product-card-name-section {
    padding: 14px 16px;
    min-height: 70px;
  }

  .product-card-name-section .card-title {
    font-size: 0.95rem;
  }

  .product-action-btn {
    padding: 14px 16px;
    font-size: 0.9rem;
    gap: 8px;
  }

  .sale-badge {
    top: 8px;
    right: 8px;
    padding: 5px 12px;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .product-carousel,
  .product-card {
    min-height: 360px;
  }

  .product-card-name-section .card-title {
    font-size: 0.9rem;
  }

  .product-action-btn {
    padding: 12px 14px;
    font-size: 0.85rem;
    flex-direction: column;
    gap: 4px;
  }

  .product-action-btn .separator {
    display: none;
  }
}

/* Ensure consistent heights in Swiper slides */
.swiper-slide {
  height: auto !important;
}

.swiper-slide .product-carousel,
.swiper-slide .product-card {
  height: 100%;
}

