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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background: linear-gradient(135deg, #6e8efb, #a777e3);
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 1000px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  height: 95vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: #4a6ee0;
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
}

.status {
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
}

.chat-container {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.users-sidebar {
  width: 200px;
  background: #f5f7fb;
  border-right: 1px solid #e1e5eb;
  padding: 15px;
  overflow-y: auto;
  flex-shrink: 0;
}

.users-sidebar h3,
.users-sidebar-title {
  margin-bottom: 15px;
  font-size: 16px;
  color: #4a5568;
}

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

.user-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #edf2f7;
}

.user-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 10px;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: white;
}

.message {
  margin-bottom: 15px;
  padding: 12px 15px;
  border-radius: 8px;
  max-width: 80%;
  animation: telegramFadeIn 0.2s ease-out;
}

.message.user {
  background: #ebf8ff;
  margin-left: auto;
  border-bottom-right-radius: 2px;
}

.message.other {
  background: #f7fafc;
  border-bottom-left-radius: 2px;
}

.message.system {
  background: #fed7d7;
  margin: 0 auto 15px;
  text-align: center;
  max-width: 90%;
}

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

.message-text {
  word-wrap: break-word;
  line-height: 1.5;
}

.message-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

.message.other .message-time {
  text-align: left;
  color: #999;
}

.input-area {
  display: flex;
  padding: 15px;
  background: #f5f7fb;
  border-top: 1px solid #e1e5eb;
  flex-shrink: 0;
}

#messageInput {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

#messageInput:focus {
  border-color: #4a6ee0;
}

#sendButton {
  margin-left: 10px;
  padding: 12px 20px;
  background: #4a6ee0;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
  flex-shrink: 0;
}

#sendButton:hover {
  background: #3b5bca;
}

#sendButton:disabled {
  background: #a0aec0;
  cursor: not-allowed;
}

/* .connection-status {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
} */

/* .connection-status.connected {
  background: #48bb78;
  color: white;
}

.connection-status.disconnected {
  background: #f56565;
  color: white;
} */

/* Анимации */
@keyframes telegramFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes telegramPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.connected {
  animation: telegramPulse 2s ease-in-out infinite;
}

/* Эффекты при наведении */
.message {
  transition: transform 0.15s ease;
}

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

/* Стиль скроллбара */
.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb {
  background: #c5cbd8;
  border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: #a8b0c0;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
  body {
    padding: 10px;
    background: #6e8efb;
  }
  
  .container {
    height: calc(100vh - 20px);
    border-radius: 0;
    max-width: none;
    box-shadow: none;
  }
  
  .chat-container {
    flex-direction: column;
    height: 100%;
  }
  
  .users-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e1e5eb;
    order: 2;
    max-height: 120px;
    padding: 12px;
    overflow-x: auto;
    flex-shrink: 0;
  }
  
  .users-sidebar h3 {
    font-size: 14px;
    margin-bottom: 10px;
  }
  
  .user-list {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 5px;
  }
  
  .user-item {
    flex: 0 0 auto;
    margin-bottom: 0;
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 6px;
    background: white;
    border: 1px solid #e1e5eb;
    white-space: nowrap;
  }
  
  .user-color {
    width: 10px;
    height: 10px;
    margin-right: 8px;
  }
  
  .chat-main {
    order: 1;
    flex: 1;
    min-height: 0;
  }
  
  .header {
    padding: 15px;
    flex-shrink: 0;
  }
  
  .header h1 {
    font-size: 1.3em;
  }
  
  .status {
    font-size: 12px;
    padding: 4px 8px;
  }
  
  .messages {
    padding: 15px;
    flex: 1;
    min-height: 0;
  }
  
  .message {
    max-width: 85%;
    padding: 10px 14px;
    margin-bottom: 10px;
    font-size: 14px;
  }
  
  .input-area {
    padding: 12px;
    gap: 8px;
    flex-shrink: 0;
  }
  
  #messageInput {
    padding: 12px 14px;
    font-size: 16px;
  }
  
  #sendButton {
    padding: 12px 16px;
    font-size: 14px;
    margin-left: 8px;
  }
  
  /* .connection-status {
    top: 15px;
    right: 15px;
    bottom: auto;
    padding: 8px 12px;
    font-size: 12px;
  } */
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg, #1e2a38 0%, #2a3b4d 100%);
    color: #ffffff;
  }
  
  .container {
    background: #1e2a38;
    box-shadow: 
      0 2px 10px rgba(0, 0, 0, 0.3),
      0 0 0 1px rgba(255, 255, 255, 0.1);
  }
  
  .messages {
    background: #1e2a38;
    background-image: 
      radial-gradient(circle at 15% 50%, rgba(50, 100, 150, 0.1) 0px, transparent 50%),
      radial-gradient(circle at 85% 30%, rgba(40, 90, 140, 0.08) 0px, transparent 50%);
  }
  
  .message.other {
    background: #2a3b4d;
    color: #ffffff;
    border: 1px solid #3a4b5d;
  }
  
  .message.user {
    background: #2a3b4d;
    color: #ffffff;
    border: 1px solid #3a4b5d;
  }
  
  #messageInput {
    background: #2a3b4d;
    color: #ffffff;
    border-color: #3a4b5d;
  }
  
  #messageInput::placeholder {
    color: #a8b0c0;
  }
  
  .users-sidebar {
    background: #1e2a38;
    border-color: #3a4b5d;
  }
  
  .user-item {
    background: #2a3b4d;
    border-color: #3a4b5d;
    color: #ffffff;
  }
  
  .input-area {
    background: #1e2a38;
    border-color: #3a4b5d;
  }
  
  @media (max-width: 768px) {
    body {
      background: #1e2a38;
    }
    
    .user-item {
      background: #2a3b4d;
    }
  }
}

@media (max-width: 320px) {
  #messageInput {
    padding: 12px 8px;
    font-size: 16px;
  }

  #sendButton {
    padding: 12px 6px;
    font-size: 14px;
    margin-left: 0;
  }
}

/* Плавные переходы */
* {
  transition: 
    background-color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

/* Улучшенная типографика */
.message-text {
  line-height: 1.5;
  letter-spacing: -0.1px;
}

/* Стиль времени сообщения */
.message-time {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}