/* Messaging Module Styles */

.messaging-container {
  display: flex;
  height: 600px;
  max-width: 1200px;
  margin: 2rem auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  overflow: hidden;
}

/* Sidebar */

.messaging-sidebar {
  width: 350px;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}

.messaging-header {
  padding: 1rem;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f9f9f9;
}

.messaging-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
}

.conversations-list .loading,
.conversations-list .empty {
  padding: 2rem;
  text-align: center;
  color: #888;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}

.conversation-item:hover {
  background: #f9f9f9;
}

.conversation-item.unread {
  background: #f0f9ff;
}

.conversation-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.conversation-info {
  flex: 1;
  min-width: 0;
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.conversation-nickname {
  font-weight: 500;
  color: #333;
}

.conversation-time {
  font-size: 0.75rem;
  color: #888;
}

.conversation-preview {
  margin: 0;
  font-size: 0.875rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: #4CAF50;
  color: white;
  border-radius: 12px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Main conversation view */

.messaging-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.conversation-view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.no-conversation {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  font-size: 1.125rem;
}

.conversation-header {
  padding: 1rem;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #f9f9f9;
}

.conversation-header .conversation-avatar {
  width: 40px;
  height: 40px;
}

.conversation-header h3 {
  margin: 0;
  font-size: 1.125rem;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #fafafa;
}

.messages-container .loading,
.messages-container .empty,
.messages-container .error {
  text-align: center;
  padding: 2rem;
  color: #888;
}

.message {
  display: flex;
  margin-bottom: 1rem;
}

.message.mine {
  justify-content: flex-end;
}

.message.theirs {
  justify-content: flex-start;
}

.message-content {
  max-width: 70%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message.mine .message-content {
  background: #4CAF50;
  color: white;
}

.message-sender {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  opacity: 0.8;
}

.message-text {
  margin: 0;
  line-height: 1.5;
  word-wrap: break-word;
}

.message-time {
  display: block;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  opacity: 0.7;
}

/* Message input */

.message-input-container {
  padding: 1rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 0.75rem;
  background: white;
}

#message-input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
}

#message-input:focus {
  outline: none;
  border-color: #4CAF50;
}

#send-message-btn {
  padding: 0.75rem 1.5rem;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#send-message-btn:hover:not(:disabled) {
  background: #45a049;
}

#send-message-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Responsive */

@media (max-width: 768px) {
  .messaging-container {
    height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .messaging-sidebar {
    width: 100%;
    border-right: none;
  }

  .messaging-main {
    display: none;
  }

  .messaging-main.active {
    display: flex;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    background: white;
  }

  .message-content {
    max-width: 85%;
  }
}
