/* =====================================================
   ZingVoice floating chat widget
   All rules scoped under #zingvoice-widget or #zingvoice-toggle
   to avoid conflicts with the host theme.
   ===================================================== */

@keyframes zv-fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes zv-pulse  { 0%,100% { opacity: 0.3; transform: scale(1); } 50% { opacity: 1; transform: scale(1.2); } }
@keyframes zv-pop    { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---------- Floating toggle button ---------- */
#zingvoice-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99998;
  background: linear-gradient(135deg, #E30B5D, #0E9A8C);
  color: #fff;
  border: none;
  border-radius: 28px;
  padding: 14px 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(227, 11, 93, 0.35);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#zingvoice-toggle:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(227, 11, 93, 0.45); }
#zingvoice-toggle .zv-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff;
  animation: zv-pulse 1.6s ease-in-out infinite;
}
#zingvoice-toggle[aria-expanded="true"] { display: none; }

/* ---------- Widget container ---------- */
#zingvoice-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 400px;
  height: 600px;
  max-height: calc(100vh - 40px);
  z-index: 99999;
  display: none;
  background: #faf9f6;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a1a1a;
  -webkit-font-smoothing: antialiased;
  animation: zv-pop 0.25s ease;
  box-sizing: border-box;
}
#zingvoice-widget.zv-open { display: flex; flex-direction: column; }

#zingvoice-widget *,
#zingvoice-widget *::before,
#zingvoice-widget *::after { box-sizing: border-box; }

#zingvoice-widget .zv-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.05);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  color: #555;
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
#zingvoice-widget .zv-close:hover { background: rgba(0,0,0,0.1); color: #000; }

/* ---------- Screens ---------- */
#zingvoice-widget .zv-screen { display: none; flex: 1; min-height: 0; }
#zingvoice-widget .zv-screen.zv-active { display: flex; }

#zingvoice-widget .zv-logo { font-size: 32px; font-weight: 700; letter-spacing: -1px; margin-bottom: 4px; }
#zingvoice-widget .zv-logo-sm { font-size: 24px; }
#zingvoice-widget .zv-logo-zing { color: #1a1a1a; }
#zingvoice-widget .zv-logo-voice { color: #E30B5D; }
#zingvoice-widget .zv-tagline { color: #666; font-size: 14px; margin-bottom: 28px; line-height: 1.5; }
#zingvoice-widget .zv-section-label { font-size: 11px; font-weight: 500; color: #999; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }

/* Welcome */
#zingvoice-widget .zv-welcome-screen { flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; overflow-y: auto; }
#zingvoice-widget .zv-welcome-inner { text-align: center; width: 100%; max-width: 340px; animation: zv-fadeIn 0.5s ease; }
#zingvoice-widget .zv-audience-btn {
  padding: 14px 16px; border-radius: 12px; border: 1.5px solid #e5e5e0;
  background: #fff; cursor: pointer; text-align: left; transition: all 0.2s;
  display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 10px;
  font-family: inherit;
}
#zingvoice-widget .zv-audience-btn:hover { transform: translateY(-1px); }
#zingvoice-widget .zv-audience-btn .zv-cdot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
#zingvoice-widget .zv-audience-btn .zv-label { font-weight: 600; font-size: 14px; color: #1a1a1a; }
#zingvoice-widget .zv-audience-btn .zv-sub { font-size: 12px; color: #888; margin-top: 2px; }
#zingvoice-widget .zv-code-link {
  background: none; border: none; color: #999; font-size: 13px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
  margin-top: 24px; font-family: inherit;
}

/* Code screen */
#zingvoice-widget .zv-code-screen { flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; overflow-y: auto; }
#zingvoice-widget .zv-code-inner { text-align: center; width: 100%; max-width: 340px; animation: zv-fadeIn 0.5s ease; }
#zingvoice-widget .zv-code-input-row { display: flex; gap: 8px; }
#zingvoice-widget .zv-code-input {
  flex: 1; padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid #e5e5e0; font-size: 14px; outline: none;
  font-family: inherit; background: #fff; color: #1a1a1a;
}
#zingvoice-widget .zv-code-submit {
  padding: 12px 20px; border-radius: 10px; border: none;
  background: #E30B5D; color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
#zingvoice-widget .zv-code-error { color: #e24b4a; font-size: 13px; margin-top: 8px; }
#zingvoice-widget .zv-back-btn {
  background: none; border: none; color: #999; font-size: 13px;
  cursor: pointer; margin-top: 20px; text-decoration: underline;
  text-underline-offset: 3px; font-family: inherit;
}

