/* Reset & Base */
:root {
  --primary: #0070f3;
  --text-dark: #1f2937;
  --text-light: #ffffff;
  --bg-light: #f9fbfe;
  --shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --transition: 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: #f9f9f9;
  color: #333;
  line-height: 1.6;
}

/* Layout */
.messages-page {
  display: flex;
  max-width: 95%;
  margin: 20px auto;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
  background: white;
  overflow: hidden;
}

.sidebar {
  width: 30%;
  border-right: 1px solid #ddd;
  padding: 20px;
  background: #f9fafb;
}

.sidebar h3 {
  margin-bottom: 10px;
}


.filters {
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap; /* 🧵 Wrap buttons instead of overflowing */
  max-width: 100%;  /* 🚫 Prevents overflow */
}

.filters .filter {
  flex: 1 1 auto; /* 📏 Allow buttons to shrink/grow */
  text-align: center;
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  transition: 0.3s;
}

.filters .filter.active {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
}



.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.chat-preview {
  padding: 10px;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: 0.2s ease;
  border: 1px solid #eee;
}

.chat-preview:hover {
  background: #f0f8ff;
}

.chat-preview.unread {
  font-weight: bold;
  background-color: #eef7ff;
}

/* Chat Window */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.chat-header {
  font-weight: bold;
  margin-bottom: 10px;
  border-bottom: 1px solid #eee;
  padding-bottom: 5px;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}


.message {
  padding: 10px 15px;
  margin: 8px 12px;
  border-radius: 12px;
  max-width: 65%;
  word-wrap: break-word;
  display: inline-block;
  font-size: 14px;
  line-height: 1.4;
}

.message.sent {
  background-color: #d1fcd3;
  color: black;
  align-self: flex-end;
  border-radius: 16px 0px 16px 16px;
  margin: 6px 0;
}

.message.received {
  background-color: #f1f1f1;
  color: black;
  align-self: flex-start;
  border-radius: 0px 16px 16px 16px;
  margin: 6px 0;
}

.chat-input {
  display: flex;
  gap: 10px;
}

.chat-input input {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

.chat-input button {
  padding: 10px 18px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
}

.chat-input button:hover {
  background: #0056b3;
}

.no-chat-selected {
  color: #999;
  text-align: center;
  margin-top: 100px;
}


.messages-page {
  display: flex;
  max-width: 1200px;
  margin: 20px auto;
  height: calc(100vh - 100px); /* Fills screen height minus navbar */
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
}


.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  min-height: 200px;
}


.filters .filter {
  padding: 8px 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  transition: 0.3s;
}

.filters .filter.active {
  background-color: #007bff;
  color: white;
  font-weight: bold;
  border-color: #007bff;
}


.active-chat {
  background-color: #e6f7ff;
  font-weight: bold;
}



/* 📱 Mobile-friendly but keep side-by-side layout */
@media (max-width: 768px) {
  .messages-page {
    max-width: 100%;
    margin: 1rem;
    border-radius: 0;
    box-shadow: none;
    height: calc(100vh - 95px); /* Adjust for mobile nav height */
  }

  .sidebar {
    width: 30%;
    padding: 8px;
  }

  .filters {
    gap: 6px;
    flex-wrap: wrap;
  }

  .filters .filter {
    font-size: 0.5rem;
    padding: 5px 8px;
  }

  .chat-window {
    padding: 8px;
  }

  .chat-header {
    font-size: 14px;
  }

  .chat-list {
    max-height: 300px;
  }

  .chat-preview {
    font-size: 0.6rem;
    padding: 6px;
  }

  .message {
    font-size: 0.6rem;
    padding: 6px 10px;
    max-width: 80%;
  }

  .chat-input {
    gap: 6px;
  }

  .chat-input input {
    font-size: 0.6rem;
    padding: 8px;
  }

  .chat-input button {
    font-size: 0.6rem;
    padding: 8px 12px;
  }
}
