/* Q Ceramic website AI floating agent */
:root {
  --sai-accent: #d28746;
  --sai-accent-dark: #a06735;
  --sai-accent-soft: #fff4eb;
  --sai-gray: #f4f7f9;
  --sai-text: #1e293b;
  --sai-muted: #64748b;
  --sai-on-accent: #ffffff;
}

#sales-ai-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 3500;
  font-family: var(--font, 'Barlow', system-ui, sans-serif);
}

html[dir="rtl"] #sales-ai-root {
  right: auto;
  left: 22px;
}

#sales-ai-fab {
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  padding: 0;
  cursor: pointer;
  position: relative;
  box-shadow: 0 10px 28px rgba(210, 135, 70, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: sai-bob 2.8s ease-in-out infinite;
}

#sales-ai-fab img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.18));
  pointer-events: none;
}

#sales-ai-fab::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(210, 135, 70, 0.55);
  animation: sai-pulse-ring 2.4s ease-out infinite;
  pointer-events: none;
}

#sales-ai-fab:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 14px 32px rgba(210, 135, 70, 0.45);
  animation: none;
}

#sales-ai-root.sai-open #sales-ai-fab {
  animation: none;
}

#sales-ai-root.sai-open #sales-ai-fab::after {
  display: none;
}

#sales-ai-root.sai-thinking #sales-ai-fab img {
  animation: sai-think 0.9s ease-in-out infinite;
}

@keyframes sai-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes sai-pulse-ring {
  0% { transform: scale(0.92); opacity: 0.7; }
  100% { transform: scale(1.28); opacity: 0; }
}

@keyframes sai-think {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

#sales-ai-close-fab {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: var(--sai-accent);
  border-radius: 50%;
  color: var(--sai-on-accent);
  font-size: 1.6rem;
  line-height: 1;
}

#sales-ai-root.sai-open #sales-ai-fab img { opacity: 0; }
#sales-ai-root.sai-open #sales-ai-close-fab { display: flex; }

#sales-ai-teaser {
  position: absolute;
  right: 0;
  bottom: 88px;
  width: min(340px, calc(100vw - 40px));
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  padding: 16px 18px 14px;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

html[dir="rtl"] #sales-ai-teaser {
  right: auto;
  left: 0;
}

#sales-ai-teaser.sai-teaser-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#sales-ai-teaser.sai-hidden {
  display: none !important;
}

.sai-teaser-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

html[dir="rtl"] .sai-teaser-close {
  right: auto;
  left: 12px;
}

.sai-teaser-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--sai-text);
  margin: 0 0 6px;
  padding-right: 18px;
}

html[dir="rtl"] .sai-teaser-title {
  padding-right: 0;
  padding-left: 18px;
}

.sai-teaser-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sai-teaser-status span {
  color: var(--sai-accent-dark);
  font-size: 0.82rem;
  font-weight: 500;
}

.sai-avatar-stack img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #fff;
  object-fit: cover;
}

.sai-teaser-actions {
  display: flex;
  gap: 8px;
}

.sai-teaser-actions button {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

#sales-ai-teaser-chat {
  background: var(--sai-accent);
  color: var(--sai-on-accent);
}

#sales-ai-teaser-chat:hover { background: var(--sai-accent-dark); }

#sales-ai-panel {
  position: absolute;
  right: 0;
  bottom: 88px;
  width: min(390px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 120px));
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(0.94);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

html[dir="rtl"] #sales-ai-panel {
  right: auto;
  left: 0;
}

#sales-ai-root.sai-open #sales-ai-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sai-header {
  background: linear-gradient(145deg, var(--sai-accent) 0%, var(--sai-accent-dark) 100%);
  color: var(--sai-on-accent);
  padding: 14px 16px 16px;
  flex-shrink: 0;
}

.sai-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sai-tabs {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  padding: 3px;
}

.sai-tab {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: default;
}

.sai-tab.active {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.sai-header-actions {
  display: flex;
  gap: 4px;
}

.sai-icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sai-icon-btn:hover { background: rgba(0, 0, 0, 0.2); }

.sai-header-body {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sai-header-body img.sai-bot-face {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}

.sai-header-body h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: #fff;
}

.sai-header-body p {
  margin: 2px 0 0;
  font-size: 0.75rem;
  opacity: 0.9;
  color: #fff;
}

#sales-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sai-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sai-chat[hidden],
.sai-lead[hidden] {
  display: none !important;
}

.sai-lead {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 16px;
  background: #fff;
}

.sai-lead-intro {
  margin: 0 0 14px;
  color: #475569;
  font-size: 0.88rem;
  line-height: 1.5;
}

.sai-lead-group {
  margin-bottom: 12px;
}

.sai-lead-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 6px;
}

