/*! BARAH Complete v3.8 - CSS optimisé pour performance (CLS minimisé) */

/* --- أنماط البطاقات العامة --- */
.s-product-card {
  display: flex !important;
  flex-direction: column !important;
}
.s-product-card-content {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  order: 2 !important;
}
.s-product-card-title {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  visibility: visible !important;
  opacity: 1 !important;
  font-size: 12.5px !important;
  font-weight: 700 !important;
  color: #111 !important;
  text-align: center !important;
  line-height: 1.3 !important;
  min-height: 32px !important;
}

/* ============================================================
   أنماط الباندل الرئيسية (موحدة ومثبتة) - تم تعديل الحدود والمسافات
   ============================================================ */
.bundle-v4 {
  width: 100%;
  max-width: 1180px;
  padding-inline: 16px;
  margin: 32px auto;
  box-sizing: border-box;
  direction: rtl;
  font-family: sans-serif;
  contain: content;
  content-visibility: auto;
  contain-intrinsic-size: 420px auto;
}

.bundle-v4 .bundle-header {
  text-align: center;
  margin-bottom: 20px;
}
.bundle-v4 .bundle-title-main {
  font-size: clamp(18px, 3vw, 24px);
  font-weight: 900;
  color: #111;
}
.bundle-v4 .bundle-sub {
  font-size: clamp(13px, 1.8vw, 15px);
  color: #666;
  margin-top: 6px;
}

/* شبكة المنتجات - متساوية الارتفاع */
.bundle-v4 .bundle-products {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: stretch;
  
  /* [تم التعديل هنا] - المسافات وحدود الحاوية */
  gap: 12px; /* المسافة بين البطاقات */
  padding: 12px; /* المسافة الداخلية للحاوية */
  
  background: #f9f9f9;
  border-radius: 16px;
  border: 1px solid #e0e0e0;
  margin-bottom: 20px;
  contain: layout style;
}

/* بطاقة الباندل - مثبتة بالكامل */
.bundle-v4 .bundle-item {
  position: relative;
  background: #fff;
  
  /* [تم التعديل هنا] - شكل حواف البطاقة الداخلية */
  border: 1.5px solid #eaeaea; /* سماكة ولون الإطار */
  border-radius: 10px; /* درجة انحناء الزوايا */
  padding: 10px 8px 10px; /* المسافات الداخلية للبطاقة */
  
  text-align: center;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 240px;
  height: 100%;
  box-sizing: border-box;
  will-change: transform; /* تحسين الأداء */
}
.bundle-v4 .bundle-item.disabled { opacity: 0.4; pointer-events: none; }
.bundle-v4 .bundle-item.current-product { border-color: #d63031; background: #fff5f5; }

/* مربع الاختيار - جهة اليسار */
.bundle-v4 .bundle-check {
  position: absolute;
  top: 10px;
  left: 10px;
  right: auto;
  z-index: 2;
}
.bundle-v4 .check-box {
  width: 18px;
  height: 18px;
  accent-color: #d63031;
  cursor: pointer;
}

/* الصورة - مثبتة الحجم مع aspect-ratio لتجنب CLS */
.bundle-v4 .bundle-image {
  width: 90px;
  height: 90px;
  flex-shrink: 0;
  margin: 0 auto 6px; /* [تم التعديل هنا] - مسافة أقل قليلاً للتقريب */
  background: #f5f5f5;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  aspect-ratio: 1 / 1; /* لمنع تغير الأبعاد */
}
.bundle-v4 .bundle-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  aspect-ratio: 1 / 1; /* تطابق العنصر الأب */
}

