* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #1f1f1f;
  margin: 0;
  padding: 20px;
}

.container {
  display: flex;
  width: 100%;
  max-width: 800px;
  height: 600px;
  background-color: #333436;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  position: relative;
}

.friends-sidebar {
  width: 280px;
  background-color: #2a2b2c;
  border-right: 1px solid #424548;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease-in-out;
  position: relative;
  z-index: 2;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

.friends-header {
  padding: 15px;
  background-color: #424548;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #525456;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #90c4f9;
}

.friends-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.close-sidebar {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 5px 10px;
  transition: color 0.3s ease;
}

.close-sidebar::after {
  content: '✕';
  display: inline-block;
}

.close-sidebar:hover {
  color: #ff6b6b;
}

.search-bar {
  padding: 10px 15px;
  background-color: #2a2b2c;
  position: relative;
}

.search-bar .search-icon {
  position: absolute;
  left: 25px;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  font-size: 16px;
}

.search-bar input {
  width: 100%;
  padding: 10px 10px 10px 35px;
  border: none;
  border-radius: 20px;
  background-color: #333436;
  color: white;
  outline: none;
  box-sizing: border-box;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.search-bar input::placeholder {
  color: #888;
  opacity: 0.7;
}

.search-bar input:focus {
  background-color: #3a3c3e;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.1);
}

.friends-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 10px;
}

.friend {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid #424548;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  position: relative;
}

.friend:hover {
  background-color: #3a3c3e;
  transform: translateX(5px);
}

.friend.active {
  background-color: #3a3c3e;
  position: relative;
}

.friend.active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: #90c4f9;
}

.friend img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 12px;
}

.friend-info {
  flex: 1;
  min-width: 0;
}

.friend-name {
  font-weight: bold;
  color: white;
  margin-bottom: 3px;
}

.friend.active .friend-name {
  color: #90c4f9;
}

.last-message {
  font-size: 12px;
  color: #a0a0a0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-time {
  font-size: 11px;
  color: #888;
  margin-left: 10px;
}

.unread-badge {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background-color: #00ff00;
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
}

.no-friends {
  padding: 15px;
  color: #a0a0a0;
  text-align: center;
}

.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #1d1b1b;
}

.chat-header {
  background-color: #333436;
  color: white;
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #424548;
  gap: 10px;
}

.mobile-menu-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
  display: none;
  z-index: 3;
  line-height: 1;
}

.current-friend {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.current-friend img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: 10px;
}

.friend-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
}

.message {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}

.message.sent {
  align-items: flex-end;
}

.message.received {
  align-items: flex-start;
}

.message-text {
  max-width: 70%;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
}

.message.sent .message-text {
  background-color: #90c4f9;
  color: rgb(37, 38, 39);
}

.message.received .message-text {
  background-color: #e4e6eb;
  color: black;
}

.message-time {
  font-size: 12px;
  color: #666;
  margin-top: 5px;
}

.chat-input {
  display: flex;
  padding: 10px;
  background-color: #1d1b1b;
  border-top: 1px solid #333436;
}

.chat-input textarea {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 5px;
  outline: none;
  font-size: 14px;
  background-color: #252627;
  color: white;
  resize: none;
  min-height: 40px;
  max-height: 200px;
  overflow-y: hidden;
  line-height: 1.4;
  transition: height 0.2s ease;
}

.chat-input button {
  padding: 12px 20px;
  margin-left: 10px;
  background-color: #252627;
  color: rgb(249, 250, 250);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
}

.chat-input button:hover {
  background-color: #333436;
}


.logout-button {
  padding: 8px 16px;
  background-color: #ff6b6b;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

.logout-button:hover {
  background-color: #ff4c4c;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 5px 15px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.typing-indicator.visible {
  opacity: 1;
}

.dot {
  width: 8px;
  height: 8px;
  background-color: #888;
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.dot:nth-child(2) {
  animation-delay: 0.2s;
}

.dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-5px);
  }
  60% {
    transform: translateY(-3px);
  }
}


/* Mobile Styles */
@media (max-width: 768px) {
  body {
    padding: 0;
  }

  .container {
    border-radius: 0;
    position: relative;
    height: 100vh;
    margin: 0;
  }

  .friends-sidebar {
    position: fixed;
    width: 280px;
    height: 100%;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 2;
  }

  .friends-sidebar.visible {
    transform: translateX(0);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }

  .mobile-menu-toggle {
    display: block;
  }

  .chat-section {
    width: 100%;
    height: 100%;
  }

  .friend img {
    width: 35px;
    height: 35px;
  }

  .message-text {
    max-width: 80%;
    padding: 8px 15px;
  }

  .chat-input {
    padding: 8px;
  }

  .container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1;
  }

  .friends-sidebar.visible ~ .container::before {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 769px) {
  .mobile-menu-toggle {
    display: none !important;
  }

  .friends-sidebar {
    transform: none !important;
  }
}

/* Toggler Icon */
.mobile-menu-toggle::after {
  content: '☰';
  display: inline-block;
}

.friends-sidebar.visible ~ .chat-section .mobile-menu-toggle::after {
  content: '✕';
}