/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-content h1 {
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff6b6b;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: #51cf66;
    animation: none;
}

.status-dot.connecting {
    background: #ffd43b;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.username-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.username-section label {
    font-size: 14px;
    font-weight: 500;
}

/* Chat Room Section */
.chat-room-section {
    background: #f8f9fa;
    padding: 15px 30px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.room-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 300px;
}

.room-selector label {
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    white-space: nowrap;
}

#chat-room-select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: #495057;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

#chat-room-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

#create-room-btn {
    padding: 8px 12px;
    font-size: 14px;
    white-space: nowrap;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    color: #6c757d;
}

#current-room-name {
    font-weight: 500;
    color: #495057;
}

#room-participants {
    display: flex;
    align-items: center;
    gap: 5px;
}

#room-participants::before {
    content: "👥";
    font-size: 12px;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-width: 300px;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-left: 4px solid #51cf66;
}

.notification.error {
    border-left: 4px solid #ff6b6b;
}

.notification.info {
    border-left: 4px solid #339af0;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
}

.notification-content i {
    font-size: 16px;
}

.notification.success .notification-content i {
    color: #51cf66;
}

.notification.error .notification-content i {
    color: #ff6b6b;
}

.notification.info .notification-content i {
    color: #339af0;
}

.notification-content span {
    font-size: 14px;
    color: #495057;
}

#username-input {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    width: 150px;
    transition: all 0.3s ease;
}

#username-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

#username-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: #51cf66;
    color: white;
}

.btn-primary:hover {
    background: #40c057;
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

#clear-username-btn {
    background: #ff6b6b;
    color: white;
    border: none;
}

#clear-username-btn:hover {
    background: #ff5252;
    color: white;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    color: #6c757d;
}

.welcome-content {
    max-width: 400px;
}

.welcome-content i {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 20px;
}

.welcome-content h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #495057;
}

.welcome-content p {
    font-size: 16px;
    line-height: 1.5;
}

/* Message Styles */
.message {
    margin-bottom: 15px;
    animation: fadeInUp 0.3s ease;
}

.message-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 80%;
}

.message.own {
    justify-content: flex-end;
}

.message.own .message-content {
    flex-direction: row-reverse;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    max-width: 100%;
}

.message.own .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message:not(.own) .message-bubble {
    background: white;
    color: #495057;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 6px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.message-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6c757d;
}

.message.own .message-header {
    justify-content: flex-end;
}

.message-username {
    font-weight: 600;
    color: #495057;
}

.message.own .message-username {
    color: rgba(255, 255, 255, 0.9);
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
}

/* System Messages */
.message.system .message-bubble {
    background: #e9ecef;
    color: #6c757d;
    font-style: italic;
    text-align: center;
    border-radius: 12px;
    max-width: 60%;
    margin: 0 auto;
}

/* Typing Indicator */
.typing-indicator {
    padding: 10px 20px;
    color: #6c757d;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #6c757d;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Message Input */
.message-input-container {
    background: white;
    border-top: 1px solid #e9ecef;
    padding: 20px;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: all 0.3s ease;
    max-height: 120px;
    min-height: 44px;
}

#message-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #667eea;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    background: #5a6fd8;
    transform: scale(1.05);
}

.send-btn:disabled {
    background: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
    color: #6c757d;
}

.char-count {
    font-weight: 500;
}

.connection-info {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #495057;
}

.close-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #f8f9fa;
    color: #495057;
}

.modal-body {
    padding: 24px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.setting-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.setting-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-group:last-child {
    display: flex;
    gap: 10px;
    margin-bottom: 0;
}

.setting-group:last-child button {
    flex: 1;
}

.error-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        border-radius: 0;
        height: 100vh;
    }
    
    .chat-header {
        padding: 15px 20px;
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .header-content {
        justify-content: space-between;
    }
    
    .user-info {
        justify-content: center;
    }
    
    .username-section {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    #username-input {
        width: 100%;
        max-width: 200px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .message-input-container {
        padding: 15px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .setting-group:last-child {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .header-content h1 {
        font-size: 20px;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .message.system .message-bubble {
        max-width: 80%;
    }
} 