#messagesPage {
  padding-top: 90px;
  overflow-y: auto;
}

.messages-page {
  padding: 20px;
  min-height: calc(100vh - 80px);
}

.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  max-width: auto;
  margin: 0 25px;
}

.chat-area {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 130px);
  min-height: 0;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #222;
  border-radius: 12px;
  color: #fff;
  overflow: hidden;
  margin-left: 55px;
}

.empty-chat {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 16px;
  padding: 50px 10px 50px 10px;
  text-align: center;
}

.empty-chat-state {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 16px;
}

.active-chat-box {
  height: 100%;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

#messagesContainer {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  min-height: 0;
}

#messagesContainer {
  scrollbar-width: thin;
  scrollbar-color: #555 transparent;
}

#messagesContainer::-webkit-scrollbar {
  width: 6px;
}

#messagesContainer::-webkit-scrollbar-track {
  background: transparent;
}

#messagesContainer::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 10px;
}

#messagesContainer::-webkit-scrollbar-thumb:hover {
  background: #777;
}

.conversation-panel,
.chat-panel {
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #222;
  border-radius: 12px;
  color: #fff;
}

.conversation-panel {
  padding-top: 14px;
  padding-bottom: 14px;
  padding-left: 10px;
  padding-right: 10px;
  width: 320px;
}

.conversation-item {
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: 10px;
  padding-right: 6px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 8px;
  background: #2a2a2ad2;
}

.conversation-item.active {
  background: #03337b;
  color: #fff;
  border-left: 4px solid #4da3ff;
}

.friend-chat-item.active {
  background: #0066ff;
  color: #fff;
  border-left: 4px solid #4da3ff;
}

.friend-chat-item.active:hover {
  background: #0066ff;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  height: 70vh;
}

.chat-header {
  position: relative;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid #222;
  font-weight: bold;
}

.messages-container {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
}

.message-row {
  display: flex;
  margin-bottom: 8px;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 70%;
  padding: 2px 12px;
  border-radius: 12px;
  background: #333;
  color: #fff;
  word-break: break-word;
}

.message-row.mine .message-bubble {
  background: #03337b;
}

.message-time {
  display: block;
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
  margin-right: -5px;
}

.message-status {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.8;
  color: #fff;
  margin-right: -5px;
}

.message-text {
  white-space: pre-wrap;
  padding-right: 55px;
  font-size: 14px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.message-input-row {
  display: flex;
  gap: 20px;
  padding: 10px;
  border-top: 1px solid #222;
}

#messageInput {
  flex: 1;
  background: #2a2a2ad2;
  color: #fff;
  border: 1px solid #444;
  border-radius: 8px;
  padding-top: 1px;
  padding-bottom: 1px;
  padding-left: 5px;
  padding-right: 5px;
  font-size: 15px;
}

#sendMessageBtn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px 6px 16px;
  cursor: pointer;
  background: #03337b;
  color: #fff;
}

.chat-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-label {
  padding-left: 4px;
}

.chat-tab-btn {
  flex: 1;
  border: none;
  padding: 8px;
  border-radius: 8px;
  background: #2a2a2ad2;
  color: #fff;
  cursor: pointer;
}

.chat-tab-btn.active {
  background: #03337b;
}

.friend-chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: 10px;
  padding-right: 10px;
  border-radius: 8px;
  background: #2a2a2ad2;
  margin-bottom: 8px;
  color: #fff;
}

.start-chat-btn {
  border: none;
  background: none;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding-right: 0px;
  padding-left: 8px;
}

.chat-back-btn {
  display: none;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.unread-badge {
  padding: 3px 7px;
  font-size: 0.6em;
  border-radius: 50%;
  background: #ff0000;
  color: #fff;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.message-row.mine .message-status {
  color: #fff;
}

.message-footer {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  margin-top: -5px;
  margin-bottom: 2px;
  font-size: 11px;
}

/* Styling for the unread count badge */
.message-icon {
  position: relative;
  /* Essential for positioning the badge */
  cursor: pointer;
  font-size: 1.5em;
  /* Adjust size as needed */
  color: #dad3d3e9;
  /* Subtle grey color */
  transition: color 0.2s ease;
  margin-right: 8px;
  padding-right: 1px;
  padding-left: 0px;
  /* A bit of space before the profile icon */
}

/* Styling for the unread count badge */
.messages-unread-badge {
  position: absolute;
  top: 8px;
  /* Position above the bell */
  right: 66px;
  /* Position to the right of the bell */
  background-color: #ff0000;
  /* Red color for alerts */
  color: white;
  border-radius: 50%;
  padding: 5px 7px;
  font-size: 0.7em;
  text-align: center;
  line-height: 1;
  pointer-events: none;
  /* Allows clicks to pass through to the bell */
}

#chatHeaderNameText {
  font-size: 15px;
  letter-spacing: 0.5px;
}

#chatHeaderStatus {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
  padding-top: 3px;
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: normal;
}

.conversation-name {
  width: 90px;
  letter-spacing: 0․5px;
  display: inline-block;
  font-size: 14px;
  font-weight: bold;
}

.conversation-status {
  /* padding-left: 10px; */
  font-size: 10px;
  letter-spacing: 1px;
  color: #b4b4b4;
}

