/*
 * ============================================================
 * PRODUCT CARD — ShopToolHP Design Kit v1.0
 * Chuẩn hóa: card, ribbon, stats, price, button, grid
 * Requires: design-tokens.css
 * ============================================================ */

/* ============================================================
   PRODUCT GRID
   ============================================================ */
.sth-product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sth-card-gap);
}
@media (max-width: 1280px) { .sth-product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .sth-product-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .sth-product-grid { grid-template-columns: 1fr; } }

/* ============================================================
   SECTION HEADER
   ============================================================ */
.sth-section-header {
  display: flex;
  align-items: center;
  gap: var(--sth-space-3);
  margin-bottom: var(--sth-space-6);
}
.sth-section-header h2 {
  font-size: var(--sth-text-xl);
  font-weight: var(--sth-font-bold);
  color: var(--sth-text-primary);
  margin: 0;
  letter-spacing: -0.3px;
}
.sth-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--sth-border), transparent);
}

/* ============================================================
   PRODUCT CARD
   ============================================================ */
.product-card {
  background: var(--sth-bg-surface) !important;
  border: 1px solid var(--sth-border) !important;
  border-radius: var(--sth-radius-lg) !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  min-height: unset !important;
  position: relative;
  cursor: pointer;
  transition: var(--sth-transition-medium) !important;
  box-shadow: var(--sth-shadow) !important;
}

.product-card:hover {
  background: var(--sth-bg-elevated) !important;
  border-color: rgba(59, 130, 246, 0.4) !important;
  transform: translateY(-4px) !important;
  box-shadow: var(--sth-shadow-blue) !important;
}

/* Remove old pseudo-border animation */
.product-card::before { display: none !important; }

/* ============================================================
   THUMBNAIL
   ============================================================ */
.product-image-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9 !important;
  height: auto !important;
  overflow: hidden;
  background: var(--sth-bg-elevated);
  flex-shrink: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  border-radius: 0 !important;
  border-bottom: 1px solid var(--sth-border);
}

/* Remove old overlay */
.product-image-container::after { display: none !important; }

.product-card .product-image-container img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  display: block !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  filter: none !important;
  transition: transform 0.35s ease !important;
  position: static !important;
  z-index: auto !important;
  cursor: pointer;
}

.product-card:hover .product-image-container img {
  transform: scale(1.04) !important;
  filter: brightness(1.05) !important;
}

/* Skeleton placeholder khi ảnh lỗi/loading */
.product-image-container img[src=""],
.product-image-container img:not([src]) {
  background: var(--sth-bg-overlay);
}

/* ============================================================
   RIBBON BADGE
   ============================================================ */
.card__ribbon {
  position: absolute;
  top: 12px;
  left: -2px;
  z-index: 5;
  /* Reset old triangle shape */
  width: auto !important;
  height: auto !important;
  display: block !important;
  overflow: visible !important;
  filter: none !important;
}