.sai-lead-group label span {
  color: #d28746;
}

.sai-lead-group label small {
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0;
  color: #94a3b8;
}

.sai-lead-group input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sai-lead-group input:focus {
  border-color: #d28746;
  box-shadow: 0 0 0 3px rgba(210, 135, 70, 0.18);
  background: #fff;
}

.sai-lead-error {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 0.82rem;
}

.sai-lead-start {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  margin-top: 4px;
  background: #d28746;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.sai-lead-start:hover {
  background: #a06735;
  transform: translateY(-1px);
}

.sai-msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
  align-items: flex-end;
}

.sai-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.sai-msg-bot {
  align-self: flex-start;
  max-width: 100%;
  width: 100%;
}

.sai-msg-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
}

.sai-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sai-msg-avatar-bot {
  background: transparent;
  border-radius: 8px;
}

.sai-msg-avatar-bot img {
  object-fit: contain;
}

.sai-msg-avatar-user {
  border: 2px solid var(--sai-accent);
  background: var(--sai-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.sai-msg-col { min-width: 0; }

.sai-bubble {
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 0.86rem;
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: anywhere;
  unicode-bidi: isolate;
  text-align: start;
}

.sai-bubble[dir="rtl"] { text-align: right; }
.sai-bubble[dir="ltr"] { text-align: left; }

.sai-bubble .sai-ltr {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline;
}

.sai-bubble code.sai-ltr {
  white-space: nowrap;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.92em;
  background: rgba(15, 23, 42, 0.06);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}

.sai-bubble .sai-text {
  unicode-bidi: plaintext;
  margin-bottom: 8px;
}

.sai-bubble .sai-text:last-child { margin-bottom: 0; }

.sai-msg-bot .sai-bubble {
  background: var(--sai-accent-soft);
  color: var(--sai-text);
  border-bottom-left-radius: 5px;
  max-width: 100%;
}

html[dir="rtl"] .sai-msg-bot .sai-bubble {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 5px;
}

.sai-msg-bot .sai-msg-col {
  max-width: calc(100% - 36px);
  min-width: 0;
}

.sai-table-wrap {
  overflow-x: auto;
  margin: 6px 0 2px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(30, 41, 59, 0.08);
}

.sai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  color: #1e293b;
  min-width: 220px;
}

.sai-table th,
.sai-table td {
  padding: 7px 10px;
  text-align: start;
  border-bottom: 1px solid #eef2f6;
  white-space: nowrap;
}

.sai-table th {
  background: #f8fafc;
  font-weight: 700;
}

.sai-msg-user .sai-bubble {
  background: var(--sai-gray);
  color: var(--sai-text);
  border-bottom-right-radius: 5px;
}

html[dir="rtl"] .sai-msg-user .sai-bubble {
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 5px;
}

.sai-msg-error .sai-bubble {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.sai-meta {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
}

.sai-msg-user .sai-meta { text-align: right; }
html[dir="rtl"] .sai-msg-user .sai-meta { text-align: left; }

.sai-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-width: 46px;
  justify-content: center;
}

.sai-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(160, 103, 53, 0.7);
  animation: sai-dot 1.2s ease-in-out infinite;
}

.sai-dots span:nth-child(2) { animation-delay: 0.15s; }
.sai-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sai-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

#sales-ai-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid #eef2f6;
  flex-shrink: 0;
}

#sales-ai-input {
  flex: 1;
  border: 0;
  background: var(--sai-gray);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 0.88rem;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  outline: none;
  color: var(--sai-text);
  font-family: inherit;
}

#sales-ai-input:focus {
  box-shadow: 0 0 0 2px rgba(210, 135, 70, 0.35);
}

#sales-ai-send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--sai-accent);
  color: var(--sai-on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}

#sales-ai-send:hover:not(:disabled) {
  background: var(--sai-accent-dark);
  transform: scale(1.05);
}

#sales-ai-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 576px) {
  #sales-ai-root {
    right: 12px;
    bottom: 12px;
  }

  html[dir="rtl"] #sales-ai-root {
    right: auto;
    left: 12px;
  }

  #sales-ai-fab {
    width: 64px;
    height: 64px;
  }

  #sales-ai-panel {
    width: calc(100vw - 24px);
    height: min(70vh, 520px);
    bottom: 80px;
  }
}
