/* ============================================================
   PRODUCT CARD & SINGLE PRODUCT STYLES
   segma-commerce-theme/assets/css/product.css
   ============================================================ */

/* ── PRODUCT GRID ────────────────────────────────────────────── */
.products-section,
.segma-archive-products {
  padding: 20px 0 40px;
}

.segma-products-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  align-items: start;
}

.no-products {
  text-align: center;
  color: var(--clr-text-muted);
  padding: 40px;
  grid-column: 1/-1;
}

/* ── PRODUCT CARD ────────────────────────────────────────────── */
.product-card {
  background: var(--clr-white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  position: relative;
  display: flex;
  flex-direction: column; /* equal-height cards: info grows to fill, button stays at bottom */
  transition: box-shadow var(--transition), transform var(--transition);
}

.product-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

/* Discount badge */
.product-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--clr-badge-bg);
  color: var(--clr-badge-text);
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  box-shadow: 0 2px 6px var(--shadow-primary-strong);
}

/* Image */
.product-card__image-link {
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f9f9f9;
}

.product-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.product-card:hover .product-card__img {
  transform: scale(1.04);
}

/* Info — fills all remaining card space so buttons always land at the bottom */
.product-card__info {
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;  /* grow to fill card height */
}

/* Title — always exactly 2 lines tall */
.product-card__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--clr-text);
  line-height: 1.45;
  /* Fixed height = 2 lines. Short titles leave a blank line; long ones get … */
  height: calc(1.45em * 2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.product-card__title a {
  color: inherit;
}

.product-card__title a:hover {
  color: var(--clr-primary);
}

/* Price */
.product-card__price-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 700;
  color: var(--clr-price-new);
}

.product-card__price-wrap del {
  font-size: 11px;
  color: var(--clr-price-old);
  text-decoration: line-through;
  font-weight: 400;
}

.product-card__price-wrap ins {
  text-decoration: none;
}

/* WC price override */
.product-card__price-wrap .woocommerce-Price-amount {
  font-size: inherit;
}

/* Add to Cart */
.product-card__atc {
  margin-top: auto;
  font-size: 12px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
}

.product-card__atc.loading {
  opacity: 0.7;
  pointer-events: none;
}

.product-card__atc.added {
  background: var(--clr-price-good);
}

/* ── SUBCATEGORY PILLS ───────────────────────────────────────── */
.subcategory-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.subcat-pill {
  display: inline-block;
  background: var(--clr-white);
  border: 1.5px solid var(--clr-primary);
  color: var(--clr-primary);
  border-radius: 20px;
  padding: 4px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
}

.subcat-pill:hover {
  background: var(--clr-primary);
  color: var(--clr-white);
}

/* ── PAGINATION ─────────────────────────────────────────────── */
.wc-pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.wc-pagination a,
.wc-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid var(--clr-border);
  color: var(--clr-text);
  transition: all var(--transition);
}

.wc-pagination a:hover,
.wc-pagination .current {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: var(--clr-white);
}

/* ── SINGLE PRODUCT ────────────────────────────────────────── */
.segma-single-product {
  padding-top: 24px;
  padding-bottom: 48px;
}

.sp-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

/* Images (right column in RTL) */
.sp-images {
  order: 1;
}

.sp-info {
  order: 2;
}

.sp-main-image-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #f9f9f9;
  margin-bottom: 10px;
  aspect-ratio: 1 / 1;
  width: 100%;
  position: relative;
  /* image inside is absolutely positioned */
}

.sp-main-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s;
}

/* Thumbnails */
.sp-thumbnails {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sp-thumb {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--clr-border);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: #f9f9f9;
  transition: border-color var(--transition);
  flex-shrink: 0;
}

.sp-thumb:hover {
  border-color: var(--clr-primary);
}

.sp-thumb.is-active {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 2px var(--shadow-primary-focus);
}

.sp-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Info Panel */
.sp-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--clr-text);
  margin-bottom: 12px;
  line-height: 1.4;
}

