/* Universal Messaging System Styles */

/* Main Container */   
/* Main Container */   
.ums-inbox-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 80vh;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  margin: 20px 0;
  padding-left: 20px;
  padding-right: 20px;
}

/* New global header styles */
.ums-global-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e1e4e8;
  background-color: #f8f9fa;
}

.ums-global-header-title {
  font-size: 18px;    font-weight: 400;
}

.ums-global-header-stats {
  display: flex;
  gap: 15px;
  font-size: 14px;
  color: #666;
}

.ums-stats-total {
  display: flex;
  align-items: center;
}

#ums-total-count {
  font-weight: bold;
  margin-right: 5px;
}

.ums-inbox-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Threads List */
.ums-threads-list {
  width: 40%;
  border-right: 1px solid #e1e4e8;
  display: flex;
  flex-direction: column;
  background-color: #f8f9fa;
}

.ums-threads-header {
  padding: 16px;
  border-bottom: 1px solid #e1e4e8;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ums-threads-header h2 {
  margin: 0;
  font-size: 18px;    font-weight: 400;
}

.ums-threads-search {
  padding: 12px 16px;
  border-bottom: 1px solid #e1e4e8;
}

.ums-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.ums-threads-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Filter tabs */
.ums-filter-tabs {
  display: flex;
  padding: 0 16px;
  border-bottom: 1px solid #e1e4e8;
  background-color: #f8f9fa;
}

.ums-filter-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}

/* Update the filter tab hover and focus styles */
.ums-filter-tab:hover {
  color: #fff !important;
  background-color: #2787db !important;
}

.ums-filter-tab:focus {
  color: #fff !important;
  background-color: #2787db !important;
  outline: none;
}

/* Make sure thread items are clickable */
.ums-thread-item {
  padding: 12px 16px;
  border-bottom: 1px solid #e1e4e8;
  cursor: pointer !important;
  transition: background-color 0.2s, border-left 0.3s;
  position: relative;
  z-index: 5;
  user-select: none; /* Prevent text selection */
  display: flex;
  align-items: center;
}

/* New message indicator styles */
.ums-thread-item.has-new-message {
  background-color: #e3f2fd !important;
  border-left: 4px solid #2787db;
  animation: newMessagePulse 2s ease-in-out;
}

@keyframes newMessagePulse {
  0% { background-color: #e3f2fd; }
  50% { background-color: #bbdefb; }
  100% { background-color: #e3f2fd; }
}

/* Enhanced unread indicator */
.ums-thread-item.unread {
  background-color: #f0f7ff;    font-weight: 400;
}

.ums-thread-item.unread .ums-thread-item-title {
  font-weight: 700;
}

.ums-thread-item.unread .ums-thread-item-preview {
  font-weight: 500;
}

/* Flag button in thread items */
.ums-thread-item {
  position: relative;
}

.ums-flag-btn {
  position: absolute;
  right: 12px;
  top: 12px;
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  transition: color 0.2s;
  z-index: 10;
  display: block; /* Ensure it's visible */
}

/* Update the flag button color to red when flagged */
.ums-flag-btn:hover {
  color: #e74c3c;
  background-color: transparent !important;
}

.ums-flag-btn.flagged {
  color: #e74c3c;
}

/* Change the flagged thread item background to a red tone */
.ums-thread-item.flagged {
  background-color: #ffebee;
}

.ums-thread-item:hover {
  background-color: #e6f2ff !important;
}

.ums-thread-item.active {
  background-color: #d1e6ff;
  border-left: 3px solid #2787db;
}

/* Add styles for thread item header */
.ums-thread-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.ums-thread-item-title {    font-weight: 400;
  font-size: 15px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.ums-thread-item-time {
  font-size: 12px;
  color: #666;
}

.ums-thread-item-preview {
  font-size: 13px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ums-thread-item-participants {
  display: flex;
  margin-top: 8px;
}

.ums-thread-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 12px;
  overflow: hidden;
  flex-shrink: 0;
}

.ums-thread-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ums-thread-item-content {
  flex: 1;
  overflow: hidden;
}

.ums-thread-item-unread-badge {
  background-color: #2787db;
  color: white;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  margin-left: 8px;
}

/* Thread actions */
.ums-thread-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-left: auto;
  gap: 10px; /* Add gap between buttons */
}

.ums-thread-action-btn {
  background: none;
  border: none;
  color: #777;
  cursor: pointer;
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 12px;
  margin-left: 5px;
  transition: all 0.2s;
}

.ums-thread-action-btn:hover {
  background-color: #f0f0f0;
  color: #333;
}

.ums-thread-action-btn.delete:hover {
  background-color: #ffebee;
  color: #c62828;
}

.ums-thread-action-btn.archive:hover {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.ums-thread-actions-header {
  display: flex;
}

/* Simplified thread action button - only delete now */
.ums-delete-thread-btn {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;    font-weight: 400;
  background-color: transparent;
  border: 1px solid #e74c3c;
  color: #e74c3c;
}

.ums-delete-thread-btn:hover {
  background-color: #e74c3c;
  color: white;
}

/* Messages View */
.ums-messages-view {
  flex: 1;
  width: 60%;
  display: flex;
  flex-direction: column;
  background-color: #fff;
  position: relative;
  height: 100%;
}

/* Thread View */
.ums-thread-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #fff;
/*  z-index: 10;*/
}

/* Thread Header */
.ums-thread-header {
  padding: 16px;
  border-bottom: 1px solid #e1e4e8;
  display: flex;
  align-items: center;
  background-color: #f8f9fa;
  justify-content: space-between;
}

.ums-thread-participants {
  display: flex;
  align-items: center;
  flex: 1;
}

.ums-participant-avatars {
  display: flex;
  margin-right: 12px;
}

.ums-participant-avatars img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: -10px;
  border: 2px solid #fff;
  object-fit: cover;
}

.ums-participant-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-right: -8px;
  border: 2px solid #fff;
  background-color: #ddd;
  overflow: hidden;
}

.ums-participant-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ums-thread-header .ums-participant-avatars img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: -10px;
  border: 2px solid #fff;
  object-fit: cover;
}

