* {
    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;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-box h1 {
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.description {
    color: #666;
    text-align: center;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    margin-top: 5px;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.instructions {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.instructions h3 {
    color: #333;
    margin-bottom: 10px;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 5px 0;
    color: #666;
}

/* 聊天页面样式 */
.chat-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    background: #f5f5f5;
}

.sidebar {
    width: 280px;
    background: white;
    padding: 20px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.room-info, .user-list, .file-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

.room-info h3, .user-list h3, .file-info h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 18px;
}

.user-list ul {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.user-list li {
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
    color: #666;
}

.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: white;
}

.message {
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 15px;
    max-width: 70%;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.own-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
}

.other-message {
    background: #f0f0f0;
    color: #333;
}

.system-message {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin: 10px 0;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.timestamp {
    font-size: 12px;
    opacity: 0.8;
}

.input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.message-input {
    display: flex;
    gap: 10px;
}

.message-input input {
    flex: 1;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.action-buttons button {
    padding: 15px;
    border: none;
    border-radius: 10px;
    background: #f0f0f0;
    cursor: pointer;
    transition: background 0.3s;
}

.action-buttons button:hover {
    background: #e0e0e0;
}

#send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* 文件预览 */
.uploaded-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 10px;
    margin-top: 10px;
    cursor: pointer;
    transition: transform 0.3s;
}

.uploaded-image:hover {
    transform: scale(1.02);
}

.uploaded-video {
    max-width: 400px;
    max-height: 300px;
    border-radius: 10px;
    margin-top: 10px;
}

.file-download {
    display: inline-block;
    padding: 8px 16px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    margin-top: 10px;
}

/* 模态框 */
.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 {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.modal-image {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 10px;
}

.close {
    position: absolute;
    top: 10px;
    right: 20px;
    color: white;
    font-size: 40px;
    cursor: pointer;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 10px;
    }

    .room-info, .user-list, .file-info {
        padding: 15px;
    }

    .message {
        max-width: 85%;
    }
}
/* ========== 新增：响应式优化 ========== */

/* 通用响应式调整 */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: 100vh;
        width: 100vw;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 15px;
        order: 2;
        display: flex;
        flex-wrap: wrap;
        gap: 15px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    .room-info, .user-list, .file-info {
        flex: 1;
        min-width: calc(50% - 15px);
        padding: 15px;
    }

    .main-chat {
        order: 1;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .messages {
        flex: 1;
        padding: 15px;
        padding-bottom: 0;
    }

    .input-area {
        padding: 15px;
        padding-top: 10px;
    }

    .message {
        max-width: 85%;
        font-size: 14px;
    }

    .message-input {
        flex-wrap: wrap;
    }

    .message-input input {
        flex: 1 0 100%;
        margin-bottom: 10px;
    }

    .action-buttons {
        display: flex;
        flex: 1;
        gap: 8px;
    }

    .action-buttons button {
        flex: 1;
        padding: 12px;
        font-size: 14px;
    }

    /* 登录页面响应式 */
    .login-box {
        padding: 25px;
        margin: 15px;
        border-radius: 15px;
    }

    .container {
        padding: 15px;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    .sidebar {
        flex-direction: column;
    }

    .room-info, .user-list, .file-info {
        min-width: 100%;
    }

    .message {
        max-width: 95%;
        padding: 12px;
    }

    .action-buttons button {
        padding: 10px 8px;
        font-size: 12px;
    }

    .action-buttons button i {
        margin-right: 5px;
    }

    .btn-primary, .btn-secondary {
        padding: 12px;
    }

    /* 登录页面小屏幕优化 */
    .login-box {
        padding: 20px;
    }

    .instructions {
        padding: 15px;
        font-size: 14px;
    }
}

/* 大屏幕优化 */
@media (min-width: 1200px) {
    .container {
        max-width: 450px;
    }

    .sidebar {
        width: 320px;
    }

    .messages {
        padding: 30px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn-primary:hover, .btn-secondary:hover,
    .action-buttons button:hover {
        transform: none;
        box-shadow: none;
    }

    .form-group input, .message-input input {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 14px 12px;
    }

    .btn-primary, .btn-secondary {
        min-height: 50px;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 600px) {
    .sidebar {
        max-height: 40vh;
        overflow-y: auto;
    }

    .user-list ul {
        max-height: 80px;
    }

    .messages {
        padding: 10px;
    }

    .message {
        margin-bottom: 8px;
        padding: 10px;
    }
}

/* 防止移动端文字过小 */
html {
    -webkit-text-size-adjust: 100%;
}

/* 优化滚动条 */
.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 优化文件上传按钮 */
.file-upload {
    margin-top: 10px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    display: none;
}

.file-upload.active {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 优化模态框在移动端 */
@media (max-width: 768px) {
    .modal-content {
        max-width: 95%;
        max-height: 80vh;
    }

    .modal-image {
        max-height: 70vh;
    }

    .close {
        top: 5px;
        right: 15px;
        font-size: 30px;
    }
}

/* 优化用户列表滚动 */
.user-list ul {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

/* 键盘弹出时优化 */
@media (max-height: 500px) {
    .input-area {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 100;
    }
}

/* ========== 侧边栏切换按钮 ========== */
.sidebar-toggle {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1000;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s;
}

.sidebar-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* 默认隐藏侧边栏 */
.chat-container .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100vh;
    width: 280px;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 999;
    transition: left 0.3s ease;
    overflow-y: auto;
    padding: 20px;
}

/* 侧边栏显示状态 */
.chat-container.sidebar-open .sidebar {
    left: 0;
}

/* 侧边栏遮罩 */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chat-container.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

/* 移动端侧边栏样式 */
@media (max-width: 768px) {
    .sidebar-toggle {
        top: 10px;
        left: 10px;
        width: 35px;
        height: 35px;
    }

    .chat-container .sidebar {
        width: 280px;
        left: -280px;
    }

    .chat-container.sidebar-open .sidebar {
        left: 0;
    }
}

/* 大屏幕时侧边栏默认显示 */
@media (min-width: 1200px) {
    .sidebar-toggle {
        display: none; /* 大屏幕隐藏切换按钮 */
    }

    .chat-container .sidebar {
        position: relative;
        left: 0;
        height: 100vh;
        width: 280px;
    }

    .chat-container {
        flex-direction: row !important;
    }

    .sidebar-overlay {
        display: none;
    }
}

/* 侧边栏关闭按钮 */
.close-sidebar {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-sidebar:hover {
    background: #f0f0f0;
}

/* 侧边栏内容布局 */
.sidebar-content {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 优化移动端侧边栏内布局 */
@media (max-width: 768px) {
    .sidebar-content {
        margin-top: 20px;
        gap: 20px;
    }

    .room-info, .user-list, .file-info {
        padding: 15px;
    }
}

/* ========== 新增：加密房间样式 ========== */
.encrypted-badge {
    display: inline-block;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 8px;
    vertical-align: middle;
}

.public-badge {
    display: inline-block;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 8px;
    vertical-align: middle;
}

.lock-icon {
    color: #ff6b6b;
    margin-right: 5px;
}

.unlock-icon {
    color: #4CAF50;
    margin-right: 5px;
}

/* 密码输入框样式 */
.password-input-container {
    position: relative;
    width: 100%;
}

.password-input-container input {
    width: 100%;
    padding: 12px 40px 12px 12px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 14px;
}

.password-toggle:hover {
    color: #333;
}

/* 创建房间时的类型选择 */
.room-type-selection {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.room-type-option {
    flex: 1;
    min-width: 120px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.room-type-option:hover {
    border-color: #667eea;
    background: #f8f9fa;
}

.room-type-option.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.room-type-option i {
    font-size: 24px;
}

.room-type-option.encrypted i {
    color: #ff6b6b;
}

.room-type-option.public i {
    color: #4CAF50;
}

/* 房间列表中的加密房间卡片 */
.room-card.encrypted {
    border-left: 4px solid #ff6b6b;
    position: relative;
}

.room-card.encrypted::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.05) 0%, rgba(255, 82, 82, 0.05) 100%);
    border-radius: 15px;
    pointer-events: none;
}

/* 加密房间的提示文字 */
.encryption-hint {
    font-size: 13px;
    color: #ff6b6b;
    margin-top: 5px;
    font-weight: 500;
}

.encryption-hint i {
    margin-right: 5px;
}

/* 密码输入模态框 */
.password-modal .modal-content {
    max-width: 400px;
}

.password-input-field {
    position: relative;
    margin-bottom: 20px;
}

.password-strength {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    width: 0%;
    transition: width 0.3s, background 0.3s;
}

.password-strength-bar.weak {
    background: #ff6b6b;
    width: 33%;
}

.password-strength-bar.medium {
    background: #ff9800;
    width: 66%;
}

.password-strength-bar.strong {
    background: #4CAF50;
    width: 100%;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .room-type-option {
        min-width: calc(50% - 15px);
    }
}

@media (max-width: 480px) {
    .room-type-option {
        min-width: 100%;
    }
}