.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 64px);
  border-top: 1px solid var(--border-color);
}

.chat-sidebar {
  border-right: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.chat-sidebar-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.chat-conversations {
  flex: 1;
  overflow-y: auto;
}

.chat-conversation {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.chat-conversation:hover {
  background: var(--bg-glass);
}

.chat-conversation.active {
  background: rgba(168, 85, 247, 0.08);
  border-left-color: var(--accent-purple);
}

.chat-conversation-avatar {
  position: relative;
  flex-shrink: 0;
}

.chat-conversation-avatar img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
}

.chat-conversation-avatar .online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: var(--accent-green);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

.chat-conversation-info {
  flex: 1;
  min-width: 0;
}

.chat-conversation-name {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-conversation-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-conversation-meta {
  text-align: right;
  flex-shrink: 0;
}

.chat-conversation-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.chat-conversation-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  background: var(--accent-purple);
  color: white;
  border-radius: 9px;
  font-size: 0.7rem;
  font-weight: 700;
}

.chat-main {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-info img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message {
  display: flex;
  gap: 12px;
  max-width: 70%;
  animation: fadeIn 0.3s ease-out;
}

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

.chat-message-avatar img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-message-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  position: relative;
}

.chat-message.own .chat-message-content {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.3);
}

.chat-message-text {
  font-size: 0.9375rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-message-image {
  max-width: 300px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.chat-message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-message.own .chat-message-meta {
  justify-content: flex-end;
}

.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 0.9375rem;
  resize: none;
  max-height: 120px;
  font-family: inherit;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-purple);
}

.chat-send-btn {
  padding: 12px 20px;
  background: var(--accent-purple);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: var(--accent-purple-dark);
  transform: translateY(-1px);
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.chat-empty svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  opacity: 0.3;
}

@media (max-width: 768px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
  .chat-sidebar {
    position: fixed;
    left: 0;
    top: 64px;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .chat-sidebar.open {
    transform: translateX(0);
  }
}
