/**
 * Chat Panel Styles
 * Agent 间消息实时显示面板
 */

/* ─── Chat Panel Container ─────────────────────────────────── */

#chatPanel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  max-height: 400px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Chat Header ──────────────────────────────────────────── */

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.chat-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 11px;
  color: var(--text3);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  transition: background 0.3s;
}

.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.chat-clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.chat-clear-btn:hover {
  opacity: 1;
}

/* ─── Chat Messages ────────────────────────────────────────── */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: var(--bg);
  max-height: 340px;
}

.chat-empty {
  text-align: center;
  color: var(--text3);
  font-size: 12px;
  padding: 30px 20px;
}

/* ─── Chat Message ─────────────────────────────────────────── */

.chat-msg {
  margin-bottom: 10px;
  padding: 10px;
  background: var(--bg2);
  border-radius: 8px;
  font-size: 12px;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.chat-msg-from,
.chat-msg-to {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
}

.chat-msg-arrow {
  color: var(--text3);
  font-size: 12px;
}

.chat-msg-arrow.blocked {
  color: var(--red);
}

.chat-msg-time {
  margin-left: auto;
  font-size: 10px;
  color: var(--text3);
  font-family: var(--mono);
}

.chat-msg-label {
  font-size: 10px;
  color: var(--text3);
  padding: 2px 6px;
  background: var(--bg3);
  border-radius: 4px;
}

.chat-msg-body {
  color: var(--text1);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg-body.blocked {
  color: var(--red);
  font-weight: 500;
}

.chat-msg-thinking-body {
  color: var(--text3);
  font-size: 11px;
  font-style: italic;
  margin-top: 4px;
  padding: 6px 8px;
  background: var(--bg3);
  border-radius: 4px;
  max-height: 100px;
  overflow-y: auto;
}

/* ─── Message Type Variations ──────────────────────────────── */

.chat-msg-intercept {
  border-left: 3px solid var(--accent);
}

.chat-msg-blocked {
  border-left: 3px solid var(--red);
  background: rgba(255, 82, 82, 0.05);
}

.chat-msg-thinking {
  border-left: 3px solid var(--yellow);
  background: rgba(255, 193, 7, 0.05);
}

.chat-msg-reply {
  border-left: 3px solid var(--blue);
}

.chat-msg-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg3);
}

.chat-msg-status-text {
  font-size: 11px;
  color: var(--text2);
}

/* ─── Scrollbar ────────────────────────────────────────────── */

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text3);
}

/* ─── Responsive ───────────────────────────────────────────── */

@media (max-width: 768px) {
  #chatPanel {
    width: calc(100% - 40px);
    left: 20px;
    right: 20px;
  }
}

/* ─── Collapsed State (optional) ───────────────────────────── */

#chatPanel.collapsed .chat-messages {
  display: none;
}

#chatPanel.collapsed {
  max-height: 48px;
}
