/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s, transform 0.1s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background-color: #007bff;
  color: white;
}

.btn-primary:hover {
  background-color: #0056b3;
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background-color: #545b62;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

/* Auth pages */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  margin-bottom: 24px;
  text-align: center;
  color: #333;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #555;
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #007bff;
}

.auth-card .btn {
  width: 100%;
  margin-top: 10px;
}

.auth-link {
  margin-top: 20px;
  text-align: center;
  color: #666;
}

.auth-link a {
  color: #007bff;
  text-decoration: none;
}

.auth-link a:hover {
  text-decoration: underline;
}

.error-message {
  background-color: #f8d7da;
  color: #721c24;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 20px;
  text-align: center;
}

/* App layout */
.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
}

.app-header h1 {
  font-size: 24px;
  color: #333;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #666;
}

/* Users list */
.main-content h2 {
  margin-bottom: 20px;
  color: #333;
}

.users-list {
  list-style: none;
}

.user-item {
  background: white;
  border-radius: 10px;
  margin-bottom: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.user-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.user-link {
  display: flex;
  align-items: center;
  padding: 16px;
  text-decoration: none;
  color: inherit;
}

.user-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007bff, #00c6ff);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  margin-right: 16px;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  color: #333;
}

.user-email {
  font-size: 13px;
  color: #888;
}

.no-users {
  text-align: center;
  color: #888;
  padding: 40px;
  background: white;
  border-radius: 10px;
}

/* Chat page */
.chat-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  background: white;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: white;
  border-bottom: 1px solid #eee;
}

.back-link {
  text-decoration: none;
  color: #007bff;
  font-weight: 500;
}

.back-link:hover {
  text-decoration: underline;
}

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

.chat-user-info .user-avatar {
  width: 40px;
  height: 40px;
  font-size: 16px;
  margin-right: 0;
}

.chat-user-name {
  font-weight: 600;
  color: #333;
}

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f5f5f5;
}

.loading,
.no-messages,
.error {
  text-align: center;
  color: #888;
  padding: 40px;
}

.error {
  color: #dc3545;
}

.message {
  max-width: 70%;
  margin-bottom: 16px;
  position: relative;
}

.message-sent {
  margin-left: auto;
}

.message-received {
  margin-right: auto;
}

.message-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 12px;
  color: #888;
}

.message-sender {
  font-weight: 500;
}

.message-content {
  padding: 12px 16px;
  border-radius: 16px;
  word-wrap: break-word;
}

.message-sent .message-content {
  background: linear-gradient(135deg, #007bff, #0056b3);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-received .message-content {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.delete-btn {
  position: absolute;
  right: -30px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #dc3545;
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.message:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  color: #a71d2a;
}

/* Chat input */
.chat-input-container {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid #eee;
}

.message-form {
  display: flex;
  gap: 12px;
}

.message-form input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.message-form input:focus {
  border-color: #007bff;
}

.message-form .btn {
  border-radius: 24px;
  padding: 12px 24px;
}

/* Optimistic update states */
.message-pending .message-content {
  opacity: 0.7;
}

.message-pending .delete-btn {
  display: none;
}

.message-error .message-content {
  background: linear-gradient(135deg, #dc3545, #a71d2a);
}

.error-indicator {
  font-size: 12px;
  opacity: 0.8;
}

/* Responsive */
@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .message {
    max-width: 85%;
  }

  .delete-btn {
    right: 5px;
    top: 5px;
    transform: none;
    opacity: 1;
  }
}
