/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    height: 100vh;
    overflow: hidden;
}

/* Username Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #2c3e50;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    color: #ecf0f1;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.modal-content p {
    color: #bdc3c7;
    margin-bottom: 1.5rem;
}

#usernameInput {
    width: 100%;
    padding: 12px;
    border: 2px solid #34495e;
    border-radius: 5px;
    background: #34495e;
    color: #ecf0f1;
    font-size: 1rem;
    margin-bottom: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

#usernameInput:focus {
    border-color: #3498db;
}

#joinButton {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

#joinButton:hover {
    background: #2980b9;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #1a1a1a;
}

/* Chat Header */
.chat-header {
    background: #2c3e50;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #34495e;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.chat-header h1 {
    color: #ecf0f1;
    font-size: 1.5rem;
    font-weight: 600;
}

.user-count {
    color: #95a5a6;
    font-size: 0.9rem;
    background: #34495e;
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #1a1a1a;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #2c3e50;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #34495e;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #4a5f7a;
}

/* Message Styles */
.message {
    margin-bottom: 0.8rem;
    padding: 0.5rem 0;
    animation: slideIn 0.3s ease-out;
}

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

.user-message {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.timestamp {
    color: #7f8c8d;
    font-size: 0.75rem;
    min-width: 60px;
    margin-top: 0.2rem;
}

.username {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 100px;
    margin-top: 0.2rem;
}

.message-text {
    color: #ecf0f1;
    flex: 1;
    word-wrap: break-word;
    line-height: 1.4;
}

.system-message {
    text-align: center;
    color: #95a5a6;
    font-style: italic;
    font-size: 0.85rem;
    padding: 0.3rem 0;
    border-top: 1px solid #34495e;
    border-bottom: 1px solid #34495e;
    margin: 0.5rem 0;
}

/* Message Input */
.message-input-container {
    background: #2c3e50;
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
    border-top: 2px solid #34495e;
}

#messageInput {
    flex: 1;
    padding: 12px;
    border: 2px solid #34495e;
    border-radius: 25px;
    background: #34495e;
    color: #ecf0f1;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

#messageInput:focus {
    border-color: #3498db;
}

#messageInput::placeholder {
    color: #7f8c8d;
}

#sendButton {
    background: #27ae60;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
    min-width: 80px;
}

#sendButton:hover {
    background: #229954;
}

#sendButton:active {
    transform: scale(0.98);
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-header {
        padding: 0.8rem;
    }
    
    .chat-header h1 {
        font-size: 1.2rem;
    }
    
    .user-count {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .chat-messages {
        padding: 0.8rem;
    }
    
    .message-input-container {
        padding: 0.8rem;
    }
    
    .user-message {
        flex-direction: column;
        gap: 0.2rem;
    }
    
    .timestamp {
        min-width: auto;
        font-size: 0.7rem;
    }
    
    .username {
        min-width: auto;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .message-input-container {
        flex-direction: column;
    }
    
    #sendButton {
        width: 100%;
        margin-top: 0.5rem;
    }
}