.ums-thread-info {
  flex: 1;
}

.ums-thread-title {
  margin: 0;
  font-size: 16px;    font-weight: 400;
}

.ums-thread-subtitle {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: #666;
}

/* Messages Container */
.ums-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background-color: #f5f8fa;
}

/* Messages */
.ums-messages-list {
  display: flex;
  flex-direction: column;
}

.ums-message {
  display: flex;
  margin-bottom: 16px;
  max-width: 75%;
}

.ums-message.incoming {
  align-self: flex-start;
}

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

.ums-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin: 0 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.ums-message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ums-message-content {
  background-color: #fff;
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ums-message.outgoing .ums-message-content {
  background-color: #e3f2fd;
}

.ums-message-sender {
  font-weight: bold;
  margin-bottom: 4px;
  font-size: 14px;
}

.ums-message-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}

.ums-message-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  text-align: right;
}

/* New message animation */
.ums-message-new {
  animation: messageSlideIn 0.5s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Message Composer */
.ums-message-composer {
  padding: 12px 16px;
  border-top: 1px solid #e1e4e8;
  background-color: #fff;
}

.ums-attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.ums-attachment-preview {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  background-color: #f1f1f1;
  border-radius: 12px;
  font-size: 12px;
}

.ums-attachment-preview-icon {
  margin-right: 6px;
  color: #666;
}

.ums-attachment-preview-remove {
  margin-left: 6px;
  cursor: pointer;
  color: #999;
}

.ums-attachment-preview-remove:hover {
  color: #f44336;
}

/* Updated composer input wrapper with inline buttons */
.ums-composer-input-wrapper {
  position: relative;
  display: flex;
  overflow: hidden;
  background-color: #fff;
  margin-bottom: 10px;
}

.ums-composer-input {
  flex: 1;
  padding: 12px 16px;
  padding-right: 80px; /* Make room for the buttons */
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  min-height: 24px;
  max-height: 120px;
}

/* Emoji and attachment buttons inside input */
.ums-composer-actions-inline {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
}

.ums-emoji-btn,
.ums-attachment-btn {
  background: none;
  border: none;
  color: #777;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  position: relative; /* Add position relative */
  z-index: 2;
}

.ums-attachment-btn {
  position: relative;
  z-index: 2;
}

/* Fix the attachment input to be contained within its button */
.ums-attachment-input {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1; /* Add z-index */
}

/* Ensure proper spacing between buttons */
.ums-emoji-btn {
  margin-right: 10px; /* Increase margin for better separation */
}

.ums-emoji-btn {
  margin-right: 10px;
  position: relative;
  z-index: 5;
  cursor: pointer;
}

.ums-emoji-btn,
.ums-attachment-btn {
  background: none;
  border: none;
  color: #777;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.ums-emoji-btn {
  margin-right: 5px;
}

.ums-emoji-btn:hover,
.ums-attachment-btn:hover {
  color: #2787db;
}

.ums-attachment-input {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: 0;
  cursor: pointer;
}

/* Updated send button as pill */
.ums-send-btn-container {
  display: flex;
  justify-content: flex-end;
}

/* Make sure the send button is blue by default */
.ums-send-btn {
  background-color: #2687db !important;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 8px 20px;
  font-weight: 400 !important;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ums-send-btn:before {
  content: "\f1d8"; /* Font Awesome send icon */
  font-family: "Font Awesome 5 Free";
  margin-right: 8px;
  font-weight: 900;
}

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

.ums-send-btn:not(:disabled):hover {
  background-color: #1a6db8 !important;
}

/* Update the emoji dropdown styles for better visibility and positioning */
.ums-emoji-dropdown {
  position: fixed;
  z-index: 10000;
  background-color: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 10px;
  width: 280px;
  display: flex;
  flex-wrap: wrap;
  max-height: 200px;
  overflow-y: auto;
  /* Ensure it doesn't go off-screen */
  max-width: 90vw;
}

.ums-emoji-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 20px;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.ums-emoji-item:hover {
  background-color: #f0f0f0;
}

/* Empty State */
.ums-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #666;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1; /* Much lower z-index than thread view */
  margin: auto;
  text-align: center;
}

.ums-empty-icon {
  font-size: 48px;
  color: #ddd;
  margin-bottom: 16px;
}

.ums-empty-state h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
}

