/* Woo AI Assistant — Chat Widget
   Design intent: a quiet, trustworthy "concierge at the counter" feel —
   not a generic bubbly chatbot. Motion is used sparingly: one entrance,
   one typing pulse. Everything else stays still and legible. */

#wooai-widget-root {
  --wooai-primary: #1F3A5F;
  --wooai-primary-light: #2E4F7C;
  --wooai-accent: #D4A373;
  --wooai-ink: #1C1F26;
  --wooai-paper: #FFFFFF;
  --wooai-surface: #F6F4F0;
  --wooai-border: rgba(28, 31, 38, 0.08);
  --wooai-shadow: 0 20px 45px rgba(20, 26, 40, 0.18), 0 4px 12px rgba(20, 26, 40, 0.10);
  --wooai-radius: 18px;
  --wooai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  position: fixed;
  z-index: 999999;
  bottom: 24px;
  font-family: var(--wooai-font);
  color: var(--wooai-ink);
}

#wooai-widget-root.wooai-pos-right { right: 24px; }
#wooai-widget-root.wooai-pos-left  { left: 24px; }

/* ---------- Launcher bubble ---------- */
.wooai-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(155deg, var(--wooai-primary) 0%, var(--wooai-primary-light) 100%);
  box-shadow: var(--wooai-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease;
  padding: 0;
}
.wooai-launcher:hover { transform: translateY(-2px) scale(1.03); }
.wooai-launcher:active { transform: translateY(0) scale(0.98); }
.wooai-launcher svg { width: 26px; height: 26px; }

.wooai-launcher-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--wooai-accent);
  border: 2px solid var(--wooai-paper);
}

/* ---------- Panel ---------- */
.wooai-panel {
  position: absolute;
  bottom: 76px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--wooai-paper);
  border-radius: var(--wooai-radius);
  box-shadow: var(--wooai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.wooai-pos-right .wooai-panel { right: 0; }
.wooai-pos-left  .wooai-panel { left: 0; }

.wooai-panel.wooai-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Header ---------- */
.wooai-header {
  background: linear-gradient(155deg, var(--wooai-primary) 0%, var(--wooai-primary-light) 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.wooai-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wooai-header-avatar svg { width: 18px; height: 18px; }
.wooai-header-text { flex: 1; min-width: 0; }
.wooai-header-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.1px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wooai-header-status {
  font-size: 12px;
  opacity: 0.78;
  margin: 1px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.wooai-header-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6FCF97;
  display: inline-block;
}
.wooai-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  opacity: 0.85;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
}
.wooai-close-btn:hover { opacity: 1; background: rgba(255,255,255,0.12); }
.wooai-close-btn svg { width: 18px; height: 18px; }

/* ---------- Messages ---------- */
.wooai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--wooai-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wooai-messages::-webkit-scrollbar { width: 6px; }
.wooai-messages::-webkit-scrollbar-thumb { background: rgba(28,31,38,0.18); border-radius: 6px; }

.wooai-msg {
  max-width: 84%;
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
}
.wooai-msg p { margin: 0 0 6px; }
.wooai-msg p:last-child { margin-bottom: 0; }
.wooai-msg a { color: var(--wooai-primary); font-weight: 600; text-decoration: underline; }

.wooai-msg-assistant {
  align-self: flex-start;
  background: var(--wooai-paper);
  border: 1px solid var(--wooai-border);
  border-radius: 4px 14px 14px 14px;
}
.wooai-msg-user {
  align-self: flex-end;
  background: var(--wooai-primary);
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}
.wooai-msg-error {
  align-self: flex-start;
  background: #FBEAEA;
  color: #9C3B3B;
  border-radius: 4px 14px 14px 14px;
  border: 1px solid rgba(156,59,59,0.18);
}

.wooai-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--wooai-paper);
  border: 1px solid var(--wooai-border);
  border-radius: 4px 14px 14px 14px;
}
.wooai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wooai-primary);
  opacity: 0.35;
  animation: wooai-pulse 1.1s infinite ease-in-out;
}
.wooai-typing span:nth-child(2) { animation-delay: 0.15s; }
.wooai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes wooai-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- Product cards ---------- */
.wooai-products {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  max-width: 90%;
  align-self: flex-start;
}
.wooai-product-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--wooai-paper);
  border: 1px solid var(--wooai-border);
  border-left: 3px solid var(--wooai-accent);
  border-radius: 10px;
  padding: 9px 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.wooai-product-card:hover { border-color: var(--wooai-accent); transform: translateX(-1px); }
.wooai-product-name {
  font-size: 12.5px;
  font-weight: 600;
  margin: 0 0 2px;
  color: var(--wooai-ink);
}
.wooai-product-price {
  font-size: 12px;
  color: var(--wooai-primary);
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Input ---------- */
.wooai-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: var(--wooai-paper);
  border-top: 1px solid var(--wooai-border);
}
.wooai-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--wooai-border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  max-height: 90px;
  outline: none;
  transition: border-color 0.15s ease;
}
.wooai-input:focus { border-color: var(--wooai-primary); }
.wooai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--wooai-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}
.wooai-send-btn:disabled { opacity: 0.45; cursor: default; }
.wooai-send-btn svg { width: 16px; height: 16px; }

.wooai-footer-note {
  font-size: 10.5px;
  text-align: center;
  color: rgba(28,31,38,0.42);
  padding: 0 12px 10px;
  background: var(--wooai-paper);
}

/* ---------- Accessibility ---------- */
.wooai-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
button:focus-visible, .wooai-input:focus-visible {
  outline: 2px solid var(--wooai-accent);
  outline-offset: 2px;
}

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

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  #wooai-widget-root { bottom: 16px; }
  #wooai-widget-root.wooai-pos-right { right: 16px; }
  #wooai-widget-root.wooai-pos-left  { left: 16px; }
  .wooai-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    bottom: 72px;
  }
}