/* Chat */
#zingvoice-widget .zv-chat-screen { flex-direction: column; height: 100%; }
#zingvoice-widget .zv-chat-header {
  padding: 14px 20px; border-bottom: 1px solid #eee; background: #fff;
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
  padding-right: 52px; /* room for close button */
}
#zingvoice-widget .zv-chat-header-left { display: flex; align-items: center; gap: 10px; }
#zingvoice-widget .zv-chat-logo { font-size: 18px; font-weight: 700; }
#zingvoice-widget .zv-tier-badge { font-size: 10px; padding: 3px 8px; border-radius: 6px; font-weight: 600; }
#zingvoice-widget .zv-start-over { background: none; border: none; color: #999; font-size: 12px; cursor: pointer; font-family: inherit; }
#zingvoice-widget .zv-chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 0;
  -webkit-overflow-scrolling: touch; min-height: 0;
}
#zingvoice-widget .zv-message { display: flex; padding: 4px 16px; animation: zv-fadeIn 0.3s ease; }
#zingvoice-widget .zv-message.zv-user { justify-content: flex-end; }
#zingvoice-widget .zv-message.zv-assistant { justify-content: flex-start; }
#zingvoice-widget .zv-bubble {
  max-width: 85%; padding: 10px 14px; font-size: 14px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word;
}
#zingvoice-widget .zv-message.zv-user .zv-bubble { border-radius: 16px 16px 4px 16px; background: #E30B5D; color: #fff; }
#zingvoice-widget .zv-message.zv-assistant .zv-bubble { border-radius: 16px 16px 16px 4px; background: #f5f5f0; color: #1a1a1a; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
#zingvoice-widget .zv-typing { display: flex; gap: 4px; padding: 12px 20px; align-items: center; }
#zingvoice-widget .zv-typing-dot { width: 7px; height: 7px; border-radius: 50%; background: #0E9A8C; }
#zingvoice-widget .zv-typing-dot:nth-child(1) { animation: zv-pulse 1.2s ease-in-out 0s infinite; }
#zingvoice-widget .zv-typing-dot:nth-child(2) { animation: zv-pulse 1.2s ease-in-out 0.2s infinite; }
#zingvoice-widget .zv-typing-dot:nth-child(3) { animation: zv-pulse 1.2s ease-in-out 0.4s infinite; }
#zingvoice-widget .zv-suggestions { padding: 0 16px 8px; display: flex; gap: 6px; flex-wrap: wrap; }
#zingvoice-widget .zv-suggestion-btn {
  padding: 7px 12px; border-radius: 20px; border: 1px solid #e5e5e0;
  background: #fff; font-size: 12px; color: #555; cursor: pointer;
  font-family: inherit; transition: all 0.2s;
}
#zingvoice-widget .zv-suggestion-btn:hover { border-color: #0E9A8C; color: #0E9A8C; }
#zingvoice-widget .zv-chat-input-area {
  padding: 10px 14px 14px; border-top: 1px solid #eee;
  background: #fff; flex-shrink: 0;
}
#zingvoice-widget .zv-chat-input-row { display: flex; gap: 8px; }
#zingvoice-widget .zv-chat-input {
  flex: 1; padding: 11px 14px; border-radius: 12px;
  border: 1.5px solid #e5e5e0; font-size: 14px; outline: none;
  font-family: inherit; background: #faf9f6; color: #1a1a1a;
  transition: border-color 0.2s;
}
#zingvoice-widget .zv-chat-input:focus { border-color: #0E9A8C; }
#zingvoice-widget .zv-send-btn {
  padding: 11px 16px; border-radius: 12px; border: none;
  background: #E30B5D; color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; min-width: 60px;
}
#zingvoice-widget .zv-send-btn:disabled { background: #ddd; cursor: default; }
#zingvoice-widget .zv-chat-footer { text-align: center; font-size: 10px; color: #bbb; margin-top: 6px; }

/* ---------- Mobile: full-screen overlay when open ---------- */
@media (max-width: 600px) {
  #zingvoice-widget.zv-open {
    right: 0; bottom: 0; left: 0; top: 0;
    width: 100%; height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  #zingvoice-toggle { right: 14px; bottom: 14px; padding: 12px 18px; font-size: 14px; }
  #zingvoice-widget .zv-bubble { max-width: 88%; font-size: 14px; }
  #zingvoice-widget .zv-chat-input { font-size: 16px; } /* prevent iOS zoom */
}
