/* Reset default browser styles for consistency */
body {
  font-family: Arial, sans-serif;
  background-color: #f4f4f4;
  margin: 2px;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 4px);
}

/* Welcome container */
#welcome-container {
  width: calc(100% - 4px);
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: white;
  border: 2px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

#welcome-message {
  text-align: center;
}

#welcome-message h1 {
  font-size: 2em;
  margin-bottom: 10px;
}

#welcome-message p {
  font-size: 1.2em;
  margin-bottom: 20px;
}

#login-btn {
  padding: 10px 20px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#login-btn:hover {
  background: #0056b3;
}

/* Back button styling */
#back-button {
  padding: 10px;
}

/* Back button */
#back-btn {
  padding: 8px 12px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#back-btn:hover {
  background: #5a6268;
}

/* Chat container styling */
#chat-container {
  width: calc(100% - 4px);
  height: 100%;
  background: white;
  border: 2px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

/* Messages area */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  border-bottom: 1px solid #ddd;
}

/* Individual message styling */
.message {
  margin-bottom: 10px;
  border-radius: 4px;
  max-width: 55%;
  word-wrap: break-word;
  position: relative;
}

/* Sent messages (right-aligned) */
.message-sent {
  background: #007bff;
  color: white;
  margin-left: auto;
  padding: 2px 4px;
}

/* Received messages (left-aligned) */
.message-received {
  background: #e9e9e9;
  margin-right: auto;
  padding: 8px;
}

/* Message content (left-aligned for both) */
.message-content {
  text-align: left;
}

/* Timestamp styling (like WhatsApp) */
.message-timestamp {
  display: block;
  font-size: 0.75em;
  color: #666;
  margin-top: 4px;
}

/* Read receipt styling (clickable) */
.message-read-receipt {
  display: block;
  font-size: 0.75em;
  color: #00b87c;
  margin-top: 2px;
  cursor: pointer;
  text-decoration: underline;
}

.message-read-receipt:hover {
  color: #007bff;
}

/* Reply quoted bubble */
.reply-quoted {
  background: rgba(255, 255, 255, 0.1);
  border-left: 3px solid #007bff;
  padding: 4px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  font-size: 0.9em;
}

.message-received .reply-quoted {
  background: rgba(0, 0, 0, 0.1);
  border-left: 3px solid #6c757d;
}

/* Media messages */
.message img {
  max-width: 100%;
  border-radius: 4px;
  margin-top: 5px;
}

/* Button container (edit/delete/reply) */
.message-actions {
  display: none;
  position: absolute;
  top: -30px;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 4px;
  padding: 2px 5px;
}

/* Show actions on hover */
.message:hover .message-actions {
  display: flex;
  gap: 5px;
}

/* Edit, delete, and reply buttons */
.edit-btn, .delete-btn, .reply-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 0.8em;
}

/* Message form */
#message-form {
  display: flex;
  padding: 10px;
  align-items: center;
}

#message-input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-right: 10px;
  resize: none;
  height: 1.5em;
  line-height: 1.5em;
  overflow-y: hidden;
  max-height: 7.5em;
}

#message-input:focus {
  outline: none;
  border-color: #007bff;
}

/* Show scrollbar after 5 lines */
#message-input:not(:empty) {
  height: auto;
  overflow-y: auto;
}

/* GIF button */
#gif-btn {
  margin-right: 10px;
}

/* Cancel reply button */
#cancel-reply-btn {
  margin-left: 10px;
  background: #6c757d;
  color: white;
}

/* GIF modal */
#gif-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  max-width: 80%;
  max-height: 80%;
  overflow-y: auto;
  z-index: 10;
}

/* Read receipt modal */
#read-receipt-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  max-width: 80%;
  max-height: 80%;
  overflow-y: auto;
  z-index: 10;
}

#read-receipt-list {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}

#read-receipt-list li {
  font-size: 0.9em;
  margin-bottom: 5px;
}

#close-read-receipt-modal {
  width: 100%;
  margin-top: 10px;
}

/* Enable notifications button */
#enable-notifications-btn {
  margin-left: 10px;
  background: #28a745;
  color: white;
}

#enable-notifications-btn:hover {
  background: #218838;
}

/* GIF search input */
#gif-search {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

#gif-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

#gif-results img {
  width: 100%;
  cursor: pointer;
  border-radius: 4px;
}

#close-gif-modal {
  width: 100%;
  margin-top: 10px;
}

/* Buttons */
button {
  padding: 8px 12px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background: #0056b3;
}

/* Authentication section */
#auth-section {
  padding: 10px;
  text-align: center;
}