* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Join Section */
.join-section {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.join-card {
  background: white;
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.join-card h1 {
  color: #333;
  margin-bottom: 30px;
  font-size: 28px;
}

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

#username-input {
  width: 100%;
  padding: 12px 15px;
  font-size: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  transition: border-color 0.3s;
}

#username-input:focus {
  outline: none;
  border-color: #667eea;
}

/* Button Styles */
.btn {
  padding: 12px 25px;
  font-size: 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary {
  background: #f44336;
  color: white;
  width: 100%;
  margin-top: 10px;
}

.btn-secondary:hover {
  background: #da190b;
  transform: translateY(-2px);
}

.btn-send {
  background: #4caf50;
  color: white;
  margin-left: 5px;
}

.btn-send:hover {
  background: #45a049;
  transform: translateY(-2px);
}

/* Chat Section */
.chat-section {
  width: 100%;
  height: 100%;
  display: flex;
}

.chat-section.hidden {
  display: none;
}

.chat-container {
  display: flex;
  width: 100%;
  height: 100%;
  background: #f5f5f5;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background: white;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #667eea;
}

.sidebar-header h2 {
  color: #333;
  font-size: 18px;
}

.user-count {
  background: #667eea;
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
}

.users-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 20px;
}

.user-item {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #f0f0f0;
  border-radius: 8px;
  color: #333;
  font-size: 14px;
  display: flex;
  align-items: center;
}

.user-item::before {
  content: "";
  width: 8px;
  height: 8px;
  background: #4caf50;
  border-radius: 50%;
  margin-right: 8px;
}

.empty-state {
  color: #999;
  font-size: 14px;
  text-align: center;
  padding: 20px 10px;
}

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

.chat-header {
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid #667eea;
}

.chat-header h2 {
  font-size: 24px;
}

.current-user {
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 14px;
}

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

.message {
  display: flex;
  margin-bottom: 10px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.own {
  justify-content: flex-end;
}

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

.message.own .message-content {
  background: #667eea;
  color: white;
}

.message.other .message-content {
  background: #e0e0e0;
  color: #333;
}

.message-username {
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 4px;
  opacity: 0.7;
}

.message.own .message-username {
  color: #667eea;
  text-align: right;
}

.message.other .message-username {
  color: #666;
}

.message-text {
  font-size: 14px;
}

.message-timestamp {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
}

.message.own .message-timestamp {
  text-align: right;
  color: white;
}

.system-message {
  text-align: center;
  padding: 10px;
  color: #999;
  font-size: 13px;
  font-style: italic;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #999;
  font-size: 12px;
}

.typing-indicator.hidden {
  display: none;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-10px);
  }
}

/* Message Input Area */
.message-input-area {
  padding: 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 10px;
}

#message-input {
  flex: 1;
  padding: 12px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 25px;
  font-size: 14px;
  transition: border-color 0.3s;
}

#message-input:focus {
  outline: none;
  border-color: #667eea;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Responsive Design */
@media (max-width: 768px) {
  .sidebar {
    width: 200px;
    padding: 15px;
  }

  .message-content {
    max-width: 90%;
  }

  .chat-header {
    padding: 15px;
  }

  .chat-header h2 {
    font-size: 18px;
  }

  .join-card {
    padding: 30px 20px;
  }
}

@media (max-width: 480px) {
  .chat-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: 150px;
    border-right: none;
    border-bottom: 1px solid #ddd;
    flex-direction: row;
    padding: 10px;
  }

  .sidebar-header {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    margin-right: 10px;
  }

  .users-list {
    flex-direction: row;
    overflow-x: auto;
    margin-bottom: 0;
    display: flex;
    gap: 5px;
  }

  .user-item {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .message-content {
    max-width: 85%;
  }

  .join-card {
    max-width: 95%;
  }
}
