/* =============================================
   PRODUCT CARDS & CATEGORY CARDS
   ============================================= */

/* === Product Card === */
.product-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition:
    transform var(--ease-base),
    box-shadow var(--ease-base);
  display: flex;
  flex-direction: column;
  position: relative;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}

/* Badges */
.product-card__badges {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 2;
}

/* Wishlist toggle */
.product-card__wishlist {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 2;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  box-shadow: var(--shadow-sm);
  transition: color var(--ease-fast), transform var(--ease-spring);
  cursor: pointer;
  border: none;
  font-size: var(--text-base);
}

.product-card__wishlist:hover {
  color: #ef4444;
  transform: scale(1.15);
}

.product-card__wishlist.is-active {
  color: #ef4444;
}

/* Image */
.product-card__image {
  aspect-ratio: 1 / 1;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  overflow: hidden;
}

.product-card__image img {
  max-height: 180px;
  width: auto;
  object-fit: contain;
  transition: transform var(--ease-slow);
}

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

/* Real image (when imageUrl is set in Firestore) */
.product-card__real-img {
  width: 100%;
  height: 180px;
  display: block;
  object-fit: contain;
  object-position: center center;
  background: #ffffff;
  /* Padding sutil para que el producto no toque los bordes */
  padding: 12px;
  box-sizing: border-box;
}

/* Image placeholder (for demo without real images) */
.product-card__image-placeholder {
  width: 100%;
  height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--color-text-muted);
}

.product-card__image-placeholder i {
  font-size: 3rem;
  opacity: 0.4;
}

.product-card__image-placeholder span {
  font-size: var(--text-xs);
  opacity: 0.5;
}

/* Quick add overlay on hover */
.product-card__quick-add {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  padding: var(--space-3);
  transform: translateY(100%);
  transition: transform var(--ease-base);
  border-top: 1px solid var(--color-border);
}

.product-card:hover .product-card__quick-add {
  transform: translateY(0);
}

/* Body */
.product-card__body {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.product-card__category {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.product-card__name {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  line-height: var(--leading-snug);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card__name a {
  color: inherit;
  transition: color var(--ease-fast);
}

.product-card__name a:hover {
  color: var(--color-primary);
}

/* Rating */
.product-card__rating {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.stars {
  display: flex;
  gap: 1px;
  color: var(--color-accent);
  font-size: var(--text-xs);
}

.product-card__rating-count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Price */
.product-card__price {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-top: auto;
  flex-wrap: wrap;
}

.price {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
}

.price--sale {
  color: var(--color-error);
}

.price--original {
  font-size: var(--text-sm);
  font-weight: var(--font-normal);
  color: var(--color-text-muted);
  text-decoration: line-through;
}

.price--savings {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-success);
}

/* Footer */
.product-card__footer {
  padding: var(--space-3) var(--space-5) var(--space-4);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}

.product-card__add-btn {
  flex: 1;
  background: var(--color-primary);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: background var(--ease-fast), transform var(--ease-fast);
  border: none;
  cursor: pointer;
}

.product-card__add-btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}

.product-card__detail-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-secondary);
  transition: border-color var(--ease-fast), color var(--ease-fast);
  flex-shrink: 0;
}

.product-card__detail-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* === Stock indicator === */
.product-card__stock {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

.stock-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
}

.stock-dot--in { background: var(--color-success); }
.stock-dot--low { background: var(--color-warning); }
.stock-dot--out { background: var(--color-error); }

.product-card__stock.stock--in { color: var(--color-success); }
.product-card__stock.stock--low { color: var(--color-accent-dark); }
.product-card__stock.stock--out { color: var(--color-error); }

/* === Category Card === */
.category-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
  transition: transform var(--ease-base), box-shadow var(--ease-base);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--cat-color, var(--color-primary)), transparent);
  opacity: 0;
  transition: opacity var(--ease-base);
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}

.category-card:hover::before {
  opacity: 0.04;
}

.category-card__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
  background: var(--cat-bg, var(--color-primary-ghost));
  color: var(--cat-color, var(--color-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  transition: transform var(--ease-spring);
}

.category-card:hover .category-card__icon {
  transform: scale(1.1) rotate(-3deg);
}

.category-card__name {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

.category-card__count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.category-card__arrow {
  opacity: 0;
  color: var(--cat-color, var(--color-primary));
  font-size: var(--text-sm);
  transition: opacity var(--ease-base);
}

.category-card:hover .category-card__arrow {
  opacity: 1;
}

/* === Horizontal Product Card (list view) === */
.product-card--horizontal {
  flex-direction: row;
  align-items: center;
}

.product-card--horizontal .product-card__image {
  width: 120px;
  height: 120px;
  min-width: 120px;
  aspect-ratio: unset;
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
  padding: var(--space-4);
}

.product-card--horizontal .product-card__body {
  flex: 1;
  padding: var(--space-5);
  border-top: none;
  border-left: 1px solid var(--color-border);
}

.product-card--horizontal .product-card__footer {
  border-top: none;
  border-left: 1px solid var(--color-border);
  flex-direction: column;
  padding: var(--space-5);
  justify-content: center;
  min-width: 160px;
}

/* === Responsive === */
@media (max-width: 480px) {
  /* La card horizontal (vista lista) se apila para no desbordar */
  .product-card--horizontal {
    flex-direction: column;
    align-items: stretch;
  }

  .product-card--horizontal .product-card__image {
    width: 100%;
    height: auto;
    min-width: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .product-card--horizontal .product-card__body,
  .product-card--horizontal .product-card__footer {
    border-left: none;
    border-top: 1px solid var(--color-border);
    min-width: 0;
  }
}
