/* =========================
   الصور العامة
   ========================= */
img {
  max-width: 100%;   /* ما تتجاوز عرض الحاوية */
  height: auto;      /* تحافظ على التناسب */
  display: block;    /* يمنع الفراغ أسفل الصورة */
}

/* تطبيق تحسينات CLS فقط على صور المحتوى */
.page-content img,
.product-entry img,
.s-product-card img,
.product-gallery img,
.item-categories-image img,
.swiper-slide img:not(header img):not(.header img):not(.logo img) {
  min-height: 120px; /* حجز مساحة أولية لمنع CLS */
  background: #f5f5f5; /* خلفية أثناء التحميل */
}

/* حالة التحميل للصور */
.page-content img[loading="lazy"],
.product-entry img[loading="lazy"],
.s-product-card img[loading="lazy"] {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* إزالة الأنيميشن بعد التحميل */
.page-content img[loading="lazy"]:not([src=""]),
.product-entry img[loading="lazy"]:not([src=""]),
.s-product-card img[loading="lazy"]:not([src=""]) {
  animation: none;
  background: #f5f5f5;
}

/* =========================
   استثناء الهيدر والشعار والعناصر المهمة
   ========================= */
header img,
.header img,
.navbar img,
.logo img,
.brand img,
.site-logo img,
.header-logo img,
.navbar-brand img,
nav img,
.nav img,
.navigation img,
.user-avatar img,
.profile-image img,
.icon img,
.btn img,
button img {
  min-height: auto !important;
  background: transparent !important;
  height: auto !important;
  max-height: none !important;
  animation: none !important;
}

/* =========================
   كرت المنتج (Product Card)
   ========================= */
.product-entry {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 6px;
  overflow: hidden; /* يخفي أي جزء خارج حدود الكرت */
  min-height: 300px; /* حجز مساحة ثابتة لمنع CLS */
  display: flex;
  flex-direction: column;
}

/* شكل عام للمنتج */
.product-entry,
.s-product-card {
  border: 1px solid #ddd;
  border-radius: 6px;
  box-sizing: border-box; /* يحسب البوردر والبيدنق مع الحجم */
  min-height: 300px; /* حجز مساحة ثابتة */
  display: flex;
  flex-direction: column;
}

/* حجز مساحة للعنوان */
.product-entry .product-title,
.s-product-card .product-title {
  min-height: 2.5em; /* حجز مساحة للعنوان */
  line-height: 1.2;
}

/* حجز مساحة للسعر */
.product-entry .product-price,
.s-product-card .product-price {
  min-height: 1.5em;
}

/* صور المنتج في الكروت */
.product-entry img,
.s-product-card img {
  min-height: 200px;
  background: #f5f5f5;
  object-fit: cover;
}

/* =========================
   حاوية الفيديو (Responsive Video)
   ========================= */
.video-container {
  position: relative;
  padding-bottom: 56.25%; /* نسبة 16:9 */
  height: 0;
  overflow: hidden;
  max-width: 100%;
  margin: 20px 0;
}

.video-container iframe {
  position: absolute;
  inset: 0;        /* يملأ الحاوية */
  width: 100%;
  height: 100%;
}

/* =========================
   العناوين في الصفحات الداخلية
   ========================= */
.page-title {
  font-weight: bold;
  font-size: 22px;
  color: #222;
  margin-bottom: 15px;
  text-align: center;
  min-height: 1.5em; /* حجز مساحة للعنوان */
}

/* =========================
   المحتوى داخل الصفحات (مقالات / وصف)
   ========================= */
.page-content {
  padding: 15px;
  font-size: 15px;
  line-height: 1.6;
  color: #444;
  min-height: 200px; /* حجز مساحة للمحتوى */
}

/* الجداول داخل المحتوى */
.page-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  font-size: 14px;
}

.page-content table th,
.page-content table td {
  border: 1px solid #ccc;
  padding: 6px;
  text-align: left;
  min-height: 2em; /* حجز مساحة للخلايا */
}

.page-content table th {
  background: #f8f8f8;
  font-weight: bold;
}

/* =========================
   ميديا كويري للشاشات الصغيرة
   ========================= */
@media (max-width:768px) {
  .page-title {
    font-size: 20px;
    min-height: 1.3em;
  }
  .page-content {
    font-size: 14px;
    padding: 15px;
    min-height: 150px;
  }
  
  .product-entry,
  .s-product-card {
    min-height: 250px; /* تقليل الارتفاع للجوال */
  }
  
  .product-entry img,
  .s-product-card img {
    min-height: 150px; /* تقليل ارتفاع الصور للجوال */
  }
}

/* =========================
   ميديا كويري للشاشات الكبيرة (فيديو في تبويب)
   ========================= */
@media (min-width:1201px) {
  #accordion-tabs iframe.ql-video {
    width: 800px;
    height: 450px;
  }
}

/* =========================
   ألوان الخلفية داخل السلايدر
   ========================= */
.swiper-slide .product-entry,
.swiper-slide .product-entry__image,
.swiper-slide .s-product-card-fit-height,
.swiper-slide .s-product-card-image {
  background-color: #fff !important;
}

