/* ============================================================
   NewsForge v3 — FIXES CSS
   sidebar widgets + footer spacing + latest section + social strip
============================================================ */

/* ══════════════════════════════════════════
   FIX 1: آخر الأخبار — latest section layout
   مشكلة: nf-latest-grid لا يعمل بشكل صحيح
══════════════════════════════════════════ */
.nf-latest-section {
  padding: 28px 0;
  background: var(--nf-page);
}
.nf-latest-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 28px;
  align-items: start;
}

/* ══════════════════════════════════════════
   FIX 2: الشريط الجانبي (Sidebar)
   إصلاح كامل لجميع الويدجات
══════════════════════════════════════════ */
.nf-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Widget container */
.nf-widget {
  background: var(--nf-card);
  border: 1.5px solid var(--nf-border);
  border-radius: var(--nf-radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.nf-widget__title {
  padding: 11px 14px;
  background: var(--nf-text);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.nf-widget__body {
  padding: 0 !important; /* remove inline padding override */
}

/* ─── Posts list (أحدث المقالات / الأكثر قراءة) ─── */
.nf-widget ul.posts-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
}
.nf-widget ul.posts-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--nf-border);
  transition: background .15s;
}
.nf-widget ul.posts-list li:last-child { border-bottom: none; }
.nf-widget ul.posts-list li:hover { background: var(--nf-page); }
.nf-widget ul.posts-list li img {
  width: 64px;
  height: 52px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
  display: block;
}
.nf-widget ul.posts-list li > div { flex: 1; min-width: 0; }
.nf-widget ul.posts-list li a {
  font-size: 12px;
  font-weight: 700;
  color: var(--nf-text);
  line-height: 1.4;
  display: block;
  transition: color .15s;
}
.nf-widget ul.posts-list li a:hover { color: var(--nf-accent); }
.nf-widget ul.posts-list li .post-date {
  font-size: 10px;
  color: var(--nf-text3);
  margin-top: 4px;
  display: block;
}

/* ─── Categories list ─── */
.nf-widget ul.cats-list {
  list-style: none;
  margin: 0; padding: 0;
}
.nf-widget ul.cats-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--nf-border);
  transition: background .15s;
}
.nf-widget ul.cats-list li:last-child { border-bottom: none; }
.nf-widget ul.cats-list li:hover { background: var(--nf-page); }
.nf-widget ul.cats-list li a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--nf-text2);
  transition: color .15s;
  flex: 1;
}
.nf-widget ul.cats-list li a::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--nf-accent);
  flex-shrink: 0;
  display: inline-block;
}
.nf-widget ul.cats-list li a:hover { color: var(--nf-accent); }
.nf-widget ul.cats-list .cat-count {
  background: var(--nf-page);
  border: 1px solid var(--nf-border);
  border-radius: 12px;
  padding: 2px 9px;
  font-size: 10px;
  font-weight: 700;
  color: var(--nf-text3);
  flex-shrink: 0;
}

/* ─── Comments list ─── */
.nf-widget ul.comments-list {
  list-style: none;
  margin: 0; padding: 0;
}
.nf-widget ul.comments-list li {
  padding: 10px 14px;
  border-bottom: 1px solid var(--nf-border);
  font-size: 12px;
  color: var(--nf-text2);
  line-height: 1.5;
}
.nf-widget ul.comments-list li:last-child { border-bottom: none; }
.nf-widget ul.comments-list li::before {
  content: '💬';
  margin-left: 5px;
  font-size: 11px;
}
.nf-widget ul.comments-list .comment-author-link {
  font-weight: 700;
  color: var(--nf-accent);
}
.nf-widget ul.comments-list .comment-excerpt {
  color: var(--nf-text3);
  display: block;
  margin-top: 3px;
  font-style: italic;
  font-size: 11px;
}
.nf-widget ul.comments-list a {
  color: var(--nf-text2);
  font-weight: 600;
}
.nf-widget ul.comments-list a:hover { color: var(--nf-accent); }