.sp-price-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.sp-badge {
  background: var(--clr-white);
  color: var(--clr-primary);
  border: 1px solid var(--clr-primary);
  font-size: 14px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sp-price-old {
  font-size: 15px;
  color: var(--clr-price-old);
  text-decoration: line-through;
}

.sp-price-new {
  font-size: 22px;
  font-weight: 700;
  color: var(--clr-price-new);
}

.sp-price-native {
  font-size: 22px;
  font-weight: 700;
  color: var(--clr-price-new);
}

.sp-price-native del {
  font-size: 15px;
  color: var(--clr-price-old);
  text-decoration: line-through;
  font-weight: 400;
  margin-left: 8px;
}

.sp-price-native ins {
  text-decoration: none;
}

.sp-price-old .woocommerce-Price-amount {
  text-decoration: line-through;
  color: var(--clr-price-old);
}

.sp-price-new .woocommerce-Price-amount {
  color: var(--clr-price-new);
  font-size: inherit;
}

/* Short Description */
.sp-short-desc {
  font-size: 14px;
  color: #3f3f46;
  line-height: 1.65;
  margin-block: 0 18px;
  padding-block: 2px 0;
  padding-inline: 0;
  border: 0;
}

.sp-short-desc p {
  margin-block: 0 8px;
}

.sp-short-desc ul,
.sp-short-desc ol {
  margin-block: 6px 10px;
  padding-inline-start: 20px;
  padding-inline-end: 0;
}

.sp-short-desc li {
  list-style: disc;
  margin-block: 4px;
}

.sp-short-desc ol li {
  list-style: decimal;
}

/* Buttons */
.sp-atc-btn {
  font-size: 15px;
  padding: 12px 24px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
}

.sp-atc-btn.loading {
  opacity: 0.7;
  pointer-events: none;
}

.sp-atc-btn.added {
  background: var(--clr-price-good);
}

.sp-checkout-btn {
  font-size: 15px;
  padding: 10px 24px;
  margin-bottom: 16px;
}

/* Trust Badges */
.sp-trust-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.trust-badge {
  font-size: 12px;
  color: var(--clr-text-muted);
  background: #f5f5f5;
  padding: 4px 12px;
  border-radius: 20px;
}

/* ── FULL DESCRIPTION (full-width section below the grid) ── */
.sp-full-description {
  margin-top: 40px;
  border-top: 2px solid var(--clr-border);
  padding-top: 32px;
}

.sp-full-description__inner {
  font-size: 15px;
  color: #333;
  line-height: 1.9;
  direction: rtl;
  text-align: right;
}

.sp-full-description__inner h1,
.sp-full-description__inner h2,
.sp-full-description__inner h3,
.sp-full-description__inner h4 {
  font-size: 18px;
  font-weight: 700;
  margin: 20px 0 10px;
  color: var(--clr-text);
}

.sp-full-description__inner p {
  margin-bottom: 12px;
}

.sp-full-description__inner ul,
.sp-full-description__inner ol {
  padding-right: 20px;
  margin-bottom: 12px;
}

.sp-full-description__inner li {
  list-style: disc;
  margin-bottom: 6px;
}

.sp-full-description__inner ol li {
  list-style: decimal;
}

.sp-full-description__inner img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
  margin: 16px auto;
}

.sp-full-description__inner table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.sp-full-description__inner td,
.sp-full-description__inner th {
  border: 1px solid var(--clr-border);
  padding: 8px 12px;
  text-align: right;
}

/* ── RESPONSIVE PRODUCT GRID ───────────────────────────────── */
@media (max-width: 1024px) {
  .segma-products-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  .segma-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Single product: 1 column, images at TOP then info below */
  .sp-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    /* override desktop align-items:start — prevents blank space in RTL flex-column */
  }

  /* Images panel — shown first (top) on mobile */
  .sp-images {
    order: 1;
    margin-bottom: 0;
  }

  /* Info panel — shown below images on mobile */
  .sp-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    order: 2;
  }

  .sp-title {
    font-size: 22px;
    margin-bottom: 0;
  }

  .sp-price-native {
    font-size: 18px;
  }
}

