/* ویجت پشتیبانی آنلاین — همیشه fixed به گوشه viewport؛ بسته = کاملاً مخفی */
#tebSupportRoot {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  pointer-events: none !important;
  transform: none !important;
  z-index: 2147482990 !important;
  overflow: hidden !important;
  contain: layout style !important;
}

#tebSupportRoot * {
  box-sizing: border-box !important;
}

.teb-support-fab {
  position: absolute !important;
  z-index: 2147483000 !important;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
  left: 24px !important;
  right: auto !important;
  top: auto !important;
  width: 56px !important;
  height: 56px !important;
  min-width: 56px !important;
  min-height: 56px !important;
  max-width: 56px !important;
  max-height: 56px !important;
  border-radius: 50% !important;
  border: none !important;
  background: linear-gradient(135deg, #0d9488, #0f766e) !important;
  color: #fff !important;
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.45) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: grab !important;
  padding: 0 !important;
  margin: 0 !important;
  transform: none !important;
  pointer-events: auto !important;
  touch-action: none !important;
  -ms-touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-user-drag: none !important;
  -webkit-tap-highlight-color: transparent !important;
  font-size: 0 !important;
  line-height: 0 !important;
  overflow: hidden !important;
  flex: 0 0 56px !important;
}

.teb-support-fab--dragging {
  cursor: grabbing !important;
  opacity: 0.92 !important;
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.55) !important;
}

.teb-support-fab svg {
  width: 26px !important;
  height: 26px !important;
  max-width: 26px !important;
  max-height: 26px !important;
  pointer-events: none !important;
  display: block !important;
  flex-shrink: 0 !important;
}

.teb-support-fab-badge {
  position: absolute !important;
  top: -2px !important;
  right: -2px !important;
  min-width: 18px !important;
  height: 18px !important;
  border-radius: 9px !important;
  background: #ef4444 !important;
  color: #fff !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  line-height: 18px !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 4px !important;
}

.teb-support-fab-badge.is-on {
  display: flex !important;
}

/* بسته: حتی اگر CSS صفحه display را مجبور کند، مخفی بماند */
.teb-support-panel {
  position: absolute !important;
  z-index: 2147482999 !important;
  bottom: 96px !important;
  left: 24px !important;
  width: min(380px, calc(100vw - 32px)) !important;
  max-height: min(520px, calc(100vh - 120px)) !important;
  background: #fff !important;
  border-radius: 16px !important;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18) !important;
  display: none !important;
  flex-direction: column !important;
  overflow: hidden !important;
  border: 1px solid rgba(13, 148, 136, 0.15) !important;
  pointer-events: none !important;
  transform: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  max-height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
}

.teb-support-panel.open {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  max-height: min(520px, calc(100vh - 120px)) !important;
  pointer-events: auto !important;
  clip: auto !important;
  clip-path: none !important;
}

.teb-support-panel:not(.open) > * {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.teb-support-head {
  background: linear-gradient(135deg, #0d9488, #0f766e) !important;
  color: #fff !important;
  padding: 12px 14px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
}

.teb-support-head h6 {
  margin: 0 !important;
  font-size: 0.95rem !important;
  font-weight: 700 !important;
  color: #fff !important;
  line-height: 1.4 !important;
}

.teb-support-log {
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  padding: 12px !important;
  background: #f8fafc !important;
  min-height: 180px !important;
}

.teb-support-msg {
  margin-bottom: 10px !important;
  max-width: 92% !important;
}

.teb-support-msg.user {
  margin-right: auto !important;
}

.teb-support-msg.ai,
.teb-support-msg.agent,
.teb-support-msg.system {
  margin-left: auto !important;
}

.teb-support-bubble {
  padding: 8px 12px !important;
  border-radius: 12px !important;
  font-size: 0.88rem !important;
  line-height: 1.55 !important;
  white-space: pre-wrap !important;
  word-break: break-word !important;
}

.teb-support-msg.user .teb-support-bubble {
  background: #0d9488 !important;
  color: #fff !important;
  border-bottom-right-radius: 4px !important;
}

.teb-support-msg.ai .teb-support-bubble,
.teb-support-msg.agent .teb-support-bubble {
  background: #fff !important;
  border: 1px solid #e2e8f0 !important;
  border-bottom-left-radius: 4px !important;
}

.teb-support-msg.system .teb-support-bubble {
  background: #fef3c7 !important;
  color: #92400e !important;
  font-size: 0.8rem !important;
}

.teb-support-meta {
  font-size: 0.7rem !important;
  color: #94a3b8 !important;
  margin-bottom: 2px !important;
}

.teb-support-compose {
  padding: 10px !important;
  border-top: 1px solid #e2e8f0 !important;
  background: #fff !important;
  flex-shrink: 0 !important;
}

.teb-support-compose-row {
  display: flex !important;
  gap: 8px !important;
  align-items: stretch !important;
  margin: 0 !important;
}

.teb-support-compose input {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 10px !important;
  padding: 8px 12px !important;
  font-size: 0.9rem !important;
  line-height: 1.4 !important;
}

.teb-support-send {
  border: none !important;
  background: #0d9488 !important;
  color: #fff !important;
  border-radius: 10px !important;
  padding: 8px 14px !important;
  font-size: 0.85rem !important;
  white-space: nowrap !important;
  width: auto !important;
  min-width: auto !important;
  max-width: none !important;
  height: auto !important;
  flex: 0 0 auto !important;
}

.teb-support-foot {
  font-size: 0.72rem !important;
  color: #64748b !important;
  padding: 0 12px 10px !important;
  line-height: 1.4 !important;
  flex-shrink: 0 !important;
}

.teb-support-backdrop {
  position: absolute !important;
  inset: 0 !important;
  z-index: 2147482998 !important;
  background: rgba(15, 23, 42, 0.25) !important;
  display: none !important;
  pointer-events: none !important;
  transform: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

.teb-support-backdrop.open {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* موبایل: FAB بالای منوی پایین */
@media (max-width: 991px) {
  body.teb-has-bottom-nav .teb-support-fab {
    bottom: calc(var(--teb-bottom-nav-offset, 72px) + 12px) !important;
  }

  body.teb-support-panel-open .teb-bottom-nav {
    z-index: 99980 !important;
  }

  .teb-support-panel.open {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    bottom: calc(var(--teb-bottom-nav-offset, 72px) + 8px) !important;
    width: calc(100vw - 16px) !important;
    max-height: min(480px, calc(100vh - var(--teb-bottom-nav-offset, 72px) - 24px)) !important;
  }
}

@media (min-width: 992px) {
  #tebBnavSupport {
    display: none !important;
  }

  .teb-support-panel.open {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

body.teb-no-support-widget #tebSupportRoot,
body.teb-no-support-widget .teb-support-fab,
body.teb-no-support-widget .teb-support-panel,
body.teb-no-support-widget .teb-support-backdrop,
body.teb-no-support-widget #tebBnavSupport {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* هنگام باز بودن پنل پیام‌ها، root پشتیبانی زیر لایهٔ اعلان برود */
body.teb-notif-panel-open #tebSupportRoot {
  z-index: 2147482900 !important;
}

.teb-support-typing .teb-support-bubble {
  opacity: 0.7 !important;
  font-style: italic !important;
}
