/* Floating chat widget — Shiftbear-inspired */
.chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 8px 24px -6px hsl(var(--primary) / 0.5), 0 2px 6px -1px rgb(0 0 0 / 0.1);
  transition: var(--transition-smooth);
}
.chat-launcher:hover { background: hsl(var(--primary-dark)); transform: translateY(-2px); }
.chat-launcher:active { transform: translateY(0); }
.chat-launcher svg { width: 18px; height: 18px; }

.chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 101;
  width: min(380px, calc(100vw - 32px));
  height: min(580px, calc(100vh - 48px));
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--border));
  border-radius: 1.25rem;
  box-shadow: 0 20px 50px -12px rgb(0 0 0 / 0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: chat-in 180ms ease-out;
}
.chat-panel[aria-hidden="false"] { display: flex; }

@keyframes chat-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--surface));
}
.chat-header .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  flex-shrink: 0;
}
.chat-header .avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-header .meta { flex: 1; min-width: 0; }
.chat-header .name { font-weight: 600; font-size: 0.95rem; margin: 0; }
.chat-header .status { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin: 0; display: flex; align-items: center; gap: 0.35rem; }
.chat-header .status::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px hsl(142 70% 45% / 0.2);
}
.chat-close {
  background: transparent;
  border: none;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 999px;
}
.chat-close:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }

.chat-body {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: hsl(var(--background));
}

.chat-msg {
  max-width: 85%;
  padding: 0.65rem 0.9rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-msg.bot {
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--border));
  align-self: flex-start;
  border-bottom-left-radius: 0.35rem;
}
.chat-msg.user {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  align-self: flex-end;
  border-bottom-right-radius: 0.35rem;
}
.chat-msg.error {
  background: hsl(0 70% 95%);
  color: hsl(0 70% 35%);
  border: 1px solid hsl(0 70% 85%);
  align-self: flex-start;
  border-bottom-left-radius: 0.35rem;
}
.chat-msg a { text-decoration: underline; }

.chat-typing {
  align-self: flex-start;
  padding: 0.65rem 0.9rem;
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  border-bottom-left-radius: 0.35rem;
  display: flex;
  gap: 0.3rem;
}
.chat-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: hsl(var(--muted-foreground));
  animation: chat-dot 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.75rem;
  background: hsl(var(--background));
}
.chat-suggestions button {
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition-smooth);
}
.chat-suggestions button:hover { background: hsl(var(--secondary)); border-color: hsl(var(--primary) / 0.4); }

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--surface));
}
.chat-form input {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-pill);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-form input:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.15);
}
.chat-form button {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}
.chat-form button:hover:not(:disabled) { background: hsl(var(--primary-dark)); }
.chat-form button:disabled { opacity: 0.5; cursor: not-allowed; }
