/*
 * Ostadyadaki — Wholesale floating button (osy-wfab)
 * All selectors are prefixed with .osy-wfab to avoid collisions with
 * DinaKala / Elementor / WooCommerce styles.
 *
 * Colors are the site's real tokens (from DinaKala Redux output on ostadyadaki.com):
 *   --dina-custom-color  #0E4A86  (primary, theme-color meta)
 *   --dina-woo-btn-bg    #0c3c6c  (darker primary, used for hover)
 *   body text            #212529
 *   --dina-head-text     #505763  (secondary text)
 *   body background      #F4F5F9
 *   card radius 10px, card shadow 0 0 10px rgba(0,0,0,.1)
 * Font: inherits the site font (var(--dina-main-font) → "yekan" / IRANYekanX).
 */

.osy-wfab {
  --osy-wfab-primary: var(--dina-custom-color, #0E4A86);
  --osy-wfab-primary-dark: var(--dina-woo-btn-bg, #0c3c6c);
  --osy-wfab-on-primary: #FFFFFF;
  --osy-wfab-text: #212529;
  --osy-wfab-muted: var(--dina-head-text-color, #505763);
  --osy-wfab-surface: #FFFFFF;
  --osy-wfab-tint: rgba(14, 74, 134, .07);
  --osy-wfab-tint-strong: rgba(14, 74, 134, .12);
  --osy-wfab-radius: 10px;
  --osy-wfab-gap-x: 24px;
  /* Bottom offset; JS refines this on mobile from the real bottom bar height. */
  --osy-wfab-bottom: 24px;

  position: fixed;
  left: calc(var(--osy-wfab-gap-x) + env(safe-area-inset-left, 0px));
  bottom: calc(var(--osy-wfab-bottom) + env(safe-area-inset-bottom, 0px));
  /* Above the theme's mobile bar (999) but below DinaKala side panels (99999). */
  z-index: 9990;
  direction: rtl;
  font-family: var(--dina-main-font, yekan, Tahoma, Arial, sans-serif);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

.osy-wfab *,
.osy-wfab *::before,
.osy-wfab *::after { box-sizing: border-box; }

/* When JS measured the real bottom bar, the value already includes any safe-area. */
.osy-wfab.osy-wfab--measured { bottom: var(--osy-wfab-bottom); }

/* Mobile/tablet: DinaKala shows .dina-mobile-footer at ≤1024px (its diamond rises ~78px). */
@media (max-width: 1024px) {
  .osy-wfab {
    --osy-wfab-gap-x: 12px;
    --osy-wfab-bottom: 90px;
  }
}

/* ---------- Main capsule button ---------- */
.osy-wfab__toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  margin: 0;
  padding: 0 14px 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--osy-wfab-primary);
  color: var(--osy-wfab-on-primary);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 0, 0, .1), 0 6px 16px rgba(14, 74, 134, .28);
  transition: background-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.osy-wfab__toggle:hover { background: var(--osy-wfab-primary-dark); }
.osy-wfab__toggle:active { transform: scale(.97); }
.osy-wfab__toggle:focus { outline: none; }
.osy-wfab__toggle:focus-visible {
  outline: 2px solid var(--osy-wfab-primary);
  outline-offset: 3px;
}

.osy-wfab__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  flex: 0 0 auto;
}
.osy-wfab__icon svg { width: 18px; height: 18px; display: block; }
.osy-wfab__icon .osy-wfab__i-close { display: none; }
.osy-wfab.is-open .osy-wfab__icon .osy-wfab__i-open { display: none; }
.osy-wfab.is-open .osy-wfab__icon .osy-wfab__i-close { display: block; }

/* Subtle periodic pulse: a ring that expands once every 9s. Transform/opacity only. */
.osy-wfab__toggle::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid var(--osy-wfab-primary);
  opacity: 0;
  pointer-events: none;
  animation: osy-wfab-pulse 9s ease-out 2.5s infinite;
}
@keyframes osy-wfab-pulse {
  0%   { transform: scale(1);    opacity: 0; }
  2%   { transform: scale(1);    opacity: .55; }
  14%  { transform: scale(1.18, 1.38); opacity: 0; }
  100% { transform: scale(1.18, 1.38); opacity: 0; }
}
/* Pause motion while the panel is open or the user is interacting. */
.osy-wfab.is-open .osy-wfab__toggle::before,
.osy-wfab__toggle:hover::before,
.osy-wfab__toggle:focus-visible::before { animation: none; opacity: 0; }

