/* ═══════════════════════════════════════════════════════
   NewsPulse Pro v6 — إصلاحات شاملة + سايدبار الرئيسية
   ═══════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────
   1. إصلاح السلايدر — منع تداخل الصور
   ───────────────────────────────────────────────────── */
.np-hero-wrap {
  position: relative;
  z-index: 1;
  margin-bottom: 32px;
  border-radius: var(--np-r-xl);
  overflow: hidden;
  box-shadow: var(--np-shadow-l);
  /* تأكيد عدم التجاوز */
  contain: layout paint;
}

.np-hero-swiper {
  overflow: hidden !important;
  border-radius: inherit;
}

.swiper-wrapper {
  display: flex;
  will-change: transform;
}

.np-hero-slide {
  position: relative;
  width: 100%;
  height: 520px;
  overflow: hidden;
  flex-shrink: 0;
}

.np-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  /* منع الصور من الخروج */
  max-width: none;
}

/* إصلاح تداخل السلايدر مع بقية المحتوى */
.np-sec-hero {
  position: relative;
  z-index: 1;
  overflow: hidden !important;
  margin-bottom: 0 !important;
}

/* ─────────────────────────────────────────────────────
   2. تخطيط الصفحة الرئيسية — محتوى + سايدبار
   ───────────────────────────────────────────────────── */
.np-home-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 28px;
  align-items: start;
}

.np-home-main {
  min-width: 0;
  /* منع المحتوى من تجاوز العمود */
  overflow: hidden;
}

.np-home-sidebar {
  position: sticky;
  top: calc(var(--np-hh) + 16px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─────────────────────────────────────────────────────
   3. ويدجت "اخترنا لكم" 
   ───────────────────────────────────────────────────── */
.np-widget-picks {
  background: var(--np-surface);
  border-radius: var(--np-r-l);
  overflow: hidden;
  box-shadow: var(--np-shadow-card);
  border: 1px solid var(--np-border);
}

.np-widget-picks .np-widget-title {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%) !important;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-family: var(--np-font-head);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .3px;
  border-bottom: 2px solid var(--np-gold);
}

.np-widget-picks .np-widget-title .np-picks-star {
  color: var(--np-gold);
  font-size: 16px;
}

.np-picks-list {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}

.np-picks-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--np-border);
  transition: background var(--np-ease-s);
  text-decoration: none;
}

.np-picks-item:last-child {
  border-bottom: none;
}

.np-picks-item:hover {
  background: rgba(211,47,47,.04);
}

.np-picks-thumb {
  width: 72px;
  height: 52px;
  border-radius: var(--np-r-s);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--np-bg);
}

.np-picks-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s;
}

.np-picks-item:hover .np-picks-thumb img {
  transform: scale(1.07);
}

.np-picks-body {
  flex: 1;
  min-width: 0;
}

.np-picks-cat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--np-primary);
  display: block;
  margin-bottom: 4px;
}

.np-picks-title {
  font-family: var(--np-font-head);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--np-text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  transition: color var(--np-ease-s);
}

.np-picks-item:hover .np-picks-title {
  color: var(--np-primary);
}

.np-picks-meta {
  font-size: 11px;
  color: var(--np-muted);
}

/* ─────────────────────────────────────────────────────
   4. ويدجت "الأكثر مشاهدة" 
   ───────────────────────────────────────────────────── */
.np-widget-popular {
  background: var(--np-surface);
  border-radius: var(--np-r-l);
  overflow: hidden;
  box-shadow: var(--np-shadow-card);
  border: 1px solid var(--np-border);
}

