/* ==========================================================================
   پشتیبانی آنلاین — ویجت گوشه‌ی پایین سمت چپ
   ========================================================================== */

.vc {
  --vc-brand: #6d28d9;
  --vc-brand-2: #4f46e5;
  --vc-bg: #ffffff;
  --vc-soft: #f6f5fb;
  --vc-line: #e7e5ef;
  --vc-ink: #1b1630;
  --vc-muted: #6b6880;
  --vc-me: #6d28d9;
  --vc-me-ink: #ffffff;
  --vc-them: #f1effa;
  --vc-them-ink: #1b1630;
  --vc-online: #10b981;
  --vc-shadow: 0 24px 60px -18px rgba(39, 16, 92, .45), 0 2px 8px rgba(17, 12, 34, .08);
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  direction: rtl;
}

html.dark .vc {
  --vc-bg: #161c25;
  --vc-soft: #10151d;
  --vc-line: #273142;
  --vc-ink: #e6eaf0;
  --vc-muted: #8d99a8;
  --vc-them: #212a37;
  --vc-them-ink: #e6eaf0;
  --vc-shadow: 0 24px 60px -18px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .4);
}

.vc [hidden] { display: none !important; }

/* دکمه‌ی بازگشت به بالا کمی بالاتر می‌رود تا روی دکمه‌ی گفتگو نیفتد */
html.vc-on #toTop { bottom: 6.25rem !important; }

/* ------------------------------------------------------------ دکمه‌ی شناور */
.vc-launcher {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  z-index: 85;
  display: grid;
  place-items: center;
  width: 3.75rem;
  height: 3.75rem;
  border: 0;
  border-radius: 1.25rem;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, var(--vc-brand-2));
  box-shadow: 0 8px 20px -8px rgba(15, 23, 42, .5);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-radius .2s ease;
}
.vc-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -10px rgba(15, 23, 42, .55); }
.vc-launcher:focus-visible { outline: 3px solid rgba(124, 58, 237, .45); outline-offset: 3px; }
.vc-launcher i { font-size: 1.45rem; transition: transform .25s ease, opacity .2s ease; }
.vc-launcher .vc-ico-close { position: absolute; opacity: 0; transform: rotate(-90deg) scale(.6); }
.vc.is-open .vc-launcher .vc-ico-open { opacity: 0; transform: rotate(90deg) scale(.6); }
.vc.is-open .vc-launcher .vc-ico-close { opacity: 1; transform: none; }

.vc-launcher::after { /* موج ملایم برای جلب توجه (فقط وقتی آنلاین است) */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(124, 58, 237, .45);
  animation: vc-pulse 2.6s ease-out 3; /* فقط چند بار بعد از باز شدن صفحه، نه همیشه */
  pointer-events: none;
}
.vc:not(.is-online) .vc-launcher::after,
.vc.is-open .vc-launcher::after { animation: none; }
@keyframes vc-pulse {
  0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, .45); }
  70%, 100% { box-shadow: 0 0 0 16px rgba(124, 58, 237, 0); }
}

.vc-dot {
  position: absolute;
  top: .3rem;
  right: .3rem;
  width: .8rem;
  height: .8rem;
  border-radius: 999px;
  border: 2px solid #fff;
  background: #94a3b8;
}
.vc.is-online .vc-dot { background: var(--vc-online); }

.vc-badge {
  position: absolute;
  top: -.4rem;
  left: -.4rem;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.35rem;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

/* ------------------------------------------------------------------ پنجره */
.vc-panel {
  position: fixed;
  left: 1.25rem;
  bottom: 5.9rem;
  z-index: 86;
  display: flex;
  flex-direction: column;
  width: 23rem;
  height: min(36rem, calc(100vh - 7.5rem));
  border-radius: 1.4rem;
  overflow: hidden;
  background: var(--vc-bg);
  color: var(--vc-ink);
  border: 1px solid var(--vc-line);
  box-shadow: var(--vc-shadow);
  transform-origin: bottom left;
  animation: vc-in .22s ease;
}
.vc-panel[hidden] { display: none; }
@keyframes vc-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.vc-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1rem .95rem;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, var(--vc-brand-2));
}
.vc-avatar {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, .18);
  font-size: 1.15rem;
}
.vc-avatar .vc-dot { top: auto; right: auto; bottom: -.15rem; left: -.15rem; border-color: #6d28d9; }
.vc-head-text { min-width: 0; flex: 1; }
.vc-title { margin: 0; font-size: .92rem; font-weight: 800; line-height: 1.5; }
.vc-sub { margin: 0; font-size: .72rem; opacity: .88; line-height: 1.6; }
.vc-icon-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: .75rem;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease;
}
.vc-icon-btn:hover { background: rgba(255, 255, 255, .26); }
.vc-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.vc-menu {
  position: absolute;
  top: 3.6rem;
  left: .9rem;
  z-index: 3;
  min-width: 11rem;
  padding: .35rem;
  border-radius: .9rem;
  background: var(--vc-bg);
  border: 1px solid var(--vc-line);
  box-shadow: var(--vc-shadow);
}
.vc-menu button {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  padding: .55rem .7rem;
  border: 0;
  border-radius: .6rem;
  background: transparent;
  color: var(--vc-ink);
  font: inherit;
  font-size: .8rem;
  text-align: right;
  cursor: pointer;
}
.vc-menu button:hover { background: var(--vc-soft); }
.vc-menu i { width: 1rem; color: var(--vc-brand); }

