/* =========================================================================
   فرم‌ساز نابغه — Live chat widget
   ========================================================================= */
#cw-root, #cw-root button, #cw-root textarea, #cw-root input, #cw-root div, #cw-root span, #cw-root p {
  box-sizing: border-box; font-family: var(--font-fa); -webkit-tap-highlight-color: transparent;
}

#cw-fab {
  position: fixed; bottom: 22px; left: 22px; width: 58px; height: 58px; border-radius: 50%; border: none;
  cursor: pointer; z-index: 2500; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--gold), var(--gold-deep)); box-shadow: 0 10px 26px -8px var(--gold-glow);
  transition: transform .18s var(--ease-pop);
}
#cw-fab:active { transform: scale(.9); }
#cw-fab svg { width: 25px; height: 25px; color: var(--on-accent); }
#cw-badge {
  position: absolute; top: -2px; left: -2px; min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: .66rem; font-weight: 900; display: none; align-items: center;
  justify-content: center; border: 2px solid var(--bg); padding: 0 4px;
}

#cw-bd { display: none; position: fixed; inset: 0; z-index: 2490; background: rgba(15,18,12,.5); backdrop-filter: blur(6px); }
#cw-bd.on { display: block; }

#cw-win {
  position: fixed; z-index: 2499; display: none; flex-direction: column; overflow: hidden; background: var(--card);
  border: 1px solid var(--border-soft); box-shadow: var(--shadow-pop);
}
#cw-win.on { display: flex; }

@media (min-width: 501px) {
  #cw-win { bottom: 92px; left: 22px; width: 372px; height: 570px; border-radius: 26px; animation: cw-pop .3s var(--ease-pop); transform-origin: bottom left; }
}
@keyframes cw-pop { from { opacity: 0; transform: scale(.86) translateY(14px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@media (max-width: 500px) {
  #cw-win { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); width: calc(100vw - 24px); max-width: 420px; height: 78vh; max-height: 620px; border-radius: 24px; }
  #cw-win.on { animation: cw-mob-in .3s var(--ease-pop) forwards; }
  @keyframes cw-mob-in { from { opacity:0; transform: translate(-50%,-46%) scale(.93); } to { opacity: 1; transform: translate(-50%,-50%) scale(1); } }
}

#cw-hdr { display: flex; align-items: center; gap: 10px; padding: 15px 16px 14px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; background: var(--surface-2); }
.cw-hav { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(150deg, var(--gold), var(--gold-deep)); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; box-shadow: 0 3px 10px var(--gold-glow); flex-shrink: 0; }
.cw-hname { font-size: .87rem; font-weight: 800; color: var(--ink); }
.cw-hst { font-size: .68rem; color: var(--success); margin-top: 1px; display: flex; align-items: center; gap: 4px; }
.cw-hdot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); display: inline-block; animation: cw-blink 2s infinite; }
@keyframes cw-blink { 0%,100%{opacity:1} 50%{opacity:.25} }
#cw-xbtn { margin-right: auto; width: 30px; height: 30px; border-radius: 50%; background: var(--card); border: 1px solid var(--border-soft); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); flex-shrink: 0; }
#cw-xbtn svg { width: 13px; height: 13px; }

#cw-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 18px 16px; display: flex; flex-direction: column; gap: 11px; min-height: 0; background: var(--bg); }

.cw-scr { display: none; flex-direction: column; gap: 12px; height: 100%; }
.cw-scr.on { display: flex; animation: fade-up .2s ease; }

.cw-ttl { font-size: .96rem; font-weight: 800; color: var(--ink); }
.cw-sub { font-size: .78rem; color: var(--ink-soft); line-height: 1.65; margin-top: 2px; }

.cw-ldr { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 40px 0; flex: 1; }

.cw-msg { max-width: 78%; padding: 10px 14px; border-radius: 16px; font-size: .84rem; line-height: 1.6; word-break: break-word; }
.cw-msg.user { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border-soft); border-bottom-left-radius: 4px; }
.cw-msg.admin { align-self: flex-end; background: linear-gradient(150deg, var(--gold), var(--gold-deep)); color: var(--on-accent); border-bottom-right-radius: 4px; }
.cw-msg .cw-time { font-size: .62rem; opacity: .65; margin-top: 4px; display: block; }
.cw-msg img { max-width: 100%; border-radius: 10px; display: block; }
.cw-day-sep { align-self: center; font-size: .68rem; color: var(--ink-faint); background: var(--surface-2); padding: 4px 12px; border-radius: var(--radius-pill); margin: 6px 0; }

#cw-composer { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border-soft); flex-shrink: 0; background: var(--surface); }
#cw-input { flex: 1; border: 1.5px solid var(--border); background: var(--surface-2); border-radius: var(--radius-pill); padding: 11px 16px; font-size: .85rem; color: var(--ink); resize: none; max-height: 90px; }
#cw-input:focus { outline: none; border-color: var(--gold); }
.cw-send-btn, .cw-attach-btn { width: 40px; height: 40px; border-radius: 50%; border: none; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cw-send-btn { background: linear-gradient(150deg, var(--gold), var(--gold-deep)); color: var(--on-accent); }
.cw-attach-btn { background: var(--surface-2); color: var(--ink-soft); }

.cw-start-form .field { margin-bottom: 12px; }
