/* =========================================================
   CBT Chatbot Widget — Styles v1.1
   Palette: #FAC407 | #EEEEEE | #0D0F1B
   Font: Yekan (loaded via Elementor)
   ========================================================= */

:root {
  --cbt-gold:      #FAC407;
  --cbt-gold-dark: #d4a406;
  --cbt-gold-glow: rgba(250, 196, 7, 0.35);
  --cbt-light:     #EEEEEE;
  --cbt-dark:      #0D0F1B;
  --cbt-dark2:     #13162a;
  --cbt-dark3:     #1b1f38;
  --cbt-dark4:     #222640;
  --cbt-text-on-dark: #dde0f0;
  --cbt-text-muted:   #7880a0;
  --cbt-radius:    20px;
  --cbt-panel-w:   380px;
  --cbt-panel-h:   560px;
  --cbt-toggle-sz: 62px;
  --cbt-shadow:    0 12px 48px rgba(0,0,0,.55), 0 4px 16px rgba(0,0,0,.35);
  --cbt-font:      'yekan', 'Yekan', Tahoma, Arial, sans-serif;
  --cbt-z:         99999;
  --cbt-bottom:    28px;
  --cbt-side:      28px;
  --cbt-ease:      cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Reset ----------
   جداسازی کامل از استایل‌های قالب سایت — بدون این ریست، قواعد عمومی
   قالب (مثلاً رنگ لینک‌ها روی هاور/فوکوس) می‌توانند وارد ویجت شوند. */
#cbt-wrapper *,
#cbt-wrapper *::before,
#cbt-wrapper *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--cbt-font) !important;
  list-style: none;
}
#cbt-wrapper a,
#cbt-wrapper a:hover,
#cbt-wrapper a:focus,
#cbt-wrapper a:visited {
  text-decoration: none !important;
}
#cbt-wrapper button {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  -webkit-appearance: none;
}

/* ---------- Wrapper ---------- */
#cbt-wrapper {
  position: fixed;
  bottom: var(--cbt-bottom);
  z-index: var(--cbt-z);
  direction: rtl;
}
#cbt-wrapper.cbt-pos-right { right: var(--cbt-side); left: auto; }
#cbt-wrapper.cbt-pos-left  { left: var(--cbt-side);  right: auto; }

/* =========================================================
   TOGGLE BUTTON
   ========================================================= */
#cbt-toggle {
  position: relative;
  width: var(--cbt-toggle-sz);
  height: var(--cbt-toggle-sz);
  border-radius: 50%;
  background: var(--cbt-gold) !important;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 22px var(--cbt-gold-glow), 0 2px 8px rgba(0,0,0,.45);
  transition: transform 0.3s var(--cbt-ease), box-shadow 0.3s ease;
  outline: none;
  overflow: visible;
}
/* قفل‌کردن رنگ در همه‌ی حالت‌ها — از رونمایی رنگ پیش‌فرض قالب (مثلاً صورتی) جلوگیری می‌کند */
#cbt-toggle:hover,
#cbt-toggle:focus,
#cbt-toggle:focus-visible,
#cbt-toggle:active,
#cbt-toggle:visited {
  background: var(--cbt-gold) !important;
}
#cbt-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px var(--cbt-gold-glow), 0 3px 14px rgba(0,0,0,.5);
}
#cbt-toggle:active { transform: scale(0.93); }

/* Pulse rings */
#cbt-toggle::before,
#cbt-toggle::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--cbt-gold);
  opacity: 0;
  inset: 0;
  animation: cbt-pulse 2.5s ease-out infinite;
}
#cbt-toggle::after { animation-delay: 0.9s; }
@keyframes cbt-pulse {
  0%   { opacity: .55; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.35); }
}
#cbt-wrapper.cbt-open #cbt-toggle::before,
#cbt-wrapper.cbt-open #cbt-toggle::after { animation: none; }