/* ─── Archive list ─── */
.nf-widget ul.archive-list {
  list-style: none;
  margin: 0; padding: 0;
}
.nf-widget ul.archive-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--nf-border);
  font-size: 12px;
}
.nf-widget ul.archive-list li:last-child { border-bottom: none; }
.nf-widget ul.archive-list li:hover { background: var(--nf-page); }
.nf-widget ul.archive-list li a {
  color: var(--nf-text2);
  font-weight: 600;
  transition: color .15s;
}
.nf-widget ul.archive-list li a:hover { color: var(--nf-accent); }
.nf-widget ul.archive-list .count {
  background: var(--nf-page);
  border: 1px solid var(--nf-border);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 10px;
  color: var(--nf-text3);
}

/* ─── Tags cloud ─── */
.nf-widget .nf-tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px;
}
.nf-widget .nf-tag {
  background: var(--nf-page);
  border: 1px solid var(--nf-border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--nf-text2);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  display: inline-block;
}
.nf-widget .nf-tag:hover {
  background: var(--nf-accent);
  border-color: var(--nf-accent);
  color: #fff;
}

/* ─── Poll widget ─── */
.nf-widget .nf-poll-opt { margin-bottom: 10px; }
.nf-widget .nf-poll-label {
  font-size: 12px; font-weight: 600;
  color: var(--nf-text);
  display: flex; justify-content: space-between;
  margin-bottom: 4px;
}
.nf-widget .nf-poll-bar {
  height: 8px; background: var(--nf-border);
  border-radius: 4px; overflow: hidden;
}
.nf-widget .nf-poll-fill {
  height: 100%; border-radius: 4px;
  background: var(--nf-accent);
  transition: width .6s;
}

/* ─── Widget body padding when no list ─── */
.nf-widget__body--padded { padding: 14px !important; }

/* ══════════════════════════════════════════
   FIX 3: SOCIAL STRIP — لا يظهر مرتين
══════════════════════════════════════════ */
.nf-social-strip {
  background: var(--nf-text);
  color: #fff;
  padding: 16px 0;
}
.nf-social-strip__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.nf-social-strip__title { font-size: 14px; font-weight: 700; }
.nf-social-strip__desc { font-size: 11px; color: #888; margin-top: 2px; }
.nf-social-strip__btns { display: flex; gap: 8px; flex-wrap: wrap; }
.nf-social-btn {
  padding: 8px 16px;
  border-radius: var(--nf-radius);
  font-size: 12px; font-weight: 700;
  border: none; cursor: pointer;
  font-family: var(--nf-font-primary);
  text-decoration: none;
  display: inline-block;
  transition: opacity .15s;
  color: #fff !important;
}
.nf-social-btn:hover { opacity: .85; }

/* ══════════════════════════════════════════
   FIX 4: FOOTER — إزالة المسافات الفارغة
══════════════════════════════════════════ */
.nf-footer {
  background: var(--nf-text);
  color: #888;
  padding: 28px 0 14px; /* reduced from 32px */
}
.nf-footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 24px; /* reduced from 32px */
  padding-bottom: 20px;
  border-bottom: 1px solid #2a2520;
  align-items: start;
}
/* Fix: إذا كانت الأعمدة أقل من 4 تملأ المساحة */
.nf-footer__grid:has(.nf-footer__col:nth-child(3):last-child) {
  grid-template-columns: 2fr 1fr 1fr;
}
.nf-footer__grid:has(.nf-footer__col:nth-child(2):last-child) {
  grid-template-columns: 2fr 1fr;
}

.nf-footer__brand { display: flex; flex-direction: column; gap: 0; }
.nf-footer__logo {
  font-family: var(--nf-font-display);
  font-size: 26px; font-weight: 900;
  color: #fff; letter-spacing: -1px;
  text-decoration: none; display: block;
  line-height: 1; margin-bottom: 8px;
}
.nf-footer__logo span { color: var(--nf-accent); }
.nf-footer__brand p {
  font-size: 12px; color: #666;
  line-height: 1.7; margin: 0 0 12px;
}
/* Social icons in footer */
.nf-footer__social {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 4px;
}
.nf-footer__soc-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px;
  font-size: 13px; color: #fff !important;
  text-decoration: none; transition: opacity .15s;
}
.nf-footer__soc-btn:hover { opacity: .85; }

