/* =========================================================
   Yadaki Product UI — 2026 RTL (Safe for header/layout)
   - فقط روی صفحات محصول: body.yadaki-product
   - بدون دست زدن به کانتینرهای کلی قالب/هدر
   - Fix Woo gallery multi-images + better qty UI
========================================================= */

:root{
  --p-border:#e5e7eb;
  --p-muted:#64748b;
  --p-text:#0f172a;
  --p-accent:#2563eb;
  --p-radius:22px;
  --p-shadow2: 0 10px 28px rgba(15,23,42,.06);
  --p-bg:#f8fafc;
}

.yadaki-product{
  direction: rtl;
  background: var(--p-bg);
}

/* کانتینر کلی صفحه محصول */
.yadakiProduct{
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

/* دسکتاپ: راست = عکس | چپ = اطلاعات (RTL قطعی) */
.yadakiProductGrid{
  display: grid;
  direction: rtl; /* ✅ خط شروع گرید راست */
  grid-template-columns: minmax(360px, 520px) 1fr; /* ستون 1 (راست) = media */
  gap: 18px;
  align-items: start;
}

/* دیگه به grid-area وابسته نیستیم */
.yadakiMediaCard{ }
.yadakiInfoCard{ }

@media (max-width: 900px){
  .yadakiProductGrid{
    grid-template-columns: 1fr;
  }
}

/* کارت‌ها */
.yadakiMediaCard,
.yadakiInfoCard{
  background:#fff;
  border:1px solid var(--p-border);
  border-radius: var(--p-radius);
  box-shadow: var(--p-shadow2);
}

/* کارت عکس */
.yadakiMediaCard{ overflow:hidden; }
.yadakiMediaTop{
  padding: 12px 14px;
  border-bottom:1px solid #eef2f7;
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.yadakiMediaTop__hint{
  font-weight:900;
  color:var(--p-muted);
  font-size:12px;
}
.yadakiMediaBody{ padding: 12px; }

/* =========================================================
   Woo Gallery (FIX multi-image)
   - wrapper MUST NOT be flex
   - fallback فقط وقتی flexslider فعال نیست
   - وقتی flexslider فعاله: هیچ چیزی hidden نشه
========================================================= */

.yadaki-product .woocommerce-product-gallery{ margin:0 !important; }

/* wrapper box */
.yadaki-product .woocommerce-product-gallery__wrapper{
  border-radius: 18px;
  overflow: hidden;
  background:#fff;
  border:1px solid #eef2f7;
  padding: 14px;
  min-height: 420px;
  display: block;          /* ✅ مهم */
}

@media (max-width: 900px){
  .yadaki-product .woocommerce-product-gallery__wrapper{
    min-height: 320px;
  }
}

/* each slide */
.yadaki-product .woocommerce-product-gallery__image{
  display:block;
  text-align:center;
}

/* image */
.yadaki-product .woocommerce-product-gallery__image img{
  max-width: 100%;
  max-height: 380px;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  display: inline-block;
}

/* when flexslider exists */
.yadaki-product .woocommerce-product-gallery .flex-viewport{
  overflow: hidden;
  border-radius: 16px;
}

/* ✅ خیلی مهم: وقتی FlexSlider فعاله، عکس‌ها نباید hidden باشند */
.yadaki-product figure.woocommerce-product-gallery.flexslider
.woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image{
  display: block !important;
}

/* ✅ fallback فقط وقتی FlexSlider فعال نیست (بدون JS) */
.yadaki-product figure.woocommerce-product-gallery:not(.flexslider)
.woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image{
  display: none;
}
.yadaki-product figure.woocommerce-product-gallery:not(.flexslider)
.woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image:first-of-type{
  display: block;
}

/* ✅ اطمینان از دیده شدن (برخی نسخه‌های Woo opacity می‌گذارند) */
.yadaki-product .woocommerce-product-gallery,
.yadaki-product .woocommerce-product-gallery img{
  opacity: 1 !important;
  visibility: visible !important;
}

/* thumbs */
.yadaki-product .flex-control-thumbs{
  margin: 12px 0 0 !important;
  padding: 0 2px !important;
  display:flex;
  gap:10px;
  overflow:auto;
}
.yadaki-product .flex-control-thumbs li{
  width: 78px !important;
  float:none !important;
  flex: 0 0 auto;
}
.yadaki-product .flex-control-thumbs img{
  border-radius: 14px;
  border:1px solid #eef2f7;
  padding: 6px;
  background:#fff;
}

/* کارت اطلاعات */
.yadakiInfoCard{
  padding: 16px;
  position: sticky;
  top: 92px;
}
@media (max-width: 900px){
  .yadakiInfoCard{ position: static; }
}

.yadakiTitle{
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 950;
  line-height: 1.65;
  color: var(--p-text);
}

/* سازگاری */
.yadakiCompat{
  margin: 10px 0 12px;
  border-radius: 18px;
  padding: 12px;
  border:1px solid #eef2f7;
  background: #f8fafc;
}
.yadakiCompat__title{ font-weight:950; margin:0 0 6px; }
.yadakiCompat__desc{
  margin:0;
  color:var(--p-muted);
  font-weight:800;
  font-size:12px;
  line-height:1.9;
}
.yadakiCompat--ok{ background: rgba(22,163,74,.08); border-color: rgba(22,163,74,.22); }
.yadakiCompat--warn{ background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.25); }
.yadakiCompat--none{ background: rgba(37,99,235,.08); border-color: rgba(37,99,235,.18); }

/* خرید */
.yadakiBuyBox{
  margin-top: 12px;
  padding: 12px;
  border-radius: 18px;
  border:1px solid #eef2f7;
  background:#fff;
}
.yadakiBuyBox .price{ margin:0 0 10px !important; }
.yadakiBuyBox .price .woocommerce-Price-amount{
  color: var(--p-accent);
  font-weight: 950;
  font-size: 20px;
}
.yadakiBuyBox .cart{ margin:0 !important; }

/* ✅ Quantity UI بهتر */
.yadakiBuyBox .quantity{
  margin: 10px 0 12px;
  display: flex;
  justify-content: flex-end;
}
.yadaki-product .quantity .qty{
  width: 110px !important;
  height: 44px !important;
  border-radius: 12px !important;
  border: 1px solid #e5e7eb !important;
  background: #fff !important;
  font-weight: 900;
  text-align: center;
  outline: none;
  box-shadow: none !important;
}
.yadaki-product .quantity .qty:focus{
  border-color: rgba(37,99,235,.45) !important;
  box-shadow: 0 0 0 4px rgba(37,99,235,.12) !important;
}
/* ✅ Stepper buttons (+ / -) injected by functions.php */
.yadaki-product .quantity{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
}
.yadaki-product .quantity .yadakiQtyMinus,
.yadaki-product .quantity .yadakiQtyPlus{
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background:#fff;
  font-weight: 950;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color: var(--p-text);
  user-select:none;
  -webkit-tap-highlight-color: transparent;
}
.yadaki-product .quantity .yadakiQtyMinus:hover,
.yadaki-product .quantity .yadakiQtyPlus:hover{
  border-color: rgba(37,99,235,.35);
}
.yadaki-product .quantity .yadakiQtyMinus:active,
.yadaki-product .quantity .yadakiQtyPlus:active{
  transform: translateY(1px);
}
.yadaki-product .quantity .yadakiQtyMinus:focus-visible,
.yadaki-product .quantity .yadakiQtyPlus:focus-visible{
  outline: none;
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
  border-color: rgba(37,99,235,.45);
}
/* hide native spinners (Chrome/Safari/Firefox) */
.yadaki-product .quantity input[type=number]::-webkit-outer-spin-button,
.yadaki-product .quantity input[type=number]::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}
.yadaki-product .quantity input[type=number]{ -moz-appearance: textfield; }


