/* Supoai Chat Widget — brand: #FF4A00 */
:root {
  --sp-brand: #FF4A00;
  --sp-brand-dark: #D93F00;
  --sp-brand-tint: #FFF1EA;
  --sp-ink: #241C1A;
  --sp-ink-dim: #8A7E7A;
  --sp-surface: #FFFFFF;
  --sp-bg: #FFF8F5;
  --sp-line: rgba(36, 28, 26, 0.10);
  --sp-whatsapp: #2FAE60;
  --sp-radius: 16px;
  --sp-shadow: 0 12px 32px rgba(36, 20, 10, 0.16);
}

#supoai-root, #supoai-root * {
  box-sizing: border-box;
  font-family: "Poppins", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}
#supoai-root {
  position: fixed;
  z-index: 999999;
  right: 20px;
  bottom: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

/* ---- Launcher button ---- */
.sp-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--sp-brand);
  border: none;
  box-shadow: var(--sp-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  transition: transform 0.15s ease;
}
.sp-launcher:hover { transform: scale(1.05); }
.sp-launcher img { width: 100%; height: 100%; object-fit: contain; }
.sp-launcher .sp-close-icon { display: none; width: 22px; height: 22px; }
#supoai-root.sp-open .sp-launcher img.sp-mark { display: none; }
#supoai-root.sp-open .sp-launcher .sp-close-icon { display: block; }

/* ---- Promo popup ---- */
.sp-promo {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 300px;
  background: var(--sp-surface);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow);
  overflow: hidden;
  border: 1px solid var(--sp-line);
  animation: sp-rise 0.35s ease;
}
@keyframes sp-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.sp-promo img { width: 100%; display: block; }
.sp-promo-body { padding: 14px 16px 16px; }
.sp-promo-body p {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--sp-ink-dim);
  line-height: 1.4;
}
.sp-promo-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--sp-brand);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  width: 100%;
  justify-content: center;
}
.sp-promo-cta:hover { background: var(--sp-brand-dark); }
.sp-promo-x {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.85);
  color: var(--sp-ink);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Chat panel ---- */
.sp-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: min(600px, 75vh);
  background: var(--sp-surface);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--sp-line);
}
#supoai-root.sp-open .sp-panel { display: flex; }
#supoai-root.sp-open .sp-promo { display: none; }

.sp-header {
  background: var(--sp-brand);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.sp-header img { height: 22px; }
.sp-header-text { color: #fff; }
.sp-header-text .sp-title { font-weight: 600; font-size: 0.95rem; line-height: 1.1; }
.sp-header-text .sp-sub { font-size: 0.72rem; opacity: 0.9; margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.sp-dot { width: 6px; height: 6px; border-radius: 50%; background: #C6FFD9; flex: none; }

.sp-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--sp-bg);
}
.sp-msg { display: flex; max-width: 86%; }
.sp-msg.sp-user { align-self: flex-end; }
.sp-msg.sp-bot { align-self: flex-start; }
.sp-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.sp-msg.sp-user .sp-bubble {
  background: var(--sp-brand-tint);
  color: var(--sp-ink);
  border-bottom-right-radius: 4px;
}
.sp-msg.sp-bot .sp-bubble {
  background: #fff;
  color: var(--sp-ink);
  border: 1px solid var(--sp-line);
  border-bottom-left-radius: 4px;
}
.sp-msg.sp-bot .sp-bubble a { color: var(--sp-brand-dark); }

.sp-typing { display: inline-flex; gap: 4px; padding: 3px 2px; }
.sp-typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--sp-ink-dim);
  opacity: 0.5;
  animation: sp-blink 1.2s infinite ease-in-out;
}
.sp-typing span:nth-child(2) { animation-delay: 0.2s; }
.sp-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sp-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 0.85; } }

.sp-handoff {
  align-self: flex-start;
  max-width: 92%;
  border: 1px solid var(--sp-line);
  border-left: 3px solid var(--sp-whatsapp);
  border-radius: 10px;
  padding: 11px 13px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.sp-handoff .sp-label { font-size: 0.68rem; font-weight: 700; color: var(--sp-whatsapp); letter-spacing: 0.2px; }
.sp-handoff p { margin: 0; font-size: 0.83rem; color: var(--sp-ink); line-height: 1.4; }
.sp-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  background: var(--sp-whatsapp);
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 8px;
}
.sp-wa-btn svg { width: 14px; height: 14px; flex: none; }

.sp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
  background: var(--sp-bg);
  flex: none;
}
.sp-chip {
  border: 1px solid var(--sp-line);
  background: #fff;
  color: var(--sp-ink);
  font-size: 0.75rem;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
}
.sp-chip:hover { border-color: var(--sp-brand); color: var(--sp-brand-dark); }

.sp-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--sp-line);
  background: #fff;
  flex: none;
}
.sp-input {
  flex: 1;
  resize: none;
  max-height: 90px;
  border: 1px solid var(--sp-line);
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 0.86rem;
  color: var(--sp-ink);
  background: var(--sp-bg);
  line-height: 1.4;
  font-family: inherit;
}
.sp-input:focus { outline: 2px solid var(--sp-brand); outline-offset: 1px; }
.sp-send {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--sp-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sp-send:hover { background: var(--sp-brand-dark); }
.sp-send:disabled { opacity: 0.45; cursor: default; }

.sp-footer {
  text-align: center;
  padding: 7px 10px;
  font-size: 0.68rem;
  color: var(--sp-ink-dim);
  border-top: 1px solid var(--sp-line);
  background: #fff;
  flex: none;
}
.sp-footer a { color: var(--sp-brand-dark); text-decoration: none; }
.sp-footer img { height: 11px; vertical-align: -1px; margin: 0 3px 0 4px; }

@media (max-width: 420px) {
  #supoai-root { right: 12px; bottom: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .sp-panel, .sp-promo { right: -4px; width: calc(100vw - 24px); }
}

@media (prefers-reduced-motion: reduce) {
  .sp-typing span { animation: none; opacity: 0.6; }
  .sp-promo { animation: none; }
}
