/* ===== ویجت چت پشتیبانی ===== */
#chatFab{position:sticky;bottom:24px;inset-inline-end:24px;z-index:140;width:58px;height:58px;border-radius:18px;
  background:var(--accent);color:#fff;display:grid;place-items:center;cursor:pointer;
  box-shadow:0 14px 34px var(--accent-soft);transition:transform .3s var(--ease),background .3s}
#chatFab:hover{transform:translateY(-3px);background:var(--accent-strong)}
#chatFab svg{width:26px;height:26px}
.fab-badge{position:absolute;top:-6px;inset-inline-start:-6px;min-width:22px;height:22px;border-radius:999px;
  background:var(--err);color:#fff;font-size:.7rem;font-weight:700;display:grid;place-items:center;padding-inline:6px}

#chatPanel{position:fixed;bottom:96px;inset-inline-end:24px;z-index:140;
  width:min(380px,calc(100vw - 32px));height:min(520px,70vh);
  background:var(--bg);border:1px solid var(--border);border-radius:20px;box-shadow:var(--shadow-lg);
  display:flex;flex-direction:column;overflow:hidden;
  opacity:0;visibility:hidden;transform:translateY(16px) scale(.98);transition:all .3s var(--ease)}
#chatPanel.open{opacity:1;visibility:visible;transform:none}

.chat-head{display:flex;align-items:center;gap:10px;background:var(--accent);color:#fff;padding:14px 16px}
.chat-head strong{display:block;font-size:.95rem;line-height:1.4}
.chat-head small{font-size:.72rem;opacity:.9}
.chat-dot{width:9px;height:9px;border-radius:50%;background:#4ADE80;flex-shrink:0;animation:chatPulse 2s infinite}
@keyframes chatPulse{0%{box-shadow:0 0 0 0 rgba(74,222,128,.5)}100%{box-shadow:0 0 0 8px rgba(74,222,128,0)}}
.chat-close{margin-inline-start:auto;color:#fff;opacity:.85;cursor:pointer}
.chat-close:hover{opacity:1}
.chat-close svg{width:18px;height:18px}

.chat-start{padding:22px;display:grid;gap:12px}
.chat-welcome{font-size:.9rem;line-height:1.9;color:var(--muted)}
.chat-name{padding:12px 14px;border-radius:12px;border:1.5px solid var(--border);background:var(--bg)}
.chat-name:focus{outline:none;border-color:var(--accent)}

.chat-body{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:10px;background:var(--surface)}
.chat-msg{display:flex;flex-direction:column;max-width:82%}
.chat-msg.out{align-self:flex-end;align-items:flex-end}
.chat-msg.in{align-self:flex-start;align-items:flex-start}
.bubble{padding:10px 14px;border-radius:14px;font-size:.88rem;line-height:1.7;word-break:break-word}
.chat-msg.out .bubble{background:var(--accent);color:#fff;border-end-end-radius:4px}
.chat-msg.in .bubble{background:var(--bg);border:1px solid var(--border);border-end-start-radius:4px}
.mtime{font-size:.66rem;color:var(--muted);margin-top:4px}
.chat-closed-note{text-align:center;color:var(--muted);font-size:.8rem;padding:10px}

.chat-foot{display:flex;gap:8px;padding:12px;border-top:1px solid var(--border);background:var(--bg)}
.chat-input{flex:1;padding:11px 14px;border-radius:12px;border:1.5px solid var(--border);background:var(--bg)}
.chat-input:focus{outline:none;border-color:var(--accent)}
.chat-send{width:44px;height:44px;border-radius:12px;background:var(--accent);color:#fff;display:grid;place-items:center;flex-shrink:0;transition:background .25s}
.chat-send:hover{background:var(--accent-strong)}
.chat-send svg{width:18px;height:18px}
html[dir="rtl"] .chat-send svg{transform:scaleX(-1)}

@media (max-width:480px){
  #chatPanel{inset-inline:16px;bottom:92px;width:auto}
}
@media (prefers-reduced-motion:reduce){
  #chatPanel,#chatFab{transition-duration:.01ms!important}
  .chat-dot{animation:none}
}