/* ===================================================================
   Poyu Chat Widget — styling
   Palette: deep teal (trust/health), warm amber accent, soft ivory panel
   =================================================================== */

:root {
  --poyu-teal-900: #0b3d3a;
  --poyu-teal-700: #0f544f;
  --poyu-teal-500: #1a7a6e;
  --poyu-teal-100: #e6f2ef;
  --poyu-amber: #e08a2c;
  --poyu-amber-dark: #c9721c;
  --poyu-ink: #1c2b2a;
  --poyu-muted: #5c716e;
  --poyu-paper: #fbfaf7;
  --poyu-border: #dde6e4;
  --poyu-danger: #c0432f;
  --poyu-radius: 16px;
  --poyu-shadow: 0 12px 32px rgba(11, 61, 58, 0.18);
  --poyu-font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#poyu-widget-root {
  font-family: var(--poyu-font);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  line-height: 1.45;
}

#poyu-widget-root * {
  box-sizing: border-box;
}

/* ---------------- Launcher button ---------------- */

.poyu-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(155deg, var(--poyu-teal-500), var(--poyu-teal-900));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--poyu-shadow);
  position: relative;
  transition: transform 0.18s ease;
}

.poyu-launcher:hover {
  transform: translateY(-2px) scale(1.03);
}

.poyu-launcher:focus-visible {
  outline: 3px solid var(--poyu-amber);
  outline-offset: 3px;
}

.poyu-launcher svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

.poyu-launcher .poyu-status-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--poyu-amber);
  border: 2px solid var(--poyu-paper);
  animation: poyu-pulse 2.2s infinite;
}

@keyframes poyu-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(224, 138, 44, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(224, 138, 44, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 138, 44, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .poyu-launcher .poyu-status-dot { animation: none; }
  .poyu-launcher { transition: none; }
}

/* ---------------- Chat panel ---------------- */

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

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

/* ---------------- Header ---------------- */

.poyu-header {
  background: linear-gradient(120deg, var(--poyu-teal-900), var(--poyu-teal-700));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.poyu-header .poyu-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.poyu-header-text {
  flex: 1;
  min-width: 0;
}

.poyu-header-text .poyu-title {
  font-weight: 700;
  font-size: 14.5px;
}

.poyu-header-text .poyu-subtitle {
  font-size: 12px;
  opacity: 0.82;
  display: flex;
  align-items: center;
  gap: 5px;
}

.poyu-header-text .poyu-subtitle::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6fe0a8;
  display: inline-block;
}

.poyu-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  opacity: 0.8;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.poyu-close-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
}

/* ---------------- Messages ---------------- */

.poyu-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--poyu-paper);
}

.poyu-msg {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.poyu-msg-bot {
  align-self: flex-start;
  background: var(--poyu-teal-100);
  color: var(--poyu-ink);
  border-bottom-left-radius: 4px;
}

.poyu-msg-user {
  align-self: flex-end;
  background: var(--poyu-teal-900);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.poyu-msg-error {
  align-self: flex-start;
  background: #fbe9e6;
  color: var(--poyu-danger);
  border: 1px solid #f2c9c1;
}

.poyu-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  background: var(--poyu-teal-100);
  border-radius: 13px;
  border-bottom-left-radius: 4px;
}

.poyu-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--poyu-teal-500);
  animation: poyu-bounce 1.1s infinite ease-in-out;
}

.poyu-typing span:nth-child(2) { animation-delay: 0.15s; }
.poyu-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes poyu-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.poyu-welcome {
  font-size: 12.5px;
  color: var(--poyu-muted);
  text-align: center;
  padding: 6px 10px 2px;
}

/* ---------------- Input area ---------------- */

.poyu-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--poyu-border);
  background: #fff;
  flex-shrink: 0;
}

.poyu-input-row textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--poyu-border);
  border-radius: 10px;
  padding: 9px 11px;
  font-family: var(--poyu-font);
  font-size: 13.5px;
  max-height: 90px;
  color: var(--poyu-ink);
}

.poyu-input-row textarea:focus {
  outline: none;
  border-color: var(--poyu-teal-500);
  box-shadow: 0 0 0 3px rgba(26, 122, 110, 0.14);
}

.poyu-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--poyu-amber);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.poyu-send-btn:hover {
  background: var(--poyu-amber-dark);
}

.poyu-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.poyu-send-btn svg {
  width: 17px;
  height: 17px;
}

.poyu-footnote {
  font-size: 10.5px;
  color: var(--poyu-muted);
  text-align: center;
  padding: 5px 10px 8px;
  background: #fff;
}

/* ---------------- Mobile ---------------- */

@media (max-width: 480px) {
  #poyu-widget-root {
    right: 12px;
    bottom: 12px;
  }
  .poyu-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 110px);
    bottom: 72px;
  }
}
