/* 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: #f0f2f5;
  min-height: 100vh;
}

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

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

.auth-card h1 {
  text-align: center;
  color: #1a73e8;
  margin-bottom: 10px;
  font-size: 1.5rem;
}

.auth-card h2 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
  font-weight: 500;
}

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

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

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

.form-group input:focus {
  outline: none;
  border-color: #1a73e8;
}

.error-message {
  color: #d93025;
  font-size: 14px;
  margin-bottom: 15px;
  text-align: center;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s;
}

.btn-primary {
  width: 100%;
  background-color: #1a73e8;
  color: white;
}

.btn-primary:hover {
  background-color: #1557b0;
}

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

.auth-link a {
  color: #1a73e8;
  text-decoration: none;
}

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

/* Chat Page Layout */
.chat-container {
  display: flex;
  height: 100vh;
  background: white;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
}

.sidebar-header h2 {
  color: #333;
  font-size: 1.25rem;
}

.btn-logout {
  background: #f5f5f5;
  color: #666;
  padding: 8px 16px;
  font-size: 13px;
}

.btn-logout:hover {
  background: #e0e0e0;
}

/* Search */
.search-container {
  padding: 15px;
  position: relative;
}

.search-container input {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  font-size: 14px;
  background: #f5f5f5;
}

.search-container input:focus {
  outline: none;
  background: white;
  border-color: #1a73e8;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 15px;
  right: 15px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.search-results.active {
  display: block;
}

.search-result-item {
  padding: 12px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background-color 0.2s;
}

.search-result-item:hover {
  background-color: #f5f5f5;
}

.search-result-item .username {
  font-weight: 500;
  color: #333;
}

/* Contact List */
.contact-list {
  flex: 1;
  overflow-y: auto;
}

.contact-list .loading {
  text-align: center;
  color: #666;
  padding: 20px;
}

.contact-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s;
}

.contact-item:hover {
  background-color: #f5f5f5;
}

.contact-item.active {
  background-color: #e8f0fe;
}

.contact-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: #1a73e8;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  margin-right: 15px;
}

.contact-info {
  flex: 1;
}

.contact-name {
  font-weight: 500;
  color: #333;
  margin-bottom: 2px;
}

.contact-status {
  font-size: 12px;
  color: #888;
}

.contact-status.online {
  color: #34a853;
}

.unread-badge {
  background: #1a73e8;
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

/* Chat Main Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f8f9fa;
}

.no-chat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.no-chat-content {
  text-align: center;
  color: #666;
}

.no-chat-content h3 {
  margin-bottom: 10px;
  color: #333;
}

/* Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 15px 20px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
}

.chat-user-info {
  display: flex;
  flex-direction: column;
}

.chat-username {
  font-weight: 600;
  color: #333;
  font-size: 16px;
}

.chat-status {
  font-size: 12px;
  color: #888;
}

.chat-status.online {
  color: #34a853;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 70%;
  padding: 10px 15px;
  border-radius: 18px;
  word-wrap: break-word;
}

.message.sent {
  align-self: flex-end;
  background: #1a73e8;
  color: white;
}

.message.received {
  align-self: flex-start;
  background: white;
  color: #333;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-content {
  font-size: 14px;
  line-height: 1.4;
}

.message-time {
  font-size: 11px;
  margin-top: 5px;
  opacity: 0.7;
}

.message.sent .message-time {
  text-align: right;
}

/* Typing Indicator */
.typing-indicator {
  padding: 10px 20px;
  color: #666;
  font-size: 13px;
  font-style: italic;
}

/* Message Input */
.message-input-container {
  padding: 15px 20px;
  background: white;
  border-top: 1px solid #e0e0e0;
}

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

.message-form input {
  flex: 1;
  padding: 12px 20px;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  font-size: 14px;
}

.message-form input:focus {
  outline: none;
  border-color: #1a73e8;
}

.btn-send {
  background: #1a73e8;
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
}

.btn-send:hover {
  background: #1557b0;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: absolute;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .chat-container {
    position: relative;
  }
}