.cbt-icon-chat,
.cbt-icon-close {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cbt-dark);
  transition: opacity 0.25s ease, transform 0.3s var(--cbt-ease);
}
.cbt-icon-chat svg,
.cbt-icon-chat img,
.cbt-icon-close svg { width: 27px; height: 27px; }
.cbt-icon-close { opacity: 0; transform: rotate(-90deg) scale(0.6); }
#cbt-wrapper.cbt-open .cbt-icon-chat  { opacity: 0; transform: rotate(90deg) scale(0.6); }
#cbt-wrapper.cbt-open .cbt-icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* Badge */
.cbt-badge {
  position: absolute;
  top: -3px;
  left: -3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e03131;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: cbt-pop 0.4s var(--cbt-ease);
}
@keyframes cbt-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* =========================================================
   PANEL
   ========================================================= */
#cbt-panel {
  position: absolute;
  bottom: calc(var(--cbt-toggle-sz) + 16px);
  width: var(--cbt-panel-w);
  height: var(--cbt-panel-h);
  background: var(--cbt-dark2);
  border-radius: var(--cbt-radius);
  box-shadow: var(--cbt-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
  opacity: 0;
  transform: translateY(18px) scale(0.94);
  transform-origin: bottom center;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.42s var(--cbt-ease);
}
.cbt-pos-right #cbt-panel { right: 0; }
.cbt-pos-left  #cbt-panel { left: 0; }

#cbt-wrapper.cbt-open #cbt-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ---------- Header ---------- */
.cbt-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--cbt-dark);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.cbt-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--cbt-gold) 0%, #e0a800 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(250,196,7,.35);
}
.cbt-header-avatar svg { width: 22px; height: 22px; color: var(--cbt-dark); }

.cbt-header-info { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.cbt-header-title { font-size: 14px; font-weight: 700; color: var(--cbt-light); }
.cbt-header-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--cbt-text-muted);
}
.cbt-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #3bc47a;
  animation: cbt-dot-blink 2.2s ease infinite;
}
@keyframes cbt-dot-blink { 0%,100%{opacity:1} 50%{opacity:.35} }

.cbt-close-btn {
  background: none; border: none; cursor: pointer;
  color: var(--cbt-text-muted);
  display: flex; align-items: center; justify-content: center;
  padding: 6px; border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.cbt-close-btn:hover { color: var(--cbt-light); background: rgba(255,255,255,.08); }
.cbt-close-btn svg { width: 18px; height: 18px; }

/* ---------- Messages ---------- */
.cbt-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  min-height: 0;
}
.cbt-messages::-webkit-scrollbar { width: 4px; }
.cbt-messages::-webkit-scrollbar-track { background: transparent; }
.cbt-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

/* Bubbles */
.cbt-msg {
  max-width: 82%;
  padding: 13px 18px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.75;
  word-break: break-word;
  animation: cbt-msg-in 0.35s var(--cbt-ease) both;
}
@keyframes cbt-msg-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}

.cbt-msg-bot {
  align-self: flex-start;
  background: var(--cbt-dark3);
  color: var(--cbt-text-on-dark);
  border-bottom-right-radius: 5px;
  border: 1px solid rgba(255,255,255,.07);
}
.cbt-msg-user {
  align-self: flex-end;
  background: var(--cbt-gold);
  color: var(--cbt-dark);
  border-bottom-left-radius: 5px;
  font-weight: 600;
}

/* Typing dots */
.cbt-typing {
  display: flex; align-items: center; gap: 6px;
  padding: 14px 18px;
  background: var(--cbt-dark3);
  border-radius: 18px;
  border-bottom-right-radius: 5px;
  border: 1px solid rgba(255,255,255,.07);
  align-self: flex-start;
  width: fit-content;
  animation: cbt-msg-in 0.3s ease both;
}
.cbt-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--cbt-gold);
  animation: cbt-dot-bounce 1.2s ease infinite;
}
.cbt-typing span:nth-child(2) { animation-delay: .18s; }
.cbt-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes cbt-dot-bounce {
  0%,60%,100%{ transform:translateY(0); opacity:.45; }
  30%{ transform:translateY(-6px); opacity:1; }
}

/* Invite banner */
.cbt-msg-invite {
  align-self: stretch;
  background: linear-gradient(135deg, rgba(250,196,7,.1), rgba(250,196,7,.05));
  color: var(--cbt-gold);
  border: 1px solid rgba(250,196,7,.28);
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
  animation: cbt-msg-in 0.4s var(--cbt-ease) both;
}

