/* 移动设备适配通用样式 */

/* 针对移动设备的触摸反馈 */
.mobile-device .FriendLink:active {
    background-color: rgba(220, 220, 220, 0.8);
    transform: scale(0.98);
}

.mobile-device a {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

/* 移动设备的滚动优化 */
.mobile-device {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* 防止输入缩放问题 */
.mobile-device input,
.mobile-device textarea,
.mobile-device select {
    font-size: 16px;
}

/* 移动设备方向适配 */
@media (orientation: portrait) and (max-width: 768px) {
    /* 竖屏时的样式 */
    .mobile-device #title {
        width: 80%;
        text-align: center;
    }
}

@media (orientation: landscape) and (max-width: 768px) {
    /* 横屏时的样式 */
    .mobile-device #friend_link_panel {
        height: 60vh;
        margin-top: 50px;
    }
    
    .mobile-device #title {
        top: 10px;
    }
}

/* 确保页面内容不会被系统UI遮挡 (特别是在iOS的PWA模式下) */
.mobile-device {
    padding-bottom: env(safe-area-inset-bottom);
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* 提升移动设备上的滚动性能 */
.mobile-device #friend_link_container {
    -webkit-overflow-scrolling: touch;
    will-change: transform;
}

/* 针对小屏幕设备的额外优化 */
@media (max-width: 320px) {
    .mobile-device #title {
        font-size: 1.5em;
    }
    
    .mobile-device .FriendLink .nickname {
        font-size: 0.85em;
    }
    
    .mobile-device .FriendLink .link {
        font-size: 0.7em;
    }
}

/* 针对平板设备的适配 */
@media (min-width: 768px) and (max-width: 1024px) {
    .mobile-device #friend_link_panel {
        width: 80%;
    }
}

/* iOS设备特定修复 */
@supports (-webkit-touch-callout: none) {
    /* 针对iOS设备的特殊处理 */
    #title.resources-loaded {
        transform: none !important; /* 确保不使用transform */
        -webkit-backface-visibility: hidden; /* 减少iOS上的渲染问题 */
        backface-visibility: hidden;
        -webkit-perspective: 1000; /* 提高iOS上的动画性能 */
        perspective: 1000;
    }
}

/* ==================== User Info 页面移动端适配 ==================== */

/* 用户信息页面移动端特定样式 */
@media (max-width: 768px) {
    /* 确保用户信息页面在移动端正确显示 */
    .mobile-device #user_panel {
        position: relative;
        z-index: 1;
    }
    
    .mobile-device #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        background: rgba(50, 50, 50, 0.95);
        overflow-y: auto;
        padding-top: 60px;
    }
    
    .mobile-device #sidebar.expanded {
        transform: translateX(0);
    }
    
    .mobile-device #sidebar-toggle {
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1001;
        background: white;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: black;
        width: 44px;
        height: 44px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        transition: all 0.3s ease;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    .mobile-device #content-container {
        padding-top: 70px;
        padding-left: 15px;
        padding-right: 15px;
        padding-bottom: 20px;
    }
    
    /* 表单优化 */
    .mobile-device .form-group {
        margin-bottom: 20px;
    }
    
    .mobile-device .form-group input,
    .mobile-device .form-group textarea {
        padding: 15px;
        font-size: 16px;
        border-radius: 10px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        background: rgba(255, 255, 255, 0.15);
        color: white;
        width: 100%;
        box-sizing: border-box;
    }
    
    .mobile-device .form-group input:focus,
    .mobile-device .form-group textarea:focus {
        border-color: rgb(104, 217, 255);
        outline: none;
        box-shadow: 0 0 0 3px rgba(104, 217, 255, 0.2);
    }
    
    /* 按钮优化 */
    .mobile-device .submit-btn {
        width: 100%;
        padding: 16px;
        font-size: 18px;
        border-radius: 10px;
        min-height: 50px;
        font-weight: 600;
        transition: all 0.2s ease;
    }
    
    /* 移除可能导致持续active状态的CSS，使用JavaScript控制的反馈 */
    .mobile-device .submit-btn:active {
        transform: none !important;
        background: transparent !important;
    }
    
    .mobile-device .submit-btn.touch-feedback {
        transform: scale(0.98);
        background: rgba(104, 217, 255, 0.9);
    }
    
    /* 头像区域优化 */
    .mobile-device .profile-avatar img,
    .mobile-device .current-avatar img {
        border-radius: 50%;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    /* 状态消息优化 */
    .mobile-device .status-message {
        padding: 12px 15px;
        border-radius: 8px;
        text-align: center;
        font-size: 14px;
        font-weight: 500;
        margin: 15px 0;
    }
    
    /* 验证码输入优化 */
    .mobile-device .verification-group .code-input-container {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .mobile-device .code-btn {
        width: 100%;
        padding: 15px;
        font-size: 16px;
        border-radius: 8px;
        min-height: 50px;
    }
    
    /* 文件上传优化 */
    .mobile-device .file-upload-btn {
        width: 100%;
        padding: 15px;
        text-align: center;
        border-radius: 10px;
        font-size: 16px;
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }
    
    /* 移除可能导致持续active状态的CSS，使用JavaScript控制的反馈 */
    .mobile-device .file-upload-btn:active {
        transform: none !important;
        background: transparent !important;
    }
    
    .mobile-device .file-upload-btn.touch-feedback {
        transform: scale(0.98);
        background: rgba(104, 217, 255, 0.9);
    }
    
    /* 侧边栏按钮的触摸反馈 */
    .mobile-device .SectionTitle:active,
    .mobile-device #back_button:active,
    .mobile-device #sidebar-toggle:active {
        transform: none !important;
        background: transparent !important;
    }
    
    .mobile-device .SectionTitle.touch-feedback {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.3);
    }
    
    .mobile-device #back_button.touch-feedback {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.3);
    }
    
    .mobile-device #sidebar-toggle.touch-feedback {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.2);
    }
}

/* 小屏幕设备优化 */
@media (max-width: 480px) {
    .mobile-device #title {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }
    
    .mobile-device .section-content h2 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }
    
    .mobile-device .form-group input,
    .mobile-device .form-group textarea {
        padding: 14px;
        font-size: 16px;
    }
    
    .mobile-device .profile-avatar,
    .mobile-device .current-avatar {
        width: 100px;
        height: 100px;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-device #title {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }
    
    .mobile-device #content-container {
        padding-top: 60px;
    }
    
    .mobile-device #sidebar {
        padding-top: 50px;
    }
    
    .mobile-device .profile-info-container {
        flex-direction: row;
        align-items: center;
    }
    
    .mobile-device .profile-avatar,
    .mobile-device .current-avatar {
        width: 80px;
        height: 80px;
    }
}

/* PWA模式下的safe area适配 */
@supports (padding: max(0px)) {
    .mobile-device {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
    
    .mobile-device #sidebar-toggle {
        top: max(15px, calc(env(safe-area-inset-top) + 15px));
        left: max(15px, env(safe-area-inset-left));
    }
}