.card__ribbon::after {
  content: attr(data-text);
  display: block;
  padding: 4px 14px 4px 10px;
  font-size: 10px;
  font-weight: var(--sth-font-bold);
  font-family: var(--sth-font-family);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  white-space: nowrap;
  border-radius: 0 var(--sth-radius-sm) var(--sth-radius-sm) 0;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
  /* Triangle tail bên trái */
  position: relative;
  /* Reset rotation */
  transform: none;
  width: auto;
  height: auto;
  background: linear-gradient(135deg, var(--ribbon-color, #3b82f6), var(--ribbon-dark, #2563eb));
}

/* Màu theo type — dùng lại biến cũ + override */
.card__ribbon[data-text="HOT"]          { --ribbon-color: #EF4444; --ribbon-dark: #DC2626; }
.card__ribbon[data-text="NEW"]          { --ribbon-color: #22C55E; --ribbon-dark: #16A34A; }
.card__ribbon[data-text="FREE"]         { --ribbon-color: #3B82F6; --ribbon-dark: #2563EB; }
.card__ribbon[data-text="FULL CHỨC NĂNG"] { --ribbon-color: #F59E0B; --ribbon-dark: #D97706; }
.card__ribbon[data-text="FULL"]         { --ribbon-color: #F59E0B; --ribbon-dark: #D97706; }

/* ============================================================
   CARD BODY
   ============================================================ */
.product-card .card-body {
  padding: var(--sth-space-4) !important;
  background: transparent !important;
  flex: 1;
  display: flex !important;
  flex-direction: column !important;
  gap: var(--sth-space-3);
}

/* ============================================================
   PRODUCT STATS (views + downloads)
   ============================================================ */
.product-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--sth-bg-elevated) !important;
  border: 1px solid var(--sth-border) !important;
  border-radius: var(--sth-radius-sm) !important;
  padding: 6px 12px !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  transition: border-color 0.2s ease !important;
}
.product-card:hover .product-stats {
  border-color: var(--sth-border-hover) !important;
  background: var(--sth-bg-elevated) !important;
  box-shadow: none !important;
}

/* Views badge */
.product-stats .badge {
  background: rgba(59, 130, 246, 0.15) !important;
  color: var(--sth-accent-blue) !important;
  border: 1px solid rgba(59, 130, 246, 0.25) !important;
  border-radius: var(--sth-radius-full) !important;
  padding: 3px 10px !important;
  font-size: var(--sth-text-xs) !important;
  font-weight: var(--sth-font-semibold) !important;
  box-shadow: none !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  width: fit-content !important;
  white-space: nowrap !important;
  line-height: 1.5 !important;
}
.product-stats .badge:hover {
  transform: none !important;
  box-shadow: none !important;
}
.product-stats .badge i {
  font-size: 12px !important;
  line-height: 1 !important;
  vertical-align: middle !important;
}

/* Download count */
.download-count {
  background: rgba(245, 158, 11, 0.12) !important;
  color: var(--sth-accent-gold) !important;
  border: 1px solid rgba(245, 158, 11, 0.25) !important;
  border-radius: var(--sth-radius-full) !important;
  padding: 3px 10px !important;
  font-size: var(--sth-text-xs) !important;
  font-weight: var(--sth-font-semibold) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  width: fit-content !important;
  white-space: nowrap !important;
  line-height: 1.5 !important;
}
.download-count:hover {
  transform: none !important;
  background: rgba(245, 158, 11, 0.15) !important;
}
.download-count .text-warning {
  color: var(--sth-accent-gold) !important;
  font-size: 12px !important;
  line-height: 1 !important;
  vertical-align: middle !important;
}
.download-count .text-warning i {
  font-size: 12px !important;
  line-height: 1 !important;
}

/* ============================================================
   CARD TITLE
   ============================================================ */
.product-card .card-title {
  font-size: var(--sth-text-base) !important;
  font-weight: var(--sth-font-semibold) !important;
  color: var(--sth-text-primary) !important;
  margin: 0 !important;
  line-height: var(--sth-lh-tight) !important;
  min-height: unset !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: 0;
}

.product-card .card-title a {
  color: inherit !important;
  text-decoration: none !important;
  transition: color 0.15s ease !important;
}

.product-card:hover .card-title a {
  color: var(--sth-accent-blue) !important;
  text-shadow: none !important;
}

/* ============================================================
   PRICE DISPLAY
   ============================================================ */
.price-display {
  text-align: center;
  padding: 10px var(--sth-space-3) !important;
  background: rgba(252, 211, 77, 0.06) !important;
  border: 1px solid rgba(252, 211, 77, 0.2) !important;
  border-radius: var(--sth-radius-sm) !important;
  min-height: unset !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  box-shadow: none !important;
  backdrop-filter: none !important;
  transition: border-color 0.2s ease !important;
}

.product-card:hover .price-display {
  border-color: rgba(252, 211, 77, 0.35) !important;
  background: rgba(252, 211, 77, 0.09) !important;
  box-shadow: none !important;
}

.price-display font {
  color: var(--sth-accent-price) !important;
  font-size: var(--sth-text-sm) !important;
  font-weight: var(--sth-font-semibold) !important;
  line-height: var(--sth-lh-normal) !important;
  text-shadow: none !important;
}

/* ============================================================
   CTA BUTTON
   ============================================================ */
.product-card .button,
.product-card a.button {
  display: block !important;
  width: 100% !important;
  padding: 10px var(--sth-space-4) !important;
  background: var(--sth-accent-cta) !important;
  color: #0F172A !important;
  text-align: center !important;
  text-decoration: none !important;
  border-radius: var(--sth-radius-sm) !important;
  font-size: var(--sth-text-sm) !important;
  font-weight: var(--sth-font-bold) !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  border: none !important;
  cursor: pointer !important;
  transition: filter 0.15s ease, transform 0.15s ease !important;
  box-shadow: 0 2px 12px rgba(34, 197, 94, 0.25) !important;
  margin-top: auto !important;
}

.product-card .button:hover,
.product-card a.button:hover {
  filter: brightness(1.1) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 18px rgba(34, 197, 94, 0.35) !important;
  color: #0F172A !important;
}

.product-card .button:active,
.product-card a.button:active {
  transform: translateY(0) !important;
  filter: brightness(0.96) !important;
}

/* Old button class override */
.product-card .btn-view-detail {
  all: unset;
  display: block !important;
  width: 100% !important;
  padding: 10px var(--sth-space-4) !important;
  background: var(--sth-accent-cta) !important;
  color: #0F172A !important;
  text-align: center !important;
  border-radius: var(--sth-radius-sm) !important;
  font-size: var(--sth-text-sm) !important;
  font-weight: var(--sth-font-bold) !important;
  cursor: pointer !important;
  transition: filter 0.15s ease !important;
  box-sizing: border-box !important;
}

/* ============================================================
   SKELETON LOADING STATE
   ============================================================ */
.product-card.sth-skeleton .product-image-container {
  background: var(--sth-bg-elevated);
  animation: sth-skeleton-pulse 1.5s ease infinite;
}
.product-card.sth-skeleton .card-title,
.product-card.sth-skeleton .price-display,
.product-card.sth-skeleton .product-stats {
  background: var(--sth-bg-elevated);
  color: transparent;
  border-radius: var(--sth-radius-sm);
  animation: sth-skeleton-pulse 1.5s ease infinite;
}

@keyframes sth-skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ============================================================
   RESPONSIVE TWEAKS
   ============================================================ */
@media (max-width: 768px) {
  .product-card .card-body {
    padding: var(--sth-space-3) !important;
    gap: var(--sth-space-2);
  }
  .product-card .card-title {
    font-size: var(--sth-text-sm) !important;
  }
  .price-display font {
    font-size: var(--sth-text-xs) !important;
  }
}