/* ---------- Lead Form ---------- */
.cbt-lead-form {
  padding: 16px 18px 18px;
  background: var(--cbt-dark);
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 1;        /* اجازه کوچک شدن در flex */
  overflow-y: auto;
  min-height: 0;         /* flex overflow fix */
  animation: cbt-slide-up 0.4s var(--cbt-ease) both;
}
@keyframes cbt-slide-up {
  from { opacity:0; transform:translateY(18px); }
  to   { opacity:1; transform:none; }
}

.cbt-form-fields { display: flex; flex-direction: column; gap: 10px; }

.cbt-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--cbt-dark3);
  border: 1.5px solid rgba(255,255,255,.1);
  border-radius: 11px;
  color: var(--cbt-light);
  font-size: 13.5px;
  font-family: var(--cbt-font) !important;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  text-align: right;
  direction: rtl;
}
.cbt-input:focus {
  border-color: var(--cbt-gold);
  background: rgba(250,196,7,.04);
  box-shadow: 0 0 0 3px rgba(250,196,7,.12);
}
.cbt-input::placeholder { color: var(--cbt-text-muted); font-family: var(--cbt-font) !important; }
.cbt-input.cbt-error { border-color: #e03131 !important; box-shadow: 0 0 0 3px rgba(224,49,49,.15) !important; }

.cbt-field-error {
  font-size: 11.5px;
  color: #ff6b6b;
  padding: 2px 4px 0;
  display: none;
}
.cbt-field-error.visible { display: block; }

.cbt-submit-btn {
  width: 100%;
  padding: 12px;
  background: var(--cbt-gold);
  color: var(--cbt-dark);
  border: none;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--cbt-font) !important;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  margin-top: 4px;
}
.cbt-submit-btn:hover:not(:disabled) {
  background: var(--cbt-gold-dark);
  box-shadow: 0 4px 14px rgba(250,196,7,.3);
}
.cbt-submit-btn:active:not(:disabled) { transform: scale(0.98); }
.cbt-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Input Area ---------- */
.cbt-input-area {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 12px 14px 14px;
  background: var(--cbt-dark);
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.cbt-textarea {
  flex: 1;
  background: var(--cbt-dark3);
  border: 1.5px solid rgba(255,255,255,.1);
  border-radius: 13px;
  padding: 10px 13px;
  color: var(--cbt-light);
  font-size: 13.5px;
  font-family: var(--cbt-font) !important;
  resize: none;
  outline: none;
  line-height: 1.55;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-align: right;
  direction: rtl;
  min-height: 40px;
}
.cbt-textarea:focus {
  border-color: var(--cbt-gold);
  box-shadow: 0 0 0 3px rgba(250,196,7,.1);
}
.cbt-textarea::placeholder { color: var(--cbt-text-muted); font-family: var(--cbt-font) !important; }

.cbt-send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--cbt-gold);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--cbt-dark); flex-shrink: 0;
  transition: background 0.2s, transform 0.15s, opacity 0.2s, box-shadow 0.2s;
}
.cbt-send-btn:hover:not(:disabled) {
  background: var(--cbt-gold-dark);
  transform: scale(1.08);
  box-shadow: 0 3px 12px rgba(250,196,7,.35);
}
.cbt-send-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.cbt-send-btn svg { width: 18px; height: 18px; }

.cbt-request-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(250,196,7,.1);
  border: 1.5px solid rgba(250,196,7,.35);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--cbt-gold); flex-shrink: 0;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.cbt-request-btn:hover {
  background: rgba(250,196,7,.2);
  transform: scale(1.08);
  box-shadow: 0 2px 10px rgba(250,196,7,.2);
}
.cbt-request-btn svg { width: 17px; height: 17px; }

