/* ==========================================================================
   product-card.css — بطاقة المنتج (Product card)
   شركة السرعة المطلقة | كل القيم من tokens.css — RTL.
   WC-NOTE: content-product.php + woocommerce_template_loop_* + إضافة للسلة AJAX
   ========================================================================== */

/* position: relative ضروري لتثبيت .badge--promo (Batch 1) ورفّ الإجراءات */
.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.product-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(calc(-1 * var(--space-4)));
}

/* رفّ الإجراءات عند التحويم (Hover actions) — مفضلة / عرض سريع / مقارنة
   مخفي افتراضيًا، يظهر عند hover أو focus-within (وصول بلوحة المفاتيح) */
.product-card__actions {
  position: absolute;
  inset-block-start: var(--space-12);
  inset-inline-end: var(--space-12);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  opacity: 0;
  visibility: hidden;
  transform: translateY(calc(-1 * var(--space-8)));
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.product-card:hover .product-card__actions,
.product-card:focus-within .product-card__actions {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* الوسائط (Media) */
.product-card__media {
  position: relative;
  padding: var(--space-16);
  background-color: var(--color-surface);
}

.product-card__media img {
  margin-inline: auto;
}

/* العلامة التجارية (Brand logo) */
.product-card__brand {
  height: 30px;
  margin-bottom: var(--space-8);
}

.product-card__brand img {
  height: 100%;
  width: auto;
  display: block;
}

/* الجسم (Body) */
.product-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  padding: var(--space-16);
}

.product-card__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--color-text);
}

.product-card__model {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
}

/* سطر السعر (Price line) */
.product-card__price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-8);
}

.product-card__price-new {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--color-text);
}

.product-card__price-old {
  font-size: var(--fs-base);
  color: var(--color-text-muted);
  text-decoration: line-through;
}

.product-card__price-unit {
  font-size: var(--fs-2xs);
  color: var(--color-text-muted);
}

/* إجمالي السعر لـ 4 إطارات */
.product-card__total {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  text-align: end;
  padding-inline: var(--space-16);
}

.product-card__total strong {
  color: var(--color-primary);
  font-weight: var(--fw-bold);
}

/* شارات الدفع (tabby / tamara) */
.product-card__payment {
  display: flex;
  gap: var(--space-8);
  align-items: center;
  padding-inline: var(--space-16);
  padding-block-start: var(--space-4);
}

.payment-badge {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-10);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-black);
  color: var(--color-text);
}

/* صف الكمية */
.product-card__qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: var(--space-16);
  padding-block-start: var(--space-8);
}

.qty-label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

/* عدّاد الكمية داخل البطاقة */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.qty-stepper__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--space-32);
  height: var(--space-32);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
  padding: 0;
}

.qty-stepper__btn:hover {
  background-color: var(--color-bg-alt);
}

.qty-stepper__value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--space-40);
  height: var(--space-32);
  text-align: center;
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  color: var(--color-text);
}

/* صف زرّي الإجراء (2 أزرار) */
.product-card__cta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
}

