/* ---------- site chat widget ---------- */
.chatw { position: fixed; z-index: 150; bottom: 20px; left: 20px; font-family: var(--font); }
.chatw__fab {
  width: 60px; height: 60px; border-radius: 20px; border: 0; background: var(--mint); color: var(--navy-900);
  display: grid; place-items: center; box-shadow: 0 14px 34px -10px rgba(62, 224, 168, .7); transition: transform .35s var(--ease-spring), border-radius .3s;
  position: relative;
}
.chatw__fab:hover { transform: translateY(-3px) rotate(-6deg); }
.chatw__fab .ico { width: 28px; height: 28px; }
.chatw__badge { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; border-radius: 8px; background: #EF4444; color: #fff; font-size: .75rem; font-weight: 800; display: grid; place-items: center; padding: 0 5px; }
.chatw__panel {
  position: absolute; bottom: 76px; left: 0; width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100vh - 120px));
  background: var(--white); color: var(--ink); border-radius: 24px; box-shadow: 0 30px 80px -20px rgba(7, 23, 51, .55), 0 0 0 1px rgba(14, 42, 90, .08);
  display: flex; flex-direction: column; overflow: hidden;
  transform-origin: bottom left; transform: scale(.9) translateY(10px); opacity: 0; visibility: hidden;
  transition: transform .35s var(--ease-spring), opacity .2s, visibility 0s .35s;
}
.chatw.is-open .chatw__panel { transform: none; opacity: 1; visibility: visible; transition: transform .35s var(--ease-spring), opacity .2s; }
.chatw__head { background: var(--navy-900); color: var(--white); padding: 16px 18px; display: flex; align-items: center; gap: 12px; }
.chatw__avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); display: grid; place-items: center; flex: none; }
.chatw__avatar img { width: 26px; }
.chatw__title { font-weight: 800; font-size: 1rem; line-height: 1.4; }
.chatw__sub { font-size: .8rem; color: var(--muted-dark); display: flex; align-items: center; gap: 6px; }
.chatw__sub::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--mint); }
.chatw__close { margin-inline-start: auto; width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .08); color: var(--white); display: grid; place-items: center; }
.chatw__log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-light); overscroll-behavior: contain; }
.chatw__msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; line-height: 1.8; white-space: pre-wrap; word-wrap: break-word; font-size: .95rem; animation: msgIn .35s var(--ease-out); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.chatw__msg--visitor { align-self: flex-start; background: var(--blue); color: var(--white); border-bottom-right-radius: 6px; }
.chatw__msg--ai, .chatw__msg--admin { align-self: flex-end; background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.chatw__msg--admin { border-color: rgba(18, 184, 134, .5); }
.chatw__msg--admin::before { content: "کارشناس"; display: block; font-size: .72rem; font-weight: 800; color: var(--green); }
.chatw__msg--system { align-self: center; background: transparent; color: var(--muted); font-size: .85rem; text-align: center; max-width: 95%; }
.chatw__typing { align-self: flex-end; display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; }
.chatw__typing i { width: 7px; height: 7px; border-radius: 2px; background: var(--blue); animation: typing 1.2s infinite; }
.chatw__typing i:nth-child(2) { animation-delay: .15s; background: var(--green); }
.chatw__typing i:nth-child(3) { animation-delay: .3s; background: var(--mint); }
@keyframes typing { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-5px) rotate(45deg); opacity: 1; } }
.chatw__quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; background: var(--bg-light); }
.chatw__quick button { border: 1px solid var(--line); background: var(--white); border-radius: 10px; padding: 6px 12px; min-height: 36px; font-size: .85rem; color: var(--ink); }
.chatw__quick button:hover { border-color: var(--blue); color: var(--blue); }
.chatw__form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--white); }
.chatw__form textarea { flex: 1; resize: none; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 14px; min-height: 46px; max-height: 120px; font-size: .95rem; line-height: 1.6; }
.chatw__form textarea:focus { outline: none; border-color: var(--blue); }
.chatw__send { width: 46px; height: 46px; border-radius: 14px; border: 0; background: var(--blue); color: var(--white); display: grid; place-items: center; flex: none; }
.chatw__send:disabled { opacity: .5; }
.chatw__send .ico { transform: scaleX(-1); }
.chatw__human { background: none; border: 0; color: var(--blue); font-size: .8rem; padding: 6px 16px 10px; text-align: start; background: var(--white); min-height: 32px; }
@media (max-width: 480px) {
  .chatw { bottom: 14px; left: 14px; }
  .chatw__panel { position: fixed; inset: auto 8px 86px 8px; width: auto; height: min(70vh, 560px); }
}