/* حجز مساحة للسلايدات - فقط للمحتوى */
.swiper-slide:has(.product-entry),
.swiper-slide:has(.s-product-card) {
  min-height: 300px; /* حجز مساحة ثابتة */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================
   Accordion (خيارات المنتج)
   ========================= */
.accordion.details-accordion .accordion-title {
  font-size: 16px;
  font-weight: 500;
  color: #222;
  min-height: 2em; /* حجز مساحة للعنوان */
}

/* إخفاء النص الأصلي واستبداله */
.accordion.details-accordion .accordion-title {
  color: transparent !important;
  position: relative;
  min-height: 2em; /* حجز مساحة ثابتة */
}

.accordion.details-accordion .accordion-title::before {
  content: "خيارات المنتج"; /* النص البديل */
  position: absolute;
  inset-inline-start: 0;
  color: #222;
  visibility: visible;
  width: 100%; /* يأخذ العرض الكامل */
  height: 100%; /* يأخذ الارتفاع الكامل */
  display: flex;
  align-items: center;
  min-height: inherit;
}

/* =========================
   صور المنتج داخل المعرض (Gallery)
   ========================= */
.product-gallery .swiper-slide {
  min-height: 480px; /* حجز مساحة ثابتة للجاليري */
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5; /* خلفية أثناء التحميل */
}

.product-gallery .swiper-slide img,
.product-gallery .swiper-slide picture img {
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 480px;
  min-height: 300px; /* حد أدنى للارتفاع */
  object-fit: contain !important;
  margin: 0 auto;
  background: #fff;
}

/* صور المنتج في الجوال */
@media (max-width:768px) {
  .product-gallery .swiper-slide {
    min-height: 320px; /* تقليل الارتفاع للجوال */
  }
  
  .product-gallery .swiper-slide img,
  .product-gallery .swiper-slide picture img {
    max-height: 320px;
    min-height: 200px; /* تقليل الحد الأدنى للجوال */
  }
}

/* =========================
   أقسام التصنيفات (Categories)
   ========================= */
.s-categories .swiper-slide,
.categories .swiper-slide,
.home-categories .swiper-slide {
  min-height: 140px; /* حجز مساحة ثابتة للتصنيفات */
}

.s-categories .swiper-slide a.item-categories-image.card-effect.rounded,
.categories .swiper-slide a.item-categories-image.card-effect.rounded,
.home-categories .swiper-slide a.item-categories-image.card-effect.rounded {
  display: block !important;
  border: 1px solid #ddd !important;
  border-radius: 8px !important;
  background: #fff !important;
  padding: 10px !important;
  box-sizing: border-box !important;
  overflow: hidden;
  text-align: center !important;
  min-height: 120px; /* حجز مساحة ثابتة */
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
}

.s-categories .swiper-slide a.item-categories-image.card-effect.rounded .card-border,
.categories .swiper-slide a.item-categories-image.card-effect.rounded .card-border,
.home-categories .swiper-slide a.item-categories-image.card-effect.rounded .card-border {
  border: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}

/* صور التصنيفات */
.item-categories-image img {
  min-height: 60px;
  background: #f5f5f5;
}

/* =========================
   صناديق التصنيفات (موديفير)
   ========================= */
.s-block--categories .swiper-slide.itme-categories,
.categories-five .swiper-slide.itme-categories,
.s-categories .swiper-slide.itme-categories {
  border: 1px solid #ddd !important;
  border-radius: 10px !important;
  background: #fff !important;
  padding: 10px !important;
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  overflow: hidden !important;
  min-height: 140px !important; /* حجز مساحة ثابتة */
  justify-content: center !important;
}

.s-block--categories .swiper-slide.itme-categories a.item-categories-image,
.categories-five .swiper-slide.itme-categories a.item-categories-image,
.s-categories .swiper-slide.itme-categories a.item-categories-image {
  display: block !important;
  border-radius: inherit !important;
  min-height: 80px; /* حجز مساحة للصورة */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.s-block--categories .swiper-slide.itme-categories .card-border,
.categories-five .swiper-slide.itme-categories .card-border,
.s-categories .swiper-slide.itme-categories .card-border {
  border: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}

/* عنوان التصنيف */
.item-categories-title {
  min-height: 1.5em; /* حجز مساحة للعنوان */
  line-height: 1.2;
}

/* =========================
   تحسينات إضافية لمنع CLS
   ========================= */

/* حاوية المنتجات الرئيسية */
.products-grid,
.products-list {
  min-height: 400px; /* حجز مساحة للشبكة */
}

/* Loading Skeleton للمحتوى المتأخر */
.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 4px;
}

/* منع Layout Shift في النصوص */
h1, h2, h3, h4, h5, h6 {
  min-height: 1em;
}

p {
  min-height: 1.2em;
}

/* حاوية الأزرار */
.btn, button {
  min-height: 2.5em;
  min-width: 80px;
}

/* منع CLS في القوائم */
ul, ol {
  min-height: 1.5em;
}