/**
 * Component: Product Card
 *
 * Reusable product card styles with quantity selector and actions.
 *
 * @package    Factoria Child
 * @subpackage Styles/Components
 * @since      1.0.0
 */

/* --------------------------------------------------------
   Card Container
   -------------------------------------------------------- */
.product-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
  overflow: hidden;
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.product-card:hover {
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* .product-card--damaged {
  border-color: hsl(var(--destructive) / 0.3);
} */

.product-card--out-of-stock {
  opacity: 0.7;
}

/* --------------------------------------------------------
   Image
   -------------------------------------------------------- */
.product-card__image-wrapper {
  position: relative;
  display: block;
  aspect-ratio: 2/3;
  overflow: hidden;
  background-color: hsl(var(--muted));
}

.product-card__image-wrapper img,
.product-card__image-wrapper .product-card__image {
  width: 100%;
  height: auto;
  transition: transform 0.3s ease;
  aspect-ratio: 2/3;
}

.product-card:hover .product-card__image-wrapper img {
  transform: scale(1.05);
}

/* --------------------------------------------------------
   Badges
   -------------------------------------------------------- */
.product-card__badge {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.2rem 0.8rem;
  border-radius: 9999px;
  line-height: 1;
  display: flex;
  aspect-ratio: 1;
  justify-content: center;
  align-items: center;
}

.product-card__badge--sale {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.product-card__badge--damaged {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.product-card__badge--damaged svg {
  width: 1.2rem;
  height: 1.2rem;
}

.product-card__badge--out-of-stock {
  background-color: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

/* --------------------------------------------------------
   Body
   -------------------------------------------------------- */
.product-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.2rem;
  gap: 0.6rem;
}

@media (min-width: 640px) {
  .product-card__body {
    padding: 1.6rem;
    gap: 0.8rem;
  }
}

/* --------------------------------------------------------
   Title
   -------------------------------------------------------- */
.product-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 1.3rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  line-height: 1.3;
  transition: color 0.2s ease;
}

.product-card__title:hover {
  color: hsl(var(--primary));
}

@media (min-width: 640px) {
  .product-card__title {
    font-size: 1.5rem;
  }
}

/* --------------------------------------------------------
   Best Before Date
   -------------------------------------------------------- */
.product-card__best-before {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.1rem;
  color: hsl(var(--muted-foreground));
}

.product-card__best-before .dashicons {
  font-size: 1.2rem;
  width: 1.2rem;
  height: 1.2rem;
}

/* --------------------------------------------------------
   Price
   -------------------------------------------------------- */
.product-card__price {
  font-size: 1.5rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.product-card__price del {
  font-weight: 400;
  color: hsl(var(--muted-foreground));
  font-size: 1.3rem;
  margin-right: 0.4rem;
}

.product-card__price ins {
  text-decoration: none;
  color: hsl(var(--primary));
}

@media (min-width: 640px) {
  .product-card__price {
    font-size: 1.7rem;
  }
}

/* --------------------------------------------------------
   Actions Row
   -------------------------------------------------------- */
.product-card__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: auto;
  padding-top: 0.6rem;
  flex-wrap: wrap;
}

@media (min-width: 640px) {
  .product-card__actions {
    gap: 0.8rem;
    padding-top: 0.8rem;
  }
}

/* --------------------------------------------------------
   Quantity Selector
   -------------------------------------------------------- */
.product-card__quantity {
  display: flex;
  align-items: center;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
  height: 3.2rem;
}

.product-card__qty-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.8rem;
  height: 100%;
  background: hsl(var(--background));
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  color: hsl(var(--foreground));
  transition: background-color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
  padding: 0;
  line-height: 1;
}

.product-card__qty-btn:hover {
  background-color: hsl(var(--muted));
}

.product-card__qty-input {
  width: 3.2rem;
  height: 100%;
  text-align: center;
  border: none;
  border-left: 1px solid hsl(var(--border));
  border-right: 1px solid hsl(var(--border));
  font-size: 1.2rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  -moz-appearance: textfield;
  -webkit-appearance: none;
  appearance: none;
  padding: 0;
}

.product-card__qty-input::-webkit-inner-spin-button,
.product-card__qty-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* --------------------------------------------------------
  Buy Now Button
   -------------------------------------------------------- */
.product-card__buy-now {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 3.2rem;
  padding: 0 1rem;
  border: 1px solid hsl(var(--primary));
  border-radius: var(--radius);
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    opacity 0.2s ease,
    transform 0.1s ease;
  -webkit-appearance: none;
  appearance: none;
  white-space: nowrap;
}

.product-card__buy-now svg {
  width: 1.7rem;
}

.product-card__buy-now:hover {
  opacity: 0.9;
}

.product-card__buy-now:active {
  transform: scale(0.97);
}

.product-card__buy-now .dashicons {
  font-size: 1.4rem;
  width: 1.4rem;
  height: 1.4rem;
}

/* Loading state */
.product-card__buy-now--loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Success state */
.product-card__buy-now--success {
  background-color: hsl(152, 55%, 40%);
  border-color: hsl(152, 55%, 40%);
}

/* --------------------------------------------------------
  Add to cart
   -------------------------------------------------------- */
.product-card__add-to-cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 3.2rem;
  padding: 0 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 1.2rem;
  font-weight: 600;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
  white-space: nowrap;
}

