/* Simple Popup Manager v2 — سمت سایت. جهت متن از خود سایت (rtl/ltr) ارث‌بری می‌شود. */

/* ---------- دیالوگ (خودش پس‌زمینهٔ تیره/تار است) ---------- */
dialog.spm-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 20px;
  border: 0;
  box-sizing: border-box;
  background: transparent;
  color: inherit;
  z-index: 999999;
  overflow: hidden;
  font-family: inherit;
}
dialog.spm-overlay::backdrop { background: transparent; }
dialog.spm-overlay[open] { display: flex; align-items: center; justify-content: center; }
dialog.spm-overlay *, dialog.spm-overlay *::before, dialog.spm-overlay *::after { box-sizing: border-box; }

html.spm-no-scroll { overflow: hidden; scrollbar-gutter: stable; }

/* مودال و تمام‌صفحه: پس‌زمینهٔ تیره + تار */
.spm-layout-modal,
.spm-layout-fullscreen {
  background: rgba(0, 0, 0, var(--spm-opacity, .55));
  -webkit-backdrop-filter: blur(var(--spm-blur, 8px));
  backdrop-filter: blur(var(--spm-blur, 8px));
}
dialog.spm-layout-modal, dialog.spm-layout-fullscreen { background: rgba(0, 0, 0, var(--spm-opacity, .55)); }

