/* ── Chat bubble launcher ── */
#map-chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--cyan);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,229,255,0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}
#map-chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,229,255,0.5); }
#map-chat-fab svg { width: 24px; height: 24px; }
#map-chat-fab .fab-close { display: none; }
#map-chat-fab.open .fab-chat { display: none; }
#map-chat-fab.open .fab-close { display: block; }

/* ── Chat window ── */
#map-chat-window {
  position: fixed;
  bottom: 94px;
  right: 28px;
  z-index: 9998;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 16px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
#map-chat-window.open {
  display: flex;
  animation: chatSlideIn 0.22s ease forwards;
}
@keyframes chatSlideIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #0d1117;
  flex-shrink: 0;
}
.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-size: 13px; font-weight: 600; color: var(--white); font-family: 'Space Grotesk', sans-serif; }
.chat-header-sub  { font-size: 11px; color: var(--cyan); margin-top: 1px; }
.chat-header-close {
  background: none;
  border: none;
  color: var(--grey);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  font-size: 18px;
  border-radius: 6px;
  transition: color 0.15s;
}
.chat-header-close:hover { color: var(--white); }

/* ── Suggestion chips ── */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
  flex-shrink: 0;
}
.chip {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--grey-lt);
  background: transparent;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--cyan); color: var(--cyan); background: rgba(0,229,255,0.06); }

/* ── Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  font-family: 'Inter', sans-serif;
  word-break: break-word;
}
.msg.bot {
  background: #161f2e;
  color: var(--grey-lt);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.msg.user {
  background: var(--cyan);
  color: #0a0a0f;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.msg.typing { opacity: 0.55; font-style: italic; }

/* ── Input area ── */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: #0d1117;
}
#chat-input {
  flex: 1;
  background: #161f2e;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--white);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  padding: 9px 12px;
  resize: none;
  line-height: 1.4;
  max-height: 100px;
  outline: none;
  transition: border-color 0.15s;
}
#chat-input::placeholder { color: var(--grey); }
#chat-input:focus { border-color: rgba(0,229,255,0.4); }
#chat-send {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--cyan);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}
#chat-send:hover { background: var(--cyan-dim); transform: scale(1.06); }
#chat-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
#chat-send svg { width: 16px; height: 16px; }

/* ── Responsive ── */
@media (max-width: 480px) {
  #map-chat-window { width: calc(100vw - 20px); right: 10px; bottom: 88px; }
  #map-chat-fab   { right: 16px; bottom: 20px; }
}
