/* ===== Chat Panel ===== */

.chat-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 360px;
  max-width: 100vw;
  height: 420px;
  max-height: 80vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.chat-panel.open {
  transform: translateY(0);
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
}
.chat-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0 0.25rem;
}
.chat-close:hover {
  color: var(--text);
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-msg {
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 85%;
  white-space: pre-line;
}
.chat-msg.bot {
  background: var(--border);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-msg.user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Suggestion chips */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
}
.chat-suggestions:empty {
  display: none;
}
.chat-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
  white-space: nowrap;
}
.chat-chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.chat-chip.chip-accent {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Input form */
.chat-input-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.chat-input:focus {
  border-color: var(--accent);
}
.chat-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-send:hover {
  background: var(--accent-hover);
}

/* Thinking indicator */
.chat-msg.thinking {
  opacity: 0.7;
  font-style: italic;
}
.chat-msg.thinking::after {
  content: '';
  display: inline-block;
  width: 1em;
  animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
  0%  { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* Group badge */
.group-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  vertical-align: middle;
  white-space: nowrap;
}

/* Mobile: full width */
@media (max-width: 480px) {
  .chat-panel {
    width: 100vw;
    border-radius: 12px 12px 0 0;
  }
}
