body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: linear-gradient(135deg, #667eea, #764ba2);
  height: 100vh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

#authScreen {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.auth-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  width: 320px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.auth-card input {
  width: 100%;
  padding: 10px;
  margin: 6px 0;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.auth-card button {
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  border-radius: 6px;
  border: none;
  background: #667eea;
  color: white;
  cursor: pointer;
  transition: 0.3s;
}

.auth-card button:hover {
  background: #5563c1;
}

.toggle {
  margin-top: 10px;
  font-size: 14px;
  color: #667eea;
  cursor: pointer;
  text-align: center;
}

#chatApp {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

#sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  flex-shrink: 0;
  background: white;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
}

#sidebarHeader {
  padding: 15px;
  font-weight: bold;
  background: #242424;
  color: white;
}

#chatList {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  padding: 12px 15px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  transition: 0.2s;
}

.chat-item:hover {
  background: #f0f0f0;
}

#mainChat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topBar {
  padding: 15px;
  background: #333;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#logoutBtn {
  padding: 6px 14px;
  border-radius: 20px;
  border: none;
  background: #ff5252;
  color: white;
  cursor: pointer;
  transition: 0.3s;
}

#logoutBtn:hover {
  background: #e04848;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
}

.message {
  padding: 12px 16px;
  margin: 6px 0;
  border-radius: 18px;
  max-width: 60%;
  display: flex;
  flex-direction: column;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.message-text {
  margin-bottom: 8px;
}

.message-actions {
  display: flex;
  width: 100%;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin-top: 6px;
}

.message-actions button {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  transition: 0.2s ease;
}

.edit-btn {
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  color: #4caf50;
}

.edit-btn:hover {
  background: rgba(76, 175, 80, 0.08);
}

.delete-btn {
  color: #e53935;
}

.delete-btn:hover {
  background: rgba(229, 57, 53, 0.08);
}

.message button {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  margin-top: 6px;
}

.message button:first-of-type {
  background: #2196f3;
  color: white;
}

.message button:last-of-type {
  background: #f44336;
  color: white;
}

.message button:hover {
  opacity: 0.85;
}

.my-message {
  align-self: flex-end;
  background: #4caf50;
  color: white;
  border-bottom-right-radius: 4px;
}

.other-message {
  align-self: flex-start;
  background: white;
  border-bottom-left-radius: 4px;
  border: 1px solid #ddd;
}

.input-bar {
  display: flex;
  padding: 10px;
  background: white;
  border-top: 1px solid #ddd;
}

#messageInput {
  flex: 1;
  padding: 10px;
  border-radius: 20px;
  border: 1px solid #ccc;
  font-size: 14px;
}

#sendBtn {
  margin-left: 10px;
  padding: 10px 18px;
  border-radius: 20px;
  border: none;
  background: #667eea;
  color: white;
  cursor: pointer;
  transition: 0.2s ease;
  white-space: nowrap;
}

#sendBtn:hover {
  background: #5563c1;
}

#newChatBtn {
  padding: 12px;
  border: none;
  background: #6bd86f;
  color: white;
  cursor: pointer;
  transition: 0.3s;
}

#newChatBtn:hover {
  background: #43a047;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-box {
  background: white;
  padding: 20px;
  border-radius: 12px;
  width: 300px;
}

.modal-box textarea {
  width: 100%;
  height: 80px;
  margin: 10px 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#toastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
}

.toast {
  background: #333;
  color: white;
  padding: 12px 16px;
  margin-top: 10px;
  border-radius: 6px;
  animation: fadeIn 0.3s ease;
}

.success {
  background: #4caf50;
}
.error {
  background: #f44336;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