.product-card__add-to-cart:hover {
  background-color: hsl(var(--muted));
  border-color: hsl(var(--foreground) / 0.2);
}

/* --------------------------------------------------------
   Out of Stock Text
   -------------------------------------------------------- */
.product-card__out-of-stock-text {
  font-size: 1.2rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

/* Product Card Expiration Warning Badge */
.product-card__image-wrapper {
  position: relative;
}

.product-card__expiration-warning {
  width: 100%;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: #fef1db;
  color: #b45309;
}

.product-card__expiration-warning svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.product-card__expiration-warning span {
  font-size: 1.2rem;
  line-height: 1;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
  .product-card__expiration-warning {
    font-size: 0.6875rem; /* 11px */
    padding: 5px 10px;
    gap: 4px;
  }

  .product-card__expiration-warning svg {
    width: 12px;
    height: 12px;
  }
}

/* Product Card Date Badges Container */
.product-card__image-wrapper {
  position: relative;
}

.product-card__date-badges {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.product-card__expiration-warning {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: #fef1db;
  color: #b45309;
}

.product-card__expiration-warning svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.product-card__expiration-warning span {
  font-size: 1.2rem;
  line-height: 1;
}

.product-card__best-before-badge,
.product-card__damaged-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: #e8f1ed;
  color: hsl(var(--primary));
}

.product-card__damaged-badge {
  background-color: #fdcaa5;
  color: #c2410c;
}

.product-card__best-before-badge svg,
.product-card__damaged-badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.product-card__best-before-badge span,
.product-card__damaged-badge span {
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 500;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
  .product-card__expiration-warning,
  .product-card__best-before-badge {
    font-size: 0.6875rem; /* 11px */
    padding: 5px 10px;
    gap: 4px;
  }

  .product-card__expiration-warning svg,
  .product-card__best-before-badge svg {
    width: 12px;
    height: 12px;
  }

  .product-card__expiration-warning span,
  .product-card__best-before-badge span {
    font-size: 1.1rem;
  }
}

.product-card__stock-badge-wrapper {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.product-card__stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
  background-color: var(--color-secondary, #f1f5f9);
  color: var(--color-secondary-foreground, #0f172a);
  transition: background-color 0.2s ease;
}

.product-card__stock-badge span {
  font-size: 1rem;
  font-weight: 500;
}

.product-card__stock-badge:hover {
  background-color: var(--color-secondary-hover, #e2e8f0);
}

.product-card__stock-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}
