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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

.screen {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* 登录界面 */
.login-box {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 350px;
}

.login-box h1 {
    color: #333;
    margin-bottom: 30px;
    font-size: 28px;
}

.login-box input[type="text"] {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

.login-box input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.login-box button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.login-box button:hover {
    transform: translateY(-2px);
}

.tip {
    margin-top: 20px;
    color: #888;
    font-size: 14px;
}

/* 聊天界面 */
.chat-container {
    display: flex;
    width: 95vw;
    height: 90vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 280px;
    background: #f5f5f5;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
}

.room-info {
    margin-bottom: 30px;
}

.room-info h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 20px;
}

.room-id-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.room-id-box span {
    flex: 1;
    font-family: monospace;
    font-size: 14px;
    color: #666;
    word-break: break-all;
}

.room-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.action-btn {
    flex: 1;
    padding: 10px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: #f5f5f5;
    border-color: #667eea;
    transform: translateY(-2px);
}

.icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s;
}

.icon-btn:hover {
    transform: scale(1.2);
}

.users-section {
    flex: 1;
    overflow-y: auto;
}

.users-section h4 {
    color: #666;
    margin-bottom: 15px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#users-list {
    list-style: none;
}

#users-list li {
    padding: 12px;
    background: white;
    margin-bottom: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#users-list li::before {
    content: attr(data-avatar);
    font-size: 24px;
}

#users-list li.you {
    background: #e8f5e9;
    font-weight: 600;
}

.leave-btn {
    margin-top: auto;
    padding: 12px;
    background: #ff5252;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.leave-btn:hover {
    background: #ff1744;
}

/* 聊天区域 */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

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

.message.self {
    align-items: flex-end;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.message.self .message-header {
    flex-direction: row-reverse;
}

.username {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.time {
    font-size: 12px;
    color: #999;
}

.message-content {
    max-width: 60%;
    padding: 12px 16px;
    border-radius: 12px;
    background: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
}

/* 视频链接样式 */
.message-content .video-link {
    color: #667eea;
    text-decoration: none;
    display: block;
    margin-bottom: 10px;
    word-break: break-all;
}

.message.self .message-content .video-link {
    color: #fff;
    text-decoration: underline;
}

.message-content .video-link:hover {
    text-decoration: underline;
}

/* 视频播放器容器 */
.video-wrapper {
    margin-top: 10px;
    position: relative;
    width: 100%;
    max-width: 500px;
}

/* 响应式视频播放器 */
.video-iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    display: block;
}

.message.self .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-content img,
.message-content video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    display: block;
    margin-top: 10px;
}

.message-content .image-caption {
    font-size: 12px;
    margin-top: 5px;
    opacity: 0.8;
}

.system-message {
    text-align: center;
    color: #888;
    font-size: 14px;
    padding: 10px;
    margin: 10px 0;
}

.system-message .emoji {
    font-size: 20px;
    margin-right: 5px;
}

/* 输入区域 */
.input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: center;
}

.media-buttons {
    display: flex;
    gap: 5px;
}

.media-btn {
    padding: 10px 15px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s;
}

.media-btn:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 16px;
    transition: border-color 0.3s;
}

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

#send-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

#send-btn:hover {
    transform: translateY(-2px);
}

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

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    min-width: 350px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 20px;
}

.modal-content input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.primary-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.primary-btn:hover {
    opacity: 0.9;
}

.secondary-btn {
    background: #f5f5f5;
    color: #333;
}

.secondary-btn:hover {
    background: #e0e0e0;
}

/* 连接状态指示器 */
.connection-status {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.status-content {
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
    min-width: 300px;
}

.status-icon {
    font-size: 40px;
    margin-bottom: 10px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.status-text {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.status-details {
    font-size: 12px;
    color: #666;
    line-height: 1.5;
}

/* 调试面板 */
.debug-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-height: 300px;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 12px;
    color: white;
    font-family: monospace;
    font-size: 12px;
    overflow: hidden;
    z-index: 1500;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

.debug-header:hover {
    background: rgba(255, 255, 255, 0.15);
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 11px;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.debug-log {
    padding: 15px;
    max-height: 250px;
    overflow-y: auto;
}

.debug-log-entry {
    margin-bottom: 8px;
    padding: 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
}

.debug-log-entry.error {
    background: rgba(255, 82, 82, 0.3);
}

.debug-log-entry.success {
    background: rgba(76, 175, 80, 0.3);
}

.debug-log-entry.info {
    background: rgba(33, 150, 243, 0.3);
}

.debug-timestamp {
    color: #999;
    font-size: 10px;
}

/* 隐藏的文件输入 */
#image-input,
#video-input {
    display: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 150px;
        padding: 10px;
    }

    .message-content {
        max-width: 80%;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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