/* ---------- Panel ---------- */
.osy-wfab__panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);
  width: min(320px, calc(100vw - 24px));
  padding: 16px;
  border-radius: var(--osy-wfab-radius);
  background: var(--osy-wfab-surface);
  color: var(--osy-wfab-text);
  box-shadow: 0 0 10px rgba(0, 0, 0, .1), 0 12px 32px rgba(18, 30, 42, .16);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transform-origin: bottom left;
  transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}
.osy-wfab.is-open .osy-wfab__panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .18s ease, transform .18s ease, visibility 0s;
}

.osy-wfab__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--osy-wfab-tint-strong);
}
.osy-wfab__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--osy-wfab-text);
  line-height: 1.5;
}
.osy-wfab__desc {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--osy-wfab-muted);
  line-height: 1.7;
}
.osy-wfab__close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: -4px 0 0 -6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--osy-wfab-muted);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.osy-wfab__close:hover { background: var(--osy-wfab-tint); color: var(--osy-wfab-primary); }
.osy-wfab__close:focus-visible { outline: 2px solid var(--osy-wfab-primary); outline-offset: 1px; }
.osy-wfab__close svg { width: 16px; height: 16px; }

.osy-wfab__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.osy-wfab__opt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid var(--osy-wfab-tint-strong);
  border-radius: var(--osy-wfab-radius);
  background: var(--osy-wfab-surface);
  color: var(--osy-wfab-text);
  text-decoration: none !important;
  transition: background-color .15s ease, border-color .15s ease;
}
.osy-wfab__opt:hover { background: var(--osy-wfab-tint); border-color: var(--osy-wfab-primary); color: var(--osy-wfab-text); }
.osy-wfab__opt:focus { outline: none; }
.osy-wfab__opt:focus-visible { outline: 2px solid var(--osy-wfab-primary); outline-offset: 2px; }

.osy-wfab__opt-ic {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--osy-wfab-tint);
  color: var(--osy-wfab-primary);
}
.osy-wfab__opt-ic svg { width: 20px; height: 20px; display: block; }
.osy-wfab__opt--primary .osy-wfab__opt-ic { background: var(--osy-wfab-primary); color: var(--osy-wfab-on-primary); }
/* WhatsApp icon only: official WhatsApp green (#25D366) for instant recognition.
   Everything else (option row, border, hover, text) stays in the Ostadyadaki palette. */
.osy-wfab__opt[data-osy-wfab="whatsapp"] .osy-wfab__opt-ic { background: #25D366; color: #FFFFFF; }

.osy-wfab__opt-txt { display: flex; flex-direction: column; min-width: 0; }
.osy-wfab__opt-label { font-size: 14px; font-weight: 600; color: var(--osy-wfab-text); line-height: 1.6; }
.osy-wfab__opt-sub { font-size: 12px; color: var(--osy-wfab-muted); line-height: 1.6; }
.osy-wfab__opt-sub bdi { direction: ltr; unicode-bidi: isolate; }

.osy-wfab__chev { margin-right: auto; color: var(--osy-wfab-muted); flex: 0 0 auto; }
.osy-wfab__chev svg { width: 16px; height: 16px; display: block; }

/* Very narrow phones */
@media (max-width: 359px) {
  .osy-wfab__toggle { font-size: 14px; height: 46px; padding: 0 12px 0 14px; }
}

/* Reduced motion: no pulse, no panel slide. */
@media (prefers-reduced-motion: reduce) {
  .osy-wfab__toggle::before { animation: none !important; opacity: 0 !important; }
  .osy-wfab__toggle,
  .osy-wfab__panel,
  .osy-wfab.is-open .osy-wfab__panel { transition: none !important; transform: none !important; }
}

/* Print: never show. */
@media print { .osy-wfab { display: none !important; } }
