* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 500px;
}

.view {
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

/* 登录视图 */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 40px 30px;
  text-align: center;
}

.header h1 {
  font-size: 32px;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 14px;
  opacity: 0.9;
}

.form {
  padding: 30px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #333;
  font-size: 14px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 14px;
  transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: #667eea;
}

.form-select {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background-color: white;
  cursor: pointer;
  transition: border-color 0.3s;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23333' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  padding-right: 40px;
}

.form-select:focus {
  outline: none;
  border-color: #667eea;
}

.form-select:hover {
  border-color: #a8b4ea;
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #666;
  font-style: italic;
}

.error-msg {
  color: #e53e3e;
  font-size: 13px;
  margin-bottom: 15px;
  min-height: 20px;
  text-align: center;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.info-box {
  margin-top: 25px;
  padding: 20px;
  background: #f7fafc;
  border-radius: 10px;
  font-size: 13px;
  color: #4a5568;
}

.info-box p {
  font-weight: 600;
  margin-bottom: 10px;
}

.info-box ul {
  padding-left: 20px;
}

.info-box li {
  margin-bottom: 5px;
}

/* 房间视图 */
#room-view {
  max-width: 800px;
}

.room-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 25px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-info h2 {
  font-size: 24px;
  margin-bottom: 5px;
}

.username {
  font-size: 14px;
  opacity: 0.9;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #48bb78;
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.disconnected {
  background: #f56565;
  animation: none;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.room-content {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  padding: 20px;
  min-height: 400px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e0e0e0;
}

.panel-header h3 {
  font-size: 16px;
  color: #333;
}

.user-count {
  background: #667eea;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.users-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.user-item {
  padding: 10px 12px;
  background: #f7fafc;
  border-radius: 8px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.user-item::before {
  content: '👤';
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 350px;
  overflow-y: auto;
}

.message {
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.message.info {
  background: #bee3f8;
  color: #2c5282;
}

.message.join {
  background: #c6f6d5;
  color: #22543d;
}

.message.leave {
  background: #fed7d7;
  color: #742a2a;
}

.message .time {
  font-size: 11px;
  opacity: 0.7;
  margin-right: 8px;
}

.room-footer {
  padding: 20px 30px;
  border-top: 1px solid #e0e0e0;
  text-align: center;
}

.btn-secondary {
  padding: 12px 30px;
  background: #e53e3e;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: #c53030;
}

/* 滚动条样式 */
.message-list::-webkit-scrollbar {
  width: 6px;
}

.message-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.message-list::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 10px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .room-content {
    grid-template-columns: 1fr;
  }

  .users-panel {
    order: 2;
  }

  .messages-panel {
    order: 1;
  }
}