/* ---------------------------------------------------------------- پیام‌ها */
.vc-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem .9rem .5rem;
  background: var(--vc-soft);
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.vc-body::-webkit-scrollbar { width: 6px; }
.vc-body::-webkit-scrollbar-thumb { background: var(--vc-line); border-radius: 6px; }

.vc-msg { display: flex; flex-direction: column; margin-bottom: .6rem; max-width: 84%; }
.vc-msg.me { margin-inline-start: 0; margin-inline-end: auto; align-items: flex-start; }
.vc-msg.them { margin-inline-start: auto; align-items: flex-end; }
.vc-bubble {
  padding: .6rem .85rem;
  border-radius: 1.1rem;
  font-size: .85rem;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.vc-msg.me .vc-bubble { background: var(--vc-me); color: var(--vc-me-ink); border-start-start-radius: .35rem; }
.vc-msg.them .vc-bubble { background: var(--vc-them); color: var(--vc-them-ink); border-start-end-radius: .35rem; }
html:not(.dark) .vc-msg.them .vc-bubble { background: #fff; box-shadow: 0 1px 2px rgba(17, 12, 34, .06); border: 1px solid var(--vc-line); }
.vc-bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.vc-meta { margin-top: .2rem; padding-inline: .3rem; font-size: .66rem; color: var(--vc-muted); }

.vc-sys {
  margin: .4rem auto .8rem;
  max-width: 92%;
  padding: .45rem .8rem;
  border-radius: .8rem;
  background: rgba(124, 58, 237, .08);
  color: var(--vc-muted);
  font-size: .74rem;
  line-height: 1.8;
  text-align: center;
}
.vc-day { margin: .3rem 0 .7rem; text-align: center; font-size: .68rem; color: var(--vc-muted); }

.vc-typing { display: inline-flex; gap: .25rem; padding: .75rem .9rem; }
.vc-typing span { width: .4rem; height: .4rem; border-radius: 999px; background: var(--vc-muted); animation: vc-blink 1.2s infinite ease-in-out; }
.vc-typing span:nth-child(2) { animation-delay: .15s; }
.vc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes vc-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* --------------------------------------------- فرم شروع، امتیاز، گفتگوی تازه */
.vc-card {
  margin: .2rem 0 .8rem;
  padding: .85rem;
  border-radius: 1rem;
  background: var(--vc-bg);
  border: 1px solid var(--vc-line);
}
.vc-card p { margin: 0 0 .55rem; font-size: .76rem; line-height: 1.8; color: var(--vc-muted); }
.vc-field { display: block; margin-bottom: .5rem; }
.vc-field span { display: block; margin-bottom: .25rem; font-size: .72rem; font-weight: 700; color: var(--vc-ink); }
.vc-input {
  width: 100%;
  box-sizing: border-box;
  padding: .6rem .75rem;
  border-radius: .75rem;
  border: 1px solid var(--vc-line);
  background: var(--vc-soft);
  color: var(--vc-ink);
  font: inherit;
  font-size: .82rem;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.vc-input:focus { border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139, 92, 246, .18); }
.vc-input.is-bad { border-color: #e11d48; }
.vc-err { display: block; margin-top: .2rem; font-size: .7rem; color: #e11d48; }

.vc-stars { display: flex; justify-content: center; gap: .35rem; direction: ltr; }
.vc-stars button { border: 0; background: transparent; font-size: 1.5rem; color: #d6d3e2; cursor: pointer; padding: 0 .1rem; transition: transform .12s ease, color .12s ease; }
.vc-stars button:hover, .vc-stars button.is-on { color: #f59e0b; transform: scale(1.1); }
.vc-btn {
  display: block;
  width: 100%;
  margin-top: .6rem;
  padding: .6rem;
  border: 0;
  border-radius: .8rem;
  background: linear-gradient(135deg, #7c3aed, var(--vc-brand-2));
  color: #fff;
  font: inherit;
  font-size: .8rem;
  font-weight: 800;
  cursor: pointer;
}

/* ------------------------------------------------------------- نوشتن پیام */
.vc-foot { padding: .65rem .7rem .7rem; background: var(--vc-bg); border-top: 1px solid var(--vc-line); }
.vc-compose { display: flex; align-items: flex-end; gap: .5rem; }
.vc-text {
  flex: 1;
  max-height: 7.5rem;
  min-height: 2.75rem;
  resize: none;
  box-sizing: border-box;
  padding: .65rem .85rem;
  border-radius: 1rem;
  border: 1px solid var(--vc-line);
  background: var(--vc-soft);
  color: var(--vc-ink);
  font: inherit;
  font-size: .85rem;
  line-height: 1.6;
  outline: none;
}
.vc-text:focus { border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139, 92, 246, .16); }
.vc-send {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: .95rem;
  background: linear-gradient(135deg, #7c3aed, var(--vc-brand-2));
  color: #fff;
  cursor: pointer;
  transition: opacity .15s ease, transform .15s ease;
}
.vc-send:hover { transform: translateY(-1px); }
.vc-send:disabled { opacity: .45; cursor: default; transform: none; }
.vc-send i { transform: scaleX(-1); }
.vc-note { margin: .45rem .2rem 0; font-size: .66rem; color: var(--vc-muted); text-align: center; }
.vc-note a { color: inherit; }

.vc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- موبایل */
@media (max-width: 520px) {
  .vc-launcher { left: .75rem; bottom: .75rem; width: 3.1rem; height: 3.1rem; border-radius: 1rem; }
  .vc-launcher i { font-size: 1.25rem; }
  html.vc-on #toTop { bottom: 4.5rem !important; left: 1.05rem !important; width: 2.5rem; height: 2.5rem; }
  .vc-panel { inset: 0; left: 0; bottom: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; border: 0; }
  .vc.is-open .vc-launcher { display: none; }
  /* هنگام اسکرول رو به پایین کنار می‌رود (chat.js) */
  .vc-launcher { transition: transform .25s ease, opacity .25s ease, box-shadow .2s ease, border-radius .2s ease; }
  .vc.is-tucked .vc-launcher { transform: translateY(calc(100% + 1.25rem)); opacity: 0; pointer-events: none; }
}

@media (prefers-reduced-motion: reduce) {
  .vc-launcher::after, .vc-panel, .vc-typing span { animation: none !important; }
}

@media print { .vc { display: none !important; } }

/* تیک‌های پیام مثل تلگرام: یک تیک = ارسال شد، دو تیک آبی = پشتیبان خواند */
.vc-tick { margin-inline-start: .3rem; font-size: .62rem; color: var(--vc-muted); vertical-align: -1px; transition: color .25s ease; }
.vc-tick.is-read { color: #0ea5e9; }
html.dark .vc-tick.is-read { color: #38bdf8; }

/* پیوست فایل و عکس */
.vc-attach { display: grid; flex: none; place-items: center; width: 2.75rem; height: 2.75rem; border: 1px solid var(--vc-line); border-radius: .95rem; color: var(--vc-muted); cursor: pointer; position: relative; transition: color .15s ease, background .15s ease; }
.vc-attach:hover { color: var(--vc-brand); background: var(--vc-soft); }
.vc-attach[hidden] { display: none; }
.vc-file { display: flex; align-items: center; gap: .55rem; max-width: 15rem; margin-top: .3rem; padding: .55rem .7rem; border: 1px solid var(--vc-line); border-radius: .9rem; background: var(--vc-bg); color: var(--vc-ink); font-size: .72rem; text-decoration: none; }
.vc-file > i { font-size: 1.1rem; color: var(--vc-brand); flex: none; }
.vc-file span { display: flex; flex-direction: column; min-width: 0; }
.vc-file b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.vc-file small { color: var(--vc-muted); font-size: .65rem; }
.vc-file.is-img { display: block; padding: 0; overflow: hidden; max-width: 14rem; }
.vc-file.is-img img { display: block; width: 100%; max-height: 14rem; object-fit: cover; }
