/* =============================================
   CHAT SYSTEM STYLES
   ============================================= */

/* Chat Avatar Styles */
.chat-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-avatar-placeholder,
.chat-avatar-placeholder-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
  border-radius: 50%;
}

.chat-avatar-placeholder {
  width: 50px;
  height: 50px;
  font-size: 18px;
}

.chat-avatar-placeholder-small {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

/* Online Indicator */
.online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background-color: #28a745;
  border: 2px solid white;
  border-radius: 50%;
}

/* Conversation List Styles */
.conversation-item {
  padding: 15px;
  transition: background-color 0.2s;
  border-left: 3px solid transparent;
}

.conversation-item:hover {
  background-color: #f8f9fa;
}

.conversation-item.unread {
  background-color: #e7f3ff;
  border-left-color: #0d6efd;
  font-weight: 600;
}

.conversation-item.unread:hover {
  background-color: #d0e7ff;
}

/* Chat Container */
.chat-container {
  height: calc(100vh - 200px);
  display: flex;
  flex-direction: column;
}

.chat-container .card-header {
  flex-shrink: 0;
  padding: 15px 20px;
}

.chat-container .card-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.chat-container .card-footer {
  flex-shrink: 0;
  padding: 15px 20px;
}

/* Messages Area */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 15px;
  background-color: #f8f9fa;
  background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
    linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Message Wrapper */
.message-wrapper {
  display: flex;
  gap: 10px;
  max-width: 70%;
  animation: messageSlideIn 0.3s ease-out;
}

.message-wrapper.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-wrapper.received {
  align-self: flex-start;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Message Bubble */
.message-bubble {
  padding: 10px 15px;
  border-radius: 18px;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-wrapper.sent .message-bubble {
  border-bottom-right-radius: 4px;
}

.message-wrapper.received .message-bubble {
  border-bottom-left-radius: 4px;
}

.message-content {
  margin-bottom: 5px;
}

.message-time {
  font-size: 0.75rem;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: flex-end;
}

/* Message Attachments */
.message-attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attachment-image img {
  max-width: 300px;
  max-height: 300px;
  border-radius: 8px;
  cursor: pointer;
}

.attachment-file {
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  display: inline-block;
}

.attachment-file a {
  color: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Message Input Area */
#messageInput {
  resize: none;
  border-radius: 20px;
  padding: 10px 15px;
}

#messageInput:focus {
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

/* Typing Indicator */
#typingIndicator {
  color: #6c757d;
  font-style: italic;
}

/* Chat Bubble Popup (Facebook Messenger Style) */
.chat-bubble-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 1000;
}

.chat-bubble-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chat-bubble-toggle .badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.chat-bubble-popup {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 380px;
  height: 500px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 1000;
  animation: chatPopupSlideIn 0.3s ease-out;
}

.chat-bubble-popup.show {
  display: flex;
}

@keyframes chatPopupSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-bubble-header {
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-bubble-body {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
}

.chat-bubble-footer {
  padding: 15px;
  border-top: 1px solid #dee2e6;
}

/* Online Users Counter */
.online-users-counter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
/*  background-color: #e7f3ff;*/
  border-radius: 20px;
  font-size: 0.875rem;
  color: #0d6efd;
}

.online-users-counter i {
  color: #28a745;
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-container {
    height: calc(100vh - 150px);
  }

  .message-wrapper {
    max-width: 85%;
  }

  .chat-bubble-popup {
    width: calc(100vw - 40px);
    height: calc(100vh - 120px);
    right: 20px;
    bottom: 90px;
  }

  .attachment-image img {
    max-width: 200px;
    max-height: 200px;
  }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar,
.chat-bubble-body::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.chat-bubble-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb,
.chat-bubble-body::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.chat-bubble-body::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Loading Spinner */
.chat-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* Empty State */
.chat-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #6c757d;
}

.chat-empty-state i {
  font-size: 4rem;
  margin-bottom: 20px;
  opacity: 0.5;
}

/* Search Results */
#searchResults {
  max-height: 400px;
  overflow-y: auto;
}

#searchResults .list-group-item {
  border-left: none;
  border-right: none;
  border-top: none;
}

#searchResults .list-group-item:first-child {
  border-top: 1px solid #dee2e6;
}

#searchResults .list-group-item:hover {
  background-color: #f8f9fa;
}

#searchResults .online-indicator {
  bottom: 0;
  right: 0;
}

/* Attachment Preview */
#attachmentPreview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-preview-item {
  position: relative;
}

.attachment-preview-item img {
  border: 2px solid #dee2e6;
}

.attachment-preview-item:hover img {
  border-color: #0d6efd;
}

.attachment-preview-item .btn-danger {
  opacity: 0.9;
}

.attachment-preview-item .btn-danger:hover {
  opacity: 1;
}