/* Tooltip for request button */
.cbt-request-btn-wrap {
  position: relative;
}
.cbt-request-btn-wrap::after {
  content: 'درخواست مشاوره';
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--cbt-dark);
  color: var(--cbt-gold);
  font-size: 11px;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid rgba(250,196,7,.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.cbt-request-btn-wrap:hover::after { opacity: 1; }

/* =========================================================
   MOBILE — تمام‌صفحه + کیبورد هوشمند
   ========================================================= */

/* تبلت: کمی کوچک‌تر */
@media (max-width: 600px) {
  :root {
    --cbt-panel-w: calc(100vw - 24px);
    --cbt-panel-h: 520px;
    --cbt-bottom: 20px;
    --cbt-side: 12px;
  }
}

/* موبایل: تمام‌صفحه */
@media (max-width: 480px) {
  :root {
    --cbt-toggle-sz: 58px;
    --cbt-bottom: 16px;
    --cbt-side: 16px;
  }

  /*
   * FIX: wrapper همیشه fixed باشد و scroll صفحه تأثیری نگذارد.
   * وقتی پنل بسته است: فقط toggle نمایش داده می‌شود (bottom/right).
   * وقتی پنل باز است: JS مختصات دقیق را از visualViewport می‌خواند.
   */
  #cbt-wrapper {
    position: fixed !important;
  }

  /* wrapper وقتی پنل باز است، تمام صفحه را می‌گیرد */
  #cbt-wrapper.cbt-open {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* پنل تمام‌صفحه — نسبت به wrapper که خودش fixed است */
  #cbt-wrapper.cbt-open #cbt-panel {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    transform-origin: bottom center;
    /* FIX: panel باید flex column باشد و overflow پنهان نشود */
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  /* وقتی کیبورد باز است — JS کلاس cbt-kb-open اضافه می‌کند */
  #cbt-wrapper.cbt-kb-open {
    top: var(--cbt-vvh-top, 0) !important;
    height: var(--cbt-vvh, 100%) !important;
    bottom: auto !important;
  }
  #cbt-wrapper.cbt-kb-open #cbt-panel {
    height: 100% !important;
  }

  /* هدر در موبایل */
  .cbt-header {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    flex-shrink: 0;
  }

  /* پیام‌ها — flex: 1 تا فضای باقیمانده را پر کند */
  .cbt-messages {
    flex: 1 !important;
    min-height: 0 !important;
    padding: 16px 14px;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
  }

  /* حباب‌های پیام */
  .cbt-msg {
    font-size: 14px;
    max-width: 88%;
    padding: 11px 15px;
  }

  /* ناحیه ورودی — چسبیده به کیبورد */
  .cbt-input-area {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    flex-shrink: 0 !important;
  }

  /*
   * FIX: فرم تماس — نباید از پنل خارج شود.
   * flex-shrink: 1 + overflow-y: auto + max-height محدود
   * تضمین می‌کند فرم درون پنل اسکرول می‌شود نه از آن خارج.
   */
  .cbt-lead-form {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    flex-shrink: 1 !important;
    flex-grow: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    max-height: 55% !important; /* حداکثر ۵۵٪ ارتفاع پنل */
  }

  /* دکمه ارسال بزرگ‌تر */
  .cbt-send-btn {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
  }

  /* textarea راحت‌تر */
  .cbt-textarea {
    font-size: 16px; /* جلوگیری از zoom خودکار iOS — باید ≥16px باشد */
    padding: 10px 12px;
    min-height: 44px;
  }

  /* فیلدهای فرم */
  .cbt-input {
    font-size: 16px; /* جلوگیری از zoom خودکار iOS — باید ≥16px باشد */
    padding: 12px 14px;
  }

  /* دکمه تأیید فرم */
  .cbt-submit-btn {
    padding: 14px;
    font-size: 15px;
  }

  /* دکمه toggle زمانی که پنل باز است پنهان شود */
  #cbt-wrapper.cbt-open #cbt-toggle {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
  }

  /* tooltip دکمه درخواست را پنهان کن */
  .cbt-request-btn-wrap::after { display: none; }
}

@media (max-width: 360px) {
  :root { --cbt-toggle-sz: 52px; }
  .cbt-msg { font-size: 13.5px; }
}

/* =========================================================
   FLOATING CONTACTS — دکمه راه‌های ارتباطی + fan-out
   فقط آیکون (بدون برچسب متنی) طبق درخواست — نکات طراحی:
     ۱) فاصله‌ی تضمینی بین آیکون‌ها (gap + margin پشتیبان) تا هیچ‌وقت
        به‌هم نچسبند، حتی اگر استایل قالب روی gap اثر بگذارد
     ۲) رنگ هر دکمه با !important در همه‌ی حالت‌ها (hover/focus/active)
        قفل شده تا رنگ پیش‌فرض قالب (مثلاً صورتی‌شدن روی هاور) هرگز
        رونمایی نکند
     ۳) لیبل قابل‌دسترس فقط از طریق aria-label + title (تولتیپ بومی
        مرورگر) ارائه می‌شود، نه با یک تولتیپ سفارشی که در موبایل
        امکان بریدگی/خروج از صفحه داشت
   ========================================================= */
