/* ==========================================================
   صفحه‌ی تک‌محصول — رنگ اصلی را فقط از همین بخش عوض کن
   ========================================================== */
:root {
  --sp-accent: #4f46e5;
  --sp-accent-dark: #4338ca;
  --sp-text: #1f2430;
  --sp-muted: #6b7280;
  --sp-border: #e7e9f0;
  --sp-bg: #f6f7fb;
  --sp-card: #ffffff;
  --sp-radius: 16px;
  --sp-ok: #16a34a;
  --sp-warn: #d97706;
  --sp-bad: #dc2626;
}

.sp-main { background: var(--sp-bg); padding: 24px 0 56px; color: var(--sp-text); }
.sp-container { width: min(1200px, 100% - 32px); margin-inline: auto; }

/* ---------- مسیر صفحه ---------- */
.sp-breadcrumb {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 13px; color: var(--sp-muted); margin-bottom: 18px;
}
.sp-breadcrumb a { color: var(--sp-muted); text-decoration: none; }
.sp-breadcrumb a:hover { color: var(--sp-accent); }
.sp-sep { opacity: .5; }

/* ---------- چیدمان بالای صفحه ---------- */
.sp-top { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: start; }
@media (min-width: 900px) {
  .sp-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 36px; }
}

/* ---------- گالری ---------- */
.sp-gallery {
  position: relative; background: var(--sp-card);
  border: 1px solid var(--sp-border); border-radius: var(--sp-radius); padding: 14px;
}
.sp-gallery .woocommerce-product-gallery {
  float: none !important; width: 100% !important; margin: 0 !important; opacity: 1 !important;
}
.sp-gallery .woocommerce-product-gallery__wrapper { margin: 0; }
.sp-gallery .woocommerce-product-gallery__image img {
  width: 100%; height: auto; display: block; border-radius: 12px;
}
.sp-gallery .flex-control-thumbs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  list-style: none; margin: 12px 0 0; padding: 0;
}
.sp-gallery .flex-control-thumbs li { float: none !important; width: 100% !important; margin: 0; }
.sp-gallery .flex-control-thumbs img {
  width: 100%; aspect-ratio: 1; object-fit: cover; cursor: pointer;
  border-radius: 10px; border: 2px solid transparent; opacity: .7; transition: .2s;
}
.sp-gallery .flex-control-thumbs img.flex-active,
.sp-gallery .flex-control-thumbs img:hover { opacity: 1; border-color: var(--sp-accent); }
.sp-gallery .onsale {
  position: absolute; z-index: 5; top: 24px; inset-inline-start: 24px;
  min-height: 0; min-width: 0; line-height: 1; margin: 0;
  background: var(--sp-bad); color: #fff; border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 700;
}

/* ---------- اطلاعات محصول ---------- */
.sp-summary {
  background: var(--sp-card); border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius); padding: 24px;
}
.sp-title { font-size: clamp(21px, 3.2vw, 30px); line-height: 1.5; font-weight: 800; margin: 0 0 10px; }
.sp-rating { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--sp-muted); margin-bottom: 12px; }
.sp-rating a { color: inherit; text-decoration: none; }
.sp-rating .star-rating { margin: 0; float: none; }

.sp-price { font-size: clamp(22px, 3.4vw, 30px); font-weight: 800; color: var(--sp-accent); margin: 6px 0 16px; }
.sp-price del { color: var(--sp-muted); font-size: .65em; font-weight: 500; margin-inline-end: 8px; }
.sp-price ins { text-decoration: none; }