.np-widget-popular .np-widget-title {
  background: linear-gradient(135deg, #1a0a0a 0%, #2d0a0a 100%) !important;
  border-bottom: 2px solid var(--np-primary);
}

.np-popular-list {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.np-popular-item {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 11px 16px;
  border-bottom: 1px solid var(--np-border);
  transition: background var(--np-ease-s);
}

.np-popular-item:last-child {
  border-bottom: none;
}

.np-popular-item:hover {
  background: rgba(211,47,47,.03);
}

.np-popular-rank {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 2px;
}

.np-popular-rank.rank-1 { background: var(--np-gold); color: #3d2800; }
.np-popular-rank.rank-2 { background: #90A4AE; color: #1a2a33; }
.np-popular-rank.rank-3 { background: #A1887F; color: #2d1a14; }
.np-popular-rank.rank-n { background: var(--np-bg); color: var(--np-muted); border: 1px solid var(--np-border); }

.np-popular-body {
  flex: 1;
  min-width: 0;
}

.np-popular-title {
  font-family: var(--np-font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--np-text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  transition: color var(--np-ease-s);
}

.np-popular-item:hover .np-popular-title {
  color: var(--np-primary);
}

.np-popular-title a {
  color: inherit;
}

.np-popular-title a:hover {
  color: var(--np-primary);
}

.np-popular-views {
  font-size: 11px;
  color: var(--np-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─────────────────────────────────────────────────────
   5. إصلاح تداخل الموبايل — السلايدر والمحتوى
   ───────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .np-home-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .np-home-sidebar {
    position: static;
    /* في الموبايل السايدبار تحت المحتوى */
    order: 2;
  }

  .np-home-main {
    order: 1;
  }

  .np-hero-slide {
    height: 380px;
  }

  /* إصلاح صريح لمنع تداخل السلايدر */
  .np-sec-hero .np-hero-wrap {
    margin-bottom: 0 !important;
  }
}

@media (max-width: 640px) {
  .np-hero-slide {
    height: 240px;
  }

  .np-hero-content {
    padding: 16px 18px !important;
  }

  .np-hero-title {
    font-size: 15px !important;
    line-height: 1.35 !important;
    margin-bottom: 8px !important;
  }

  .np-hero-meta {
    font-size: 11px !important;
    gap: 12px !important;
  }

  /* السلايدر مضبوط تماماً في الموبايل */
  .np-hero-wrap {
    border-radius: var(--np-r-l) !important;
    margin-bottom: 20px !important;
  }

  /* الأقسام في الموبايل */
  .np-home-layout {
    gap: 16px;
  }

  .np-widget-picks,
  .np-widget-popular {
    border-radius: var(--np-r-m);
  }
}

/* ─────────────────────────────────────────────────────
   6. إصلاح عام — منع الـ overflow في كل الأقسام
   ───────────────────────────────────────────────────── */
.np-section {
  overflow: hidden !important;
  /* ضمان عدم خروج الصور خارج الحدود */
}

.np-card-v .np-card-thumb img,
.np-card-h .np-card-h-thumb img,
.np-card-feat .np-card-feat-img,
.np-card-overlay img {
  /* تأكيد أن الصور لا تتجاوز حاوياتها */
  max-width: 100% !important;
  width: 100% !important;
  display: block !important;
}

/* ─────────────────────────────────────────────────────
   7. تحسين عام للقراءة والتنسيق
   ───────────────────────────────────────────────────── */
.np-sec-head {
  /* ضمان ارتفاع ثابت بدون تداخل */
  min-height: 52px !important;
  overflow: hidden !important;
}

/* تحسين أزرار التنقل في السلايدر */
.np-hero-wrap .swiper-button-prev,
.np-hero-wrap .swiper-button-next {
  z-index: 10 !important;
}

/* ضمان ظهور النقاط في السلايدر */
.np-hero-wrap .swiper-pagination {
  z-index: 10 !important;
}

/* منع الـ layout shift */
.np-hero-swiper .swiper-slide {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* ─────────────────────────────────────────────────────
   8. Dark mode للسايدبار الجديد
   ───────────────────────────────────────────────────── */
body.np-dark .np-widget-picks,
body.np-dark .np-widget-popular {
  background: var(--np-surface);
  border-color: var(--np-border);
}

body.np-dark .np-picks-item:hover,
body.np-dark .np-popular-item:hover {
  background: rgba(255,255,255,.04);
}

body.np-dark .np-picks-title,
body.np-dark .np-popular-title {
  color: var(--np-text);
}

body.np-dark .np-popular-rank.rank-n {
  background: rgba(255,255,255,.06);
  border-color: var(--np-border);
}

/* ─────────────────────────────────────────────────────
   9. إصلاح الصفحة الداخلية (المقال الفردي والأرشيف)
   ───────────────────────────────────────────────────── */
.np-art-img img.np-art-featured {
  width: 100% !important;
  height: auto !important;
  max-height: 500px !important;
  object-fit: cover !important;
  display: block !important;
}

/* منع خروج الصور في المحتوى */
.np-art-body img {
  max-width: 100% !important;
  height: auto !important;
}

/* ─────────────────────────────────────────────────────
   10. تحسين بطاقة الخبر الأفقي (card-h) في الموبايل
   ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .np-card-h-thumb {
    width: 88px !important;
    height: 66px !important;
  }

  .np-picks-thumb {
    width: 60px;
    height: 44px;
  }
}

/* ═══════════════════════════════════════════════════════
   v6.1 — إصلاحات إضافية
   ═══════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────
   A. تصميم شعار/عنوان القالب — جميل واحترافي
   ───────────────────────────────────────────────────── */
.np-logo-text {
  font-family: 'Cairo', sans-serif !important;
  font-size: 28px !important;
  font-weight: 900 !important;
  letter-spacing: -1px !important;
  line-height: 1 !important;
  background: linear-gradient(135deg, var(--np-primary) 0%, #ff6b35 50%, var(--np-primary-dk) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  padding-bottom: 2px;
  transition: opacity .2s;
}

.np-logo-text::after {
  content: '';
  position: absolute;
  bottom: -3px;
  right: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--np-primary), transparent);
  border-radius: 2px;
}

.np-logo a:hover .np-logo-text {
  opacity: .85;
}

/* صورة الشعار إذا كانت موجودة */
.np-logo-img {
  max-height: 52px !important;
  width: auto !important;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.15));
  transition: transform .2s, filter .2s;
}

.np-logo a:hover .np-logo-img {
  transform: translateY(-1px);
  filter: drop-shadow(0 4px 8px rgba(211,47,47,.25));
}

/* ─────────────────────────────────────────────────────
   B. صورة بارزة واحدة فقط داخل المقال
   ───────────────────────────────────────────────────── */

/* إخفاء أي صورة مميزة تظهر داخل محتوى المقال (the_content)
   لأن ووردبريس أحياناً يضيفها تلقائياً */
.np-art-body .wp-post-image,
.np-art-body img.attachment-full,
.np-art-body > p:first-child > img.size-full,
.np-art-body > figure:first-child img {
  /* نخفي فقط إذا كانت نفس الصورة البارزة الأولى */
  display: none !important;
}

/* الصورة البارزة الرسمية — واحدة فقط، مضبوطة */
.np-art-img {
  position: relative;
  overflow: hidden;
  background: var(--np-dark-hdr);
  /* منع أي صورة ثانية */
}

.np-art-img .np-art-featured {
  width: 100% !important;
  max-height: 480px !important;
  height: auto !important;
  object-fit: cover !important;
  object-position: center top !important;
  display: block !important;
}

/* إخفاء صورة مكررة داخل محتوى المقال إن كانت هي ذاتها */
.np-art-body .wp-block-image:first-child,
.np-art-body > .wp-block-cover:first-child {
  display: none !important;
}

/* ─────────────────────────────────────────────────────
   C. صفحة المقال الفردي — بدون سايدبار، عرض كامل
   ───────────────────────────────────────────────────── */
.np-single-full {
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.np-single-full .np-article {
  width: 100%;
}

/* الأرشيف والبحث والتصنيف — بدون سايدبار */
.archive .np-sidebar,
.search .np-sidebar,
.tag .np-sidebar,
.category .np-sidebar {
  display: none !important;
}

.archive .np-content-wrap,
.search .np-content-wrap {
  grid-template-columns: 1fr !important;
}

/* ─────────────────────────────────────────────────────
   D. صفحات الأرشيف — عرض كامل بدون سايدبار
   ───────────────────────────────────────────────────── */
.np-archive-full {
  width: 100%;
}

.np-archive-hdr {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--np-border);
}

.np-archive-title {
  font-family: var(--np-font-head);
  font-size: 26px;
  font-weight: 900;
  color: var(--np-text);
  margin-bottom: 6px;
  border-right: 4px solid var(--np-primary);
  padding-right: 14px;
  display: inline-block;
}

.np-archive-desc {
  font-size: 14.5px;
  color: var(--np-muted);
  margin-top: 6px;
}

/* ─────────────────────────────────────────────────────
   E. السايدبار الرئيسي — الأكثر مشاهدة فقط (بدون تكرار)
   ───────────────────────────────────────────────────── */

/* في الصفحة الرئيسية، نخفي ويدجت الأكثر قراءة من المتن */
.np-sec-trending,
section.np-section[class*="trending"] {
  display: none !important;
}

/* ─────────────────────────────────────────────────────
   F. تحسين عرض الصور في المقالات — منع التكرار
   ───────────────────────────────────────────────────── */

/* طبقة بيضاء فوق الصورة البارزة لمنع الـ overlap */
.np-art-img + .np-art-body .wp-post-image {
  display: none !important;
}

/* تحسين نص المقال — عرض مقروء */
.np-single-full .np-art-body {
  font-size: 17px !important;
  line-height: 2 !important;
}

.np-single-full .np-art-title {
  font-size: clamp(22px, 3.5vw, 36px) !important;
}

/* ─────────────────────────────────────────────────────
   G. Responsive — الموبايل
   ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .np-single-full {
    max-width: 100%;
  }

  .np-art-img .np-art-featured {
    max-height: 280px !important;
  }

  .np-logo-text {
    font-size: 22px !important;
  }
}

@media (max-width: 480px) {
  .np-logo-text {
    font-size: 20px !important;
  }
}

/* ─────────────────────────────────────────────────────
   H. سايدبار المقال الفردي
   ───────────────────────────────────────────────────── */
.np-sidebar-s {
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: calc(var(--np-hh) + 16px);
}

.np-single-wrap {
  display: grid;
  grid-template-columns: 1fr 308px;
  gap: 32px;
  align-items: start;
}

@media (max-width: 960px) {
  .np-single-wrap {
    grid-template-columns: 1fr;
  }
  .np-sidebar-s {
    position: static;
  }
}