/* التذييل (Footer) — أضف إلى السلة */
.product-card__footer {
  padding: var(--space-16);
  padding-block-start: var(--space-8);
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

/* نفد من المخزون (Out of stock) */
.product-card--out {
  opacity: 0.6;
}

.product-card--out .product-card__media {
  filter: grayscale(1);
}

/* ==========================================================================
   بطاقة "أفضل الاختيارات للطريق" — نسخة تفصيلية مطابقة لفيجما (الصفحة الرئيسية)
   تُبقي البطاقة الأساسية كما هي (تُستخدم في صفحة التصنيف) وتضيف فوقها فقط.
   ========================================================================== */
.product-card--detailed {
  border-radius: var(--radius-md);
  /* ponytail: ظل فيجما الدقيق؛ لا نغمة مطابقة في tokens */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* الوسائط: الشعار أعلى اليمين والصورة موسّطة */
.product-card--detailed .product-card__media {
  min-height: 232px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-card__logo {
  position: absolute;
  inset-block-start: var(--space-16);
  inset-inline-start: var(--space-16);
  /* start = يمين في RTL */
  height: var(--space-24);
  width: auto;
  object-fit: contain;
}

.product-card__image {
  max-width: 70%;
  height: auto;
}

/* شارة العرض إلى اليسار (start=يمين، لذا end=يسار)، فوق الوسائط */
.product-card--detailed .badge--promo {
  inset-inline: auto 0;
  inset-block-start: 0;
  z-index: 2;
  background-color: var(--color-gradient-end);
  font-weight: var(--fw-medium);
  /* تدوير الحافة الداخلية فقط؛ حافة البطاقة تقصّ الزاوية الخارجية */
  /* border-radius: 0; */
  border-radius: 4px !important;
  padding: 8px;
  /* border-end-start-radius: var(--radius-md); */
}

/* الجسم محاذى لليمين */
.product-card--detailed .product-card__body {
  align-items: flex-start;
  /* flex-start = يمين في RTL */
}

/* شريحة المقاس */
.product-card__size {
  padding: var(--space-4) var(--space-12);
  background-color: var(--color-bg-alt);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  letter-spacing: 0.03em;
}

/* شريط السعر: صندوق التوفير (يسار) + السعر (يمين) */
.product-card__pricebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  width: 100%;
  padding-block-start: var(--space-8);
}

.product-card__save {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-8) var(--space-16);
  background-color: color-mix(in srgb, var(--color-success) 10%, transparent);
  border: var(--border-width) solid color-mix(in srgb, var(--color-success) 20%, transparent);
  border-radius: var(--radius-md);
  color: var(--color-success);
  line-height: 1.15;
  white-space: nowrap;
}

.product-card__save strong {
  font-size: var(--fs-md);
  font-weight: var(--fw-black);
}

.product-card__save span {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
}

/* السعر الرئيسي (يمين) */
.product-card--detailed .product-card__price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

.product-card--detailed .product-card__price-unit {
  font-size: var(--fs-2xs);
  color: var(--color-text-muted);
  align-self: normal;
}

.product-card--detailed .product-card__price-new {
  font-size: var(--fs-4xl);
  font-weight: var(--fw-black);
  color: var(--color-price);
  line-height: 1;
}

.product-card--detailed .product-card__price-new small {
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
}

.product-card--detailed .product-card__price-old {
  font-size: var(--fs-2xs);
  color: var(--color-border-strong);
  text-decoration: line-through;
}

/* صندوق الإجمالي */
.product-card--detailed .product-card__total {
  margin-inline: var(--space-16);
  margin-block-end: var(--space-16);
  padding: var(--space-16);
  background-color: var(--color-bg-alt);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  text-align: start;
}

.product-card__total-row {
  display: flex;
  flex-direction: row-reverse;
  /* التسمية يسارًا والقيمة يمينًا (مطابقة لفيجما) */
  align-items: center;
  justify-content: space-between;
}

.product-card__total-label {
  font-size: var(--fs-2xs);
  color: var(--color-text-muted);
}

.product-card__total-values {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
}

.product-card__total-value {
  font-size: var(--fs-lg);
  font-weight: var(--fw-black);
  color: var(--color-dark);
}

.product-card__total-value small {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
}

.product-card__total-value--old {
  font-size: var(--fs-2xs);
  color: var(--color-text-muted);
  text-decoration: line-through;
}

.product-card__total-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-start: var(--space-12);
  padding-block-start: var(--space-12);
  border-block-start: var(--border-width) solid var(--color-border);
}

.product-card__per {
  font-size: var(--fs-xs);
  font-weight: var(--fw-black);
  color: var(--color-price);
}

.product-card__per small {
  font-weight: var(--fw-bold);
  color: var(--color-text-muted);
}

.product-card__pay {
  display: flex;
  gap: var(--space-8);
  align-items: center;
}

.product-card__pay-logo {
  height: var(--space-16);
  width: auto;
  object-fit: contain;
}

/* التذييل: صف الكمية ثم زرّان متراصّان بعرض كامل */
.product-card--detailed .product-card__footer {
  gap: var(--space-12);
}

.product-card--detailed .product-card__qty-row {
  padding-inline: 0;
  padding-block-start: 0;
}

.product-card--detailed .qty-stepper {
  border-radius: var(--radius-sm);
  flex-direction: row-reverse;
  /* − يسارًا و + يمينًا (مطابقة لفيجما) */
}

.product-card--detailed .qty-stepper__btn {
  width: var(--space-40);
  height: var(--space-40);
}

.product-card--detailed .qty-stepper__value {
  height: var(--space-40);
  border-inline: var(--border-width) solid var(--color-border);
}

.product-card--detailed .product-card__footer .btn {
  width: 100%;
  border-radius: var(--radius-sm);
  font-weight: var(--fw-extrabold);
  box-shadow: var(--shadow-cta);
}

.product-card--detailed .product-card__add {
  background-color: var(--color-gradient-end);
}

.product-card--detailed .product-card__add:hover {
  background-color: var(--color-primary-darkest);
}

.product-card--detailed .product-card__footer .btn svg {
  flex-shrink: 0;
}