:root{
  --pcms-chat-primary:#1E40AF;
  --pcms-chat-primary-dark:#1B3897;
  --pcms-chat-bg:#FFFFFF;
  --pcms-chat-ink:#1B2333;
  --pcms-chat-muted:#6B7280;
  --pcms-chat-border:#E5E7EB;
  --pcms-chat-danger:#DC2626;
}
#pcms-chat-widget,#pcms-chat-widget *{box-sizing:border-box;font-family:'Vazirmatn',Tahoma,sans-serif}
#pcms-chat-widget{position:fixed;bottom:20px;z-index:9999;direction:rtl}
#pcms-chat-widget.pos-left{left:20px}
#pcms-chat-widget.pos-right{right:20px}

.pcms-chat-bubble{
  width:58px;height:58px;border-radius:50%;background:linear-gradient(135deg,var(--pcms-chat-primary),var(--pcms-chat-primary-dark));
  border:0;box-shadow:0 10px 26px rgba(30,64,175,.4);cursor:pointer;display:flex;align-items:center;justify-content:center;
  color:#fff;position:relative;transition:transform .2s ease,box-shadow .2s ease;
}
.pcms-chat-bubble:hover{transform:translateY(-2px);box-shadow:0 14px 32px rgba(30,64,175,.5)}
.pcms-chat-bubble svg{width:26px;height:26px}
.pcms-chat-badge{
  position:absolute;top:-4px;left:-4px;background:var(--pcms-chat-danger);color:#fff;font-size:11px;font-weight:800;
  min-width:20px;height:20px;border-radius:999px;display:flex;align-items:center;justify-content:center;padding:0 5px;
  border:2px solid #fff;
}
@keyframes pcms-pulse{0%,100%{box-shadow:0 10px 26px rgba(30,64,175,.4)}50%{box-shadow:0 10px 26px rgba(30,64,175,.4),0 0 0 8px rgba(30,64,175,.15)}}
.pcms-chat-bubble.has-unread{animation:pcms-pulse 1.8s ease-in-out infinite}
@media (prefers-reduced-motion:reduce){.pcms-chat-bubble.has-unread{animation:none}}

.pcms-chat-panel{
  position:absolute;bottom:72px;width:340px;max-width:88vw;height:480px;max-height:70vh;
  background:var(--pcms-chat-bg);border-radius:18px;box-shadow:0 24px 60px rgba(0,0,0,.25);
  display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--pcms-chat-border);
}
.pos-left .pcms-chat-panel{left:0}
.pos-right .pcms-chat-panel{right:0}
.pcms-chat-panel[hidden]{display:none}

.pcms-chat-header{
  background:linear-gradient(135deg,var(--pcms-chat-primary),var(--pcms-chat-primary-dark));color:#fff;
  padding:14px 16px;display:flex;align-items:center;justify-content:space-between;flex-shrink:0;
}
.pcms-chat-header b{font-size:14px}
.pcms-chat-header span{font-size:11.5px;opacity:.8;display:block;margin-top:2px}
.pcms-chat-close{background:rgba(255,255,255,.15);border:0;color:#fff;width:30px;height:30px;border-radius:50%;cursor:pointer;font-size:16px;flex-shrink:0}
.pcms-chat-close:hover{background:rgba(255,255,255,.25)}

.pcms-chat-body{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:10px}
.pcms-chat-msg{max-width:80%;padding:9px 13px;border-radius:14px;font-size:13px;line-height:1.6;white-space:pre-wrap;word-break:break-word}
.pcms-chat-msg.visitor{align-self:flex-start;background:var(--pcms-chat-primary);color:#fff;border-bottom-left-radius:4px}
.pcms-chat-msg.agent{align-self:flex-end;background:#F1F3F6;color:var(--pcms-chat-ink);border-bottom-right-radius:4px}
.pcms-chat-msg-time{font-size:10px;opacity:.65;margin-top:4px;display:block}

.pcms-chat-form{padding:18px;display:flex;flex-direction:column;gap:10px}
.pcms-chat-form label{font-size:12px;color:var(--pcms-chat-muted);font-weight:700}
.pcms-chat-form input,.pcms-chat-form textarea{
  width:100%;padding:10px 12px;border:1.5px solid var(--pcms-chat-border);border-radius:10px;font-size:13px;font-family:inherit;
}
.pcms-chat-form input:focus,.pcms-chat-form textarea:focus{outline:none;border-color:var(--pcms-chat-primary)}
.pcms-chat-form textarea{min-height:70px;resize:vertical}
.pcms-chat-submit{
  background:var(--pcms-chat-primary);color:#fff;border:0;border-radius:10px;padding:11px;font-weight:700;font-size:13.5px;
  cursor:pointer;margin-top:4px;
}
.pcms-chat-submit:hover{background:var(--pcms-chat-primary-dark)}

.pcms-chat-footer{border-top:1px solid var(--pcms-chat-border);padding:10px;display:flex;gap:8px;flex-shrink:0}
.pcms-chat-footer textarea{
  flex:1;border:1.5px solid var(--pcms-chat-border);border-radius:10px;padding:9px 12px;font-size:13px;font-family:inherit;
  resize:none;max-height:80px;min-height:40px;
}
.pcms-chat-footer textarea:focus{outline:none;border-color:var(--pcms-chat-primary)}
.pcms-chat-send-btn{
  background:var(--pcms-chat-primary);color:#fff;border:0;border-radius:10px;width:42px;flex-shrink:0;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
}
.pcms-chat-send-btn:hover{background:var(--pcms-chat-primary-dark)}
.pcms-chat-send-btn svg{width:18px;height:18px}

.pcms-chat-empty{text-align:center;color:var(--pcms-chat-muted);font-size:12.5px;padding:20px 10px}

@media (max-width:480px){
  .pcms-chat-panel{width:92vw;height:75vh;bottom:76px}
}
