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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Стили для авторизации */
.auth-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #333;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: #555;
}

.form-group input {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.form-group small {
    color: #666;
    font-size: 0.8rem;
}

.btn-primary {
    background: #667eea;
    color: white;
    padding: 0.75rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: #5a67d8;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

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

.auth-link a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

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

.error-message {
    background: #fee;
    color: #c33;
    padding: 0.75rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    text-align: center;
    border-left: 3px solid #c33;
}

/* Стили для чата */
.chat-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 800px;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 10px 10px 0 0;
}

.chat-header h3 {
    color: #333;
}

.user-info {
    color: #666;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logout-link {
    color: #667eea;
    text-decoration: none;
    margin-left: 0.5rem;
}

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

.connection-status {
    font-size: 0.8rem;
    transition: color 0.3s;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #fff;
}

.message {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 8px;
    border-left: 3px solid #667eea;
    animation: messageAppear 0.3s ease-out;
}

.message.own-message {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.message.own-message .message-username {
    color: #1976d2;
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.message-username {
    font-weight: 600;
    color: #667eea;
}

.message-time {
    color: #999;
}

.message-text {
    color: #333;
    word-wrap: break-word;
}

.message-form {
    padding: 1rem;
    border-top: 1px solid #eee;
    display: flex;
    gap: 0.5rem;
    background: #f8f9fa;
    border-radius: 0 0 10px 10px;
}

.message-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

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

.message-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.send-button {
    background: #667eea;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.send-button:hover:not(:disabled) {
    background: #5a67d8;
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

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

/* Индикатор набора текста */
.typing-indicator {
    display: flex;
    gap: 0.3rem;
    padding: 0.5rem;
    background: #f0f0f0;
    border-radius: 10px;
    width: fit-content;
    margin-top: 0.5rem;
}

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

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

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

@keyframes typing {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* Системные сообщения */
.system-message {
    text-align: center;
    color: #999;
    font-size: 0.9rem;
    padding: 0.5rem;
    font-style: italic;
}

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

.messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #5a67d8;
}

/* Адаптивность */
@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        border-radius: 0;
    }
    
    .auth-container {
        margin: 1rem;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .user-info {
        flex-direction: column;
        align-items: center;
        gap: 0.3rem;
    }
    
    .message-form {
        flex-direction: column;
    }
    
    .send-button {
        width: 100%;
    }
}

.logout-button {
    background: #f44336;
    color: white;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 0.5rem;
    transition: background 0.3s;
}

.logout-button:hover {
    background: #d32f2f;
}

.logout-button:active {
    transform: scale(0.98);
}

/* Обновляем существующие стили для user-info */
.user-info {
    color: #666;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .user-info {
        justify-content: center;
    }
    
    .logout-button {
        margin-left: 0;
        width: 100%;
    }
}