.chat-panel {
  position: fixed;
  top: 80px;
  right: 0;
  bottom: 0;
  width: 800px;
  max-width: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  z-index: var(--z-chat);
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition-normal);
}

.chat-layout {
  display: flex;
  height: 100%;
}

/* Conversation List */
.chat-list {
  width: 320px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: var(--bg-tertiary);
}

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

.chat-list-header h3 {
  font-size: 20px;
  margin: 0;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-color);
}

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

.conversation-item.active {
  background: var(--bg-secondary);
}

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

.conversation-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.conversation-last-message {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-xs);
}

.conversation-time {
  font-size: 12px;
  color: var(--text-muted);
}

.conversation-unread {
  background: var(--gradient-primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* Chat Window */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.chat-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-secondary);
}

.chat-user-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.chat-user-name {
  font-weight: 600;
  font-size: 16px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  background-image: 
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(102, 126, 234, 0.02) 10px,
      rgba(102, 126, 234, 0.02) 20px
    );
}

.message {
  max-width: 70%;
  padding: var(--space-sm) var(--space-md);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  animation: messageIn 0.2s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.message.sent {
  align-self: flex-end;
  background: var(--gradient-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.received {
  align-self: flex-start;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.message-media {
  max-width: 100%;
  border-radius: 8px;
  margin-top: var(--space-xs);
  cursor: pointer;
}

.message-media img,
.message-media video {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  display: block;
}

.message-audio {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-top: var(--space-xs);
}

.audio-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-waveform {
  flex: 1;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.message-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 4px;
  text-align: right;
}

.message.received .message-time {
  color: var(--text-muted);
}

/* Chat Input */
.chat-input-container {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-secondary);
}

.chat-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-primary);
  border-radius: 24px;
  padding: 0 var(--space-md);
  border: 1px solid var(--border-color);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 0;
  color: var(--text-primary);
  font-size: 14px;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.voice-btn {
  width: 36px;
  height: 36px;
}

.voice-btn.recording {
  color: #f5576c;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.send-btn {
  width: 44px;
  height: 44px;
  background: var(--gradient-primary);
  color: white;
  border-radius: 50%;
}

.send-btn:hover {
  box-shadow: var(--shadow-glow);
}

/* Mobile Chat */
@media (max-width: 768px) {
  .chat-panel {
    width: 100%;
    top: 0;
  }
  
  .chat-layout {
    position: relative;
  }
  
  .chat-list {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }
  
  .chat-window {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
  }
  
  .chat-window.active {
    transform: translateX(0);
  }
  
  .message {
    max-width: 85%;
  }
}