/* ---------- کادر ---------- */
.spm-modal {
  position: relative;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 28px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
  line-height: 1.8;
  text-align: start;
}
.spm-modal:focus { outline: none; }
.spm-modal :focus-visible { outline: 2px solid var(--spm-accent, #0F6E56); outline-offset: 2px; }
.spm-content img { max-width: 100%; height: auto; }
.spm-content > *:first-child { margin-top: 0; }
.spm-content > *:last-child { margin-bottom: 0; }

.spm-close {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  z-index: 3;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: #222;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.spm-close:hover { background: #fff; }

.spm-dismiss {
  display: block;
  margin: 14px auto 0;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: #6b7280;
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}
.spm-modal-vertical .spm-dismiss { margin: 0 auto 14px; }

/* ---------- چیدمان‌ها ---------- */
.spm-layout-fullscreen { padding: 0; }
.spm-layout-fullscreen .spm-modal {
  max-width: none;
  max-height: none;
  height: 100%;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 24px 24px;
}
.spm-layout-fullscreen .spm-content { width: min(100%, 760px); }

dialog.spm-layout-bar,
dialog.spm-layout-slide {
  background: transparent;
  padding: 0;
  pointer-events: none;
  width: auto;
  height: auto;
  inset: auto;
  overflow: visible;
}
dialog.spm-layout-bar[open], dialog.spm-layout-slide[open] { display: block; }
.spm-layout-bar .spm-modal,
.spm-layout-slide .spm-modal { pointer-events: auto; }

dialog.spm-layout-bar { left: 0; right: 0; width: 100%; bottom: 0; top: auto; }
dialog.spm-layout-bar.spm-pos-top { top: 0; bottom: auto; }
.spm-layout-bar .spm-modal {
  max-width: none;
  max-height: 40vh;
  border-radius: 0;
  padding: 14px 64px 14px 20px;
  padding-inline: 20px 64px;
  box-shadow: 0 -6px 30px rgba(0, 0, 0, .15);
}
.spm-layout-bar.spm-pos-top .spm-modal { box-shadow: 0 6px 30px rgba(0, 0, 0, .15); }
.spm-layout-bar .spm-close { top: 50%; transform: translateY(-50%); }

dialog.spm-layout-slide { bottom: 16px; top: auto; width: min(380px, calc(100vw - 32px)); }
dialog.spm-layout-slide.spm-pos-right { right: 16px; left: auto; }
dialog.spm-layout-slide.spm-pos-left { left: 16px; right: auto; }
.spm-layout-slide .spm-modal { padding: 22px; border-radius: 16px; }

/* ---------- انیمیشن ---------- */
.spm-overlay { opacity: 0; transition: opacity .22s ease; }
.spm-overlay.spm-in { opacity: 1; }
.spm-overlay .spm-modal { transition: transform .22s ease; }
.spm-anim-zoom:not(.spm-in) .spm-modal { transform: scale(.94); }
.spm-anim-slide:not(.spm-in) .spm-modal { transform: translateY(26px); }
.spm-anim-slide.spm-pos-top:not(.spm-in) .spm-modal { transform: translateY(-26px); }
.spm-anim-none, .spm-anim-none .spm-modal { transition: none; }

@media (prefers-reduced-motion: reduce) {
  .spm-overlay, .spm-overlay .spm-modal { transition: none !important; }
}

/* ---------- کارت عمودی ---------- */
.spm-modal-vertical { padding: 0; overflow: hidden; border-radius: 22px; }
.spm-modal-vertical .spm-close { background: rgba(255, 255, 255, .95); }
.spm-vcard { color: #1a1a1a; }
.spm-vc-image {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 240px;
  background: color-mix(in srgb, var(--spm-accent, #0F6E56) 12%, #fff);
  background: #f3f4f6;
  background: color-mix(in srgb, var(--spm-accent, #0F6E56) 10%, #fff);
}
.spm-vc-img { width: 100%; height: 100%; object-fit: contain; padding: 22px; }
.spm-vc-badge {
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  z-index: 2;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--spm-accent, #0F6E56);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.spm-vc-body { padding: 20px 22px 24px; text-align: start; }
.spm-vc-cat { margin-bottom: 4px; color: #6b7280; font-size: 13px; }
.spm-vc-title { margin-bottom: 10px; font-size: 18px; font-weight: 700; line-height: 1.6; }
.spm-vc-title a { color: inherit; text-decoration: none; }
.spm-vc-price { margin-bottom: 14px; font-size: 17px; font-weight: 700; }
.spm-vc-price del { color: #9ca3af; font-weight: 400; font-size: .85em; }
.spm-vc-price ins { text-decoration: none; }
.spm-vc-countdown { margin-bottom: 16px; }

.spm-vc-button,
.spm-product-button {
  display: block;
  padding: 13px 18px;
  border-radius: 12px;
  background: var(--spm-accent, #0F6E56);
  color: #fff;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.spm-vc-button:hover, .spm-product-button:hover { filter: brightness(.92); color: #fff; }
.spm-vc-button.spm-loading, .spm-product-button.spm-loading { opacity: .7; pointer-events: none; }
.spm-cart-msg { margin-bottom: 10px; color: #0a7a4b; font-weight: 700; text-align: center; }

/* ---------- کارت کلاسیک ---------- */
.spm-product-card { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: center; color: #1a1a1a; }
.spm-product-image-wrap { display: block; }
.spm-product-image { width: 100%; height: auto; border-radius: 14px; }
.spm-product-title { margin-bottom: 8px; font-size: 20px; font-weight: 700; }
.spm-product-title a { color: inherit; text-decoration: none; }
.spm-product-price { margin-bottom: 14px; font-size: 18px; font-weight: 700; }
.spm-product-price del { color: #9ca3af; font-weight: 400; }
.spm-product-price ins { text-decoration: none; }
.spm-sale-badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--spm-accent, #0F6E56);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.spm-product-button { display: inline-block; min-width: 190px; }

/* ---------- شمارش معکوس ---------- */
.spm-countdown-wrap { margin: 0 0 14px; }
.spm-countdown-label { margin-bottom: 6px; color: #6b7280; font-size: 13px; }
.spm-countdown { display: flex; gap: 8px; direction: ltr; justify-content: flex-start; }
.spm-countdown span {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  padding: 7px 6px;
  border-radius: 10px;
  background: #f3f4f6;
  color: #111;
}
.spm-countdown b { font-size: 18px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.spm-countdown small { color: #6b7280; font-size: 11px; }
.spm-countdown strong { color: #b42318; }

/* ---------- کد تخفیف ---------- */
.spm-coupon {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  padding-inline: 14px 10px;
  border: 2px dashed var(--spm-accent, #0F6E56);
  border-radius: 12px;
}
.spm-coupon-code { padding: 0; background: none; font-size: 18px; font-weight: 700; letter-spacing: .08em; direction: ltr; }
.spm-coupon-copy {
  padding: 6px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--spm-accent, #0F6E56);
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.spm-coupon-copy.spm-done { background: #0a7a4b; }

/* ---------- فرم ---------- */
.spm-form { display: grid; gap: 10px; max-width: 420px; }
.spm-form input[type="text"], .spm-form input[type="email"], .spm-form input[type="tel"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  color: #111;
  font: inherit;
}
.spm-form input:focus-visible { outline: 2px solid var(--spm-accent, #0F6E56); outline-offset: 1px; }
.spm-hp { position: absolute !important; inset-inline-start: -9999px; width: 1px; height: 1px; opacity: 0; }
.spm-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: #4b5563; }
.spm-form-btn {
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--spm-accent, #0F6E56);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.spm-form-btn:disabled { opacity: .6; cursor: default; }
.spm-form-msg { min-height: 1.4em; font-size: 14px; }
.spm-form-msg.spm-ok { color: #0a7a4b; font-weight: 700; }
.spm-form-msg.spm-err { color: #b42318; }
.spm-form-done input, .spm-form-done .spm-consent, .spm-form-done .spm-form-btn { display: none; }

/* ---------- نوار: کارت محصول فشرده ---------- */
.spm-layout-bar .spm-vcard { display: flex; align-items: center; gap: 16px; }
.spm-layout-bar .spm-vc-image { flex: 0 0 90px; width: 90px; height: 70px; border-radius: 10px; overflow: hidden; }
.spm-layout-bar .spm-vc-img { padding: 6px; }
.spm-layout-bar .spm-vc-badge { display: none; }
.spm-layout-bar .spm-vc-body { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; flex: 1; padding: 0; }
.spm-layout-bar .spm-vc-title, .spm-layout-bar .spm-vc-price, .spm-layout-bar .spm-vc-countdown { margin: 0; }
.spm-layout-bar .spm-vc-cat { display: none; }
.spm-layout-bar .spm-vc-button { display: inline-block; padding: 10px 22px; }
.spm-layout-bar .spm-modal-vertical, .spm-layout-bar .spm-modal.spm-modal-vertical { padding: 10px 64px 10px 16px; padding-inline: 16px 64px; border-radius: 0; }
.spm-layout-bar .spm-countdown span { min-width: 44px; padding: 4px; }

/* ---------- موبایل ---------- */
@media (max-width: 640px) {
  dialog.spm-overlay { padding: 12px; }
  .spm-modal { padding: 22px 18px; border-radius: 16px; }
  .spm-modal.spm-modal-vertical { padding: 0; }
  .spm-product-card { grid-template-columns: 1fr; gap: 14px; }
  .spm-product-button { display: block; }
  .spm-layout-bar .spm-vcard { align-items: flex-start; }
  .spm-layout-bar .spm-vc-image { display: none; }
  .spm-layout-bar .spm-modal { padding: 14px 52px 14px 14px; padding-inline: 14px 52px; max-height: 60vh; }
  dialog.spm-layout-slide { left: 12px; right: 12px; width: auto; bottom: 12px; }
}


/* ==================================================================== */
/*  چیدمان‌های جدید: دو ستونه، کشوی کناری، نوار شمارنده، چرخ شانس،        */
/*  اعلان خرید، دکمهٔ شناور                                              */
/* ==================================================================== */

/* ---------- دو ستونه: تصویر + متن ---------- */
.spm-modal-split { padding: 0; overflow: hidden; border-radius: 22px; }
.spm-split { display: grid; grid-template-columns: 1fr 1fr; min-height: 340px; }
.spm-split-rev .spm-split-img { order: 2; }
.spm-split-img { display: block; width: 100%; height: auto; min-height: 260px; align-self: stretch; object-fit: cover; }
.spm-split-body { display: flex; flex-direction: column; justify-content: center; padding: 40px 32px; min-width: 0; }
.spm-modal-split .spm-close { background: rgba(255, 255, 255, .95); }

/* ---------- کشوی کناری تمام‌قد ---------- */
dialog.spm-layout-drawer { padding: 0; background: rgba(0, 0, 0, var(--spm-opacity, .55)); -webkit-backdrop-filter: blur(var(--spm-blur, 8px)); backdrop-filter: blur(var(--spm-blur, 8px)); }
dialog.spm-layout-drawer[open] { display: flex; align-items: stretch; justify-content: flex-start; }
dialog.spm-layout-drawer .spm-modal {
  width: 100%;
  height: 100%;
  max-height: none;
  padding: 60px 26px 28px;
  border-radius: 0;
  box-shadow: 0 0 60px rgba(0, 0, 0, .3);
}
dialog.spm-layout-drawer.spm-pos-right .spm-modal { margin-left: auto; margin-right: 0; }
dialog.spm-layout-drawer.spm-pos-left .spm-modal { margin-right: auto; margin-left: 0; }
.spm-layout-drawer.spm-pos-right:not(.spm-in) .spm-modal { transform: translateX(100%); }
.spm-layout-drawer.spm-pos-left:not(.spm-in) .spm-modal { transform: translateX(-100%); }
.spm-layout-drawer .spm-modal { transition: transform .3s ease; }
.spm-layout-drawer.spm-anim-none .spm-modal { transition: none; }

/* ---------- نوار شمارندهٔ تخفیف ---------- */
.spm-kind-countdown .spm-modal { padding: 10px 56px 10px 16px; padding-inline: 16px 56px; text-align: center; }
.spm-cd-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 18px; }
.spm-cd-text { font-weight: 700; font-size: 16px; }
.spm-kind-countdown .spm-countdown-wrap { margin: 0; }
.spm-kind-countdown .spm-countdown { justify-content: center; gap: 6px; direction: inherit; }
.spm-kind-countdown .spm-countdown span { min-width: 46px; padding: 4px 6px; background: rgba(255, 255, 255, .2); color: #fff; }
.spm-kind-countdown .spm-countdown b { font-size: 17px; }
.spm-kind-countdown .spm-countdown small { color: rgba(255, 255, 255, .88); }
.spm-kind-countdown .spm-countdown strong { color: #fff; }
.spm-cd-btn { display: inline-block; padding: 8px 20px; border-radius: 999px; background: #fff; color: var(--spm-accent, #0F6E56); font-weight: 700; text-decoration: none; }
.spm-cd-btn:hover { filter: brightness(.95); color: var(--spm-accent, #0F6E56); }
.spm-kind-countdown .spm-close { background: rgba(255, 255, 255, .22); color: #fff; box-shadow: none; }
.spm-kind-countdown .spm-close:hover { background: rgba(255, 255, 255, .35); }

/* ---------- چرخ شانس ---------- */
.spm-wheel { margin-top: 14px; text-align: center; }
.spm-wheel-stage { position: relative; width: min(100%, 300px); aspect-ratio: 1 / 1; margin: 12px auto 20px; }
.spm-wheel-rotor { width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 10px 28px rgba(0, 0, 0, .22), 0 0 0 6px #fff, 0 0 0 9px var(--spm-accent, #0F6E56); will-change: transform; }
.spm-wheel-rotor svg { display: block; width: 100%; height: 100%; }
.spm-wheel-pointer {
  position: absolute;
  top: -14px;
  left: 50%;
  z-index: 2;
  width: 0;
  height: 0;
  margin-left: -13px;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-top: 26px solid #1f2937;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3));
}
.spm-wheel-hub { position: absolute; top: 50%; left: 50%; z-index: 1; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px var(--spm-accent, #0F6E56), 0 2px 8px rgba(0, 0, 0, .25); }
.spm-wheel-form { display: grid; gap: 10px; max-width: 320px; margin: 0 auto; }
.spm-wheel-input { width: 100%; padding: 12px 14px; border: 1px solid #d1d5db; border-radius: 10px; background: #fff; color: #111; font: inherit; }
.spm-wheel-input:focus-visible { outline: 2px solid var(--spm-accent, #0F6E56); outline-offset: 1px; }
.spm-wheel-btn { padding: 13px 18px; border: 0; border-radius: 12px; background: var(--spm-accent, #0F6E56); color: #fff; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.spm-wheel-btn:hover { filter: brightness(.92); }
.spm-wheel-btn:disabled { opacity: .6; cursor: default; }
.spm-wheel-msg { min-height: 1.4em; margin-top: 8px; color: #4b5563; font-size: 14px; }
.spm-wheel-msg.spm-err { color: #b42318; }
.spm-wheel-won { margin-bottom: 12px; font-size: 18px; font-weight: 700; }
.spm-wheel-lose { color: #4b5563; font-size: 16px; }
.spm-wheel-result .spm-coupon { justify-content: center; }

/* ---------- اعلان کوچک خرید ---------- */
.spm-toast {
  position: fixed;
  bottom: 16px;
  z-index: 999990;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(340px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 14px;
  border-inline-start: 4px solid var(--spm-accent, #0F6E56);
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 10px 36px rgba(0, 0, 0, .22);
  font-size: 14px;
  line-height: 1.7;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.spm-toast.spm-in { opacity: 1; transform: none; pointer-events: auto; }
.spm-toast.spm-pos-right { right: 16px; }
.spm-toast.spm-pos-left { left: 16px; }
.spm-toast.spm-anim-none { transition: none; }
.spm-toast-img { flex: none; width: 52px; height: 52px; border-radius: 10px; object-fit: cover; }
.spm-toast-body { flex: 1; min-width: 0; }
.spm-toast-text a, .spm-toast-text strong.spm-toast-product { color: var(--spm-accent, #0F6E56); font-weight: 700; text-decoration: none; }
.spm-toast-time { color: #6b7280; font-size: 12px; }
.spm-toast-close { flex: none; align-self: flex-start; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 999px; background: #f3f4f6; color: #4b5563; font-size: 18px; line-height: 1; cursor: pointer; }
.spm-toast-close:hover { background: #e5e7eb; }

/* ---------- دکمهٔ شناور بازشونده ---------- */
dialog.spm-layout-fab { top: auto; bottom: 16px; width: auto; height: auto; padding: 0; overflow: visible; background: transparent; pointer-events: none; }
dialog.spm-layout-fab[open] { display: flex; flex-direction: column; gap: 12px; }
dialog.spm-layout-fab.spm-pos-right { right: 16px; left: auto; }
dialog.spm-layout-fab.spm-pos-left { left: 16px; right: auto; }
dialog.spm-layout-fab.spm-pos-right > * { margin-left: auto; }
dialog.spm-layout-fab.spm-pos-left > * { margin-right: auto; }
.spm-layout-fab .spm-modal { display: none; width: min(380px, calc(100vw - 32px)); max-height: 70vh; padding: 24px 22px 22px; border-radius: 18px; pointer-events: auto; }
.spm-layout-fab.spm-fab-open .spm-modal { display: block; animation: spm-pop .2s ease; }
.spm-fab-btn { padding: 13px 22px; border: 0; border-radius: 999px; background: var(--spm-accent, #0F6E56); color: #fff; font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); pointer-events: auto; }
.spm-fab-btn:hover { filter: brightness(.92); }
.spm-fab-btn:focus { outline: none; }
.spm-fab-btn:focus-visible { outline: 3px solid #fff; box-shadow: 0 0 0 5px var(--spm-accent, #0F6E56), 0 8px 24px rgba(0, 0, 0, .25); }
@keyframes spm-pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .spm-toast, .spm-layout-drawer .spm-modal { transition: none !important; }
  .spm-layout-fab.spm-fab-open .spm-modal { animation: none; }
}

@media (max-width: 640px) {
  .spm-split { grid-template-columns: 1fr; min-height: 0; }
  .spm-split-img, .spm-split-rev .spm-split-img { order: 0; height: 190px; min-height: 0; }
  .spm-split-body { padding: 22px 18px 24px; }
  dialog.spm-layout-drawer .spm-modal { padding: 56px 18px 24px; }
  .spm-kind-countdown .spm-modal { padding: 10px 48px 10px 12px; padding-inline: 12px 48px; }
  .spm-cd-text { font-size: 14px; }
  .spm-toast { bottom: 12px; }
  .spm-toast.spm-pos-right { right: 12px; }
  .spm-toast.spm-pos-left { left: 12px; }
  dialog.spm-layout-fab { bottom: 12px; }
  dialog.spm-layout-fab.spm-pos-right { right: 12px; }
  dialog.spm-layout-fab.spm-pos-left { left: 12px; }
}
