/* =====================================================
   products.css — صفحة المنتجات
   حباش حمدي | Mobile-First | RTL
   تحديث 2026-06-30 (٦): الصورة والاسم أصبحا روابط لصفحة تفاصيل المنتج.
   .prod-card__img-wrap أصبح عنصر <a> بدل <div> — أضفنا display:block
   صراحة لأن الروابط افتراضيًا inline ولازم تتصرف كـ block لتحترم
   width/aspect-ratio المطلوبين. باقي الملف بدون تغيير جوهري.
   ===================================================== */

/* ─── Page Header ────────────────────────────────────── */
.products-page { padding: 1.5rem 0 4rem; }

.products-page-header {
  background: var(--color-brown);
  padding: 2rem 0;
  margin-bottom: 2rem;
}
.products-page-header .container {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.products-page-header h1 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--color-gold);
  line-height: 1.2;
}
.products-page-header p {
  font-size: var(--fs-base);
  color: rgba(255,255,255,.7);
  margin: 0;
}

/* ─── Products Count Bar ─────────────────────────────── */
.products-count-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  gap: .75rem;
}
.products-count-bar__text {
  font-size: var(--fs-sm);
  color: var(--color-muted);
}
.products-count-bar__text strong {
  color: var(--color-brown);
  font-weight: 700;
}
.products-go-cart {
  display: none;
  align-items: center;
  gap: .4rem;
  min-height: 40px;
  padding: 0 1rem;
  background: var(--color-golden);
  color: var(--color-brown);
  font-family: var(--font-main);
  font-size: var(--fs-sm);
  font-weight: 700;
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: background .15s ease, transform .15s ease;
  white-space: nowrap;
}
.products-go-cart.show { display: inline-flex; }
.products-go-cart:hover { background: var(--color-gold); color: var(--color-brown); }
.products-go-cart__badge {
  background: var(--color-brown);
  color: var(--color-gold);
  border-radius: var(--radius-full);
  font-size: .7rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ─── Products Grid — Mobile First: عمودين افتراضيًا ──
   الأساس (بدون media query) = عمودين، يغطي كل عروض الموبايل
   المطلوب اختبارها (360/375/390/430). من 600px نوسّع لثلاثة،
   ومن 1200px لأربعة على الديسكتوب. ───── */
.products-main-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
@media (min-width: 480px) {
  .products-main-grid { gap: 12px; }
}
@media (min-width: 600px) {
  .products-main-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; }
}
@media (min-width: 1200px) {
  .products-main-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ─── Product Card — مبسّط ليتناسب مع عمودين على الموبايل ── */
.prod-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  transition: box-shadow .2s ease, transform .2s ease;
}
@media (min-width: 600px) {
  .prod-card { border-radius: var(--radius-lg); }
}
.prod-card:hover {
  box-shadow: 0 10px 30px rgba(90,36,24,.14);
  transform: translateY(-3px);
}

/* صورة المنتج — الآن رابط <a> لصفحة تفاصيل المنتج، مربّعة 1:1 دائمًا.
   display:block ضروري هنا لأن <a> افتراضيًا inline ولازم يتصرف كـ block
   عشان width/aspect-ratio يشتغلوا صح. object-fit:cover يمنع أي تمدد. */
.prod-card__img-wrap {
  display: block;
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: linear-gradient(135deg, var(--color-bg), #EDE0C4);
  width: 100%;
  text-decoration: none;
}
.prod-card__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform .35s ease;
}
.prod-card:hover .prod-card__img-wrap img {
  transform: scale(1.045);
}
/* Placeholder — أيقونة صغيرة وسط الصندوق، وليس فراغًا فاضيًا ضخمًا */
.prod-card__img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  color: var(--color-gold);
}
.prod-card__img-placeholder svg { width: 26px; height: 26px; opacity: .7; }
.prod-card__img-placeholder-label {
  font-size: .62rem;
  font-weight: 600;
  color: var(--color-muted);
  text-align: center;
}
@media (min-width: 480px) {
  .prod-card__img-placeholder svg { width: 34px; height: 34px; }
  .prod-card__img-placeholder-label { font-size: .68rem; }
}

