/* ── AI Chat Widget — floating bottom-right ─────────────────────── */
.chat-widget-wrap {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  font-family: var(--font-body);
}

/* FAB button */
.chat-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,119,182,0.4);
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
  position: relative;
}
.chat-fab:hover {
  transform: scale(1.08);
  background: var(--blue-dark);
  box-shadow: 0 8px 28px rgba(0,91,138,0.5);
}
.chat-fab svg { transition: opacity 0.2s; }
.chat-fab .chat-icon-close { display: none; }

/* Badge dot */
.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}
.chat-badge.show { display: block; }

/* Chat window */
.chat-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,45,68,0.18), 0 4px 16px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,119,182,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.chat-header {
  background: var(--blue-dark);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.chat-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,180,216,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header-text { flex: 1; }
.chat-header-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}
.chat-header-sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-header-sub .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2ecc71;
  display: inline-block;
}
.chat-close-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.7);
  transition: background 0.2s;
  flex-shrink: 0;
}
.chat-close-btn:hover { background: rgba(255,255,255,0.22); color: #fff; }

/* Messages area */
.chat-messages {
  flex: 1;
  min-height: 220px;
  max-height: 340px;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--off-white);
}
.chat-msg {
  display: flex;
  gap: 8px;
  animation: msgSlideIn 0.25s ease;
}
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.user { flex-direction: row-reverse; }
.chat-msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg.bot .chat-msg-bubble {
  background: #fff;
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(0,119,182,0.08);
  box-shadow: 0 2px 8px rgba(0,91,138,0.06);
}
.chat-msg.user .chat-msg-bubble {
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-display);
}
.chat-msg.bot .chat-msg-avatar {
  background: var(--blue-pale);
  color: var(--blue-dark);
}
.chat-msg.user .chat-msg-avatar {
  background: rgba(0,119,182,0.15);
  color: #fff;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 5px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(0,119,182,0.08);
  width: fit-content;
}
.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-light);
  opacity: 0.5;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.chat-input-area {
  padding: 14px 16px;
  border-top: 1px solid rgba(0,119,182,0.08);
  background: #fff;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid rgba(0,119,182,0.15);
  background: var(--off-white);
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text);
  resize: none;
  max-height: 100px;
  min-height: 42px;
  line-height: 1.4;
  transition: border-color 0.2s;
}
.chat-input:focus {
  outline: none;
  border-color: var(--blue);
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.chat-send-btn:hover { background: var(--blue-dark); transform: scale(1.05); }
.chat-send-btn:disabled { background: var(--blue-pale); cursor: not-allowed; transform: none; }

/* Disclosure */
.chat-disclosure {
  padding: 8px 16px;
  background: var(--off-white);
  border-top: 1px solid rgba(0,119,182,0.06);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0,119,182,0.2);
  border-radius: 2px;
}

/* Mobile: smaller window */
@media (max-width: 480px) {
  .chat-widget-wrap { bottom: 16px; right: 16px; }
  .chat-fab { width: 52px; height: 52px; }
  .chat-window { width: calc(100vw - 32px); bottom: 64px; }
}