/* SmartShop AI chat widget. Everything is scoped under .ssai so themes
   cannot leak in and the widget cannot leak out. Sizes are in px on purpose:
   block themes scale the root font, which would blow the widget up. */
.ssai {
  --ssai-primary: #1f6feb;
  --ssai-primary-text: #ffffff;
  --ssai-bg: #ffffff;
  --ssai-surface: #f5f6f8;
  --ssai-text: #1f2328;
  --ssai-muted: #6b7280;
  --ssai-border: #e5e7eb;
  --ssai-radius: 18px;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font: 400 14.5px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ssai-text);
  letter-spacing: normal;
  text-align: left;
}
.ssai *, .ssai *::before, .ssai *::after { box-sizing: border-box; margin: 0; }
.ssai button, .ssai input, .ssai textarea { font-family: inherit; letter-spacing: normal; text-transform: none; }

/* ---------- launcher ---------- */
.ssai-launcher {
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--ssai-primary);
  color: var(--ssai-primary-text);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .22), 0 2px 6px rgba(15, 23, 42, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 0;
  transition: transform .18s ease, box-shadow .18s ease;
}
.ssai-launcher:hover { transform: scale(1.06); box-shadow: 0 10px 28px rgba(15, 23, 42, .26); }
.ssai-launcher svg { display: block; transition: transform .2s ease; }
.ssai-is-open .ssai-launcher svg { transform: rotate(90deg); }
.ssai-launcher:focus-visible, .ssai-icon:focus-visible, .ssai-send:focus-visible, .ssai-callme:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
}

/* ---------- panel ---------- */
.ssai-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--ssai-bg);
  border-radius: var(--ssai-radius);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .22), 0 4px 14px rgba(15, 23, 42, .08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: ssai-in .2s ease-out;
}
.ssai-panel[hidden] { display: none; }
@keyframes ssai-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* ---------- header ---------- */
.ssai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 14px 16px;
  background: var(--ssai-primary);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, .14), rgba(0, 0, 0, .06));
  color: var(--ssai-primary-text);
  flex: none;
}
.ssai-avatar, .ssai-initial {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: none;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .55);
}
.ssai-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .22);
  color: inherit;
  font-weight: 700;
  font-size: 16px;
}
.ssai-heading { flex: 1; min-width: 0; }
.ssai-title { font-weight: 650; font-size: 15.5px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ssai-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; opacity: .88; line-height: 1.3; }
.ssai-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }
.ssai-icon {
  border: 0;
  background: transparent;
  color: inherit;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: .9;
}
.ssai-icon:hover { background: rgba(255, 255, 255, .16); opacity: 1; }

/* ---------- messages ---------- */
.ssai-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 14px 10px;
  background: var(--ssai-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}
.ssai-msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
}
.ssai-assistant {
  background: #fff;
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
  border: 1px solid var(--ssai-border);
}
.ssai-user {
  background: var(--ssai-primary);
  color: var(--ssai-primary-text);
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}
.ssai-msg strong { font-weight: 650; }
.ssai-msg a { color: var(--ssai-primary); text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.ssai-user a { color: inherit; }

/* typing dots */
.ssai-typing { display: flex; gap: 4px; align-items: center; padding: 14px 16px; }
.ssai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: ssai-dot 1.2s infinite ease-in-out;
}
.ssai-typing span:nth-child(2) { animation-delay: .15s; }
.ssai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ssai-dot {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- request a call ---------- */
.ssai-actions { padding: 8px 14px 0; background: var(--ssai-bg); flex: none; display: flex; }
.ssai-callme {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--ssai-border);
  background: #fff;
  color: var(--ssai-text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ssai-callme svg { color: var(--ssai-primary); flex: none; }
.ssai-callme:hover { border-color: var(--ssai-primary); background: var(--ssai-surface); }

/* ---------- composer ---------- */
.ssai-form {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 8px 12px 6px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--ssai-border);
  border-radius: 24px;
  background: #fff;
  flex: none;
  transition: border-color .15s, box-shadow .15s;
}
.ssai-form:focus-within { border-color: var(--ssai-primary); box-shadow: 0 0 0 3px rgba(31, 111, 235, .12); }
.ssai-input {
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  padding: 7px 0;
  font-size: 14.5px;
  line-height: 1.4;
  color: inherit;
  background: transparent;
  max-height: 120px;
  min-height: 22px;
  box-shadow: none;
}
.ssai-input::placeholder { color: #9ca3af; }
.ssai-send {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: var(--ssai-primary);
  color: var(--ssai-primary-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s, transform .15s;
}
.ssai-send:hover { transform: scale(1.05); }
.ssai-send:disabled { opacity: .45; cursor: default; transform: none; }
.ssai-foot {
  padding: 0 14px 10px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--ssai-muted);
  text-align: center;
  flex: none;
}

/* ---------- lead form (inside a bubble) ---------- */
.ssai-lead { display: flex; flex-direction: column; gap: 10px; max-width: 100%; width: 100%; padding: 14px; }
.ssai-lead > strong { font-size: 14.5px; }
.ssai-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ssai-muted); }
.ssai-field input, .ssai-field textarea {
  border: 1px solid var(--ssai-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
  color: var(--ssai-text);
  outline: 0;
}
.ssai-field input:focus, .ssai-field textarea:focus { border-color: var(--ssai-primary); box-shadow: 0 0 0 3px rgba(31, 111, 235, .12); }
.ssai-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.4; color: var(--ssai-muted); }
.ssai-consent input { margin-top: 2px; flex: none; }
.ssai-consent a { color: inherit; }
.ssai-error { color: #b42318; font-size: 13px; }
.ssai-error:empty { display: none; }
.ssai-lead-buttons { display: flex; gap: 12px; align-items: center; }
.ssai-lead-buttons .ssai-send {
  width: auto;
  height: auto;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
}
.ssai-link { border: 0; background: transparent; color: var(--ssai-muted); font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; }
.ssai-hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; opacity: 0; }

/* ---------- position ---------- */
.ssai-left { right: auto; left: 20px; }
.ssai-left .ssai-panel { right: auto; left: 0; transform-origin: bottom left; }
.ssai-left .ssai-launcher { margin-left: 0; margin-right: auto; }

/* ---------- phones: full screen ---------- */
@media (max-width: 520px) {
  .ssai, .ssai-left { right: 12px; left: auto; bottom: 12px; }
  .ssai-left { left: 12px; right: auto; }
  .ssai-panel {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 0;
    animation: none;
  }
  .ssai-is-open .ssai-launcher { display: none; }
  .ssai-input { font-size: 16px; } /* iOS zooms in on smaller inputs */
}

@media (prefers-reduced-motion: reduce) {
  .ssai-panel, .ssai-typing span { animation: none; }
  .ssai-launcher, .ssai-launcher svg { transition: none; }
}

/* The form is already open: the "request a call" chip would be redundant. */
.ssai-lead-open .ssai-actions { display: none; }
