/* Farnam Smart Robot – frontend styles */
.fsbot{
  --fs-red:#D71921; --fs-dark:#323232;
  --bot-w:var(--fs-bot-size,92px);
  position:fixed; right:var(--fs-side,16px); bottom:var(--fs-bottom,16px); z-index:99990;
  display:flex; flex-direction:column; align-items:flex-end; direction:ltr;
  font-family:"IranSans-Fa","IRANSansX","Vazirmatn",Tahoma,sans-serif;
  pointer-events:none;
  /* تا زمان رسیدن به شرط نمایش (تأخیر / اسکرول) پنهان است */
  opacity:0; visibility:hidden; translate:0 24px;
  transition:opacity .6s ease, translate .6s cubic-bezier(.2,.9,.3,1.2), visibility 0s linear .6s;
}
.fsbot.is-visible{opacity:1; visibility:visible; translate:0 0;
  transition:opacity .6s ease, translate .6s cubic-bezier(.2,.9,.3,1.2), visibility 0s}
.fsbot.is-leaving{opacity:0; translate:0 24px; visibility:hidden;
  transition:opacity .5s ease, translate .5s ease, visibility 0s linear .5s}
.fsbot:not(.is-visible) .fsbot__stage,.fsbot:not(.is-visible) .fsbot__bubble{pointer-events:none}
.fsbot *{box-sizing:border-box}

/* ---------- سمت چپ صفحه ---------- */
.fsbot--left{right:auto; left:var(--fs-side,16px); align-items:flex-start}
.fsbot--left .fsbot__tail{right:auto; left:calc(var(--bot-w) * .325 - 2px); transform:scaleX(-1)}
.fsbot--left .fsbot__bubble{transform-origin:15% 100%}
.fsbot--left .fsbot__stage{margin-right:0; margin-left:calc(var(--bot-w) * -.175)}
.fsbot__stage,.fsbot__bubble{pointer-events:auto}

