/* =====================================================
   LATEST PRODUCTS — عیناً فونت‌ایران
===================================================== */

:root {
  --br-1: 4px;
  --br-2: 8px;
  --br-3: 12px;
  --br-4: 16px;
  --br-round: 9999px;
  --fs-2: 0.694rem;
  --fs-2-5: 0.722rem;
  --fs-3: 0.833rem;
  --fs-4: 1rem;
  --fs-5: 1.2rem;
  --c-grey-light-8: #f9f9fc;
  --c-grey-light-7: #f3f3f7;
  --c-grey-light-6: #ebebef;
  --c-grey-light-5: #e8e8ec;
  --c-grey-light-4: #d1d1d8;
  --c-grey-light-2: #b1b1b8;
  --c-grey:         #919199;
  --c-grey-dark-2:  #636369;
  --c-grey-dark-5:  #2d2d33;
  --c-text-1:       #1f1a1e;
  --c-red-3:        #b32a65;
  --c-red:          #b32a65;
  --white:          #ffffff;
}

/* ═══════════════════════════════════════════════════════
   SECTION WRAPPER
═══════════════════════════════════════════════════════ */
.latest-products {
  padding: 50px 0;
  border-bottom: 1px solid var(--c-grey-light-5);
  background: var(--white);
}

.latest-products .page-container {
  max-width: 100%;
}

.latest-products .page-width {
  margin: 0 auto;
  padding: 0 15px;
  width: 100%;
  max-width: 1220px;
}

/* ═══════════════════════════════════════════════════════
   SECTION TITLE — «پرفروش‌ترین» + «مشاهده همه»
═══════════════════════════════════════════════════════ */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 25px;
  gap: 12px;
}

.section-title .title {
  font-size: var(--fs-5);
  margin: 0;
  padding: 5px 0;
  color: var(--c-text-1);
  font-weight: 700;
}

.section-title .view-more {
  text-decoration: none;
  font-size: var(--fs-3);
  font-weight: 500;
  color: var(--c-grey-dark-2);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color .2s ease;
}

.section-title .view-more .icon {
  display: flex;
  align-items: center;
  transition: transform .25s ease;
}

.section-title .view-more:hover {
  color: var(--c-red-3);
}

.section-title .view-more:hover .icon {
  transform: translateX(-4px);
}

/* ═══════════════════════════════════════════════════════
   CARDS WRAPPER — گرید
═══════════════════════════════════════════════════════ */
.cards-wrapper {
  padding: 10px 0 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* ═══════════════════════════════════════════════════════
   CARD
═══════════════════════════════════════════════════════ */
.card.small {
  width: 100%;
  min-width: 0;
}

.card.small .wrapper {
  background-color: var(--c-grey-light-7);
  border-radius: var(--br-3);
  overflow: hidden;
  transition: 0.25s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--c-grey-light-6);
}

.card.small:hover .wrapper {
  background-color: var(--c-grey-light-6);
  border-color: var(--c-grey-light-4);
  box-shadow: 0 12px 24px -12px rgba(179, 42, 101, .18);
  transform: translateY(-3px);
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  position: relative;
}

/* ───── تصویر ───── */
.card.small .thumb {
  width: 100%;
  height: 220px;
  position: relative;
  overflow: hidden;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card.small .thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform .4s ease;
}

.card.small:hover .thumb img {
  transform: scale(1.06);
}

.card.small .no-image {
  font-size: 3.5rem;
  opacity: .3;
}

/* بج تخفیف (٪) */
.card.small .discount-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #d7194b;
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  padding: 3px 10px 4px;
  border-radius: 999px;
  z-index: 2;
  letter-spacing: .5px;
}

/* بج محصول */
.card.small .badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--c-red-3);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  padding: 3px 10px 4px;
  border-radius: 999px;
  z-index: 2;
}

/* ناموجود */
.card.small .out-of-stock {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .7);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d7194b;
  font-weight: 800;
  font-size: 1rem;
  z-index: 3;
}

/* ───── متن ───── */
.card.small .details {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card.small .details-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.card.small .details .title {
  font-size: var(--fs-4);
  font-weight: 700;
  color: var(--c-text-1);
  margin: 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.9em;
  transition: color .2s ease;
}

.card.small .details-link:hover .title {
  color: var(--c-red-3);
}

/* ───── بج دسته ───── */
.card.small .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.card.small .tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  font-size: var(--fs-2);
  color: var(--c-grey-dark-2);
  background-color: var(--white);
  border-radius: var(--br-round);
  text-decoration: none;
  transition: background-color .2s ease, color .2s ease;
  font-weight: 500;
}

.card.small .tag:hover {
  background-color: var(--c-red-3);
  color: #fff;
}

/* ───── قیمت ───── */
.card.small .price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}

.card.small .price .old-price {
  font-size: .82rem;
  color: #b8aeba;
  text-decoration: line-through;
  font-weight: 400;
}

.card.small .price .value {
  font-weight: 800;
  font-size: var(--fs-5);
  color: var(--c-red-3);
  font-feature-settings: "ss02";
}