:root {
  /* فاصله بین دکمه «تماس» (contacts-toggle) و آیکون واتساپ بالای آن — افزایش یافت */
  --cbt-contact-gap: 22px;
  --cbt-contact-gap-between: 14px;
  /* فاصله بین دکمه «چت» اصلی و دکمه «تماس» بالای آن — کاهش یافت */
  --cbt-gap-chat-contacts: 8px;
}

.cbt-contacts {
  position: absolute !important;
  /* فاصله‌ی بین دکمه چت و دکمه تماس */
  bottom: calc(var(--cbt-toggle-sz) + var(--cbt-gap-chat-contacts)) !important;
  width: calc(var(--cbt-toggle-sz) * 0.72);
  height: calc(var(--cbt-toggle-sz) * 0.72);
  z-index: 1;
}
.cbt-pos-right .cbt-contacts { right: calc((var(--cbt-toggle-sz) - (var(--cbt-toggle-sz) * 0.72)) / 2); }
.cbt-pos-left  .cbt-contacts { left:  calc((var(--cbt-toggle-sz) - (var(--cbt-toggle-sz) * 0.72)) / 2); }

/* وقتی پنل چت بازه دکمه راه‌های ارتباطی پنهان بشه */
#cbt-wrapper.cbt-open .cbt-contacts {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.7);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.cbt-contacts-toggle {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--cbt-dark) !important;
  border: 2px solid var(--cbt-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cbt-gold) !important;
  box-shadow: 0 4px 18px rgba(0,0,0,.45), 0 0 0 0 var(--cbt-gold-glow);
  transition: transform 0.3s var(--cbt-ease), box-shadow 0.3s ease, background 0.3s ease, color 0.3s ease;
  outline: none;
  padding: 0;
}
/* قفل‌کردن حالت‌های تعاملی — تا استایل پیش‌فرض قالب (مثلاً صورتی‌شدن دکمه)
   هرگز نتواند روی این دکمه اثر بگذارد */
.cbt-contacts-toggle:hover,
.cbt-contacts-toggle:focus,
.cbt-contacts-toggle:focus-visible,
.cbt-contacts-toggle:active,
.cbt-contacts-toggle:visited {
  background: var(--cbt-dark) !important;
  color: var(--cbt-gold) !important;
  border-color: var(--cbt-gold) !important;
}
.cbt-contacts-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(0,0,0,.5), 0 0 0 6px var(--cbt-gold-glow);
}
.cbt-contacts-toggle:active { transform: scale(0.94); }

.cbt-contacts-toggle svg {
  width: 55%;
  height: 55%;
}

.cbt-contacts-icon-default,
.cbt-contacts-icon-close {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  inset: 0;
  transition: opacity 0.25s ease, transform 0.35s var(--cbt-ease);
}
.cbt-contacts-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
  color: var(--cbt-dark);
}
.cbt-contacts.cbt-contacts-open .cbt-contacts-toggle,
.cbt-contacts.cbt-contacts-open .cbt-contacts-toggle:hover,
.cbt-contacts.cbt-contacts-open .cbt-contacts-toggle:focus {
  background: var(--cbt-gold) !important;
  color: var(--cbt-dark) !important;
  border-color: var(--cbt-gold) !important;
}
.cbt-contacts.cbt-contacts-open .cbt-contacts-icon-default {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}
.cbt-contacts.cbt-contacts-open .cbt-contacts-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Pulse طلایی ملایم وقتی بسته است */
.cbt-contacts-toggle::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--cbt-gold);
  opacity: 0;
  animation: cbt-pulse 3s ease-out infinite;
  animation-delay: 1.2s;
  pointer-events: none;
}
.cbt-contacts.cbt-contacts-open .cbt-contacts-toggle::before { animation: none; }