/* العنوان - في المنتصف ومرن */
.bundle-v4 .bundle-title {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px; /* [تم التعديل هنا] - تقليل الارتفاع ليكون أجمل */
  padding: 0 4px;
  font-size: clamp(12px, 1.5vw, 14px);
  font-weight: 700;
  color: #222;
  line-height: 1.4;
  width: 100%;
  text-align: center;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* السعر - في الأسفل */
.bundle-v4 .bundle-price {
  margin-top: auto;
  padding-top: 8px;
  font-size: 17px;
  font-weight: 900;
  color: #d63031;
}

.bundle-v4 .bundle-plus { display: none; }

/* الملخص - شبكة */
.bundle-v4 .bundle-summary {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: #f8fdf8;
  border: 1.5px solid #e5f0e5;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
}
.bundle-v4 .bundle-summary .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #333;
}
.bundle-v4 .bundle-summary .row.total {
  border-top: 2px solid #ddd;
  padding-top: 12px;
  margin-top: 4px;
  font-size: 16px;
  color: #d63031;
}
.bundle-v4 .bundle-summary .sum-discount { color: #e84343; }
.bundle-v4 .bundle-summary .sum-final { font-weight: 900; color: #d63031; }

/* الأزرار */
.bundle-v4 .bundle-btns {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 10px;
}
.bundle-v4 .bundle-btn {
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  font-weight: 800;
  font-size: clamp(14px, 1.8vw, 16px);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bundle-v4 .btn-add {
  background: linear-gradient(135deg, #d63031, #e84343);
  color: #fff;
  box-shadow: 0 4px 12px rgba(214,48,49,0.2);
}
.bundle-v4 .btn-add:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(214,48,49,0.3); }
.bundle-v4 .btn-add:disabled { opacity: 0.6; cursor: not-allowed; }
.bundle-v4 .btn-select {
  background: #f5f5f5;
  color: #111;
  border: 1.5px solid #ddd;
}
.bundle-v4 .btn-select:hover { background: #efefef; border-color: #999; }

/* ============================================================
   أنماط مسار التنقل
   ============================================================ */
.breadcrumb, [class*="breadcrumb"], nav[aria-label*="breadcrumb"] { direction: rtl !important; text-align: right !important; }
.breadcrumb-separator { user-select: none; pointer-events: none; flex-shrink: 0; }
.auto-breadcrumb { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.auto-breadcrumb::-webkit-scrollbar { display: none; }
.auto-breadcrumb a { transition: all 0.2s ease; }
.auto-breadcrumb a:hover { color: #d63031; text-decoration: underline; background: rgba(0,102,204,0.05); }
.nav-active { color: #d63031 !important; font-weight: 700 !important; background: rgba(214,48,49,0.08) !important; }

/* خريطة المتجر */
#barah-store-map { min-height: 320px; }
#barah-store-map iframe { aspect-ratio: 16 / 9; }

/* أزرار المشاركة */
#barah-social-share { min-height: 50px; }

/* تحسينات الأداء العامة */
img { content-visibility: auto; }
.bundle-v4, .bundle-item { contain: content; }

/* ============================================================
   استجابة الشاشات (3 نقاط فقط)
   ============================================================ */

/* 1. الجوال (أقل من 768px) */
@media (max-width: 768px) {
  .bundle-v4 {
    padding-inline: 10px;
    margin: 20px auto;
    contain-intrinsic-size: 380px auto;
  }
  .bundle-v4 .bundle-products {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px; /* [تم التعديل هنا] - تقريب المسافات للجوال */
    padding: 8px;
  }
  .bundle-v4 .bundle-item {
    padding: 6px; /* [تم التعديل هنا] - تقليل الحواشي للجوال */
    min-height: 200px;
  }
  .bundle-v4 .bundle-image {
    width: 70px;
    height: 70px;
  }
  .bundle-v4 .bundle-title {
    font-size: 11px;
    min-height: 36px;
  }
  .bundle-v4 .bundle-price {
    font-size: 14px;
  }
  .bundle-v4 .bundle-title-main { font-size: 17px; }
  .bundle-v4 .bundle-sub { font-size: 12px; }
  .bundle-v4 .bundle-btns {
    grid-template-columns: 1fr;
  }
  .bundle-v4 .bundle-btn {
    min-height: 44px;
    font-size: 13px;
    padding: 10px;
  }
  .auto-breadcrumb {
    padding: 4px 8px;
    margin: 4px 0;
    font-size: 10px;
    gap: 2px;
  }
  .auto-breadcrumb a, .auto-breadcrumb span {
    font-size: 10px;
    max-width: 80px !important;
  }
  #barah-social-share { gap: 6px; }
  #barah-social-share a { font-size: 11px; padding: 4px 10px; }
  #barah-store-map { min-height: 280px; }
  #barah-store-map > div > div { grid-template-columns: 1fr !important; }
  #barah-store-map iframe { position: relative !important; height: 260px !important; aspect-ratio: auto; }
  .barah-page-btn {
    font-size: 12px;
    padding: 6px 10px;
    min-width: 32px;
    min-height: 32px;
  }
  .barah-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* 2. الأجهزة اللوحية (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .bundle-v4 .bundle-products {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px; /* [تم التعديل هنا] - مسافة متوسطة للتابلت */
  }
  .bundle-v4 .bundle-image {
    width: 85px;
    height: 85px;
  }
}

/* 3. الشاشات الكبيرة (أكبر من 1024px) */
@media (min-width: 1025px) {
  .bundle-v4 .bundle-products {
    grid-template-columns: repeat(5, 1fr);
    gap: 20px; /* [تم التعديل هنا] - مسافة أوسع للكمبيوتر */
  }
  .bundle-v4 .bundle-image {
    width: 90px;
    height: 90px;
  }
}

/* عناصر إضافية (الترقيم) */
.barah-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  flex-wrap: wrap;
  padding: 12px 0;
}
.barah-page-btn {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  transition: all 0.2s;
  min-height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.barah-page-btn:hover:not(:disabled) { background: #e9e9e9; border-color: #bbb; }
.barah-page-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.barah-page-btn.active { background: #d63031; color: #fff; border-color: #d63031; }
.barah-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}