.online-status {
  color: #00ff5e;
  font-weight: bold;
  font-weight: 500;
}

.last-seen {
  color: #b4b4b4;
  font-weight: 500;
}

#chatTypingStatus {
  margin-left: 3px;
  font-size: 11px;
  color: #9ca3af;
}

.typing-status {
  margin-left: 3px;
  font-size: 11px;
  color: #00ff5e;
}

.message-date-separator {
  width: fit-content;
  margin: 0px auto 12px auto;
  padding: 6px 100px;
  color: #ffffff;
  font-size: 12px;
  letter-spacing: 1px;
  text-align: center;
}

@media (max-width: 480px) {

  #messagesPage {
    padding: 70px 8px 0 8px;
    -webkit-overflow-scrolling: touch;
    /* smooth scroll on iOS */
    margin-inline: 0
  }

  .messages-page {
    padding: 20px;
    min-height: calc(100vh - 80px);
  }

  .chat-area {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    min-height: 0;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #222;
    border-radius: 12px;
    color: #fff;
    overflow: hidden;
    margin-left: 0px;
  }

  #messagesContainer {
    flex: 1;
    padding: 0px 6px 6px 6px;
    overflow-y: auto;
    min-height: 0;
  }

  .chat-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    max-width: 1100px;
    margin: 2px 2px 4px 2px;
  }

  .conversation-panel,
  .chat-panel {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #222;
    border-radius: 8px;
    color: #fff;
    margin-bottom: 10px;
  }

  .conversation-panel {
    padding-top: 14px;
    padding-bottom: 5px;
    padding-left: 8px;
    padding-right: 8px;
    width: unset;

  }

  .conversation-item {
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 8px;
    background: #2a2a2ad2;
    font-size: 12px;
  }

  .friend-chat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 7px;
    padding-bottom: 7px;
    padding-left: 10px;
    padding-right: 10px;
    border-radius: 8px;
    background: #2a2a2ad2;
    margin-bottom: 8px;
    color: #fff;
    font-size: 12px;
  }

  .start-chat-btn {
    border: none;
    background: none;
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
  }

  .chat-panel {
    height: 65vh;
  }

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

  .chat-layout.mobile-chat-open .conversation-panel {
    display: none;
  }

  .chat-layout.mobile-chat-open .chat-area {
    display: block;
  }

  .chat-layout:not(.mobile-chat-open) .chat-area {
    display: none;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-back-btn {
    display: flex;
    padding-top: 6px;
    padding-bottom: 0px;
    padding-left: 14px;
    padding-right: 10px;
  }

  .chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .message-icon {
    font-size: 1.1em;
    /* Smaller bell icon */
    margin-right: 2px;
    padding-right: 1px;
    padding-left: 0px;
  }

  .messages-unread-badge {
    padding: 2px 4px;
    font-size: 0.6em;
    /* Smaller text in the badge */
    text-align: center;
    top: 10px;
    right: 44px;
  }

  .unread-badge {
    padding: 2px 6px;
    background: #ff0000;
    color: #fff;
    font-size: 10px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
  }

  .message-bubble {
    position: relative;
    max-width: 75%;
    padding: 2px 8px 15px 10px;
    word-break: break-word;
  }

  .message-footer {
    position: absolute;
    right: 8px;
    bottom: 2px;
    display: flex;
    align-items: center;
    gap: 0px;
    font-size: 11px;
    opacity: 0.8;
    line-height: 1;
  }

  .message-time {
    display: block;
    font-size: 10px;
    opacity: 0.7;
    margin-top: 0px;
    margin-right: 0px;
  }

  .message-status {
    display: inline-block;
    font-size: 10px;
    opacity: 0.8;
    color: #fff;
    margin-left: 3px;
    margin-right: -2px;
  }

  .message-text {
    white-space: pre-wrap;
    padding-right: 30px;
    font-size: 14px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  }

  #messageInput {
    flex: 1;
    background: #2a2a2ad2;
    color: #fff;
    border: 1px solid #444;
    border-radius: 8px;
    padding-top: 1px;
    padding-bottom: 1px;
    padding-left: 5px;
    padding-right: 5px;
    font-size: 13px;
  }

  #sendMessageBtn {
    border: none;
    border-radius: 8px;
    padding: 4px 8px 1px 11px;
    cursor: pointer;
    background: #03337b;
    color: #fff;
  }

  #chatHeaderNameText {
    font-size: 14px;
    letter-spacing: 0.5px;
  }

  #chatHeaderStatus {
    position: unset;
    left: unset;
    transform: unset;
    padding-top: unset;
    margin-left: auto;
    font-size: 10px;
    letter-spacing: 1px;
  }

  .conversation-name {
    width: 100px;
    display: inline-block;
    font-size: 12px;
    letter-spacing: 0.5px;
  }

  .conversation-status {
    padding-right: 0px;
    letter-spacing: 1px;
  }

  #chatTypingStatus {
    margin-left: 3px;
    font-size: 10px;
    color: #9ca3af;
  }

  .typing-status {
    margin-left: 3px;
    font-size: 10px;
    color: #00ff5e;
  }
}

@media (max-width: 768px) {
  #messagesContainer {
    scrollbar-width: none;
  }

  #messagesContainer::-webkit-scrollbar {
    display: none;
  }
}