/* Badge نوع البيع — أعلى يمين الصورة، أصغر شوية على الموبايل الضيق */
.prod-card__type-badge {
  position: absolute;
  top: 7px;
  right: 7px;
  font-size: .6rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
}
@media (min-width: 480px) {
  .prod-card__type-badge { top: 10px; right: 10px; font-size: .68rem; padding: 5px 11px; }
}
.prod-card__type-badge--weight  { background: var(--color-brown);  color: var(--color-gold); }
.prod-card__type-badge--package { background: var(--color-red);    color: #fff; }
.prod-card__type-badge--both    { background: var(--color-golden); color: #fff; }

/* Badge خصم المنتج — أعلى يسار الصورة (الجهة المقابلة لبادج نوع البيع)،
   أحمر دافئ شيك وليس صارخًا، يظهر فقط عندما يكون الخصم فعّالًا فعليًا
   الآن (isProductDiscountActive يحدد ذلك في PHP، لا شيء وهمي هنا). */
.prod-card__discount-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  font-size: .6rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  line-height: 1.3;
  white-space: nowrap;
  background: var(--color-red, #C62828);
  color: #fff;
  box-shadow: 0 3px 10px rgba(198,40,40,.35);
  z-index: 1;
}
@media (min-width: 480px) {
  .prod-card__discount-badge { top: 10px; left: 10px; font-size: .68rem; padding: 5px 12px; }
}

/* جسم الكارت — حشو مضغوط على الموبايل */
.prod-card__body {
  padding: .6rem .6rem .65rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: .4rem;
  width: 100%;
  box-sizing: border-box;
}
@media (min-width: 480px) {
  .prod-card__body { padding: .8rem .85rem .85rem; gap: .5rem; }
}
@media (min-width: 600px) {
  .prod-card__body { padding: 1.1rem 1.15rem 1.15rem; gap: .6rem; }
}

/* صف الاسم + السعر — عمودي على الموبايل الضيق جدًا (اسم فوق، سعر تحت)
   عشان الاسم ياخد عرضه كامل بدل ما يتزاحم مع السعر في عمود ضيق */
.prod-card__head-row {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  width: 100%;
}
@media (min-width: 600px) {
  .prod-card__head-row {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: .6rem;
  }
}

.prod-card__name {
  font-size: .82rem;
  font-weight: 700;
  color: var(--color-brown);
  line-height: 1.3;
  margin: 0;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (min-width: 480px) {
  .prod-card__name { font-size: .92rem; }
}
@media (min-width: 600px) {
  .prod-card__name { font-size: var(--fs-md); -webkit-line-clamp: 1; flex: 1; }
}
/* الاسم أصبح رابطًا — نفس لون النص، بدون تسطير، بس underline خفيف عند hover
   للدلالة على إنه قابل للضغط بدون ما يكسر الشكل النظيف الحالي */
.prod-card__name a {
  color: inherit;
  text-decoration: none;
}
.prod-card__name a:hover { text-decoration: underline; }

.prod-card__price-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .3rem;
  line-height: 1;
}
@media (min-width: 600px) {
  .prod-card__price-line { flex-direction: column; align-items: flex-end; flex-shrink: 0; white-space: nowrap; }
}

/* السعر القديم — صغير ومشطوب، يظهر فقط لما الخصم فعّال */
.prod-card__price-old {
  font-size: .68rem;
  font-weight: 600;
  color: var(--color-muted);
  text-decoration: line-through;
  text-decoration-color: var(--color-red, #C62828);
  line-height: 1;
}
@media (min-width: 480px) {
  .prod-card__price-old { font-size: .78rem; }
}
@media (min-width: 600px) {
  .prod-card__price-old { order: -1; }
}

.prod-card__price-amount {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-golden);
  line-height: 1;
}
@media (min-width: 480px) {
  .prod-card__price-amount { font-size: var(--fs-lg); }
}
@media (min-width: 600px) {
  .prod-card__price-amount { font-size: 1.4rem; }
}
/* لو فيه خصم فعّال، السعر الجديد يبان بلون أحمر دافئ بدل الذهبي المعتاد،
   عشان يلفت الانتباه للتخفيض بشكل شيك وواضح. تم استخدام class صريح
   مضافة من PHP (مش :has()) لضمان دعم كامل في كل المتصفحات دون استثناء. */
.prod-card__price-line--discounted .prod-card__price-amount {
  color: var(--color-red, #C62828);
}

.prod-card__price-unit {
  font-size: .62rem;
  color: var(--color-muted);
}
@media (min-width: 600px) {
  .prod-card__price-unit { font-size: .66rem; margin-top: 3px; }
}

/* وصف مختصر — مخفي بالكامل على الموبايل (عمودين) لتقصير الكارت،
   يظهر فقط من 600px فأكثر حيث المساحة تسمح */
.prod-card__desc { display: none; }
@media (min-width: 600px) {
  .prod-card__desc {
    display: -webkit-box;
    font-size: var(--fs-sm);
    color: var(--color-muted);
    line-height: 1.6;
    margin: 0;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* ─── اختيار الكمية / العبوة — Select واحد، مضغوط على الموبايل ── */
.prod-card__selector { width: 100%; }
.prod-card__selector-label {
  font-size: .64rem;
  font-weight: 700;
  color: var(--color-brown);
  margin-bottom: .3rem;
  display: block;
}
@media (min-width: 480px) {
  .prod-card__selector-label { font-size: .74rem; margin-bottom: .4rem; }
}

.prod-select-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.prod-variant-select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-height: 40px;
  padding: 0 .6rem 0 1.9rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface, #FBF4E8);
  background-image: none;
  font-family: var(--font-main);
  font-size: .74rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  text-overflow: ellipsis;
}
@media (min-width: 480px) {
  .prod-variant-select {
    min-height: 44px;
    padding: 0 .85rem 0 2.4rem;
    border-radius: var(--radius-md);
    font-size: .84rem;
  }
}
@media (min-width: 600px) {
  .prod-variant-select { min-height: 46px; padding: 0 1rem 0 2.6rem; font-size: .88rem; }
}
.prod-variant-select::-ms-expand { display: none; }
.prod-variant-select:hover { border-color: var(--color-golden); }
.prod-variant-select:focus {
  outline: none;
  border-color: var(--color-golden);
  background: var(--color-white);
  box-shadow: 0 0 0 3px rgba(232,154,45,.15);
}
.prod-variant-select option {
  font-family: var(--font-main);
  font-size: 1rem;
  padding: 10px;
  color: var(--color-text);
  background: var(--color-white);
}
.prod-variant-select optgroup {
  font-weight: 700;
  color: var(--color-brown);
  font-style: normal;
}

.prod-select-arrow {
  position: absolute;
  top: 50%;
  left: .6rem;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  color: var(--color-golden);
  pointer-events: none;
  transition: color .15s ease;
}
@media (min-width: 480px) {
  .prod-select-arrow { left: .9rem; width: 16px; height: 16px; }
}
.prod-variant-select:focus ~ .prod-select-arrow { color: var(--color-brown); }

/* حقل الوزن المخصص */
.prod-custom-weight {
  display: none;
  align-items: center;
  gap: .35rem;
  margin-top: .4rem;
  flex-wrap: wrap;
  width: 100%;
}
.prod-custom-weight.show { display: flex; }
.prod-custom-weight__input {
  width: 76px;
  padding: 5px 7px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: .78rem;
  direction: ltr;
  min-height: 36px;
  box-sizing: border-box;
}
@media (min-width: 480px) {
  .prod-custom-weight__input { width: 88px; font-size: var(--fs-sm); min-height: 40px; border-radius: var(--radius-md); }
}
.prod-custom-weight__input:focus {
  outline: none;
  border-color: var(--color-golden);
  box-shadow: 0 0 0 3px rgba(232,154,45,.12);
}
.prod-custom-weight__label {
  font-size: .62rem;
  color: var(--color-muted);
  white-space: nowrap;
}
@media (min-width: 480px) {
  .prod-custom-weight__label { font-size: .7rem; }
}

/* ─── زر أضف للسلة — نص مختصر "أضف" على الموبايل، كامل من 600px ── */
.prod-card__add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .3rem;
  width: 100%;
  max-width: 100%;
  min-height: 40px;
  background: var(--grad-golden, linear-gradient(135deg, #E89A2D 0%, #D8821A 100%));
  color: #fff;
  font-family: var(--font-main);
  font-size: .76rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  margin-top: auto;
  padding: 0 .6rem;
  box-sizing: border-box;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  box-shadow: 0 4px 12px rgba(208,126,27,.3);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
@media (min-width: 480px) {
  .prod-card__add-btn { min-height: 44px; font-size: .85rem; padding: 0 .9rem; gap: .4rem; }
}
@media (min-width: 600px) {
  .prod-card__add-btn { min-height: 48px; font-size: var(--fs-base); padding: 0 1rem; gap: .45rem; box-shadow: 0 5px 16px rgba(208,126,27,.32); }
}
.prod-card__add-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 20px rgba(208,126,27,.4);
}
.prod-card__add-btn:active { transform: scale(.97); }
.prod-card__add-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  pointer-events: none;
}
.prod-card__add-btn.is-added {
  background: #22C55E;
  box-shadow: 0 4px 12px rgba(34,197,94,.3);
}
.prod-card__add-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
@media (min-width: 480px) {
  .prod-card__add-btn svg { width: 17px; height: 17px; }
}
.prod-card__add-btn-label { flex-shrink: 0; white-space: nowrap; }

/* النص الكامل/المختصر — تبديل عبر CSS فقط، بدون أي تعديل JS */
.prod-card__add-btn-label .lbl-full { display: none; }
.prod-card__add-btn-label .lbl-short { display: inline; }
@media (min-width: 600px) {
  .prod-card__add-btn-label .lbl-full { display: inline; }
  .prod-card__add-btn-label .lbl-short { display: none; }
}

.prod-card__line-total {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: .95;
  font-size: .72rem;
}
@media (min-width: 480px) {
  .prod-card__line-total { font-size: inherit; }
}
.prod-card__line-total.is-hidden { display: none; }

/* ─── Empty State ────────────────────────────────────── */
.products-empty {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--color-muted);
}
.products-empty svg { width: 64px; height: 64px; opacity: .3; margin: 0 auto 1rem; }
.products-empty h2 { color: var(--color-brown); margin-bottom: .5rem; }

/* ─── Bottom CTA ─────────────────────────────────────── */
.products-bottom-cta {
  margin-top: 2.5rem;
  text-align: center;
}
.products-bottom-cta p {
  font-size: var(--fs-sm);
  color: var(--color-muted);
  margin-bottom: 1rem;
}
@media (min-width: 600px) {
  .products-bottom-cta { margin-top: 3rem; }
  .products-bottom-cta p { font-size: var(--fs-base); }
}

/* ─── Toast Cart Notification ────────────────────────── */
.prod-added-toast {
  position: fixed;
  bottom: calc(var(--sticky-bar-h, 70px) + 12px);
  right: 1rem;
  left: 1rem;
  background: var(--color-brown);
  color: var(--color-gold);
  border-radius: var(--radius-lg);
  padding: .9rem 1.25rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  font-family: var(--font-main);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.2);
  direction: rtl;
  transform: translateY(20px);
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
  pointer-events: none;
  box-sizing: border-box;
  max-width: calc(100% - 2rem);
}
.prod-added-toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.prod-added-toast__name { flex: 1; color: rgba(255,255,255,.9); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-added-toast__price { color: var(--color-golden); font-weight: 700; flex-shrink: 0; }
.prod-added-toast__btn {
  background: var(--color-golden);
  color: var(--color-brown);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-main);
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  flex-shrink: 0;
  transition: background .15s ease;
}
.prod-added-toast__btn:hover { background: var(--color-gold); color: var(--color-brown); }

@media (min-width: 768px) {
  .prod-added-toast {
    right: 2rem;
    left: auto;
    max-width: 340px;
    bottom: 2rem;
  }
}

/* ─── ضمان صارم: صفر Scroll أفقي على أي مقاس ─────────── */
.products-page,
.products-page-header,
.products-main-grid,
.prod-card {
  max-width: 100%;
}