.nf-footer__col { min-width: 0; }
.nf-footer__col h4 {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1px;
  color: #e0dbd0; margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #2a2520;
}
.nf-footer__col ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.nf-footer__col ul li a {
  font-size: 12px; color: #666; transition: color .15s;
}
.nf-footer__col ul li a:hover { color: #ccc; }
.nf-footer__col ul li a::before {
  content: '›'; margin-left: 5px; color: var(--nf-accent);
}

.nf-footer__bottom {
  padding-top: 14px;
  display: flex; justify-content: space-between;
  font-size: 11px; color: #444;
  flex-wrap: wrap; gap: 6px;
}

/* ══════════════════════════════════════════
   FIX 5: Infographic section spacing
   إزالة المسافة الفارغة إذا لم تكن هناك صور
══════════════════════════════════════════ */
.nf-infographic-section {
  background: var(--nf-text);
  padding: 24px 0;
  /* إزالة margin إضافي */
  margin-bottom: 0;
}
/* إخفاء القسم إذا كانت فارغة */
.nf-infographic-grid:empty {
  display: none;
}
.nf-infographic-section:has(.nf-infographic-grid:empty) {
  display: none;
}

/* ══════════════════════════════════════════
   FIX 6: Social strip duplication fix
   منع التكرار — يظهر مرة واحدة فقط
══════════════════════════════════════════ */
.nf-social-strip + .nf-social-strip {
  display: none;
}
/* Footer margin-top reset */
.nf-footer { margin-top: 0; }
.nf-infographic-section + .nf-footer { margin-top: 0; }
.nf-social-strip + .nf-footer { margin-top: 0; }

/* ══════════════════════════════════════════
   FIX 7: Widget body inline padding override
══════════════════════════════════════════ */
/* Override inline styles from sidebar.php */
.nf-widget > div[style*="padding:12px 14px"] {
  padding: 0 !important;
}
.nf-widget > .nf-widget__body[style] {
  padding: 0 !important;
}

/* ══════════════════════════════════════════
   FIX 8: nf-latest-grid sidebar width
══════════════════════════════════════════ */
.nf-latest-grid {
  grid-template-columns: 1fr 300px;
}
.nf-latest-grid .nf-sidebar {
  position: sticky;
  top: 80px; /* matches nav height */
}

/* ══════════════════════════════════════════
   FIX 9: Responsive fixes
══════════════════════════════════════════ */
@media (max-width: 1100px) {
  .nf-latest-grid { grid-template-columns: 1fr 280px; }
}
@media (max-width: 900px) {
  .nf-latest-grid { grid-template-columns: 1fr; }
  .nf-latest-grid .nf-sidebar { position: static; }
  .nf-footer__grid { grid-template-columns: 1fr 1fr; gap: 18px; }
  .nf-infographic-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .nf-footer__grid { grid-template-columns: 1fr; gap: 16px; }
  .nf-infographic-grid { grid-template-columns: repeat(2, 1fr); }
  .nf-social-strip__inner { flex-direction: column; text-align: center; }
}

/* ══════════════════════════════════════════
   NAV SEARCH — البحث داخل شريط التنقل
══════════════════════════════════════════ */
.nf-nav-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: auto; /* يدفع القائمة ناحية اليمين */
  padding-right: 6px;
}
.nf-nav-search-form {
  display: flex;
  align-items: center;
  background: var(--nf-page);
  border: 1.5px solid var(--nf-border);
  border-radius: 24px;
  padding: 0 4px 0 12px;
  gap: 4px;
  transition: border-color .15s;
  height: 36px;
}
.nf-nav-search-form:focus-within {
  border-color: var(--nf-accent);
  background: #fff;
}
.nf-nav-search-form input {
  background: none;
  border: none;
  outline: none;
  font-family: var(--nf-font-primary);
  font-size: 12px;
  color: var(--nf-text);
  width: 170px;
  padding: 0;
}
.nf-nav-search-form input::placeholder { color: var(--nf-text3); }
.nf-nav-search-form button {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  transition: background .15s;
  color: var(--nf-text3);
}
.nf-nav-search-form button:hover {
  background: var(--nf-accent);
  color: #fff;
}
.nf-nav-search-form button svg {
  width: 15px; height: 15px;
  stroke: currentColor; fill: none; stroke-width: 2.2;
}
.nf-nav-rss {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--nf-page);
  border: 1.5px solid var(--nf-border);
  color: var(--nf-text3);
  transition: all .15s;
}
.nf-nav-rss:hover {
  background: var(--nf-accent);
  border-color: var(--nf-accent);
  color: #fff;
}
.nf-nav-rss svg { width: 16px; height: 16px; }

