/* ویجت شناور AI Chat Assistant */
#aca-widget-root *,
#aca-widget-root *::before,
#aca-widget-root *::after { box-sizing: border-box; }

.aca-wc {
  --aca-primary: #6d28d9;
  --aca-primary-dark: #5b21b6;
  --aca-bg: #ffffff;
  --aca-text: #1f2937;
  --aca-muted: #6b7280;
  --aca-border: #e5e7eb;
  --aca-user: #6d28d9;
  --aca-bot: #f3f4f6;
  font-family: 'Vazirmatn', 'IRANSans', Tahoma, Arial, sans-serif;
  direction: rtl;
  text-align: right;
  position: fixed;
  bottom: 22px;
  left: 22px;
  z-index: 999999;
  font-size: 14px;
  line-height: 1.8;
}
.aca-wc[data-position="left"] { left: 22px; right: auto; }
.aca-wc[data-position="right"] { right: 22px; left: auto; }

/* دکمه شناور — حباب دایره‌ای کوچک با فقط آیکون */
.aca-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--aca-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  transition: transform .15s, box-shadow .15s;
  padding: 0;
}
.aca-bubble:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 10px 26px rgba(0,0,0,.3); }
.aca-bubble-icon { display: block; font-size: 28px; line-height: 1; }
.aca-bubble-text { display: none; }

/* پنجره چت */
.aca-panel-win {
  position: absolute;
  bottom: 70px;
  left: 0;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--aca-bg);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.28);
  border: 1px solid var(--aca-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: aca-pop .18s ease-out;
}
.aca-wc[data-position="left"] .aca-panel-win { left: 0; right: auto; }
.aca-wc[data-position="right"] .aca-panel-win { right: 0; left: auto; }

@keyframes aca-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.aca-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--aca-primary), var(--aca-primary-dark));
  color: #fff;
}
.aca-head-avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.aca-head-title { font-weight: 700; font-size: 15px; flex: 1; }
.aca-head-close { background: none; border: none; color: #fff; cursor: pointer; font-size: 18px; padding: 4px; opacity: .85; }
.aca-head-close:hover { opacity: 1; }

.aca-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aca-msgrow { display: flex; flex-direction: column; max-width: 86%; }
.aca-msgrow.user { align-self: flex-end; align-items: flex-end; }
.aca-msgrow.bot { align-self: flex-start; align-items: flex-start; }

.aca-msg {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}
.aca-msgrow.user .aca-msg { background: var(--aca-user); color: #fff; border-bottom-left-radius: 4px; }
.aca-msgrow.bot .aca-msg { background: var(--aca-bot); color: var(--aca-text); border-bottom-right-radius: 4px; }
.aca-msg.error { background: #fef2f2; color: #b91c1c; }
.aca-msg.typing { color: var(--aca-muted); font-style: italic; }

.aca-sources { font-size: 11px; color: var(--aca-muted); margin-top: 4px; padding: 0 4px; }

.aca-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.aca-btn-small {
  background: #fff; border: 1px solid var(--aca-border); border-radius: 999px;
  padding: 4px 12px; font-size: 11.5px; cursor: pointer; color: var(--aca-muted);
}
.aca-btn-small:hover { border-color: var(--aca-primary); color: var(--aca-primary); }
.aca-btn-small.handoff { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }
.aca-btn-small.handoff:hover { background: #e0e7ff; }

.aca-rate { display: flex; align-items: center; gap: 3px; margin-top: 4px; }
.aca-rate button { background: none; border: none; cursor: pointer; font-size: 16px; opacity: .4; transition: opacity .1s; }
.aca-rate button.rated { opacity: 1; }

.aca-inputbar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--aca-border);
  background: #fff;
}
.aca-inputbar input {
  flex: 1;
  border: 1px solid var(--aca-border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
}
.aca-inputbar input:focus { border-color: var(--aca-primary); }
.aca-inputbar button {
  background: var(--aca-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.aca-inputbar button:hover { background: var(--aca-primary-dark); }
.aca-inputbar button:disabled { opacity: .5; cursor: not-allowed; }

/* فرم ارجاع انسانی */
.aca-handoff-form { padding: 12px; border-top: 1px solid var(--aca-border); background: #f9fafb; display: flex; flex-direction: column; gap: 8px; }
.aca-handoff-form input { border: 1px solid var(--aca-border); border-radius: 8px; padding: 8px 12px; font-size: 13px; font-family: inherit; }
.aca-handoff-form button { background: var(--aca-primary); color: #fff; border: none; border-radius: 8px; padding: 9px; cursor: pointer; font-weight: 600; }

.aca-note { font-size: 11px; color: var(--aca-muted); text-align: center; padding: 4px 12px 6px; background: #fff; }

/* پاسخ‌گو */
@media (max-width: 480px) {
  .aca-panel-win { width: calc(100vw - 24px); height: 70vh; left: 0; right: 0; bottom: 64px; }
}