/* 移动端适配样式 */
@media (max-width: 768px) {
    /* 显示移动端菜单按钮 */
    .menu-btn {
        display: flex !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* 菜单按钮触摸反馈 */
    .menu-btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
    
    /* 用户列表面板动画优化 */
    #user-list-panel {
        transition: transform 0.3s ease, opacity 0.3s ease;
        will-change: transform, opacity;
    }
    
    #user-list-panel.animating {
        pointer-events: none;
    }
    
    /* 隐藏桌面端控制按钮 */
    .refresh-btn,
    .minimize-btn {
        display: none !important;
    }
    
    .login-container {
        width: 95%;
        padding: 20px;
        margin: 10px;
    }

    .chat-page {
        padding: 10px;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        margin-bottom: 10px;
    }

    .main-content {
        margin-left: 0;
    }

    .user-sections {
        height: 200px;
    }

    .messages {
        height: calc(100vh - 350px);
    }

    .input-area {
        padding: 10px;
    }

    .input-group {
        flex-direction: column;
        gap: 10px;
    }

    .input-group input {
        width: 100%;
    }

    .button-group {
        flex-direction: column;
        width: 100%;
    }

    .button-group button {
        width: 100%;
        margin: 5px 0;
    }

    .file-upload-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    /* ❌ 移除这段代码，模态框样式已在 modal.css 的媒体查询中处理 */
    /* .modal {
        width: 95%;
        margin: 10px;
    } */



    .paste-preview {
        width: 95%;
        padding: 15px;
    }

    .toast {
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        max-width: 90%;
        width: auto;
        text-align: center;
    }
    
    .toast.show {
        transform: translate(-50%, -50%) scale(1);
    }
    
    /* 移动端消息容器底部间距优化 - 防止消息被输入框遮挡 */
    #msg {
        padding-bottom: 180px !important; /* 移动端默认间距 */
    }
    
    /* iOS设备需要更大的间距（Safari键盘问题） */
    .ios-device #msg {
        padding-bottom: 220px !important;
    }
    
    /* Android设备使用较小的间距（键盘处理较好） */
    .android-device #msg {
        padding-bottom: 160px !important;
    }
    
    /* 移动端图片消息优化 - 移除阴影避免视觉冲突 */
    .message-bubble img {
        max-width: 120px !important;
        max-height: 120px !important;
        width: auto !important;
        height: auto !important;
        border-radius: 8px;
        object-fit: cover;
        touch-action: manipulation;
        transition: transform 0.1s ease !important;
    }
    
    /* 移动端图片消息悬停效果优化 */
    .message-bubble img:hover {
        transform: scale(1.05) !important;
    }
    
    /* 移动端图片消息点击反馈 */
    .message-bubble img:active {
        transform: scale(0.95) !important;
        opacity: 0.8;
    }
    
    /* 图片预览模态框移动端优化 */
    .image-preview-modal {
        width: 100% !important;
        height: 100vh !important;
        margin: 0 !important;
        left: 0 !important;
        top: 0 !important;
        transform: none !important;
    }
    
    .image-preview-content {
        /* 合并并统一移动端图片预览内容规则，避免冲突 */
        padding: 60px 20px 20px !important;
        height: 100% !important;
        width: 100% !important;
        display: block !important;
        box-sizing: border-box !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .image-preview-content img,
    .image-preview-content #previewImage {
        max-width: calc(100% - 40px) !important;
        max-height: calc(100vh - 40px) !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        margin: 0 auto !important;
        display: block !important;
    }
    
    /* 移动端图片预览模态框关闭按钮优化 */
    .close-preview {
        top: 15px !important;
        right: 15px !important;
        width: 50px !important;
        height: 50px !important;
        font-size: 28px !important;
        background: rgba(0, 0, 0, 0.7) !important;
        border: 2px solid rgba(255, 255, 255, 0.3) !important;
    }
    
    /* （已合并到上方）移动端图片预览内容区域优化 */
    
    /* 移动端图片预览缩放行为优化 */
    #previewImage {
        cursor: default !important;
        transition: none !important;
    }
    
    #previewImage:active {
        transform: none !important;
        cursor: default !important;
    }
    
    /* 移动端双击缩放支持 */
    #previewImage {
        touch-action: manipulation !important;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 15px;
    }

    .login-container h2 {
        font-size: 24px;
    }

    .input-area {
        padding: 5px;
    }

    .button-group button {
        padding: 8px 12px;
        font-size: 14px;
    }

    .user-item {
        padding: 8px 5px;
    }

    .username {
        font-size: 14px;
    }

    .message {
        padding: 8px;
    }

    .message-content {
        font-size: 14px;
    }

    .timestamp {
        font-size: 11px;
    }
    
    /* 超小屏幕图片消息优化 */
    .message-bubble img {
        max-width: 100px !important;
        max-height: 100px !important;
    }
    
    /* 超小屏幕图片预览关闭按钮 */
    .close-preview {
        width: 45px !important;
        height: 45px !important;
        font-size: 24px !important;
        top: 10px !important;
        right: 10px !important;
    }
    
    /* 超小屏幕图片预览内容区域 */
    .image-preview-content {
        padding: 50px 15px 15px !important;
    }
}