/* ---------- حباب گفتگو (کپسولی) ---------- */
.fsbot__bubble{
  position:relative;
  width:var(--fs-bubble-w,166px); max-width:calc(100vw - 24px);
  margin-bottom:17px;
  animation:fsbBob 3.2s ease-in-out infinite;
  transform-origin:85% 100%;
  filter:drop-shadow(0 0 1.5px rgba(50,50,50,.10)) drop-shadow(0 10px 18px rgba(50,50,50,.14));
}
.fsbot__bubble::before{ /* بدنه کپسول */
  content:""; position:absolute; inset:0; border-radius:36px;
  background:linear-gradient(160deg,#ffffff 0%,#f7f7f8 45%,#ececee 100%);
}
/* فلش کوچک؛ نوک آن دقیقاً بالای وسط ربات است */
.fsbot__tail{position:absolute; right:calc(var(--bot-w) * .325 - 2px); bottom:-20px; width:20px; height:21px; overflow:visible}
.fsbot__title{position:relative; padding:14px 20px 0; color:var(--fs-dark);
  font-size:var(--fs-font,12px); line-height:1.7; font-weight:700; text-align:right}
.fsbot--has-title .fsbot__msg{padding-top:5px}
.fsbot--no-msg .fsbot__msg{display:none}
.fsbot--no-msg .fsbot__title{padding-bottom:14px}
.fsbot__msg{position:relative; display:grid; padding:14px 20px; color:var(--fs-dark);
  font-size:var(--fs-font,12px); line-height:1.8; font-weight:500; text-align:justify; text-align-last:right; text-justify:inter-word; white-space:pre-line}
.fsbot__sizer,.fsbot__text{grid-area:1/1}
.fsbot__sizer{visibility:hidden}
.fsbot__text{transition:opacity .35s}
.fsbot__text.is-fading{opacity:0}
.fsbot__caret{display:inline-block; width:1.5px; height:1.15em; margin-inline-start:2px;
  background:var(--fs-red); vertical-align:-.25em; animation:fsbCaret .8s steps(1) infinite}

/* ---------- ربات ---------- */
.fsbot__stage{width:var(--bot-w); aspect-ratio:240/285; cursor:pointer; outline:none;
  /* لبه بیرونی سر ربات (نه کادر SVG) با لبه حباب هم‌راستا می‌شود */
  margin-right:calc(var(--bot-w) * -.175);
  -webkit-tap-highlight-color:transparent; flex:none}
.fsbot__stage:focus-visible{outline:2px dashed var(--fs-red); outline-offset:4px; border-radius:12px}
.fsbot__svg{width:100%; height:100%; display:block; overflow:visible;
  filter:drop-shadow(0 0 1.5px rgba(50,50,50,.12)) drop-shadow(0 6px 12px rgba(50,50,50,.12))}
.fsbot__svg *{transform-box:view-box}

.fsbot__float{animation:fsbFloat 3.2s ease-in-out infinite}
.fsbot__shadow{transform-origin:120px 276px; animation:fsbShadow 3.2s ease-in-out infinite}
.fsbot__head{transform-origin:120px 150px; animation:fsbHead 6s ease-in-out infinite}
.fsbot__eyes{transform-origin:120px 86px; animation:fsbBlink 4.5s infinite}
.fsbot__chest circle{animation:fsbPulse 2s ease-in-out infinite}
.fsbot__mouth{transform-origin:120px 107px}
.fsbot.is-talking .fsbot__mouth{animation:fsbTalk .26s ease-in-out infinite alternate}
.fsbot__happy{opacity:0; transition:opacity .2s}
.fsbot__face{transition:opacity .2s}
.fsbot.is-happy .fsbot__face{opacity:0}
.fsbot.is-happy .fsbot__happy{opacity:1}

@keyframes fsbFloat{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}
@keyframes fsbShadow{0%,100%{transform:scale(1);opacity:.2}50%{transform:scale(.84);opacity:.11}}
@keyframes fsbHead{0%,100%{transform:rotate(0)}30%{transform:rotate(-3deg)}65%{transform:rotate(2.5deg)}}
@keyframes fsbBlink{0%,44%,48%,100%{transform:scaleY(1)}46%{transform:scaleY(.1)}}
@keyframes fsbPulse{0%,100%{opacity:1}50%{opacity:.45}}
@keyframes fsbTalk{from{transform:scaleY(1)}to{transform:scaleY(.35) translateY(4px)}}
@keyframes fsbCaret{50%{opacity:0}}
@keyframes fsbFade{from{opacity:0}to{opacity:1}}
@keyframes fsbIn{from{opacity:0;transform:scale(.4)}to{opacity:1;transform:scale(1)}}
@keyframes fsbBob{0%,100%{translate:0 0}50%{translate:0 calc(var(--bot-w) * -8 / 240)}}

@media (prefers-reduced-motion:reduce){
  .fsbot,.fsbot *{animation-duration:0s!important; animation-iteration-count:1!important}
}

/* پاپ شدن حباب هنگام ظاهر شدن ربات */
.fsbot.is-visible .fsbot__bubble{animation:fsbIn .6s .25s cubic-bezier(.3,1.5,.5,1) both, fsbBob 3.2s ease-in-out infinite}
/* عنوان: هم‌زمان با ظاهر شدن حباب، محوشونده (بدون تایپ) */
.fsbot__title{opacity:0}
.fsbot.is-visible .fsbot__title{animation:fsbFade .7s .25s ease both}

/* بدون حلقه: پس از پایان تایپ، نشانگر پنهان می‌شود */
.fsbot.is-done .fsbot__caret{display:none}
.fsbot--no-bubble .fsbot__bubble{display:none}

/* ---------- واکنش‌گرا و نمایش بر اساس دستگاه ---------- */
@media (max-width:767px){
  .fsbot{--bot-w:var(--fs-bot-size-m,72px); bottom:var(--fs-bottom-m,16px); right:var(--fs-side-m,16px)}
  .fsbot.fsbot--left{right:auto; left:var(--fs-side-m,16px)}
  .fsbot__bubble{width:var(--fs-bubble-w-m,var(--fs-bubble-w,166px))}
  .fsbot.fsbot--hide-mobile{display:none!important}
}
@media (min-width:768px) and (max-width:1024px){
  .fsbot.fsbot--hide-tablet{display:none!important}
}
@media (min-width:1025px){
  .fsbot.fsbot--hide-desktop{display:none!important}
}

/* ---------- پاپ‌آپ ---------- */
.fsbot-modal{position:fixed; inset:0; z-index:99999; display:flex; align-items:center; justify-content:center;
  padding:16px; background:rgba(30,30,32,.45); backdrop-filter:blur(3px); -webkit-backdrop-filter:blur(3px);
  opacity:0; visibility:hidden; transition:opacity .25s, visibility .25s;
  font-family:"IranSans-Fa","IRANSansX","Vazirmatn",Tahoma,sans-serif}
.fsbot-modal.is-open{opacity:1; visibility:visible}
.fsbot-modal__dialog{position:relative; width:min(560px,100%); max-height:85vh; overflow:auto;
  background:#fff; border-radius:22px; padding:28px 24px 22px; color:#323232;
  box-shadow:0 20px 60px rgba(0,0,0,.25); transform:translateY(16px) scale(.97); transition:transform .3s cubic-bezier(.3,1.4,.5,1)}
.fsbot-modal.is-open .fsbot-modal__dialog{transform:none}
.fsbot-modal__close{position:absolute; top:10px; left:10px; width:34px; height:34px; border:0; border-radius:50%;
  background:#f1f1f1; color:#323232; font-size:20px; line-height:34px; cursor:pointer; padding:0; transition:background .2s}
.fsbot-modal__close:hover{background:#D71921; color:#fff}
.fsbot-modal__content > :first-child{margin-top:0}
.fsbot-modal__content > :last-child{margin-bottom:0}
body.fsbot-modal-open{overflow:hidden}


/* ---------- محافظت در برابر استایل دکمه‌های قالب ----------
   ربات و حباب نقش button دارند؛ قالب‌ها نباید به آن‌ها border، padding یا پس‌زمینه بدهند */
.fsbot .fsbot__stage,.fsbot .fsbot__bubble{
  border:0 !important; outline:0 !important; background:transparent !important; box-shadow:none !important;
  padding:0 !important; min-height:0 !important; min-width:0 !important; border-radius:0 !important; text-decoration:none !important;
}
.fsbot .fsbot__stage:focus-visible{outline:2px dashed #D71921 !important; outline-offset:4px !important; border-radius:12px !important}
.fsbot .fsbot__bubble.is-clickable:focus-visible{outline:2px dashed #D71921 !important; outline-offset:4px !important; border-radius:36px !important}

/* ---------- دکمه بستن ----------
   با !important تا استایل دکمه‌های قالب (border، outline، padding و...) روی آن اثر نگذارد */
.fsbot .fsbot__close{
  position:absolute !important; top:-9px !important; right:-7px !important; left:auto !important; bottom:auto !important; z-index:3 !important;
  box-sizing:border-box !important; width:22px !important; height:22px !important; min-width:0 !important; min-height:0 !important;
  padding:0 !important; margin:0 !important; border:0 !important; outline:0 !important; border-radius:50% !important;
  background:#D71921 !important; color:#fff !important; font-size:0 !important; line-height:0 !important; text-decoration:none !important;
  box-shadow:0 3px 8px rgba(215,25,33,.35), 0 0 0 2px #fff !important;
  display:flex !important; align-items:center; justify-content:center;
  cursor:pointer; pointer-events:auto;
  opacity:0; scale:.6; transition:transform .2s, background-color .2s;
  -webkit-tap-highlight-color:transparent; -webkit-appearance:none; appearance:none;
}
.fsbot .fsbot__close::before{content:""; position:absolute; inset:-10px; border-radius:6px; background:transparent}   /* ۱۰ پیکسل ناحیه کلیک اضافه */
.fsbot .fsbot__close svg{width:10px !important; height:10px !important; display:block !important; margin:0 !important}
.fsbot .fsbot__close:hover{background:#b5141b !important; transform:scale(1.1) rotate(90deg)}
.fsbot .fsbot__close:focus-visible{outline:2px solid #D71921 !important; outline-offset:3px !important}
.fsbot.is-visible .fsbot__close{animation:fsbClose .4s .5s cubic-bezier(.3,1.5,.5,1) both}
@keyframes fsbClose{from{opacity:0; scale:.6}to{opacity:1; scale:1}}
.fsbot--left .fsbot__close{right:auto !important; left:-7px !important}

/* ---------- حباب کلیک‌خور ---------- */
.fsbot__bubble.is-clickable{cursor:pointer}
.fsbot__bubble.is-clickable:focus-visible{outline:2px dashed #D71921; outline-offset:4px; border-radius:36px}

/* ---------- حالت ناراحت ---------- */
.fsbot__sad{opacity:0; transition:opacity .25s}
.fsbot.is-sad .fsbot__face,.fsbot.is-sad .fsbot__happy{opacity:0}
.fsbot.is-sad .fsbot__sad{opacity:1}

/* ---------- انیمیشن بستن ---------- */
.fsbot.is-closing .fsbot__stage,.fsbot.is-closing .fsbot__bubble{pointer-events:none}
.fsbot.is-visible.is-closing .fsbot__bubble{animation:fsbOut .3s cubic-bezier(.5,-.5,.7,.4) both}
.fsbot.is-visible.is-closing .fsbot__close{animation:fsbCloseOut .2s ease both}
@keyframes fsbOut{from{opacity:1; transform:scale(1)}to{opacity:0; transform:scale(.4)}}
@keyframes fsbCloseOut{from{opacity:1; scale:1}to{opacity:0; scale:.3}}

/* تبدیل ربات به یک دایره و ناپدید شدن */
.fsbot__stage{position:relative}
.fsbot.is-poof .fsbot__svg{transform-origin:50% 48%; animation:fsbShrink .32s cubic-bezier(.6,0,.6,1) forwards}
.fsbot.is-poof .fsbot__shadow{opacity:0; transition:opacity .2s}
.fsbot__stage::after{
  content:""; position:absolute; left:50%; top:48%; width:44%; aspect-ratio:1; translate:-50% -50%;
  border-radius:50%; pointer-events:none; opacity:0; scale:.2;
  background:radial-gradient(circle at 35% 30%, #ffffff 0%, #f3f3f4 45%, #d9dbdf 100%);
  box-shadow:0 0 0 2px rgba(215,25,33,.85), 0 0 14px 3px rgba(255,59,68,.55);
}
.fsbot.is-poof .fsbot__stage::after{animation:fsbOrb .8s cubic-bezier(.3,1.3,.5,1) forwards}
@keyframes fsbShrink{
  0%{transform:scale(1); opacity:1; filter:blur(0)}
  100%{transform:scale(.3); opacity:0; filter:blur(3px)}
}
@keyframes fsbOrb{
  0%{opacity:0; scale:.2}
  30%{opacity:1; scale:1}
  60%{opacity:1; scale:1}
  100%{opacity:0; scale:0}
}
