/* =====================================================================
   کاسب — AI Chatbot widget + Review summary box
   (visually consistent with widgets.css / the contact widget)
   ===================================================================== */

.vrs-ai-cw {
  position: fixed;
  z-index: 99991;
  font-family: var(--vrs-font-family, 'Vazirmatn', Tahoma, sans-serif);
  direction: rtl;
}

/* Toggle circle */
.vrs-ai-toggle {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, var(--vrs-color-primary, #2563eb), color-mix(in srgb, var(--vrs-color-primary, #2563eb) 72%, #000));
  color: var(--vrs-color-primary-text, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
  transition: transform .2s ease, box-shadow .2s ease;
}
.vrs-ai-toggle:hover { transform: scale(1.06); box-shadow: 0 10px 26px rgba(0, 0, 0, .28); }
.vrs-ai-toggle__icon { display: flex; }
.vrs-ai-toggle__icon svg { width: 28px; height: 28px; }
.vrs-ai-toggle__x { display: none; font-size: 30px; line-height: 1; font-weight: 300; }
.vrs-ai-cw.is-open .vrs-ai-toggle__icon { display: none; }
.vrs-ai-cw.is-open .vrs-ai-toggle__x { display: block; }

.vrs-ai-toggle.is-pulse::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--vrs-color-primary, #2563eb);
  z-index: -1;
  animation: vrs-ai-pulse 2s ease-out infinite;
}
@keyframes vrs-ai-pulse {
  0%   { transform: scale(1);   opacity: .55; }
  70%  { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Panel */
.vrs-ai-panel {
  position: absolute;
  bottom: 72px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 110px);
  background: var(--vrs-color-surface, #fff);
  border: 1px solid var(--vrs-color-border, #e5e7eb);
  border-radius: 16px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, .2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(8px) scale(.97);
  transform-origin: bottom;
  transition: opacity .18s ease, transform .18s ease;
}
.vrs-ai-cw.is-open .vrs-ai-panel { opacity: 1; transform: translateY(0) scale(1); }
.vrs-ai-panel[hidden] { display: none; }

.vrs-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: linear-gradient(135deg, var(--vrs-color-primary, #2563eb), color-mix(in srgb, var(--vrs-color-primary, #2563eb) 78%, #000));
  color: var(--vrs-color-primary-text, #fff);
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}
.vrs-ai-head-actions { display: inline-flex; align-items: center; gap: 6px; }
.vrs-ai-close { background: transparent; border: 0; color: var(--vrs-color-primary-text, #fff); font-size: 24px; line-height: 1; cursor: pointer; opacity: .9; }
.vrs-ai-close:hover { opacity: 1; }
.vrs-ai-clear { background: transparent; border: 0; color: var(--vrs-color-primary-text, #fff); font-size: 15px; line-height: 1; cursor: pointer; opacity: .8; padding: 2px 4px; }
.vrs-ai-clear:hover { opacity: 1; }

.vrs-ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--vrs-color-surface-soft, #f7f8fa);
}

/* messages */
.vrs-ai-msg {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.vrs-ai-msg a { color: var(--vrs-color-primary, #2563eb); text-decoration: underline; }
.vrs-ai-msg--bot {
  align-self: flex-start;
  background: var(--vrs-color-surface, #fff);
  border: 1px solid var(--vrs-color-border, #e5e7eb);
  color: var(--vrs-color-text, #111827);
  border-bottom-right-radius: 4px;
}
.vrs-ai-msg--user {
  align-self: flex-end;
  background: var(--vrs-color-primary, #2563eb);
  color: var(--vrs-color-primary-text, #fff);
  border-bottom-left-radius: 4px;
}

/* recommended product cards (below a bot message — same width/alignment as the answer) */
.vrs-ai-cards { display: flex; flex-direction: column; gap: 8px; align-self: flex-start; width: 100%; max-width: 84%; }
.vrs-ai-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  background: var(--vrs-color-surface, #fff);
  border: 1px solid var(--vrs-color-border, #e5e7eb);
  border-radius: 12px;
  text-decoration: none;
  color: var(--vrs-color-text, #111827);
  transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.vrs-ai-card:hover {
  border-color: var(--vrs-color-primary, #2563eb);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .1);
  transform: translateY(-1px);
  color: var(--vrs-color-text, #111827);
}
.vrs-ai-card__img {
  flex-shrink: 0;
  width: 54px;
  height: 54px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--vrs-color-surface-soft, #f3f4f6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.vrs-ai-card__img img { width: 100%; height: 100%; object-fit: cover; }
.vrs-ai-card__img--ph { background: linear-gradient(135deg, #eef2ff, #f3f4f6); }
.vrs-ai-card__name { flex: 1; font-size: 13.5px; font-weight: 600; line-height: 1.6; }
.vrs-ai-card__chevron { flex-shrink: 0; color: color-mix(in srgb, var(--vrs-color-primary, #2563eb) 60%, #999); font-size: 18px; }

/* typing indicator */
.vrs-ai-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--vrs-color-surface, #fff); border: 1px solid var(--vrs-color-border, #e5e7eb); border-radius: 14px; }
.vrs-ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--vrs-color-muted, #9ca3af); animation: vrs-ai-blink 1.2s infinite both; }
.vrs-ai-typing span:nth-child(2) { animation-delay: .2s; }
.vrs-ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes vrs-ai-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* gate forms (login / name+phone) */
.vrs-ai-gate { background: var(--vrs-color-surface, #fff); border: 1px dashed var(--vrs-color-border, #e5e7eb); border-radius: 12px; padding: 14px; font-size: 14px; }
.vrs-ai-gate input { width: 100%; box-sizing: border-box; margin: 6px 0; padding: 9px 11px; border: 1px solid var(--vrs-color-border, #e5e7eb); border-radius: 9px; font-family: inherit; }
.vrs-ai-gate .vrs-ai-btn, .vrs-ai-gate a.vrs-ai-btn { display: inline-block; margin-top: 6px; padding: 8px 18px; background: var(--vrs-color-primary, #2563eb); color: var(--vrs-color-primary-text, #fff); border: 0; border-radius: 9px; cursor: pointer; text-decoration: none; font-weight: 600; }

/* quick-action chips */
.vrs-ai-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; flex-shrink: 0; }
.vrs-ai-chip {
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--vrs-color-primary, #2563eb) 40%, #fff);
  background: color-mix(in srgb, var(--vrs-color-primary, #2563eb) 8%, #fff);
  color: var(--vrs-color-primary, #2563eb);
  cursor: pointer;
  transition: background .15s ease;
}
.vrs-ai-chip:hover { background: color-mix(in srgb, var(--vrs-color-primary, #2563eb) 16%, #fff); }

/* input row */
.vrs-ai-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--vrs-color-border, #e5e7eb); background: var(--vrs-color-surface, #fff); flex-shrink: 0; }
.vrs-ai-input textarea {
  flex: 1;
  resize: none;
  max-height: 96px;
  padding: 9px 12px;
  border: 1px solid var(--vrs-color-border, #e5e7eb);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
}
.vrs-ai-input button {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: var(--vrs-color-primary, #2563eb);
  color: var(--vrs-color-primary-text, #fff);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transform: scaleX(-1);
}
.vrs-ai-input button:disabled { opacity: .5; cursor: default; }

/* inline order-tracking mini form */
.vrs-ai-order { align-self: stretch; background: var(--vrs-color-surface, #fff); border: 1px solid var(--vrs-color-border, #e5e7eb); border-radius: 12px; padding: 12px; }
.vrs-ai-order input { width: 100%; box-sizing: border-box; margin: 5px 0; padding: 8px 10px; border: 1px solid var(--vrs-color-border, #e5e7eb); border-radius: 8px; font-family: inherit; }
.vrs-ai-order button { margin-top: 6px; padding: 7px 16px; background: var(--vrs-color-primary, #2563eb); color: var(--vrs-color-primary-text, #fff); border: 0; border-radius: 8px; cursor: pointer; font-family: inherit; }

/* =====================================================================
   Review summary box (above product/post reviews)
   ===================================================================== */
.vrs-ai-summary {
  font-family: var(--vrs-font-family, 'Vazirmatn', Tahoma, sans-serif);
  border: 1px solid var(--vrs-color-border, #e5e7eb);
  border-radius: 14px;
  padding: 16px 18px;
  margin: 0 0 22px;
  background: var(--vrs-color-surface-soft, #f7f8fa);
}
.vrs-ai-summary__head { margin-bottom: 8px; }
.vrs-ai-summary__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--vrs-color-primary, #2563eb) 12%, #fff);
  color: var(--vrs-color-primary, #2563eb);
}
.vrs-ai-summary__overview { margin: 6px 0 12px; font-size: 15px; line-height: 1.9; color: var(--vrs-color-text, #111827); }
.vrs-ai-summary__cols { display: flex; flex-wrap: wrap; gap: 16px; }
.vrs-ai-summary__col { flex: 1; min-width: 220px; }
.vrs-ai-summary__col h4 { margin: 0 0 6px; font-size: 14px; }
.vrs-ai-summary__col ul { margin: 0; padding-inline-start: 18px; }
.vrs-ai-summary__col li { font-size: 13.5px; line-height: 1.9; }
.vrs-ai-summary__pros h4 { color: var(--vrs-color-success-dark, #15803d); }
.vrs-ai-summary__cons h4 { color: var(--vrs-color-warning-dark, #b45309); }

/* Mobile: full-screen chat panel */
@media (max-width: 768px) {
  .vrs-ai-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }
  /* Keep cards the SAME width as the answer bubble (like desktop). */
  .vrs-ai-cards { max-width: 84%; }
  /* While the full-screen panel is open, hide the floating toggle so it never
     overlaps the panel's items (e.g. the send button). Close via the header ✕. */
  .vrs-ai-cw.is-open .vrs-ai-toggle { display: none; }
}