.sp-excerpt { color: #4b5160; font-size: 15px; line-height: 2; margin-bottom: 18px; }
.sp-excerpt p { margin: 0 0 8px; }

.sp-meta {
  list-style: none; margin: 0 0 20px; padding: 14px 0;
  border-block: 1px dashed var(--sp-border); display: grid; gap: 10px; font-size: 14px;
}
.sp-meta li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sp-meta .lbl { color: var(--sp-muted); min-width: 84px; }
.sp-meta a { color: var(--sp-accent); text-decoration: none; }

.sp-stock {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.sp-stock::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sp-stock.in   { color: var(--sp-ok);   background: #e8f7ee; }
.sp-stock.back { color: var(--sp-warn); background: #fff4e0; }
.sp-stock.out  { color: var(--sp-bad);  background: #fdecec; }

/* ---------- تعداد و افزودن به سبد ---------- */
.sp-cart > p.stock { display: none; } /* موجودی را بالاتر خودمان نشان دادیم */
.sp-cart form.cart { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; margin: 0; }
.sp-cart .quantity {
  display: inline-flex; align-items: center; direction: ltr; overflow: hidden;
  background: #fff; border: 1px solid var(--sp-border); border-radius: 12px;
}
.sp-cart .quantity input.qty {
  width: 56px; min-height: 48px; padding: 0; border: 0; background: transparent;
  text-align: center; font-size: 16px; font-weight: 700; -moz-appearance: textfield;
}
.sp-cart .quantity input.qty::-webkit-outer-spin-button,
.sp-cart .quantity input.qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sp-cart .qty-btn {
  width: 42px; align-self: stretch; border: 0; background: #f3f4f9;
  color: var(--sp-text); font-size: 20px; line-height: 1; cursor: pointer;
}
.sp-cart .qty-btn:hover { background: #e8eaf5; }

.sp-cart .single_add_to_cart_button.button.alt {
  flex: 1 1 180px; min-height: 48px; padding: 0 22px; border: 0; border-radius: 12px;
  background: var(--sp-accent); color: #fff; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: background .2s, transform .1s;
}
.sp-cart .single_add_to_cart_button.button.alt:hover { background: var(--sp-accent-dark); }
.sp-cart .single_add_to_cart_button.button.alt:active { transform: scale(.98); }
.sp-cart .single_add_to_cart_button.disabled { opacity: .5; cursor: not-allowed; }

/* محصول متغیر (انتخاب رنگ، سایز و ...) */
.sp-cart table.variations { width: 100%; flex: 1 0 100%; border: 0; margin: 0 0 4px; }
.sp-cart table.variations td, .sp-cart table.variations th { display: block; padding: 0 0 8px; border: 0; text-align: start; }
.sp-cart table.variations select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--sp-border); border-radius: 12px; background: #fff; font: inherit;
}
.sp-cart .woocommerce-variation-add-to-cart { display: flex; flex-wrap: wrap; gap: 12px; flex: 1 0 100%; }

/* ---------- بخش‌ها ---------- */
.sp-section {
  background: var(--sp-card); border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius); padding: 24px; margin-top: 24px;
}
.sp-section__title {
  position: relative; margin: 0 0 16px; padding-inline-start: 14px;
  font-size: 20px; font-weight: 800;
}
.sp-section__title::before {
  content: ""; position: absolute; inset-inline-start: 0; top: .25em; bottom: .25em;
  width: 4px; border-radius: 4px; background: var(--sp-accent);
}
.sp-desc { color: #3b4150; font-size: 15px; line-height: 2.1; }
.sp-desc img { max-width: 100%; height: auto; border-radius: 12px; }

/* ---------- دیدگاه‌ها ---------- */
.sp-reviews .woocommerce-Reviews-title,
.sp-reviews .comment-reply-title { display: block; margin: 0 0 14px; font-size: 18px; font-weight: 800; }
.sp-reviews ol.commentlist { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 14px; }
.sp-reviews ol.commentlist li { margin: 0; padding: 0; }
.sp-reviews .comment_container {
  display: flex; align-items: flex-start; gap: 14px; padding: 16px;
  background: var(--sp-bg); border-radius: 14px;
}
.sp-reviews .comment_container img.avatar {
  position: static; float: none; flex: none; width: 48px; height: 48px;
  padding: 0; border: 0; border-radius: 50%; background: #fff;
}
.sp-reviews .comment-text { flex: 1; margin: 0 !important; padding: 0 !important; border: 0 !important; }
.sp-reviews .comment-text p { margin: 6px 0 0; line-height: 1.9; }
.sp-reviews .comment-text .meta { margin: 0 0 6px !important; font-size: 13px; color: var(--sp-muted); }
.sp-reviews .woocommerce-review__author { color: var(--sp-text); font-weight: 700; }
.sp-reviews .woocommerce-noreviews,
.sp-reviews .woocommerce-verification-required { color: var(--sp-muted); }

.sp-reviews .comment-form { display: grid; gap: 14px; }
.sp-reviews .comment-form label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.sp-reviews .comment-form input[type="text"],
.sp-reviews .comment-form input[type="email"],
.sp-reviews .comment-form textarea {
  width: 100%; box-sizing: border-box; padding: 12px 14px; font: inherit;
  background: #fff; border: 1px solid var(--sp-border); border-radius: 12px;
}
.sp-reviews .comment-form textarea { min-height: 130px; resize: vertical; }
.sp-reviews .comment-form input:focus,
.sp-reviews .comment-form textarea:focus { outline: 2px solid var(--sp-accent); outline-offset: 1px; }
.sp-reviews .comment-form-cookies-consent { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sp-reviews .comment-form-cookies-consent label { margin: 0; font-weight: 400; }
.sp-reviews p.stars { margin: 0 0 4px; }
.sp-reviews .form-submit { margin: 0; }
.sp-reviews .form-submit input#submit {
  padding: 12px 28px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--sp-accent); color: #fff; font-weight: 700;
}
.sp-reviews .form-submit input#submit:hover { background: var(--sp-accent-dark); }

/* ---------- محصولات مرتبط ---------- */
.sp-related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.sp-card {
  display: flex; flex-direction: column; overflow: hidden; background: #fff;
  border: 1px solid var(--sp-border); border-radius: 14px;
  transition: box-shadow .2s, transform .2s;
}
.sp-card:hover { box-shadow: 0 10px 28px rgba(31, 36, 48, .1); transform: translateY(-3px); }
.sp-card__img { display: block; aspect-ratio: 1 / 1; overflow: hidden; background: var(--sp-bg); }
.sp-card__img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.sp-card:hover .sp-card__img img { transform: scale(1.05); }
.sp-card__body { display: flex; flex-direction: column; flex: 1; gap: 8px; padding: 14px; }
.sp-card__title { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.7; }
.sp-card__title a {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; color: var(--sp-text); text-decoration: none;
}
.sp-card__price { margin-top: auto; color: var(--sp-accent); font-weight: 800; }
.sp-card__price del { color: var(--sp-muted); font-size: .85em; font-weight: 500; }
.sp-card__price ins { text-decoration: none; }
.sp-card__btn {
  display: block; padding: 9px; text-align: center; font-weight: 700; text-decoration: none;
  color: var(--sp-accent); border: 1.5px solid var(--sp-accent); border-radius: 10px; transition: .2s;
}
.sp-card__btn:hover { background: var(--sp-accent); color: #fff; }

/* ---------- ریسپانسیو ---------- */
@media (max-width: 820px) {
  .sp-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .sp-main { padding-top: 16px; }
  .sp-summary, .sp-section { padding: 16px; }
  .sp-gallery { padding: 10px; }
  .sp-cart .single_add_to_cart_button.button.alt { flex-basis: 100%; }
  .sp-cart .quantity { width: 100%; justify-content: space-between; }
  .sp-cart .quantity input.qty { flex: 1; }
}
@media (max-width: 480px) {
  .sp-related-grid { grid-template-columns: 1fr; }
}
