:root {
  --mdc-primary: #1e5c6d;
  --mdc-primary-dark: #164b57;
  --mdc-gold: #d6b15e;
  --mdc-ink: #0f172a;
  --mdc-border: rgba(15, 23, 42, .12);
  --mdc-bg: #fff;
  --mdc-surface: #f6f7f9;
  --mdc-shadow: 0 14px 40px rgba(15, 23, 42, .10);
  --mdc-radius: 18px;
}

/* --- شروع اصلاحات ضدتداخل --- */
.mdc-wrap {
  direction: rtl;
  padding: 10px 0 0;
  width: 100%;
  max-width: 100%; /* جلوگیری از بیرون زدن از کادر نوشته */
  box-sizing: border-box;
  position: relative;
  overflow: hidden; /* اگر چیزی بیرون زد مخفی شود */
}

/* ریست کردن تمام استایل‌های قالب داخل اسلایدر */
.mdc-wrap * {
  box-sizing: border-box;
}
/* --- پایان اصلاحات اولیه --- */

.mdc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}

.mdc-title {
  margin: 0 !important; /* حذف مارجین پیش‌فرض قالب */
  padding: 0 !important;
  font-size: 18px !important;
  font-weight: 900 !important;
  color: var(--mdc-ink);
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.4 !important;
}

.mdc-title:before {
  content: "";
  display: block; /* اطمینان از نمایش */
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--mdc-gold);
  box-shadow: 0 0 0 4px rgba(214, 177, 94, .20);
  flex-shrink: 0; /* جلوگیری از له شدن دایره */
}

.mdc-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mdc-all {
  height: 40px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--mdc-border);
  background: #fff;
  color: var(--mdc-ink) !important; /* اولویت رنگ */
  font-weight: 900;
  text-decoration: none !important; /* حذف زیرخط قالب */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  white-space: nowrap;
  box-shadow: none; /* حذف سایه قالب */
}

.mdc-all:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, .10);
  border-color: rgba(30, 92, 109, .25);
  color: var(--mdc-primary) !important;
}

.mdc-arrows {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mdc-btn {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--mdc-border);
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, opacity .12s ease;
  padding: 0;
  font-weight: 900;
  color: var(--mdc-primary);
  line-height: 1;
  font-size: 18px;
  /* جلوگیری از استایل دکمه قالب */
  min-width: unset;
  margin: 0;
}

.mdc-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, .10);
  border-color: rgba(30, 92, 109, .25);
}

.mdc-btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.mdc-track {
  display: flex;
  gap: 14px;
  overflow: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 6px 4px 18px;
  -webkit-overflow-scrolling: touch;
  margin: 0 !important; /* حذف مارجین‌های مزاحم */
}

.mdc-track::-webkit-scrollbar {
  height: 10px;
}
.mdc-track::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, .18);
  border-radius: 999px;
}
.mdc-track::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, .06);
  border-radius: 999px;
}

.mdc-card {
  flex: 0 0 240px; /* سایز ثابت */
  width: 240px !important; /* اجبار سایز */
  max-width: 240px !important;
  scroll-snap-align: start;
  border: 1px solid var(--mdc-border);
  border-radius: var(--mdc-radius);
  background: var(--mdc-bg);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
  overflow: hidden;
  transition: transform .12s ease, box-shadow .12s ease;
  margin: 0 !important;
}

.mdc-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--mdc-shadow);
}

/* لینک دور کارت */
.mdc-card > a {
  text-decoration: none !important;
  border: none !important;
  display: block !important;
}

.mdc-thumb {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 4/3;
  background: var(--mdc-surface);
  object-fit: cover;
  display: block !important;
  margin: 0 !important; /* حذف مارجین عکس در نوشته‌ها */
  padding: 0 !important;
  border: none !important; /* حذف بردر عکس در برخی قالب‌ها */
  max-width: 100% !important; /* جلوگیری از بزرگ شدن بیش از حد */
}

.mdc-body {
  padding: 12px 14px;
}

.mdc-name {
  margin: 0 0 8px !important; /* اجبار مارجین ما به جای قالب */
  padding: 0 !important;
  font-weight: 900 !important;
  font-size: 14px !important;
  color: var(--mdc-ink) !important;
  line-height: 1.7 !important;
  min-height: 44px;
  /* برش متن */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.mdc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px; /* فاصله تا دکمه */
}

.mdc-price {
  font-weight: 900;
  color: var(--mdc-primary);
  font-size: 14px;
  white-space: nowrap;
}

/* استایل قیمت خط خورده */
.mdc-price del {
  color: #999;
  font-size: 11px;
  margin-left: 5px;
  text-decoration: line-through !important;
}

.mdc-stock {
  font-size: 12px;
  font-weight: 900;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(214, 177, 94, .16);
  border: 1px solid rgba(214, 177, 94, .28);
  color: var(--mdc-ink);
  white-space: nowrap;
  line-height: 1;
}

.mdc-cta {
  margin-top: 0; /* فاصله توسط meta هندل شده */
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(30, 92, 109, .18);
  background: linear-gradient(135deg, var(--mdc-primary), var(--mdc-primary-dark));
  color: #fff !important; /* رنگ سفید اجباری */
  font-weight: 900;
  text-decoration: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%; /* تمام عرض */
}

.mdc-cta:hover {
  filter: brightness(1.03);
  color: #fff !important;
}

/* ریسپانسیو */
@media(max-width: 640px) {
  .mdc-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .mdc-controls {
    width: 100%;
    justify-content: space-between;
  }
  .mdc-card {
    flex-basis: 82%; /* نمایش تکی در موبایل */
    width: 82% !important;
    max-width: 82% !important;
  }
  .mdc-title {
    font-size: 16px !important;
  }
}

/* =========================================
   SINGLE POST: 4 visible + horizontal scroll
   فقط داخل صفحه نوشته (mdsp__content)
========================================= */

.mdsp__content .mdc-wrap{ 
  width:100%;
  max-width:100%;
}

/* همیشه اسکرول افقی فعال باشد */
.mdsp__content .mdc-track{
  overflow-x:auto !important;
  overflow-y:hidden !important;
  flex-wrap:nowrap !important;
}

/* در صفحه نوشته: کارت‌ها 4 تا در عرض */
.mdsp__content .mdc-card{
  /* override سایز ثابت 240px */
  width:auto !important;
  max-width:none !important;

  /* 4 کارت در عرض (با gap=14 => 3 تا فاصله) */
  flex: 0 0 calc((100% - 14px * 3) / 4) !important;
}

/* ارتفاع تصویر در صفحه نوشته کمی جمع‌وجور */
.mdsp__content .mdc-thumb{
  height: 120px !important;   /* اگر خواستی کوچکتر: 110px */
  aspect-ratio: auto !important;
}

/* تبلت: 2 کارت */
@media (max-width: 920px){
  .mdsp__content .mdc-card{
    flex: 0 0 calc((100% - 14px) / 2) !important;
  }
}

/* موبایل: 1 کارت */
@media (max-width: 520px){
  .mdsp__content .mdc-card{
    flex: 0 0 85% !important;
  }
}