/* =========================================================
   FAN-OUT LIST — آیتم‌های راه‌های ارتباطی (فقط آیکون، دایره‌ای)
   لیست وسط‌چین است درست مثل نسخه‌ی اولیه، اما با فاصله‌ی تضمینی
   دوبرابر (gap فلکس + margin پشتیبان) تا آیکون‌ها هرگز به هم یا
   به دکمه‌ی اصلی نچسبند.
   ========================================================= */
.cbt-contacts-fan {
  position: absolute !important;
  bottom: 100% !important;
  left: 50%;
  transform: translateX(-50%);
  /* فاصله‌ی بین دکمه تماس و آیکون واتساپ — با !important قفل شده تا استایل قالب آن را خنثی نکند */
  margin: 0 0 var(--cbt-contact-gap) !important;
  padding: 0 !important;
  list-style: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* فاصله‌ی بین خود آیکون‌ها با یکدیگر */
  gap: var(--cbt-contact-gap-between) !important;
  pointer-events: none;
}

.cbt-contact-item {
  opacity: 0;
  transform: translateY(14px) scale(0.5);
  transition: opacity 0.3s ease, transform 0.4s var(--cbt-ease);
  transition-delay: 0s;
  /* فاصله‌ی تضمینی اضافه — حتی اگر gap فلکس توسط قالب خنثی شود */
  margin-bottom: var(--cbt-contact-gap-between) !important;
}
.cbt-contact-item:last-child { margin-bottom: 0 !important; }

.cbt-contacts.cbt-contacts-open .cbt-contacts-fan { pointer-events: auto; }
.cbt-contacts.cbt-contacts-open .cbt-contact-item {
  opacity: 1;
  transform: translateY(0) scale(1);
  /* انیمیشن پلکانی — آیتم پایینی اول می‌آد بالا */
  transition-delay: calc(var(--i) * 55ms);
}

.cbt-contact-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--cbt-toggle-sz) * 0.72);
  height: calc(var(--cbt-toggle-sz) * 0.72);
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(0,0,0,.4), 0 0 0 0 rgba(255,255,255,0);
  transition: transform 0.25s var(--cbt-ease), box-shadow 0.25s ease, filter 0.2s;
}
/* رنگ آیکون در همه‌ی حالت‌ها با !important قفل می‌شود تا رنگ
   پیش‌فرض قالب (لینک/دکمه) هرگز جایگزین رنگ تعریف‌شده در تنظیمات نشود */
.cbt-contact-link,
.cbt-contact-link:hover,
.cbt-contact-link:focus,
.cbt-contact-link:focus-visible,
.cbt-contact-link:active,
.cbt-contact-link:visited {
  background: var(--cbt-c, var(--cbt-gold)) !important;
  color: #fff !important;
  text-decoration: none !important;
}
.cbt-contact-link:hover {
  transform: scale(1.15) rotate(-6deg);
  box-shadow: 0 6px 20px rgba(0,0,0,.5), 0 0 0 4px rgba(255,255,255,.18);
  filter: brightness(1.08);
}
.cbt-contact-link:active { transform: scale(0.95); }

.cbt-contact-link .cbt-contact-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 55%;
  height: 55%;
  pointer-events: none;
}
.cbt-contact-link .cbt-contact-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* حالت تاریک برای آیکون X (توییتر) که بک‌گراند مشکیه */
.cbt-contact-link[style*="#000000"],
.cbt-contact-link[style*="#000"] {
  border: 1px solid rgba(255,255,255,.2);
}

/* =========================================================
   MOBILE — راه‌های ارتباطی
   ========================================================= */
@media (max-width: 480px) {
  :root {
    --cbt-gap-chat-contacts: 6px;
    --cbt-contact-gap: 18px;
    --cbt-contact-gap-between: 12px;
  }
  .cbt-contacts {
    bottom: calc(var(--cbt-toggle-sz) + var(--cbt-gap-chat-contacts)) !important;
  }
  .cbt-contacts-fan {
    margin: 0 0 var(--cbt-contact-gap) !important;
    gap: var(--cbt-contact-gap-between) !important;
  }
  .cbt-contact-item { margin-bottom: var(--cbt-contact-gap-between) !important; }
  .cbt-contact-item:last-child { margin-bottom: 0 !important; }
  .cbt-contact-link {
    width: calc(var(--cbt-toggle-sz) * 0.68);
    height: calc(var(--cbt-toggle-sz) * 0.68);
  }
}
