/* Chat View */
.chat-container {
  display: flex;
  height: calc(100vh - 60px);
  max-width: 100%;
  margin: -2rem -1.5rem;
}

.chat-sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  overflow-y: auto;
}

.chat-sidebar-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: white;
  font-weight: 700;
}

.chat-sidebar-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.chat-sidebar h2 {
  font-size: 1.1rem;
  text-align: center;
}

.chat-sidebar-role {
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 600;
  text-align: center;
}

.chat-topic-label {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-light);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  margin: 0.25rem 0;
}

.sidebar-topics-list {
  width: 100%;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-topics-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: 0.05em;
  padding: 0.25rem 0.5rem;
}

.sidebar-topic {
  display: block;
  text-decoration: none;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sidebar-topic:hover {
  background: var(--bg);
  color: var(--primary);
}

.sidebar-topic.active {
  background: var(--bg);
  color: var(--primary);
  font-weight: 600;
}

.chat-sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  margin-top: auto;
  padding-top: 0.75rem;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fafaf9;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  display: flex;
  gap: 0.75rem;
  max-width: 75%;
  animation: fadeIn 0.3s ease;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: white;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #93c5fd, #3b82f6);
}

.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  line-height: 1.6;
  font-size: 0.95rem;
  word-break: break-word;
}

.message.assistant .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}

.message.user .message-bubble {
  background: var(--accent);
  color: white;
  border-top-right-radius: 4px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.75rem 1rem;
  align-items: center;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--text-light);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.chat-input-area {
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input-area textarea {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 44px;
  line-height: 1.5;
  transition: var(--transition);
}

.chat-input-area textarea:focus {
  border-color: var(--accent);
}

.send-btn {
  padding: 0.65rem 1.25rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.send-btn:hover {
  background: var(--primary-dark);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
  .chat-container {
    flex-direction: column;
  }

  .chat-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
  }

  .chat-sidebar-avatar {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }

  .chat-sidebar h2 {
    font-size: 1rem;
  }

  .chat-sidebar-role,
  .sidebar-topics-list,
  .chat-sidebar-actions .btn:first-child {
    display: none;
  }

  .chat-topic-label {
    font-size: 0.75rem;
  }

  .chat-sidebar-actions {
    flex-direction: row;
    margin-top: 0;
    padding-top: 0;
  }

  .message {
    max-width: 90%;
  }
}
