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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.online-status {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 600;
}

.online-status #onlineCount {
    color: #4cd964;
    font-size: 1.2rem;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 300px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    overflow-y: auto;
}

.user-info {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.avatar {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
}

#username {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 10px;
    text-align: center;
    transition: border-color 0.3s;
}

#username:focus {
    outline: none;
    border-color: #6a11cb;
}

.user-id {
    font-size: 0.9rem;
    color: #6c757d;
    word-break: break-all;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 5px;
    margin-top: 10px;
}

.file-upload-area h3 {
    margin-bottom: 15px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-box {
    background: white;
    border: 3px dashed #dee2e6;
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
}

.upload-box:hover {
    border-color: #6a11cb;
    background: #f8f9ff;
}

.upload-box i {
    font-size: 3rem;
    color: #6a11cb;
    margin-bottom: 15px;
}

.upload-box p {
    color: #6c757d;
    margin: 5px 0;
}

.file-types {
    font-size: 0.85rem;
    color: #868e96;
    line-height: 1.4;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    padding: 15px;
    border-radius: 10px;
    max-width: 70%;
    position: relative;
    word-wrap: break-word;
}

.message.user {
    background: #e3f2fd;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.message.other {
    background: white;
    border: 1px solid #e9ecef;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message.system {
    background: #fff3cd;
    align-self: center;
    text-align: center;
    max-width: 90%;
    border: 1px solid #ffeaa7;
    margin: 5px auto;
}

.message.system.success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.message.system.error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.message.system.info {
    background: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.username {
    font-weight: 600;
    color: #495057;
}

.timestamp {
    color: #868e96;
    font-size: 0.8rem;
}

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

.message-text a {
    color: #6a11cb;
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

.image-container {
    margin-top: 10px;
    border-radius: 5px;
    overflow: hidden;
    max-width: 400px;
}

.image-container img {
    max-width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.3s ease;
    border-radius: 5px;
}

.image-container img:hover {
    transform: scale(1.02);
}

.file-container {
    margin-top: 10px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 400px;
}

.file-icon {
    font-size: 1.5rem;
    color: #6a11cb;
}

.file-info {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.85rem;
    color: #868e96;
}

.download-btn {
    background: #6a11cb;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.3s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.download-btn:hover {
    background: #2575fc;
    color: white;
}

.message-input {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    background: white;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#messageInput {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

#messageInput:focus {
    outline: none;
    border-color: #6a11cb;
}

.input-actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(106, 17, 203, 0.4);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #e9ecef;
    background: white;
    color: #495057;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    border-color: #6a11cb;
    color: #6a11cb;
    transform: scale(1.1);
}

.upload-preview {
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    max-height: 200px;
    overflow-y: auto;
}

.upload-preview h3 {
    margin-bottom: 10px;
    color: #495057;
}

.preview-item {
    background: white;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #e9ecef;
}

.preview-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.preview-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.preview-remove {
    color: #dc3545;
    cursor: pointer;
    padding: 5px;
    margin-left: 10px;
}

.preview-remove:hover {
    color: #bd2130;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
    margin-top: 10px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    display: block;
    border-radius: 5px;
}

.close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: #ccc;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        height: auto;
        min-height: calc(100vh - 40px);
    }
    
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 300px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}