/* إخفاء البحث القديم في الـ masthead إن بقي */
.nf-masthead .nf-search-form { display: none !important; }
.nf-masthead__right .nf-search-form { display: none !important; }

/* المحاذاة الصحيحة للـ nav inner */
.nf-primary-nav__inner {
  display: flex;
  align-items: center;
  gap: 0;
}
.nf-nav-menu {
  display: flex;
  flex: 0 0 auto;
}

@media (max-width: 900px) {
  .nf-nav-search-form input { width: 130px; }
  .nf-nav-search-wrap { order: -1; margin-right: 0; margin-left: auto; }
}
@media (max-width: 640px) {
  .nf-nav-search-wrap { display: none; }
}

/* ============================================================
   COMMENTS — NewsForge v3
============================================================ */
.nf-comments { margin: 40px 0; }
.nf-comments__title { font-size: 1.3rem; font-weight: 700; margin-bottom: 24px; color: var(--nf-text1); border-right: 4px solid var(--nf-accent); padding-right: 12px; }
.nf-comment-list { list-style: none; padding: 0; margin: 0 0 32px; }
.nf-comment { display: flex; gap: 14px; padding: 20px 0; border-bottom: 1px solid var(--nf-border); }
.nf-comment__avatar img { border-radius: 50%; width: 48px; height: 48px; flex-shrink: 0; }
.nf-comment__body { flex: 1; }
.nf-comment__meta { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.nf-comment__author { font-weight: 700; color: var(--nf-text1); }
.nf-comment__time { font-size: .82rem; color: var(--nf-text3); }
.nf-comment__text { font-size: .95rem; line-height: 1.7; color: var(--nf-text2); }
.nf-comment__pending { color: var(--nf-accent); font-size: .85rem; margin-bottom: 6px; }
.nf-comment__reply a { font-size: .83rem; color: var(--nf-accent); margin-top: 8px; display: inline-block; }
.nf-comment__reply a:hover { text-decoration: underline; }
.nf-comments__closed { color: var(--nf-text3); font-style: italic; text-align: center; padding: 20px; }

/* Comment Form */
.nf-comment-form { margin-top: 32px; }
.nf-comment-form p { margin-bottom: 16px; }
.nf-comment-form label { display: block; font-size: .88rem; font-weight: 600; color: var(--nf-text2); margin-bottom: 6px; }
.nf-comment-form input[type="text"],
.nf-comment-form input[type="email"],
.nf-comment-form textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--nf-border);
    border-radius: 6px;
    background: var(--nf-bg2);
    color: var(--nf-text1);
    font-family: inherit;
    font-size: .95rem;
    transition: border-color .2s;
    box-sizing: border-box;
}
.nf-comment-form input:focus,
.nf-comment-form textarea:focus { outline: none; border-color: var(--nf-accent); }
.nf-comment-form textarea { resize: vertical; min-height: 120px; }
.nf-comment-form .nf-btn-primary { margin-top: 8px; }
