/* ─── Chat Widget ─────────────────────────────────────── */
/* Floating chat button */
#chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--teal);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(10, 42, 42, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  transition: transform 0.2s ease, background 0.2s ease;
}
#chat-launcher:hover { background: var(--teal-light); transform: scale(1.07); }
#chat-launcher svg { width: 28px; height: 28px; }

/* Chat window */
#chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-height: 560px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(10, 42, 42, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9000;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
#chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
#chat-header {
  background: var(--teal);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#chat-header-info { display: flex; flex-direction: column; gap: 2px; }
#chat-header-info strong { font-family: var(--font-display); font-size: 15px; font-weight: 600; }
#chat-header-info span { font-family: var(--font-body); font-size: 12px; opacity: 0.8; }
#chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
#chat-close:hover { color: #fff; }

/* Messages area */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 380px;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 2px; }

.msg { display: flex; flex-direction: column; max-width: 85%; }
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.msg.user .msg-bubble {
  background: var(--teal);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.assistant .msg-bubble {
  background: var(--surface-2);
  color: var(--fg);
  border-bottom-left-radius: 4px;
}

.msg-time {
  font-family: var(--font-body);
  font-size: 10px;
  color: var(--fg-subtle);
  margin-top: 3px;
}
.msg.user .msg-time { text-align: right; }

/* Typing indicator */
.msg.typing .msg-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 16px;
}
.msg.typing .msg-bubble::before,
.msg.typing .msg-bubble::after,
.msg.typing .msg-bubble span {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-subtle);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.msg.typing .msg-bubble span { animation-delay: 0.2s; }
.msg.typing .msg-bubble::after { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input area */
#chat-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--surface-2);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
#chat-input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--fg);
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.15s;
  outline: none;
}
#chat-input:focus { border-color: var(--teal); }
#chat-input::placeholder { color: var(--fg-subtle); }
#chat-send {
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
#chat-send:hover { background: var(--teal-light); }
#chat-send:disabled { background: var(--surface-2); color: var(--fg-subtle); cursor: not-allowed; }

/* Welcome message */
#chat-welcome {
  padding: 12px 20px 4px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--fg-muted);
  text-align: center;
}