@media (max-width: 360px) {
  .segma-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .product-card__title {
    font-size: 12px;
  }

  .product-card__atc {
    font-size: 11px;
    padding: 7px 4px;
  }
}

/* ── WOOCOMMERCE FORM STYLES ───────────────────────────────── */
.sp-add-to-cart-wrapper {
  --segma-swatch-selected: var(--clr-primary);
  --segma-swatch-selected-shadow: var(--shadow-primary-focus);
}

.sp-add-to-cart-wrapper form.cart {
  margin-bottom: 20px;
}

.sp-add-to-cart-wrapper .single_add_to_cart_button {
  background: var(--clr-primary);
  color: #fff;
  border: none;
  font-size: 16px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  width: 100%;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
  font-weight: 700;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sp-add-to-cart-wrapper .single_add_to_cart_button:hover {
  opacity: 0.9;
}

.sp-add-to-cart-wrapper .variations {
  width: 100%;
  margin-bottom: 15px;
}

.sp-add-to-cart-wrapper .variations td {
  padding-bottom: 10px;
  display: block;
}

.sp-add-to-cart-wrapper .variations label {
  font-weight: 600;
  margin-bottom: 5px;
  display: block;
}

.sp-add-to-cart-wrapper .variations select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
}

.sp-add-to-cart-wrapper .woocommerce-variation-price {
  margin-bottom: 15px;
}

.sp-add-to-cart-wrapper .woocommerce-variation-price .price {
  font-size: 20px;
  font-weight: 700;
  color: var(--clr-price-new);
}

.sp-add-to-cart-wrapper .segma-quantity-wrapper {
  margin-bottom: 20px;
  display: inline-block;
}

.sp-add-to-cart-wrapper .segma-quantity-label {
  display: block;
  font-size: 14px;
  color: var(--clr-text);
  margin-bottom: 5px;
  text-align: center;
}

.sp-add-to-cart-wrapper .segma-quantity-box {
  display: flex;
  align-items: center;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 44px;
  width: 140px;
  margin: 0;
  background: var(--clr-white);
}

.sp-add-to-cart-wrapper .segma-qty-btn {
  background: transparent;
  border: none;
  width: 44px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
  transition: background 0.2s;
}

.sp-add-to-cart-wrapper .segma-qty-btn:hover {
  background: #f5f5f5;
  color: #000;
}

.sp-add-to-cart-wrapper .segma-qty-input {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: #000;
  -moz-appearance: textfield;
  padding: 0;
  margin: 0;
}

.sp-add-to-cart-wrapper .segma-qty-input::-webkit-outer-spin-button,
.sp-add-to-cart-wrapper .segma-qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.sp-variation-custom-label {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
  color: var(--clr-text);
  margin: 0 0 8px;
  text-align: start;
  direction: inherit;
}

/* Hide default select and labels */
.sp-add-to-cart-wrapper table.variations {
  border: none;
  background: transparent !important;
  box-shadow: none !important;
  width: 100%;
  margin-bottom: 20px;
}

.sp-add-to-cart-wrapper table.variations td.label,
.sp-add-to-cart-wrapper table.variations th.label,
.sp-add-to-cart-wrapper table.variations th {
  display: none !important;
  /* Hide default 'Size' label because we use custom one */
}

.sp-add-to-cart-wrapper table.variations select {
  display: none !important;
}

.reset_variations {
  display: none !important;
  /* Hide "إزالة" text */
}

/* Custom Visual Radio Buttons Container */
.segma-variation-radios {
  display: flex !important;
  visibility: visible;
  flex-wrap: wrap;
  gap: 10px;
}

.segma-var-radio {
  appearance: none;
  border: 1.5px solid var(--clr-border);
  background: var(--clr-white);
  color: var(--clr-text);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 50px;
  text-align: center;
  position: relative;
  overflow: hidden;
  font-family: inherit;
}

.segma-var-radio:hover {
  border-color: #999;
}

.segma-var-radio:focus-visible {
  outline: 2px solid var(--clr-primary);
  outline-offset: 2px;
}

