/* A2 CRM - Web Chat Widget */
:root{
  --a2-chat-bg: rgba(255,252,245,0.92);
  --a2-chat-bg1: rgba(255,255,255,0.95);
  --a2-chat-bg2: rgba(255,243,214,0.86);
  --a2-chat-header-bg1: rgba(212,175,55,0.12);
  --a2-chat-header-bg2: rgba(212,175,55,0.04);
  --a2-chat-soft: rgba(212,175,55,0.12);
  --a2-chat-border: rgba(212,175,55,0.28);
  --a2-chat-accent: #d4af37;
  --a2-chat-accent-2: #b9891f;
  --a2-chat-text: #0f172a;
  --a2-chat-muted: #64748b;
  --a2-chat-glow: rgba(212,175,55,0.35);
  --a2-chat-shadow: 0 18px 50px rgba(0,0,0,0.18);
}

#a2-chat-widget{position:fixed;bottom:20px;right:18px;z-index:2147483646;direction:rtl;font-family:"Vazirmatn","IRANSans","IRANYekan",Tahoma,Arial,sans-serif}
#a2-chat-toggle{width:60px;height:60px;border-radius:50%;border:none;background:linear-gradient(135deg,var(--a2-chat-accent),var(--a2-chat-accent-2));color:#fff;cursor:pointer;box-shadow:0 12px 26px var(--a2-chat-glow);display:flex;align-items:center;justify-content:center;font-size:23px;position:relative;animation:a2pulse-chat 1.2s infinite}
#a2-chat-toggle svg{width:52px;height:52px;display:block}
.a2-chat-toggle-label{position:absolute;top:100%;left:50%;transform:translate(-50%,2px);font-size:11px;line-height:1;font-weight:700;color:var(--a2-chat-accent-2);background:rgba(255,255,255,0.96);border:1px solid var(--a2-chat-border);padding:2px 8px;border-radius:999px;white-space:nowrap;box-shadow:0 8px 18px rgba(0,0,0,0.12)}
#a2-chat-toggle:active{transform:translateY(1px)}
.a2-chat-badge{position:absolute;top:-6px;right:-6px;min-width:18px;height:18px;border-radius:999px;background:#dc2626;color:#fff;font-size:10px;display:none;align-items:center;justify-content:center;padding:0 5px;box-shadow:0 6px 16px rgba(220,38,38,0.35)}
.a2-chat-badge.a2-active{display:flex}

#a2-chat-panel{position:fixed;bottom:92px;right:18px;width:340px;max-width:92vw;background:linear-gradient(135deg,var(--a2-chat-bg1),var(--a2-chat-bg2));border:1px solid var(--a2-chat-border);border-radius:18px;box-shadow:var(--a2-chat-shadow);backdrop-filter:blur(16px) saturate(1.08);-webkit-backdrop-filter:blur(16px) saturate(1.08);display:none;flex-direction:column;overflow:hidden}
#a2-chat-panel.a2-open{display:flex}

.a2-chat-header{padding:12px 14px;background:linear-gradient(135deg,var(--a2-chat-header-bg1),var(--a2-chat-header-bg2));border-bottom:1px solid var(--a2-chat-border);display:flex;align-items:center;justify-content:space-between}
.a2-chat-title{font-size:14px;font-weight:700;color:var(--a2-chat-text)}
.a2-chat-status{font-size:11px;color:var(--a2-chat-muted)}
.a2-chat-operator{font-size:11px;color:var(--a2-chat-muted)}
.a2-chat-close{border:none;background:var(--a2-chat-soft);width:28px;height:28px;border-radius:10px;cursor:pointer;font-size:16px;line-height:1;color:var(--a2-chat-accent-2);display:flex;align-items:center;justify-content:center}
.a2-chat-close:hover{background:var(--a2-chat-header-bg1);color:var(--a2-chat-accent-2)}

.a2-chat-body{padding:12px 12px 6px;max-height:380px;overflow:auto}
.a2-chat-start{display:flex;flex-direction:column;gap:8px}
.a2-chat-start input,.a2-chat-start textarea,.a2-chat-start select{border:1px solid var(--a2-chat-border);border-radius:10px;padding:8px 10px;font-size:16px;color:var(--a2-chat-text);background:var(--a2-chat-bg1)}
.a2-chat-start .a2-chat-phone{text-align:right;direction:ltr}
.a2-chat-start textarea{min-height:72px;resize:vertical}
.a2-chat-start-btn{border:none;background:linear-gradient(135deg,var(--a2-chat-accent),var(--a2-chat-accent-2));color:#fff;padding:10px;border-radius:10px;cursor:pointer;font-weight:700;box-shadow:0 10px 22px var(--a2-chat-glow)}
.a2-chat-help{font-size:11px;color:var(--a2-chat-muted)}
.a2-chat-dept{display:flex;flex-direction:column;gap:6px}
.a2-chat-label{font-size:12px;color:var(--a2-chat-muted)}
.a2-chat-archive{display:flex;flex-direction:column;gap:8px}
.a2-chat-archive-btn{border:1px dashed var(--a2-chat-border);background:var(--a2-chat-bg1);color:var(--a2-chat-accent-2);padding:8px;border-radius:10px;cursor:pointer;font-weight:700}
.a2-chat-archive-btn:disabled{opacity:0.5;cursor:not-allowed}
.a2-chat-archive-status{font-size:11px;color:var(--a2-chat-muted)}
.a2-chat-archive-list{display:flex;flex-direction:column;gap:8px}
.a2-chat-archive-item{border:1px solid var(--a2-chat-border);background:var(--a2-chat-bg1);border-radius:12px;padding:8px 10px;cursor:pointer;text-align:right}
.a2-chat-archive-item:hover{background:rgba(255,255,255,1)}
.a2-chat-archive-title{font-size:12px;font-weight:700;color:var(--a2-chat-text)}
.a2-chat-archive-time{font-size:10px;color:var(--a2-chat-muted)}
.a2-chat-archive-preview{font-size:11px;color:var(--a2-chat-muted);margin-top:4px}

.a2-chat-thread{display:none}
.a2-chat-thread.a2-active{display:block}
.a2-chat-search{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:8px}
.a2-chat-search input{flex:1;border:1px solid var(--a2-chat-border);border-radius:10px;padding:6px 8px;font-size:12px;background:var(--a2-chat-bg1)}
.a2-chat-search-clear{border:none;background:var(--a2-chat-soft);color:var(--a2-chat-accent-2);width:26px;height:26px;border-radius:8px;cursor:pointer;font-size:16px;line-height:1}
.a2-chat-search-results{flex:1 1 100%;background:var(--a2-chat-bg1);border:1px solid var(--a2-chat-border);border-radius:12px;padding:6px;max-height:160px;overflow:auto}
.a2-chat-search-item{width:100%;border:0;background:transparent;padding:6px 8px;border-radius:8px;text-align:right;cursor:pointer}
.a2-chat-search-item:hover{background:rgba(15,23,42,0.04)}
.a2-chat-search-snippet{font-size:12px;color:var(--a2-chat-text)}
.a2-chat-search-meta{font-size:10px;color:var(--a2-chat-muted)}
.a2-chat-search-empty{font-size:12px;color:var(--a2-chat-muted);text-align:center;padding:8px}
.a2-chat-messages{display:flex;flex-direction:column;gap:8px}
.a2-msg{max-width:82%;padding:8px 10px 24px;border-radius:12px;font-size:13px;line-height:1.6;position:relative}
.a2-msg.in{background:rgba(255,255,255,0.96);color:var(--a2-chat-text);align-self:flex-start;border-top-left-radius:4px;border:1px solid var(--a2-chat-border)}
.a2-msg.out{background:linear-gradient(135deg,var(--a2-chat-accent),var(--a2-chat-accent-2));color:#fff;align-self:flex-end;border-top-right-radius:4px}
.a2-msg-text{white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere}
.a2-msg-text a{color:inherit;text-decoration:underline;word-break:break-word;overflow-wrap:anywhere}
.a2-msg-highlight{outline:2px solid var(--a2-chat-accent-2);box-shadow:0 0 0 3px rgba(212,175,55,0.25)}
.a2-msg-time{display:block;margin-top:4px;font-size:10px;opacity:0.7}
.a2-msg-meta{display:flex;align-items:center;gap:8px;justify-content:flex-end;flex-wrap:wrap;row-gap:4px}
.a2-msg-reply{position:absolute;bottom:6px;left:6px;background:rgba(255,255,255,0.15);border:none;color:inherit;border-radius:8px;width:22px;height:22px;cursor:pointer;font-size:12px;line-height:1}
.a2-msg-reply:hover{background:rgba(255,255,255,0.25)}
.a2-msg-ticks{font-size:10px;opacity:0.7}
.a2-msg-ticks.a2-delivered{opacity:0.85}
.a2-msg-ticks.a2-seen{color:#38bdf8;opacity:1}
.a2-msg-edited{font-size:10px;opacity:0.7}
.a2-msg.a2-msg-deleted{opacity:0.7;font-style:italic}
.a2-msg.a2-msg-deleted .a2-msg-reply{display:none}
.a2-reply-quote{border-right:2px solid rgba(255,255,255,0.6);padding:4px 6px;font-size:11px;opacity:0.9;background:rgba(255,255,255,0.12);border-radius:8px}
.a2-msg.in .a2-reply-quote{border-right-color:var(--a2-chat-border);background:rgba(15,23,42,0.04)}
.a2-msg-media{display:flex;flex-direction:column;gap:6px}
.a2-msg-media img{max-width:210px;border-radius:10px}
.a2-msg-media audio{width:210px}
.a2-chat-typing{font-size:11px;color:var(--a2-chat-muted);padding:6px 4px}
.a2-chat-rating{margin-top:8px;border:1px dashed var(--a2-chat-border);background:rgba(15,23,42,0.04);border-radius:12px;padding:8px;display:flex;flex-direction:column;gap:6px}
.a2-chat-rating-label{font-size:12px;color:var(--a2-chat-muted)}
.a2-chat-rating-stars{display:flex;gap:6px}
.a2-chat-rating-btn{border:1px solid var(--a2-chat-border);background:var(--a2-chat-bg1);color:var(--a2-chat-accent-2);border-radius:10px;width:30px;height:30px;cursor:pointer;font-size:16px;line-height:1}
.a2-chat-rating-btn.a2-active{background:linear-gradient(135deg,var(--a2-chat-accent),var(--a2-chat-accent-2));color:#fff;border-color:transparent}
.a2-chat-rating-status{font-size:11px;color:var(--a2-chat-muted)}

.a2-chat-footer{padding:10px;border-top:1px solid var(--a2-chat-border);display:flex;gap:8px;align-items:center;flex-wrap:wrap;background:var(--a2-chat-bg1)}
.a2-chat-tools{display:flex;gap:6px;align-items:center}
.a2-chat-reply-preview{flex:1 1 100%;display:flex;align-items:center;justify-content:space-between;gap:8px;background:rgba(15,23,42,0.04);border:1px dashed var(--a2-chat-border);border-radius:10px;padding:6px 8px;font-size:11px;color:var(--a2-chat-muted)}
.a2-chat-reply-text{flex:1;min-width:0}
.a2-chat-reply-close{border:none;background:rgba(15,23,42,0.08);color:var(--a2-chat-muted);width:22px;height:22px;border-radius:8px;cursor:pointer;line-height:1}
.a2-chat-attach,.a2-chat-voice{width:36px;height:36px;border:1px solid var(--a2-chat-border);background:var(--a2-chat-bg1);color:var(--a2-chat-accent-2);border-radius:10px;padding:0;cursor:pointer;display:flex;align-items:center;justify-content:center;position:relative;font-size:0}
.a2-chat-attach::before,.a2-chat-voice::before{content:'';width:18px;height:18px;display:block;background-color:currentColor;-webkit-mask-repeat:no-repeat;-webkit-mask-position:center;-webkit-mask-size:contain;mask-repeat:no-repeat;mask-position:center;mask-size:contain}
.a2-chat-attach::before{-webkit-mask-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"black\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21.44 11.05l-8.49 8.49a5 5 0 0 1-7.07-7.07l8.49-8.49a3.5 3.5 0 0 1 4.95 4.95l-8.49 8.49a2 2 0 0 1-2.83-2.83l7.78-7.78\"/></svg>');mask-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"black\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21.44 11.05l-8.49 8.49a5 5 0 0 1-7.07-7.07l8.49-8.49a3.5 3.5 0 0 1 4.95 4.95l-8.49 8.49a2 2 0 0 1-2.83-2.83l7.78-7.78\"/></svg>')}
.a2-chat-voice::before{-webkit-mask-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"black\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z\"/><path d=\"M19 10v2a7 7 0 0 1-14 0v-2\"/><line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"23\"/><line x1=\"8\" y1=\"23\" x2=\"16\" y2=\"23\"/></svg>');mask-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"black\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z\"/><path d=\"M19 10v2a7 7 0 0 1-14 0v-2\"/><line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"23\"/><line x1=\"8\" y1=\"23\" x2=\"16\" y2=\"23\"/></svg>')}
.a2-chat-attach:hover,.a2-chat-voice:hover{background:var(--a2-chat-soft);color:var(--a2-chat-accent-2)}
.a2-chat-attach:active,.a2-chat-voice:active{transform:translateY(1px)}
.a2-chat-voice.a2-recording{border-color:#dc2626;background:rgba(220,38,38,0.12);color:#b91c1c;box-shadow:0 0 0 3px rgba(220,38,38,0.15)}
.a2-chat-voice.a2-recording::after{content:'';position:absolute;top:6px;right:6px;width:6px;height:6px;border-radius:999px;background:#dc2626}
.a2-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.a2-chat-footer input{flex:1;border:1px solid var(--a2-chat-border);border-radius:10px;padding:8px 10px;font-size:16px;background:var(--a2-chat-bg1)}
.a2-chat-footer .a2-chat-send{border:none;background:linear-gradient(135deg,var(--a2-chat-accent),var(--a2-chat-accent-2));color:#fff;border-radius:10px;padding:8px 12px;cursor:pointer;font-weight:700}
.a2-chat-footer button:disabled{opacity:0.5;cursor:not-allowed}

@keyframes a2pulse-chat{
  0%{box-shadow:0 12px 26px var(--a2-chat-glow),0 0 0 0 var(--a2-chat-glow);}
  70%{box-shadow:0 12px 26px var(--a2-chat-glow),0 0 0 18px rgba(0,0,0,0);}
  100%{box-shadow:0 12px 26px var(--a2-chat-glow),0 0 0 0 rgba(0,0,0,0);}
}

.single-product #a2-chat-widget{bottom:50px}
.single-product #a2-chat-panel{bottom:122px}

@media (max-width:480px){
  #a2-chat-widget{bottom:96px;right:14px}
  #a2-chat-panel{width:92vw;right:4vw;bottom:80px}
  .single-product #a2-chat-widget{bottom:141px}
  .single-product #a2-chat-panel{bottom:125px}
  .a2-chat-start input,.a2-chat-start textarea,.a2-chat-footer input{direction:rtl;text-align:right}
  .a2-chat-start input::placeholder,.a2-chat-start textarea::placeholder,.a2-chat-footer input::placeholder{direction:rtl;text-align:right}
  .a2-chat-start .a2-chat-phone{direction:ltr;text-align:right}
}