.card.small .price .currency {
  font-size: var(--fs-2);
  font-weight: 300;
  color: var(--c-grey);
}

/* ═══════════════════════════════════════════════════════
   ADD-TO-CART BUTTON
═══════════════════════════════════════════════════════ */
.card.small .add-to-cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  margin-top: 4px;
  border: 1px solid transparent;
  border-radius: var(--br-2);
  background: var(--c-red-3);
  color: #fff;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.25s ease;
  flex-shrink: 0;
}

.card.small .add-to-cart:hover {
  background: #9a2457;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px -6px rgba(179, 42, 101, .5);
}

.card.small .add-to-cart:active {
  transform: translateY(0);
}

.card.small .add-to-cart svg {
  flex-shrink: 0;
}

.card.small .add-to-cart.disabled,
.card.small .add-to-cart:disabled {
  background: var(--c-grey-light-5);
  color: var(--c-grey);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* حالت loading */
.card.small .add-to-cart.is-loading {
  pointer-events: none;
  opacity: .75;
}

.card.small .add-to-cart.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: prodSpin .7s linear infinite;
}

.card.small .add-to-cart.is-loading svg {
  display: none;
}

/* حالت موفق */
.card.small .add-to-cart.is-done {
  background: #27ae60;
}

.card.small .add-to-cart.is-done svg {
  animation: prodPop .35s ease;
}

@keyframes prodSpin {
  to { transform: rotate(360deg); }
}

@keyframes prodPop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ═══════════════════════════════════════════════════════
   MOBILE VIEW-ALL
═══════════════════════════════════════════════════════ */
.mobile-view-all {
  display: none;
  text-align: center;
  padding: 14px 0;
  margin-top: 12px;
  background: var(--c-grey-light-7);
  color: var(--c-text-1);
  text-decoration: none;
  border-radius: var(--br-2);
  font-weight: 600;
  font-size: var(--fs-3);
  transition: background .2s ease;
}

.mobile-view-all:hover {
  background: var(--c-grey-light-6);
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════ */

/* ─── تبلت ─── */
@media (max-width: 991px) {
  .cards-wrapper {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }

  .card.small .thumb {
    height: 180px;
    padding: 14px;
  }

  .card.small .details {
    padding: 12px 14px 14px;
  }

  .card.small .details .title {
    font-size: .92rem;
  }

  .card.small .price .value {
    font-size: 1.05rem;
  }
}

/* ─── موبایل ─── */
@media (max-width: 640px) {
  .latest-products {
    padding: 30px 0;
  }

  .cards-wrapper {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .card.small .thumb {
    height: 150px;
    padding: 12px;
  }

  .card.small .details {
    padding: 10px 12px 12px;
    gap: 6px;
  }

  .card.small .details .title {
    font-size: .82rem;
    min-height: 2.6em;
  }

  .card.small .tag {
    font-size: .62rem;
    height: 20px;
    padding: 0 8px;
  }

  .card.small .price .old-price {
    font-size: .68rem;
  }

  .card.small .price .value {
    font-size: .92rem;
  }

  .card.small .price .currency {
    font-size: .64rem;
  }

  .card.small .add-to-cart {
    height: 34px;
    font-size: .72rem;
    gap: 4px;
  }

  .card.small .add-to-cart svg {
    width: 13px;
    height: 13px;
  }

  .card.small .discount-badge {
    top: 8px;
    right: 8px;
    font-size: .62rem;
    padding: 2px 8px 3px;
  }

  .card.small .badge {
    top: 8px;
    left: 8px;
    font-size: .6rem;
    padding: 2px 8px 3px;
  }

  /* نمایش دکمه view-more در انتهای گرید به صورت کامل */
  .section-title .view-more {
    display: none;
  }

  .mobile-view-all {
    display: block;
  }
}

@media (max-width: 360px) {
  .card.small .thumb {
    height: 130px;
  }

  .card.small .details .title {
    font-size: .78rem;
  }

  .card.small .add-to-cart {
    font-size: .68rem;
    padding: 0 8px;
  }
}

/* ═══════════════════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════════════════ */
[data-theme="dark"] .latest-products {
  background: #121014;
  border-bottom-color: #2a242f;
}

[data-theme="dark"] .card.small .wrapper {
  background-color: #1e1b22;
  border-color: #2a242f;
}

[data-theme="dark"] .card.small:hover .wrapper {
  background-color: #262230;
  border-color: #3a3440;
}

[data-theme="dark"] .card.small .thumb {
  background: #191620;
}

[data-theme="dark"] .card.small .details .title {
  color: #f8f4f7;
}

[data-theme="dark"] .card.small .tag {
  background: #2a242f;
  color: #c9c9cf;
}

[data-theme="dark"] .card.small .tag:hover {
  background: var(--c-red-3);
  color: #fff;
}

[data-theme="dark"] .card.small .out-of-stock {
  background: rgba(18, 16, 20, .75);
}

[data-theme="dark"] .mobile-view-all {
  background: #1e1b22;
  color: #f8f4f7;
}

[data-theme="dark"] .mobile-view-all:hover {
  background: #262230;
}