.segma-var-radio.selected {
  border-color: var(--segma-swatch-selected);
  background: var(--segma-swatch-selected);
  color: var(--clr-white);
}

.sp-add-to-cart-wrapper .cfvsw-swatches-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 10px;
}

.sp-add-to-cart-wrapper .cfvsw-swatches-option.cfvsw-selected-swatch,
.sp-add-to-cart-wrapper .cfvsw-swatches-option.selected,
.sp-add-to-cart-wrapper .cfvsw-swatches-option.active,
.sp-add-to-cart-wrapper .cfvsw-swatches-option[aria-checked="true"],
.sp-add-to-cart-wrapper .cfvsw-swatches-option[aria-pressed="true"] {
  border-color: var(--segma-swatch-selected) !important;
  box-shadow: 0 0 0 2px var(--segma-swatch-selected-shadow);
}

.sp-add-to-cart-wrapper .cfvsw-swatches-option.cfvsw-label-option.cfvsw-selected-swatch,
.sp-add-to-cart-wrapper .cfvsw-swatches-option.cfvsw-label-option.selected,
.sp-add-to-cart-wrapper .cfvsw-swatches-option.cfvsw-label-option.active,
.sp-add-to-cart-wrapper .cfvsw-swatches-option.cfvsw-label-option[aria-checked="true"],
.sp-add-to-cart-wrapper .cfvsw-swatches-option.cfvsw-label-option[aria-pressed="true"] {
  background: var(--segma-swatch-selected) !important;
  color: var(--clr-white) !important;
}

.segma-var-radio.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  color: #999;
  border-color: #ddd;
  background: #fcfcfc;
}

/* X Cross for out-of-stock variations */
.segma-var-radio.disabled::before,
.segma-var-radio.disabled::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -10%;
  width: 120%;
  height: 1.5px;
  background-color: #ff4d4f;
  opacity: 0.8;
}

.segma-var-radio.disabled::before {
  transform: translateY(-50%) rotate(45deg);
}

.segma-var-radio.disabled::after {
  transform: translateY(-50%) rotate(-45deg);
}

/* Mobile Sticky CTA */
.segma-mobile-sticky-cta {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--clr-white);
  padding: 10px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 999;
}

.segma-mobile-sticky-cta .btn-primary {
  width: 100%;
  margin: 0;
  font-size: 18px;
  height: 50px;
  border-radius: var(--radius-sm);
}

@media (max-width: 768px) {
  .segma-single-product {
    padding-bottom: 80px;
    /* Space for sticky button */
  }

  .segma-mobile-sticky-cta {
    display: block;
  }
}

/* ── RELATED PRODUCTS ────────────────────────────────────────── */
.segma-related-products {
  margin-top: 50px;
  margin-bottom: 30px;
  padding-top: 30px;
  border-top: 2px solid var(--clr-border);
}

.segma-related-products__title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: right;
  color: var(--clr-text);
}

.segma-related-products__slider {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 12px;
  padding-bottom: 15px; /* for scrollbar */
  scrollbar-width: none; /* Firefox */
  -webkit-overflow-scrolling: touch;
}

.segma-related-products__slider::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.segma-related-products__slider .product-card {
  scroll-snap-align: start;
  flex: 0 0 calc(25% - 9px);
  min-width: 0;
}

@media (max-width: 1024px) {
  .segma-related-products__slider .product-card {
    flex: 0 0 calc(33.333% - 8px);
  }
}

@media (max-width: 768px) {
  .segma-related-products__slider .product-card {
    flex: 0 0 calc(50% - 6px);
  }
}

/* Shopingo French/LTR overrides */
body.segma-preset-shopingo .segma-products-grid,
body.segma-preset-shopingo .segma-single-product { direction: ltr; }
body.segma-preset-shopingo .product-card,
body.segma-preset-shopingo .sp-info,
body.segma-preset-shopingo .sp-full-description { text-align: left; direction: ltr; }
body.segma-preset-shopingo .sp-layout { direction: ltr; }
body.segma-preset-shopingo .sp-trust-badges { align-items: flex-start; }
