/* ─── Chat Root ─────────────────────────────────────────────────── */
#chat-root { --c: #2A9D8F; --cd: #1f7a6e; --white: #fff; --bg: #f6fffe; --muted: #6b7280; font-family: 'Inter', sans-serif; }

/* ─── Bubble ────────────────────────────────────────────────────── */
.chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--c);
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  box-shadow: 0 6px 24px rgba(42,157,143,.35);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, box-shadow .2s;
}
.chat-bubble:hover { transform: scale(1.1); box-shadow: 0 8px 32px rgba(42,157,143,.45); }

.chat-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  animation: badgePop .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes badgePop { from { transform: scale(0); } to { transform: scale(1); } }

@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(42,157,143,.55); }
  70%  { box-shadow: 0 0 0 18px rgba(42,157,143,0); }
  100% { box-shadow: 0 0 0 0 rgba(42,157,143,0); }
}
.chat-bubble.pulse { animation: pulseRing 1.2s ease-out 2; }

/* ─── Widget ────────────────────────────────────────────────────── */
.chat-widget {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9998;
  width: 380px;
  max-height: 600px;
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0,0,0,.15), 0 2px 8px rgba(42,157,143,.12);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: scale(.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
}
.chat-widget.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ─── Header ────────────────────────────────────────────────────── */
.chat-header {
  background: linear-gradient(135deg, var(--c), var(--cd));
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-header-left { display: flex; align-items: center; gap: 12px; }
.chat-avatar { font-size: 1.8rem; background: rgba(255,255,255,.15); border-radius: 50%; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.chat-bot-name { color: #fff; font-weight: 700; font-size: .98rem; }
.chat-status { color: rgba(255,255,255,.8); font-size: .75rem; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.status-dot { width: 7px; height: 7px; background: #4ade80; border-radius: 50%; display: inline-block; animation: blink 2s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.chat-header-actions { display: flex; gap: 6px; }
.chat-icon-btn { background: rgba(255,255,255,.15); border: none; color: #fff; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: .85rem; display: flex; align-items: center; justify-content: center; transition: background .2s; }
.chat-icon-btn:hover { background: rgba(255,255,255,.3); }

/* ─── Messages ──────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(42,157,143,.2); border-radius: 99px; }

.chat-msg { display: flex; gap: 8px; align-items: flex-end; animation: msgIn .25s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.chat-msg-bot  { flex-direction: row; }
.chat-msg-user { flex-direction: row-reverse; }

.msg-avatar { font-size: 1.2rem; flex-shrink: 0; margin-bottom: 2px; }

.msg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .88rem;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg-bot  .msg-bubble { background: #fff; color: #1a1a2e; border: 1px solid rgba(42,157,143,.12); border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.chat-msg-user .msg-bubble { background: var(--c); color: #fff; border-bottom-right-radius: 4px; }

/* Typing */
.typing-bubble { display: flex; align-items: center; gap: 4px; padding: 12px 16px; }
.typing-bubble span {
  width: 7px; height: 7px;
  background: var(--c);
  border-radius: 50%;
  opacity: .5;
  animation: typingDot 1.2s infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: .2s; }
.typing-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes typingDot { 0%,80%,100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-5px); opacity: 1; } }

/* ─── Quick replies ─────────────────────────────────────────────── */
.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px 8px;
  background: var(--bg);
  border-top: 1px solid rgba(42,157,143,.08);
  min-height: 0;
  transition: min-height .2s;
}
.quick-btn {
  background: #fff;
  border: 1.5px solid var(--c);
  color: var(--c);
  border-radius: 99px;
  padding: 5px 13px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
  font-family: inherit;
}
.quick-btn:hover { background: var(--c); color: #fff; }

/* ─── Input ─────────────────────────────────────────────────────── */
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(42,157,143,.1);
  background: #fff;
  flex-shrink: 0;
}
#chatInput {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 99px;
  padding: 9px 16px;
  font-size: .88rem;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
  color: #1a1a2e;
}
#chatInput:focus { border-color: var(--c); box-shadow: 0 0 0 3px rgba(42,157,143,.1); }
.chat-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--c);
  color: #fff;
  font-size: .95rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .15s;
  flex-shrink: 0;
}
.chat-send:hover { background: var(--cd); transform: scale(1.08); }

/* ─── Footer ────────────────────────────────────────────────────── */
.chat-footer {
  text-align: center;
  font-size: .72rem;
  color: var(--muted);
  padding: 6px 0 10px;
  background: #fff;
  flex-shrink: 0;
}
.chat-footer a { color: var(--c); }

/* ─── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .chat-widget { width: calc(100vw - 24px); right: 12px; bottom: 88px; max-height: 70vh; }
  .chat-bubble { bottom: 18px; right: 18px; }
}