.ums-empty-state p {
  margin: 0;
  text-align: center;
  max-width: 300px;
}

/* Loading Indicator */
.ums-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  color: #666;
}

.ums-spinner {
  border: 2px solid #f3f3f3;
  border-top: 2px solid #2787db;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  animation: ums-spin 1s linear infinite;
  margin-bottom: 4px;
}

@keyframes ums-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Error Message */
.ums-error {
  padding: 12px;
  background-color: #fef1f1;
  border: 1px solid #fde2e2;
  border-radius: 4px;
  color: #f56c6c;
  margin: 8px 0;
  font-size: 14px;
  text-align: center;
}

/* Login Required */
.ums-login-required {
  padding: 20px;
  text-align: center;
  background-color: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

.ums-login-required p {
  margin-bottom: 15px;
  font-size: 16px;
  color: #555;
}

/* Empty filter message */
.ums-empty-filter-message {
  padding: 20px;
  text-align: center;
  color: #666;
  font-style: italic;
}

/* Ensure the emoji picker is visible on mobile */
@media (max-width: 768px) {
  .ums-inbox-wrapper {
    flex-direction: column;
  }

  .ums-threads-list {
    width: 100%;
    height: 50%;
    border-right: none;
    border-bottom: 1px solid #e1e4e8;
  }

  .ums-messages-view {
    height: 50%;
  }

  .ums-message {
    max-width: 85%;
  }

  #ums-modal-content {
    width: 95%;
  }

  .ums-emoji-dropdown {
    width: 240px;
    left: 50% !important;
    transform: translateX(-50%);
    bottom: 60px;
    top: auto !important;
  }

  .ums-thread-actions {
    flex-direction: column;
    align-items: flex-end;
  }

  .ums-delete-thread-btn {
    font-size: 12px;
    padding: 4px 8px;
  }
}

/* Add styles for archive button in thread list */
.ums-archive-btn {
  position: absolute;
  right: 40px;
  top: 12px;
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  transition: color 0.2s;
  z-index: 10;
  display: block;
}

.ums-archive-btn:hover {
  color: #4caf50;
  background-color: transparent !important;
}

.ums-archive-btn.archived {
  color: #4caf50;
}

/* Change the archived thread item background to a green tone */
.ums-thread-item.archived {
  background-color: #e8f5e9;
}

/* Add styles for thread item date */
.ums-thread-item-date {
  font-size: 12px;
  color: #777;
  position: absolute;
  bottom: 12px;
  right: 16px;
  white-space: nowrap;
}


/* Thread update animation */
.ums-thread-updated {
  animation: threadUpdate 2s ease-in-out;
}

@keyframes threadUpdate {
  0% { background-color: #fff3cd; }
  50% { background-color: #ffeaa7; }
  100% { background-color: inherit; }
}


/* === Mobile fix: make chat pane full-width === */
@media (max-width: 768px) {
  .ums-messages-view {
    width: 100% !important;  /* override default 60% */
  }
	
	.ums-inbox-container{
		padding:0px !important;
		margin:0px !important;
	}	
	
}
