/* ============================================
   URBot Chat Widget — Reusable chat UI
   ============================================ */

.urbot-chat {
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 26, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.urbot-chat.compact {
  max-height: 400px;
}

/* ---- Messages area ---- */
.urbot-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  max-height: 380px;
}

.urbot-chat.compact .urbot-chat-messages {
  max-height: 280px;
  min-height: 120px;
}

/* Individual message */
.urbot-chat-msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
  animation: chatMsgIn 0.2s ease;
}

@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.urbot-chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.urbot-chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.12);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.urbot-chat-msg-avatar img {
  width: 22px;
  height: 22px;
}

.urbot-chat-msg.user .urbot-chat-msg-avatar {
  background: rgba(99, 102, 241, 0.15);
}

.urbot-chat-msg-body {
  position: relative;
}

.urbot-chat-msg-content {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #e2e8f0;
}

.urbot-chat-msg.bot .urbot-chat-msg-content {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px 12px 12px 4px;
}

.urbot-chat-msg.user .urbot-chat-msg-content {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px 12px 4px 12px;
}

/* Structured content card */
.urbot-chat-msg.bot .urbot-chat-msg-content.structured {
  border-color: rgba(139, 92, 246, 0.25);
  background: rgba(139, 92, 246, 0.06);
}

/* Copy button */
.urbot-chat-msg-copy {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #64748b;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  font-family: inherit;
}
.urbot-chat-msg-body:hover .urbot-chat-msg-copy {
  opacity: 1;
}
.urbot-chat-msg-copy:hover {
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.12);
}

/* Copy format buttons for structured responses */
.urbot-chat-msg-copy-bar {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.urbot-chat-msg-copy-bar button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.urbot-chat-msg-copy-bar button:hover {
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.3);
}

/* Disclaimer */
.urbot-chat-msg-disclaimer {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(234, 179, 8, 0.08);
  border-left: 2px solid rgba(234, 179, 8, 0.3);
  border-radius: 4px;
}

/* Timestamp */
.urbot-chat-msg-time {
  font-size: 10px;
  color: #475569;
  margin-top: 3px;
  padding: 0 4px;
}

/* ---- Typing indicator ---- */
.urbot-chat-typing {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 14px 8px;
}
.urbot-chat-typing.active { display: flex; }

.urbot-chat-typing-dots {
  display: flex;
  gap: 4px;
}
.urbot-chat-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64748b;
  animation: chatTypingBounce 1.2s infinite;
}
.urbot-chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.urbot-chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.urbot-chat-typing-label {
  font-size: 12px;
  color: #64748b;
}

/* ---- Input bar ---- */
.urbot-chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 15, 35, 0.6);
}

.urbot-chat-input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #e2e8f0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 100px;
}
.urbot-chat-input:focus {
  border-color: rgba(139, 92, 246, 0.5);
}
.urbot-chat-input::placeholder {
  color: #64748b;
}

.urbot-chat-send {
  padding: 10px 18px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.urbot-chat-send:hover { opacity: 0.88; }
.urbot-chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Source badge ---- */
.urbot-chat-source {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.urbot-chat-source.qwen {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}
.urbot-chat-source.fallback {
  background: rgba(234, 179, 8, 0.15);
  color: #fde047;
}

/* ---- Scrollbar ---- */
.urbot-chat-messages::-webkit-scrollbar { width: 4px; }
.urbot-chat-messages::-webkit-scrollbar-track { background: transparent; }
.urbot-chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
