/*==================================================
  SPACING SCALE
==================================================*/

:root {
  --sp-xs: 8px;
  --sp-sm: 12px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
}

/*==================================================
  BLOG HEADER
==================================================*/

.blog-header {
  text-align: center !important;
  padding-top: 0px !important;
  padding-bottom: 0px !important;
  margin-top: 0px !important;
  margin-bottom: var(--sp-xs) !important;
}

.blog-header h1 {
  font-size: 24px !important;
  font-weight: 800 !important;
  color: var(--text-primary, #ffffff) !important;
  margin-bottom: 4px !important;
  line-height: 1.2 !important;
}

.blog-header p {
  font-size: 13px !important;
  color: var(--text-secondary, #94a3b8) !important;
  margin: 0 !important;
  opacity: 0.8 !important;
}

/*==================================================
  BLOG PAGE LAYOUT
==================================================*/

.blog-layout {
  display: grid !important;
  grid-template-columns: 280px minmax(0, 1fr) !important;
  gap: var(--sp-lg) !important;
  align-items: start !important;
  margin: var(--sp-sm) 0 50px 0 !important;
}

/*==================================================
  Sidebar (فیلتر مقالات)
==================================================*/

.blog-sidebar {
  position: sticky !important;
  top: 90px !important;
  padding: var(--sp-lg) !important;
  border-radius: 16px !important;
  background: var(--bg-surface, #0d121a) !important;
  border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.05)) !important;
  box-shadow: var(--shadow-soft, 0 12px 30px rgba(0, 0, 0, 0.4)) !important;
  transition: 0.3s ease !important;
}

.filter-title {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-direction: row !important;
  gap: 10px !important;
  font-size: 17px !important;
  font-weight: 800 !important;
  margin-bottom: var(--sp-lg) !important;
  color: var(--text-primary, #fff) !important;
  border-bottom: 1px solid var(--border-soft, rgba(255, 255, 255, 0.06)) !important;
  padding-bottom: var(--sp-sm) !important;
  text-align: right !important;
}

.filter-title i {
  color: var(--accent-2, #38bdf8) !important;
}

.filter-toggle-btn {
  display: none !important;
}

.filter-group {
  margin-bottom: var(--sp-md) !important;
}

.filter-group label {
  display: block !important;
  margin-bottom: var(--sp-xs) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  color: var(--text-secondary, #94a3b8) !important;
}

/*==================================================
  Fields & Search
==================================================*/

.field {
  width: 100% !important;
  height: 42px !important;
  padding: 0 14px !important;
  border-radius: 10px !important;
  border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.08)) !important;
  background: var(--bg-elevated, rgba(255, 255, 255, 0.03)) !important;
  color: var(--text-primary, #fff) !important;
  font-size: 13px !important;
  outline: none !important;
  transition: 0.25s ease !important;
}

.field::placeholder {
  color: var(--text-muted, rgba(255, 255, 255, 0.35)) !important;
}

.field:hover {
  border-color: rgba(56, 189, 248, 0.3) !important;
}

.field:focus {
  border-color: var(--accent-2, #38bdf8) !important;
  background: var(--bg-elevated, rgba(255, 255, 255, 0.05)) !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12) !important;
}

.field option {
  background: var(--bg-surface, #0f141c) !important;
  color: var(--text-primary, #fff) !important;
}

.search-box {
  display: flex !important;
  gap: var(--sp-xs) !important;
  position: relative !important;
}

.search-box input {
  flex: 1 !important;
}

.search-box button {
  width: 42px !important;
  height: 42px !important;
  border: none !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  flex-shrink: 0 !important;
  color: #fff !important;
  background: linear-gradient(180deg, #38bdf8 0%, #1d8ed1 100%) !important;
  transition: 0.25s ease !important;
}

.search-box button:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 16px rgba(29, 142, 209, 0.35) !important;
}

/*==================================================
  Filter Buttons
==================================================*/

.filter-buttons {
  display: flex !important;
  gap: var(--sp-sm) !important;
  margin-top: var(--sp-lg) !important;
}

.filter-buttons .btn-primary {
  flex: 1 !important;
  height: 42px !important;
  border: none !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #fff !important;
  background: linear-gradient(180deg, #38bdf8 0%, #1d8ed1 100%) !important;
  transition: 0.25s ease !important;
}

.filter-buttons .btn-primary:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 20px rgba(29, 142, 209, 0.35) !important;
}

.filter-buttons .btn-ghost {
  flex: 1 !important;
  height: 42px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  color: var(--text-secondary, #94a3b8) !important;
  border-radius: 10px !important;
  background: var(--bg-elevated, rgba(255, 255, 255, 0.04)) !important;
  border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.08)) !important;
  transition: 0.25s ease !important;
}

.filter-buttons .btn-ghost:hover {
  background: var(--border-soft, rgba(255, 255, 255, 0.08)) !important;
  color: var(--text-primary, #fff) !important;
}

/*==================================================
  Content Grid
  رفع اصلی ایراد "وسط‌چین نشدن" و "همیشه وسط باشه چه کم چه زیاد":
  به‌جای grid با ستون ثابت (که وقتی ۱ یا ۲ کارت هست، فضای خالی
  کنارش می‌مونه)، از flex + wrap + justify-content:center استفاده
  می‌کنیم. حالا با هر تعداد کارت (۱، ۲، ۵، ۹...) گروه کارت‌ها
  همیشه وسط کانتینر قرار می‌گیره.
==================================================*/

.blog-content {
  width: 100% !important;
}

.blog-grid {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: flex-start !important;
  align-items: stretch !important;
  gap: var(--sp-lg) !important;
}

/*==================================================
  Blog Card
  عرض هر کارت با flex-basis ثابت میشه تا روی دسکتاپ همیشه
  ۳ کارت در هر ردیف جا بشه، ولی اگه کمتر از ۳ کارت باشه،
  به‌جای کش اومدن یا کنار افتادن، همون عرض ثابتشون رو حفظ
  می‌کنن و justify-content:center وسط‌چینشون می‌کنه.
==================================================*/

.blog-card {
  position: relative !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  flex: 0 1 250px !important;
  max-width: 250px !important;
  border-radius: 14px !important;
  background: var(--bg-surface, #0d121a) !important;
  border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.05)) !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.blog-card:hover {
  transform: translateY(-5px) !important;
  border-color: rgba(56, 189, 248, 0.25) !important;
  box-shadow: var(--shadow-soft, 0 14px 30px rgba(0, 0, 0, 0.5)) !important;
}

/* تصویر مقاله - نسبت ثابت به‌جای ارتفاع ثابت */
.blog-image {
  position: relative !important;
  display: block !important;
  aspect-ratio: 16 / 10 !important;
  width: 100% !important;
  overflow: hidden !important;
}

.blog-image img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
  transition: transform 0.4s ease !important;
}

.blog-card:hover .blog-image img {
  transform: scale(1.06) !important;
}

.blog-image::after {
  content: "" !important;
  position: absolute !important;
  inset: auto 0 0 !important;
  height: 60px !important;
  background: linear-gradient(
    transparent,
    var(--bg-surface, rgba(13, 18, 26, 0.9))
  ) !important;
}

.blog-body {
  padding: var(--sp-md) !important;
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
}

/*==================================================
  Tags
==================================================*/

.blog-top-tags {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
  margin-bottom: var(--sp-sm) !important;
  min-height: 26px !important;
}

.tag {
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 4px 10px !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  color: var(--accent-2, #38bdf8) !important;
  background: rgba(56, 189, 248, 0.08) !important;
  border: 1px solid rgba(56, 189, 248, 0.15) !important;
  transition: 0.2s ease !important;
}

.tag i {
  font-size: 10px !important;
}

.tag:hover {
  background: rgba(56, 189, 248, 0.16) !important;
}

/*==================================================
  Title & Excerpt
==================================================*/

.blog-title {
  font-size: 15px !important;
  font-weight: 700 !important;
  line-height: 1.6 !important;
  margin-bottom: var(--sp-xs) !important;
  min-height: 48px !important;
  overflow: hidden !important;
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
}

.blog-title a {
  color: var(--text-primary, #fff) !important;
  text-decoration: none !important;
  transition: color 0.2s ease !important;
}

.blog-title a:hover {
  color: var(--accent-2, #38bdf8) !important;
}

.blog-excerpt {
  flex: 1 !important;
  font-size: 13px !important;
  color: var(--text-secondary, #94a3b8) !important;
  line-height: 1.7 !important;
  margin-bottom: var(--sp-md) !important;
  overflow: hidden !important;
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
}

/*==================================================
  Footer
==================================================*/

.blog-footer {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: var(--sp-sm) !important;
  margin-top: auto !important;
  padding-top: var(--sp-sm) !important;
  border-top: 1px solid var(--border-soft, rgba(255, 255, 255, 0.05)) !important;
}

.blog-date {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  font-size: 11px !important;
  color: var(--text-muted, #64748b) !important;
  white-space: nowrap !important;
}

.blog-date i {
  color: var(--accent-2, #38bdf8) !important;
}

.read-more {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  color: var(--accent-2, #38bdf8) !important;
  transition: 0.2s ease !important;
  white-space: nowrap !important;
}

.read-more:hover {
  gap: 10px !important;
}

.read-more i {
  transition: transform 0.2s ease !important;
}

.read-more:hover i {
  transform: translateX(-4px) !important;
}

/*==================================================
  Pagination
==================================================*/

.blog-pagination {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: var(--sp-xs) !important;
  margin-top: var(--sp-xl) !important;
}

.pagination-item {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 38px !important;
  height: 38px !important;
  border-radius: 10px !important;
  background: var(--bg-surface, #0d121a) !important;
  border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.06)) !important;
  color: var(--text-secondary, #94a3b8) !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  transition: all 0.25s ease !important;
}

.pagination-item:hover {
  border-color: var(--accent-2, #38bdf8) !important;
  color: var(--text-primary, #fff) !important;
}

.pagination-item.active {
  background: linear-gradient(180deg, #38bdf8 0%, #1d8ed1 100%) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 4px 12px rgba(29, 142, 209, 0.3) !important;
}

/*==================================================
  Responsive
==================================================*/

@media (max-width: 1100px) {
  .blog-card {
    flex-basis: 230px !important;
    max-width: 230px !important;
  }
}

@media (max-width: 850px) {
  .blog-layout {
    grid-template-columns: 1fr !important;
  }

  .blog-sidebar {
    position: relative !important;
    top: auto !important;
  }

  .blog-grid {
    justify-content: center !important;
  }

  .blog-card {
    flex-basis: 260px !important;
    max-width: 260px !important;
  }
}

/*==================================================
  موبایل - فیلتر به‌صورت دراپ‌داون واقعی (ایراد موبایل 2)
  ==================================================

  این بخش بدون جاوااسکریپت کار می‌کنه (ترفند چک‌باکس مخفی خالص CSS)
  اما به یه تغییر کوچیک توی HTML نیاز داره. ساختار مورد نیاز:

  <div class="blog-sidebar">
    <input type="checkbox" id="blogFilterToggle" class="filter-toggle-checkbox">
    <label for="blogFilterToggle" class="filter-title">
      فیلتر مقالات <i class="icon-filter"></i>
    </label>
    <div class="filter-body">
      <!-- همون search-box, filter-group ها, filter-buttons که الان هست -->
      <div class="search-box">...</div>
      <div class="filter-group">...</div>
      <div class="filter-group">...</div>
      <div class="filter-buttons">...</div>
    </div>
  </div>

  فقط باید همون فیلدهای موجود رو داخل یه <div class="filter-body">
  بپیچی و یه چک‌باکس + label قبلش اضافه کنی. هیچ JS لازم نیست.
==================================================*/

.filter-toggle-checkbox {
  display: none !important;
}

@media (max-width: 680px) {
  .blog-grid {
    gap: var(--sp-md) !important;
  }

  .blog-card {
    flex-basis: 100% !important;
    max-width: 340px !important;
  }

  .blog-sidebar {
    position: relative !important;
    padding: var(--sp-md) var(--sp-lg) !important;
    z-index: 20 !important;
  }

  .filter-title {
    cursor: pointer !important;
    margin-bottom: 0 !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
    user-select: none !important;
  }

  .filter-title i {
    transition: transform 0.2s ease !important;
  }

  .filter-toggle-checkbox:checked + .filter-title i {
    transform: rotate(180deg) !important;
  }

  /* پنل فیلتر به‌صورت دراپ‌داون روی محتوا میفته، محتوا رو پایین نمیده */
  .filter-body {
    display: none !important;
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    left: 0 !important;
    margin-top: var(--sp-sm) !important;
    padding: var(--sp-lg) !important;
    border-radius: 14px !important;
    background: var(--bg-surface, #0d121a) !important;
    border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.08)) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55) !important;
    z-index: 30 !important;
  }

  .filter-toggle-checkbox:checked + .filter-title + .filter-body {
    display: block !important;
  }
}

@media (max-width: 480px) {
  .blog-card {
    max-width: 100% !important;
  }
}

/*==================================================
  STAGE 0 FIX — بازچینی صفحه‌ی بلاگ
  هدر جمع‌وجور، گرید دقیقِ ۳تایی، پلیس‌هولدر تصویر،
  و فاصله‌های بالا/پایین
==================================================*/

/* هدر بلاگ: فاصله‌ی بالا و پایین خیلی کمتر */
.blog-page-header {
  padding: calc(var(--header-h, 76px) + 22px) 20px 6px !important;
}
.blog-page-header h1 {
  font-size: 30px !important;
  margin-bottom: 6px !important;
}
.blog-page-header p {
  font-size: 13.5px !important;
  color: var(--text-secondary, #94a3b8) !important;
  margin: 0 !important;
}

/* گریدِ دقیقِ ۳تایی (۳ ستون، ردیف بعدی خودکار → ۳ ردیف در هر صفحه) */
.blog-grid {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 22px !important;
  align-items: stretch !important;
}

/* در گرید، کارت‌ها عرضِ ستون را می‌گیرند (نه عرض ثابت) */
.blog-card {
  flex: initial !important;
  width: auto !important;
  max-width: none !important;
}

/* تبلت: ۲تایی، موبایل: ۱تایی */
@media (max-width: 900px) {
  .blog-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .blog-card { max-width: none !important; }
}
@media (max-width: 560px) {
  .blog-grid { grid-template-columns: 1fr !important; }
  .blog-card { max-width: 420px !important; margin: 0 auto !important; width: 100% !important; }
}

/* جای تصویر وقتی عکسی نیست/خراب است: پلیس‌هولدرِ تمیز بدون متنِ بیرون‌زده */
.blog-image.no-image {
  background: linear-gradient(135deg, #16202b, #0d121a) !important;
}
.blog-image.no-image::before {
  content: "\f1b9"; /* آیکون خودرو (Font Awesome) */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: rgba(56, 189, 248, 0.35);
}
.blog-image.no-image img { display: none !important; }

/* اطلاعات صفحه‌بندی + فاصله‌ی پایین صفحه */
.pagination-info {
  text-align: center !important;
  color: var(--text-muted, #64748b) !important;
  font-size: 12.5px !important;
  margin: 14px 0 0 !important;
}
.blog-layout {
  margin-bottom: 70px !important;
}

/* کارتِ کاملاً راست‌چین و مرتب (RTL): همه‌چیز از یک سمت */
html[dir="rtl"] .blog-body,
html[dir="rtl"] .blog-title,
html[dir="rtl"] .blog-excerpt {
  text-align: right !important;
}

/* کاراتِ دراپ‌داونِ موبایل فقط در موبایل دیده شود */
.filter-caret { display: none !important; }
@media (max-width: 680px) {
  .filter-caret {
    display: inline-block !important;
    margin-inline-start: auto !important;
    transition: transform 0.2s ease !important;
    font-size: 13px !important;
  }
  .filter-toggle-checkbox:checked + .filter-title .filter-caret {
    transform: rotate(180deg) !important;
  }
}
