/* كارت المنتج الموحّد لمنصة التسويق بالعمولة.
   يُحمَّل في كل صفحة تستدعي includes/affiliate_product_card.php.

   الأصناف المزدوجة (product-card + aff-card) مقصودة: الأولى يقرأها JS،
   والثانية تحمل الشكل. قواعد الأبناء بصيغة `.aff-card .aff-card__x`
   لتتغلّب على `.product-card .product-image` القادمة من main.css. */

/* ═══ كارت المنتج بمفردات المسوّق ═══════════════════════════════════════
   الأصناف المزدوجة (product-card + aff-card) مقصودة: الأولى يقرأها JS،
   والثانية تحمل الشكل الجديد. قواعد الأبناء مكتوبة بصيغة
   `.aff-card .aff-card__x` لتتغلّب على `.product-card .product-image`
   القادمة من main.css بنفس درجة التخصيص وترتيب لاحق.
   ══════════════════════════════════════════════════════════════════════ */

.aff-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  transition: var(--transition);
  height: auto;
}

.aff-card:hover {
  border-color: var(--primary-light);
  box-shadow: 0 10px 24px rgba(16, 40, 24, 0.09);
  transform: translateY(-3px);
}

.aff-card .aff-card__media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  background: var(--light-gray);
  overflow: hidden;
  border-radius: 0;
}

.aff-card .aff-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.aff-card .store-no-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  color: var(--dark-gray);
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--light-gray);
}

.aff-card .store-no-image__icon {
  font-size: 1.6rem;
  color: #9ca3af;
  opacity: 1;
}

.aff-card .store-no-image__caption {
  color: var(--dark-gray);
  font-weight: 700;
}

/* شارة المخزون — أهم إشارة للمسوّق قبل ما يقرر */
.aff-card__stock {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.6;
  background: #ffffff;
  border: 1px solid var(--border-color);
}

.aff-card__stock::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.aff-card__stock--ok {
  color: var(--primary-dark);
  border-color: var(--medium-gray);
}

.aff-card__stock--low {
  color: #b45309;
  border-color: #fde68a;
  background: #fffbeb;
}

.aff-card__stock--out {
  color: #6b7280;
  border-color: #e5e7eb;
  background: #f9fafb;
}

.aff-card--out .aff-card__media img {
  filter: grayscale(1);
  opacity: 0.55;
}

.aff-card .product-wishlist {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border-color);
  color: var(--dark-gray);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.aff-card .product-wishlist:hover,
.aff-card .product-wishlist.active {
  color: #ef4444;
  border-color: #fecaca;
}

.aff-card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 14px 12px;
  flex: 1 1 auto;
}

.aff-card__name {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.55;
  color: var(--text-color);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

.aff-card__pricing {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.aff-card__price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.aff-card__price-lbl {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--dark-gray);
  white-space: nowrap;
}

/* سعر المنصة هو الرقم البطل — ده اللي المسوّق هيدفعه */
.aff-card__price-row--mine .product-price {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.aff-card__price-row--mine .price {
  font-size: 1.08rem;
  font-weight: 900;
  /* main.css يفرض color:#f44336!important على .price — نتغلّب عليه هنا */
  color: var(--primary-color) !important;
  white-space: nowrap;
}

.aff-card__price-row--mine .price-old {
  font-size: 0.75rem;
  color: var(--dark-gray);
  text-decoration: line-through;
  opacity: 0.75;
}

.aff-card__price-val {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-color);
  white-space: nowrap;
}

.aff-card__profit {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary-dark);
  background: var(--light-gray);
  border-radius: 6px;
  padding: 2px 6px;
}

.aff-card__price-none {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--dark-gray);
  border-bottom: 1px dotted var(--dark-gray);
  cursor: help;
}

.aff-card__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}

.aff-card__cta {
  flex: 1 1 auto;
  text-align: center;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--light-gray);
  border: 1px solid var(--border-color);
  color: var(--primary-dark);
  font-size: 0.83rem;
  font-weight: 800;
  transition: var(--transition);
}

.aff-card:hover .aff-card__cta {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
}

.aff-card .add-to-cart-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--primary-color);
  background: var(--primary-color);
  color: #ffffff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.aff-card .add-to-cart-btn:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.aff-card .add-to-cart-btn.is-unavailable {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}
@media (max-width: 767px) {
  .aff-card__body {
    padding: 11px 11px 10px;
    gap: 7px;
  }

  .aff-card__name {
    font-size: 0.85rem;
  }

  .aff-card__price-row--mine .price {
    font-size: 1rem;
  }

  /* الصف الأفقي يضيق تحت 390px فيتقصّ «ج.م» — نرصّه رأسياً */
  .aff-card__price-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
  }

  .aff-card__price-val {
    flex-wrap: wrap;
  }
}
