/* ==========================================================
   درمیسا — اصلاح نهایی فروشگاه (موبایل + تبلت + دسکتاپ)
   این فایل باید آخرین CSS لود‌شده باشد (در functions.php همین‌طور ثبت می‌شود).
   ========================================================== */

/* ---------- ۱) جلوگیری از پهن‌شدن صفحه و جابه‌جا شدن هدر روی موبایل ---------- */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}
@supports (overflow: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

/* ---------- ۲) حذف «نمایش همه N نتیجه» ---------- */
.woocommerce-result-count {
  display: none !important;
}
.woocommerce-ordering {
  float: none !important;
  margin: 0 12px 16px !important;
}

/* ---------- ۳) لیست محصولات: شبکه، بدون اسکرول افقی ---------- */
.woocommerce ul.products,
.woocommerce-page ul.products,
ul.products,
.carousel-wrap:not(:has(ul.products)) {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 12px !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 0 24px !important;
  padding: 0 12px !important;
  box-sizing: border-box !important;
  clear: both !important;
  overflow: visible !important;
  scroll-snap-type: none !important;
  transform: none !important;
}
.carousel-wrap {
  overflow: visible !important;
  scroll-snap-type: none !important;
}
ul.products::before,
ul.products::after {
  display: none !important;
  content: none !important;
}

/* ---------- ۴) خود کارت ---------- */
ul.products > li.product,
.carousel-wrap:not(:has(ul.products)) > * {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  float: none !important;
  flex: none !important;
  scroll-snap-align: none !important;
  box-sizing: border-box !important;
}
ul.products li.product {
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  overflow: hidden !important; /* هیچ چیزی از کارت بیرون نمی‌زند */
}
ul.products li.product img {
  max-width: 100%;
  height: auto;
}
ul.products li.product .woocommerce-loop-product__title {
  overflow-wrap: anywhere;
}

/* ---------- ۵) دکمه‌ها (مشاهده محصول / افزودن به سبد): زیر هم و هم‌عرض کارت ---------- */
ul.products li.product :is(div, span, p):has(> .button),
ul.products li.product :is(div, span, p):has(> .added_to_cart) {
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  gap: 8px !important;
  position: static !important;
  inset: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 8px 0 0 !important;
  transform: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  box-sizing: border-box !important;
}
ul.products li.product .button,
ul.products li.product .add_to_cart_button,
ul.products li.product a.added_to_cart {
  position: static !important;
  inset: auto !important;
  transform: none !important;
  display: block !important;
  float: none !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 8px 0 0 !important;
  padding: 10px 8px !important;
  box-sizing: border-box !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
  text-align: center !important;
  white-space: normal !important;
  opacity: 1 !important;
  visibility: visible !important;
}
ul.products li.product :is(div, span, p) > .button,
ul.products li.product :is(div, span, p) > .added_to_cart {
  margin: 0 !important;
}

/* ---------- ۶) موبایل: اندازه متن کارت‌ها ---------- */
@media (max-width: 767px) {
  ul.products li.product .woocommerce-loop-product__title {
    font-size: 14px !important;
    line-height: 1.7 !important;
  }
  ul.products li.product .price {
    font-size: 15px !important;
  }
  ul.products li.product .price del {
    font-size: 12px !important;
  }
}

/* ---------- ۷) تبلت: ۳ ستون ---------- */
@media (min-width: 768px) {
  .woocommerce ul.products,
  .woocommerce-page ul.products,
  ul.products,
  .carousel-wrap:not(:has(ul.products)) {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 16px !important;
    padding: 0 !important;
  }
  .woocommerce-ordering {
    margin: 0 0 20px !important;
  }
}

/* ---------- ۸) دسکتاپ: ۴ ستون ---------- */
@media (min-width: 1100px) {
  .woocommerce ul.products,
  .woocommerce-page ul.products,
  ul.products,
  .carousel-wrap:not(:has(ul.products)) {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 20px !important;
  }
}
