.site-assistant-root,
.site-assistant-root * {
  box-sizing: border-box;
}

.site-assistant-root {
  --sa-primary: #5a332b;
  --sa-accent: #ff244c;
  --sa-text: #1f2937;
  --sa-bubble: 62px;
  position: fixed;
  bottom: 22px;
  z-index: 999999;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--sa-text);
}

.site-assistant-root.sa-right { right: 22px; }
.site-assistant-root.sa-left { left: 22px; }

.sa-launcher {
  width: var(--sa-bubble);
  height: var(--sa-bubble);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--sa-primary), var(--sa-accent));
  color: #fff;
  box-shadow: 0 18px 38px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0;
  transition: transform .22s ease, box-shadow .22s ease;
}

.sa-launcher:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 22px 46px rgba(0,0,0,.3);
}

.sa-launcher-icon { font-size: 24px; line-height: 1; }
.sa-launcher-text { font-size: 10px; font-weight: 700; margin-top: 2px; }

.sa-panel {
  position: absolute;
  bottom: calc(var(--sa-bubble) + 16px);
  width: 380px;
  max-width: calc(100vw - 34px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 22px 70px rgba(15,23,42,.28);
  border: 1px solid rgba(15,23,42,.08);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(.96);
  transition: opacity .22s ease, transform .22s ease;
}

.sa-right .sa-panel { right: 0; }
.sa-left .sa-panel { left: 0; }
.site-assistant-root.sa-open .sa-panel { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.site-assistant-root.sa-open .sa-launcher { transform: rotate(2deg) scale(.96); }

.sa-header {
  min-height: 68px;
  background: var(--sa-primary);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sa-back {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,.15);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.sa-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: rgba(255,255,255,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  text-transform: uppercase;
}

.sa-header-info { flex: 1; min-width: 0; }
.sa-title { font-weight: 800; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-subtitle { font-size: 12px; opacity: .82; line-height: 1.2; }

.sa-lang-toggle {
  display: flex;
  background: rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 3px;
}

.sa-lang-toggle button {
  border: 0;
  border-radius: 999px;
  padding: 5px 7px;
  background: transparent;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.sa-lang-toggle button.active {
  background: #fff;
  color: var(--sa-primary);
}

.sa-prechat {
  padding: 18px;
  background: linear-gradient(180deg, #fff, #f8fafc);
  flex: 1;
  display: flex;
  align-items: center;
}

.sa-prechat-card {
  width: 100%;
  padding: 20px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15,23,42,.08);
}

.sa-prechat-card h4 {
  margin: 0 0 6px;
  font-size: 18px;
  color: var(--sa-text);
}

.sa-prechat-note {
  margin: 0 0 14px;
  font-size: 13px;
  color: #64748b;
}

.sa-input,
.sa-message-input {
  width: 100%;
  border: 1px solid #d7dee9;
  background: #fff;
  color: var(--sa-text);
  border-radius: 12px;
  padding: 12px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.sa-input {
  margin-bottom: 10px;
}

.sa-input:focus,
.sa-message-input:focus {
  border-color: var(--sa-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--sa-accent) 16%, transparent);
}

.sa-start-chat {
  width: 100%;
  border: 0;
  background: linear-gradient(135deg, var(--sa-primary), var(--sa-accent));
  color: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 800;
}

.sa-form-error {
  margin-top: 10px;
  font-size: 12px;
  color: #dc2626;
}

.sa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #f4f6fb;
  scroll-behavior: smooth;
}

.sa-msg {
  display: flex;
  margin-bottom: 10px;
}

.sa-msg.sa-user { justify-content: flex-end; }
.sa-msg.sa-bot { justify-content: flex-start; }

.sa-msg-bubble {
  max-width: 82%;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.46;
  word-wrap: break-word;
}

.sa-user .sa-msg-bubble {
  background: var(--sa-primary);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.sa-bot .sa-msg-bubble {
  background: #fff;
  color: var(--sa-text);
  border: 1px solid rgba(15,23,42,.08);
  border-bottom-left-radius: 5px;
  box-shadow: 0 8px 18px rgba(15,23,42,.05);
}

.sa-msg-bubble a {
  color: var(--sa-accent);
  font-weight: 800;
  text-decoration: none;
}

.sa-product-card,
.sa-result-card {
  margin-top: 9px;
  padding: 10px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.sa-compose {
  padding: 12px;
  background: #fff;
  border-top: 1px solid rgba(15,23,42,.08);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sa-send {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 0;
  border-radius: 14px;
  background: var(--sa-accent);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.sa-credit {
  text-align: center;
  font-size: 10px;
  padding: 6px 8px;
  background: #fff;
  color: #94a3b8;
  border-top: 1px solid rgba(15,23,42,.06);
}

.sa-credit a {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.sa-fade-in {
  animation: saFadeIn .18s ease both;
}

@keyframes saFadeIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.sa-typing {
  display: flex;
  gap: 4px;
  align-items: center;
}

.sa-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: saTyping 1s infinite ease-in-out;
}

.sa-typing span:nth-child(2) { animation-delay: .15s; }
.sa-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes saTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 480px) {
  .site-assistant-root {
    right: 16px;
    left: auto;
    bottom: 16px;
  }
  .site-assistant-root.sa-left { left: 16px; }
  .sa-panel {
    position: fixed;
    left: 10px !important;
    right: 10px !important;
    bottom: 88px;
    width: auto;
    height: min(620px, calc(100vh - 106px));
    max-width: none;
  }
}