/* Quantity stepper buttons (±) for better UX */
.yadakiBuyBox .yadakiQtyMinus,
.yadakiBuyBox .yadakiQtyPlus{
  width: 32px;
  height: 32px;
  line-height: 32px;
  font-size: 20px;
  font-weight: 900;
  border: 1px solid var(--p-border);
  border-radius: 12px;
  background: #fff;
  color: var(--p-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 4px;
  padding: 0;
}
.yadakiBuyBox .yadakiQtyMinus:hover,
.yadakiBuyBox .yadakiQtyPlus:hover{
  background: var(--p-accent);
  color: #fff;
}
.yadakiBuyBox .quantity{
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.yadakiBuyBox .single_add_to_cart_button{
  width:100%;
  height: 52px;
  border-radius: 16px !important;
  background: var(--p-accent) !important;
  color:#fff !important;
  font-weight: 950 !important;
  border:0 !important;
}

/* چیپ‌های اعتماد */
.yadakiTrust{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top: 12px;
}
.yadakiChip{
  display:inline-flex;
  align-items:center;
  padding: 8px 10px;
  border-radius: 999px;
  border:1px solid var(--p-border);
  background:#fff;
  font-weight:900;
  font-size:12px;
  color: var(--p-text);
}

/* =========================================================
   More section (Accordions)
========================================================= */
.yadakiMore{
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 70px;
  padding-top: 10px;
}

.yadakiAcc{
  background:#fff;
  border:1px solid var(--p-border);
  border-radius: 18px;
  box-shadow: var(--p-shadow2);
  overflow:hidden;
  margin-top: 12px;
}

.yadakiAcc__sum{
  list-style:none;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 14px 14px;
  font-weight: 950;
  color: var(--p-text);
}
.yadakiAcc__sum::-webkit-details-marker{ display:none; }

.yadakiAcc__icon{
  width: 28px;
  height: 28px;
  border-radius: 12px;
  border:1px solid #eef2f7;
  background: #f8fafc;
  position: relative;
  flex: 0 0 28px;
}
.yadakiAcc__icon::before,
.yadakiAcc__icon::after{
  content:"";
  position:absolute;
  inset:0;
  margin:auto;
  background: var(--p-accent);
  border-radius: 2px;
}
.yadakiAcc__icon::before{ width: 12px; height: 2px; }
.yadakiAcc__icon::after{ width: 2px; height: 12px; }

.yadakiAcc[open] .yadakiAcc__icon::after{ display:none; }

.yadakiAcc__body{
  border-top:1px solid #eef2f7;
  padding: 14px;
}

.yadakiRichText{
  color: var(--p-text);
  font-weight: 800;
  font-size: 13px;
  line-height: 2;
}
.yadakiRichText p{ margin: 0 0 10px; }
.yadakiRichText p:last-child{ margin-bottom:0; }

/* مشخصات فنی داخل آکاردئون */
.yadakiSpecGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}
@media (max-width: 560px){ .yadakiSpecGrid{ grid-template-columns: 1fr; } }

.yadakiSpec{
  border:1px solid #eef2f7;
  border-radius: 16px;
  padding: 10px 12px;
  background:#f8fafc;
}
.yadakiSpec__k{ font-size: 11px; color: var(--p-muted); font-weight: 900; margin:0 0 4px; }
.yadakiSpec__v{ font-size: 12px; color: var(--p-text); font-weight: 950; margin:0; line-height:1.85; }

/* لیست ارسال */
.yadakiDelivery{
  list-style:none;
  padding: 0;
  margin: 0;
  color: var(--p-text);
  font-weight: 850;
  font-size: 12px;
  line-height: 2.1;
}
.yadakiDelivery li{
  display:flex;
  gap:10px;
  align-items:flex-start;
  margin-top: 6px;
}
.yadakiDelivery li:first-child{ margin-top:0; }
.yadakiDelivery li::before{
  content:"•";
  color: var(--p-accent);
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
}

/* مخفی کردن متا/related/tabs پیش‌فرض (اگه جایی ظاهر شد) */
.yadaki-product .product_meta,
.yadaki-product .related.products,
.yadaki-product .woocommerce-tabs{
  display:none !important;
}

/* =========================================================
   Custom Gallery Styles (yadakiGallery)
   - Used by custom gallery markup in functions.php
   - Provides styled main image and thumbnails
========================================================= */

.yadakiGallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.yadakiGallery__main {
  position: relative;
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  background: #fff;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yadakiGallery__main .yadakiGallery__frame {
  width: 100%;
  max-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yadakiGallery__main .yadakiGallery__frame img {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
  display: block;
}

.yadakiGallery__zoom {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 18px;
  color: var(--p-accent);
  text-decoration: none;
  cursor: pointer;
}

.yadakiGallery__thumbs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  padding: 8px;
  background: #fff;
}

.yadakiGallery__thumb {
  width: 80px;
  height: 80px;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
}

.yadakiGallery__thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.yadakiGallery__thumb.is-active {
  border-color: var(--p-accent);
}

/* =========================================================
   ✅ FIX نهایی: جلوگیری از "دو تا گالری"
   اگر به هر دلیل گالری پیش‌فرض ووکامرس هم رندر شد،
   اینجا مخفی میشه تا فقط yadakiGallery دیده بشه.
   (در functions.php هم remove_action انجام شده)
========================================================= */
.yadaki-product .woocommerce-product-gallery{
  display:none !important;
}

/* =========================
   (1) Mobile gallery behavior
========================= */
@media (max-width: 900px){
  .yadakiGallery__main .yadakiGallery__frame{
    max-height: 320px;
  }
  .yadakiGallery__thumbs{
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 10px;
  }
  .yadakiGallery__thumb{
    scroll-snap-align: start;
    width: 74px;
    height: 74px;
  }
}

/* لمس بهتر */
.yadakiGallery__thumb,
.yadakiGallery__zoom{
  -webkit-tap-highlight-color: transparent;
}
/* =========================
   (2) Image stability + CLS fix
========================= */
.yadakiGallery__main .yadakiGallery__frame{
  width: 100%;
  aspect-ratio: 1 / 1;      /* قاب ثابت */
  max-height: 420px;
}

@media (max-width: 900px){
  .yadakiGallery__main .yadakiGallery__frame{
    max-height: 320px;
  }
}

.yadakiGallery__main .yadakiGallery__frame img{
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* =========================
   (3) Buy box UX polish
========================= */
.yadakiBuyBox{
  display: grid;
  gap: 10px;
}

.yadakiBuyBox .cart{
  display: grid;
  gap: 10px;
}

.yadakiBuyBox .single_add_to_cart_button:disabled,
.yadakiBuyBox .single_add_to_cart_button.disabled{
  opacity: .55;
  cursor: not-allowed;
}

/* پیام‌های ووکامرس داخل کارت */
.yadakiInfoCard .woocommerce-notices-wrapper{
  margin: 8px 0 0;
}
.yadakiInfoCard .woocommerce-message,
.yadakiInfoCard .woocommerce-error,
.yadakiInfoCard .woocommerce-info{
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 800;
}
