/* =========================================
   SAVANNAH CHAT UI
   Fixed bottom-right chat launcher + window
   ========================================= */

/* Chat launcher button */
.savannah-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--fg, #1A1A1A);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}
.savannah-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(0,0,0,0.3);
}
.savannah-launcher svg {
  width: 26px;
  height: 26px;
  color: white;
}

/* Chat window — slides up from bottom-right */
.savannah-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 420px;
  max-width: calc(100vw - 40px);
  height: 580px;
  max-height: calc(100vh - 140px);
  background: #111111;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.06);
  z-index: 998;
  transition: opacity 0.25s, transform 0.25s;
}
.savannah-window.hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  pointer-events: none;
}

/* Header */
.savannah-header {
  background: #1A1A1A;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.savannah-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F59E0B, #D97706);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.savannah-info { flex: 1; }
.savannah-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: #F4F4F4;
  line-height: 1.2;
}
.savannah-status {
  font-size: 0.72rem;
  color: #22C55E;
  margin-top: 2px;
}
.savannah-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.4);
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 0.2s, background 0.2s;
}
.savannah-close:hover { color: #F4F4F4; background: rgba(255,255,255,0.08); }
.savannah-close svg { width: 18px; height: 18px; }

/* Messages area */
.savannah-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.savannah-messages::-webkit-scrollbar { width: 4px; }
.savannah-messages::-webkit-scrollbar-track { background: transparent; }
.savannah-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.msg-row { display: flex; flex-direction: column; max-width: 88%; }
.msg-row.user { align-items: flex-end; }
.msg-row.savannah { align-items: flex-start; }
.msg-row.system { align-items: center; }

.msg-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
  opacity: 0.5;
}
.msg-label.you { color: #60A5FA; }
.msg-label.savannah { color: #F59E0B; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.55;
}
.msg-row.user .msg-bubble {
  background: #2563EB;
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-row.savannah .msg-bubble {
  background: rgba(245,158,11,0.12);
  color: #F4F4F4;
  border-bottom-left-radius: 4px;
  border-left: 2px solid #F59E0B;
}
.msg-row.system .msg-bubble {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.5);
  font-size: 0.78rem;
  font-style: italic;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  background: rgba(245,158,11,0.6);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
.savannah-input-area {
  padding: 14px 16px;
  background: #1A1A1A;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.savannah-input {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px 14px;
  color: #F4F4F4;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.85rem;
  resize: none;
  min-height: 42px;
  max-height: 100px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}
.savannah-input::placeholder { color: rgba(255,255,255,0.35); }
.savannah-input:focus { border-color: rgba(245,158,11,0.5); }

.savannah-send {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #F59E0B;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.savannah-send:hover { background: #D97706; transform: scale(1.04); }
.savannah-send:disabled { background: rgba(245,158,11,0.3); cursor: not-allowed; transform: none; }
.savannah-send svg { width: 18px; height: 18px; color: white; }

/* Context chips in chat */
.context-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 100px;
  padding: 4px 10px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
  margin-top: 6px;
}

@media (max-width: 480px) {
  .savannah-window { right: 16px; bottom: 90px; width: calc(100vw - 32px); }
  .savannah-launcher { right: 20px; bottom: 20px; }
}