html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  overflow: hidden;
  background-color: #f5f6f7;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Navbar */
.navbar {
  height: 56px;
  flex-shrink: 0;
  position: relative;
  z-index: 1030;
}

.navbar-brand {
  font-weight: 600;
  font-size: 1.1rem;
}

#toggleSidebarBtn {
  border: none;
  padding: 0.25rem 0.5rem;
}

#toggleSidebarBtn:focus {
  box-shadow: none;
}

/* Main Container */
.main-container {
  padding: 0;
  height: calc(100vh - 56px);
  position: relative;
}

.main-container .row {
  height: 100%;
  margin: 0;
}

/* Sidebar */
.sidebar {
  height: 100%;
  overflow-y: auto;
  border-right: 1px solid #dee2e6;
  background-color: #ffffff;
  position: relative;
  z-index: 1020;
}

.sidebar-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #f8f9fa;
}

.sidebar .list-group {
  border-radius: 0;
}

.sidebar .list-group-item {
  cursor: pointer;
  font-size: 0.95rem;
  color: #000;
  border-left: 4px solid transparent;
  border-right: none;
  border-top: none;
  transition: all 0.2s ease;
}

.sidebar .list-group-item:hover {
  background-color: #f1f3f5;
}

.sidebar .list-group-item.active {
  background-color: #ebebeb;
  color: #000;
  font-weight: 600;
  border-left-color: #25d366;
  z-index: 1;
}

/* Sidebar overlay para mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 56px;
  left: 0;
  width: 100%;
  height: calc(100vh - 56px);
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1010;
}

/* Chat Container */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Chat Header */
.chat-header {
  min-height: 60px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.chat-header h6 {
  font-weight: 600;
  color: #111;
  font-size: 1rem;
}

#closeConversationBtn {
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#closeConversationBtn:hover {
  background-color: #e9ecef;
}

/* Chat Messages Area */
.chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  background-color: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d9d9d9' fill-opacity='0.08'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Messages */
.msg {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  max-width: 65%;
  word-wrap: break-word;
  font-size: 0.9rem;
  line-height: 1.4;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.msg.in {
  align-self: flex-start;
  background-color: #ffffff;
  border-bottom-left-radius: 0;
}

.msg.out {
  align-self: flex-end;
  background-color: #dcf8c6;
  border-bottom-right-radius: 0;
}

/* Message Meta (timestamp + status) */
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

/* Message timestamp */
.msg-time {
  font-size: 0.7rem;
  color: #667781;
}

/* Message Status Icons */
.msg-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  color: #667781;
}

.msg-status.sent {
  color: #8696a0;
}

.msg-status.delivered {
  color: #8696a0;
}

.msg-status.read {
  color: #53bdeb;
}

.msg-status.failed {
  color: #df3333;
}

/* Media Elements */
.msg img {
  max-width: 280px;
  width: 100%;
  height: auto;
  border-radius: 0.5rem;
  display: block;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-bottom: 0.5rem;
}

.msg img:hover {
  opacity: 0.9;
}

.msg audio {
  max-width: 280px;
  width: 100%;
  height: 40px;
  margin-bottom: 0.5rem;
}

.msg video {
  max-width: 280px;
  width: 100%;
  border-radius: 0.5rem;
}

/* Caption */
.media-caption {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #111;
}

/* Audio Transcription */
.audio-transcription {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background-color: rgba(0,0,0,0.05);
  border-radius: 0.25rem;
  font-size: 0.85rem;
  font-style: italic;
  color: #667781;
}

.audio-transcription i {
  margin-right: 0.25rem;
}

/* Document & Location Links */
.msg a {
  color: #025c83;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.msg a:hover {
  text-decoration: underline;
}

.document-link,
.location-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #025c83;
  text-decoration: none;
  font-weight: 500;
}

.document-link:hover,
.location-link:hover {
  text-decoration: underline;
  color: #014661;
}

/* Reply messages (buttons & lists) */
.reply-message {
  font-style: italic;
  background-color: rgba(0,0,0,0.05);
  padding: 0.5rem;
  border-radius: 0.25rem;
  border-left: 3px solid #25d366;
}

.reply-message i {
  margin-right: 0.5rem;
}

/* Reaction messages */
.msg .d-flex.align-items-center.gap-2 {
  align-items: center;
}
/* Reaction container */
.reaction-container {
  display: flex;
  flex-direction: column;
}

.reaction-reference {
  font-size: 0.75rem;
  color: #8696a0;
  padding: 0.5rem;
  background-color: rgba(0,0,0,0.05);
  border-radius: 0.25rem;
  border-left: 3px solid #25d366;
  transition: background-color 0.2s;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reaction-reference:hover {
  background-color: rgba(0,0,0,0.1);
}

.reaction-reference i {
  margin-right: 0.25rem;
}
/* Chat Input Area */
.chat-input {
  min-height: 70px;
  flex-shrink: 0;
  box-shadow: 0 -1px 2px rgba(0,0,0,0.05);
  background-color: white;
  display: none; 
}

.chat-input form {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-input input {
  flex: 1;
  border-radius: 2rem;
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  font-size: 0.95rem;
}

.chat-input input:focus {
  border-color: #25d366;
  box-shadow: 0 0 0 0.2rem rgba(37, 211, 102, 0.25);
  outline: none;
}

.chat-input button {
  border-radius: 50%;
  width: 45px;
  height: 45px;
  padding: 0;
  background-color: #25d366;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.2s;
}

.chat-input button:hover:not(:disabled) {
  background-color: #20bd5a;
}

.chat-input button:active:not(:disabled) {
  background-color: #1da851;
  transform: scale(0.95);
}

.chat-input button i {
  font-size: 1.1rem;
  color: white;
}

/* Empty states */
.chat .text-muted {
  font-size: 0.95rem;
  align-self: center;
}

/* Scrollbar styling */
.chat::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.chat::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.chat::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}

.chat::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.3);
}

/* Loading spinner */
.spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.15em;
}

/* Modal image */
#modalImage {
  max-height: 80vh;
  max-width: 100%;
  object-fit: contain;
}

/* Responsive - Mobile */
@media (max-width: 767.98px) {
  .sidebar {
    position: fixed;
    top: 56px;
    left: -100%;
    width: 80%;
    max-width: 300px;
    height: calc(100vh - 56px);
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }

  .sidebar.show {
    left: 0;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .chat-container {
    width: 100%;
  }

  .msg {
    max-width: 80%;
  }

  .msg img,
  .msg audio {
    max-width: 220px;
  }

  .chat-input {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
  }
}