/* ===== SAFAREJA — دستیار چت‌بات سوالات متداول (صفحه اصلی) ===== */

.faq-chat-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-height, 68px) + 16px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3d6bff 0%, #6a5df0 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(61, 93, 240, 0.4);
  z-index: 61;
  transition: transform 0.25s var(--transition, ease);
}
.faq-chat-fab:hover { transform: scale(1.08); }
.faq-chat-fab:active { transform: scale(0.95); }
.faq-chat-fab-label {
  position: absolute;
  right: calc(100% + 8px);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.faq-chat-fab:hover .faq-chat-fab-label { opacity: 1; }
.faq-chat-fab.is-open { transform: scale(0.92); }

/* روی دسکتاپ هم باید نسبت به کل صفحه (viewport) ثابت بماند، نه فقط نسبت
   به .app-inner — وگرنه پایین‌ترِ محتوای صفحه گیر می‌کند و با اسکرول
   جابه‌جا نمی‌شود. همان‌طور که .support-fab هم با !important در
   css/desktop.css همیشه fixed نگه داشته می‌شود. */
.faq-chat-fab { position: fixed !important; }

/* ─── پنل چت ───────────────────────────────────────────────────────── */

.faq-chat-panel {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-height, 68px) + 78px);
  width: min(340px, calc(100vw - 32px));
  max-height: min(480px, calc(100vh - 220px));
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 24px);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 61;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s var(--transition, ease);
}
.faq-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.faq-chat-panel { position: fixed !important; }

.faq-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #3d6bff 0%, #6a5df0 100%);
  color: #fff;
  flex-shrink: 0;
}
.faq-chat-head-title { display: flex; align-items: center; gap: 10px; }
.faq-chat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.faq-chat-head-title .t { font-weight: 800; font-size: 0.88rem; line-height: 1.4; }
.faq-chat-head-title .s { font-weight: 500; font-size: 0.68rem; opacity: 0.85; line-height: 1.4; }
.faq-chat-close {
  width: 28px; height: 28px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.18); color: #fff;
  font-size: 0.85rem; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.faq-chat-close:hover { background: rgba(255,255,255,0.3); }

.faq-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

.faq-msg { display: flex; max-width: 88%; }
.faq-msg.bot { align-self: flex-start; }
.faq-msg.user { align-self: flex-end; }
.faq-msg .bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.8rem;
  line-height: 1.9;
  white-space: pre-line;
}
.faq-msg.bot .bubble {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.faq-msg.user .bubble {
  background: linear-gradient(135deg, #3d6bff 0%, #6a5df0 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.faq-msg .bubble a.faq-support-link {
  display: inline-block;
  margin-top: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.74rem;
  padding: 7px 12px;
  border-radius: 10px;
}

.faq-chat-quick {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  max-height: 120px;
  overflow-y: auto;
}
.faq-chat-quick .qbtn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.faq-chat-quick .qbtn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.faq-chat-input-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.faq-chat-input-row input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.8rem;
  font-family: var(--font, 'Vazirmatn', sans-serif);
  outline: none;
}
.faq-chat-input-row input:focus { border-color: var(--accent); }
.faq-chat-input-row button {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #3d6bff 0%, #6a5df0 100%);
  color: #fff; font-size: 1rem; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.faq-chat-input-row button:active { transform: scale(0.92); }

.faq-typing { display: flex; gap: 4px; padding: 3px 0; }
.faq-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: faqTypingBlink 1.2s infinite ease-in-out;
}
.faq-typing span:nth-child(2) { animation-delay: 0.2s; }
.faq-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes faqTypingBlink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}
