/* ==========================================================
   Pharmaco AI Assistant — Chat Widget
   Brand palette approximated from pharmaco.co.in (24x7 healthcare,
   teal-green trust + emergency orange CTA). Swap the variables below
   for exact brand hex/fonts if you have the site's design tokens.
   ========================================================== */
:root {
  --pw-primary: #0e7c66;
  --pw-primary-dark: #0a5c4b;
  --pw-accent: #f36f21;
  --pw-bg: #ffffff;
  --pw-bg-soft: #f6faf9;
  --pw-text: #14261f;
  --pw-muted: #6b7a76;
  --pw-border: rgba(14, 124, 102, 0.15);
  --pw-shadow: 0 20px 50px rgba(14, 60, 50, 0.25);
  --pw-radius: 20px;
  --pw-font: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#pharmaco-ai-widget, #pharmaco-ai-widget * { box-sizing: border-box; font-family: var(--pw-font); }
#pharmaco-ai-widget { position: fixed; z-index: 999999; bottom: 20px; right: 20px; }

/* ---------- Floating bubble ---------- */
.pw-bubble {
  width: 62px; height: 62px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pw-primary), var(--pw-primary-dark));
  box-shadow: var(--pw-shadow);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none; position: relative;
  transition: transform .25s ease;
  animation: pw-float 3s ease-in-out infinite;
}
.pw-bubble:hover { transform: scale(1.06); }
.pw-bubble svg { width: 28px; height: 28px; fill: #fff; }
.pw-bubble .pw-online-dot {
  position: absolute; bottom: 2px; right: 2px; width: 14px; height: 14px;
  background: #22c55e; border: 2px solid #fff; border-radius: 50%;
}
.pw-bubble .pw-unread-badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--pw-accent); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700;
  display: none; align-items: center; justify-content: center; border: 2px solid #fff;
}
@keyframes pw-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ---------- Chat window ---------- */
.pw-window {
  position: absolute; bottom: 78px; right: 0;
  width: 380px; max-width: calc(100vw - 40px);
  height: 560px; max-height: calc(100vh - 120px);
  background: var(--pw-bg);
  border-radius: var(--pw-radius);
  box-shadow: var(--pw-shadow);
  display: none; flex-direction: column; overflow: hidden;
  backdrop-filter: blur(20px);
  border: 1px solid var(--pw-border);
  animation: pw-slide-in .25s ease;
}
.pw-window.pw-open { display: flex; }
@keyframes pw-slide-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.pw-header {
  background: linear-gradient(135deg, var(--pw-primary), var(--pw-primary-dark));
  color: #fff; padding: 16px 18px; display: flex; align-items: center; gap: 12px;
}
.pw-header-avatar { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.pw-header-text { flex: 1; }
.pw-header-text strong { display: block; font-size: 15px; }
.pw-header-status { font-size: 11.5px; opacity: 0.85; display: flex; align-items: center; gap: 5px; }
.pw-header-status .pw-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }
.pw-header-actions { display: flex; gap: 6px; }
.pw-header-actions button { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.pw-header-actions button:hover { background: rgba(255,255,255,0.28); }

.pw-messages { flex: 1; overflow-y: auto; padding: 16px; background: var(--pw-bg-soft); display: flex; flex-direction: column; gap: 12px; }
.pw-messages::-webkit-scrollbar { width: 6px; }
.pw-messages::-webkit-scrollbar-thumb { background: var(--pw-border); border-radius: 3px; }

.pw-msg { max-width: 84%; display: flex; flex-direction: column; gap: 4px; }
.pw-msg.pw-user { align-self: flex-end; align-items: flex-end; }
.pw-msg.pw-assistant { align-self: flex-start; align-items: flex-start; }
.pw-bubble-text { padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.pw-user .pw-bubble-text { background: var(--pw-primary); color: #fff; border-bottom-right-radius: 4px; }
.pw-assistant .pw-bubble-text { background: #fff; color: var(--pw-text); border: 1px solid var(--pw-border); border-bottom-left-radius: 4px; }
.pw-bubble-text code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.pw-bubble-text pre { background: #0f2620; color: #d1fadf; padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 12px; }
.pw-bubble-text a { color: var(--pw-primary-dark); font-weight: 600; }
.pw-timestamp { font-size: 10px; color: var(--pw-muted); padding: 0 4px; }
.pw-msg-actions { display: flex; gap: 6px; }
.pw-msg-actions button { background: none; border: none; color: var(--pw-muted); font-size: 11px; cursor: pointer; padding: 2px 4px; }
.pw-msg-actions button:hover { color: var(--pw-primary); }

.pw-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #fff; border: 1px solid var(--pw-border); border-radius: 16px; border-bottom-left-radius: 4px; }
.pw-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--pw-muted); animation: pw-blink 1.2s infinite; }
.pw-typing span:nth-child(2) { animation-delay: .2s; }
.pw-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes pw-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.pw-suggested { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 12px; background: var(--pw-bg-soft); }
.pw-chip { background: #fff; border: 1px solid var(--pw-border); color: var(--pw-primary-dark); font-size: 12px; padding: 7px 12px; border-radius: 999px; cursor: pointer; transition: all .15s; }
.pw-chip:hover { background: var(--pw-primary); color: #fff; border-color: var(--pw-primary); }

.pw-inputbar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--pw-border); background: #fff; }
.pw-inputbar textarea { flex: 1; border: 1px solid var(--pw-border); border-radius: 20px; padding: 10px 16px; resize: none; font-size: 13.5px; max-height: 90px; font-family: inherit; }
.pw-inputbar textarea:focus { outline: none; border-color: var(--pw-primary); }
.pw-send-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--pw-primary); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pw-send-btn:hover { background: var(--pw-primary-dark); }
.pw-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pw-send-btn svg { width: 18px; height: 18px; fill: #fff; }

.pw-footer-note { text-align: center; font-size: 10.5px; color: var(--pw-muted); padding: 6px 0 10px; background: #fff; }

.pw-skeleton { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.pw-skeleton-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #eef3f2 25%, #e2ebe9 37%, #eef3f2 63%); background-size: 400% 100%; animation: pw-shimmer 1.4s ease infinite; }
@keyframes pw-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (max-width: 480px) {
  .pw-window { width: calc(100vw - 24px); right: -8px; height: 78vh; }
}
