/* 移动端专用优化CSS */

/* iOS Safari 特殊处理 */
@supports (-webkit-touch-callout: none) {
    .message-input {
        font-size: 16px !important; /* 防止iOS缩放 */
        transform: translateZ(0); /* 硬件加速 */
    }
    
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    .chat-messages {
        -webkit-overflow-scrolling: touch;
    }
}

/* Android Chrome 优化 */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .message-input:focus {
        background-color: var(--light-bg);
        outline: none;
        border: 2px solid var(--primary-color);
    }
}

/* 高DPI屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .video-player video {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    .message-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* 横屏模式优化 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .connection-panel {
        flex-direction: row;
        align-items: flex-start;
        padding: 20px;
    }
    
    .qr-container {
        margin-right: 20px;
        margin-bottom: 0;
    }
    
    .chat-header {
        padding: 8px 12px;
        padding-top: 40px;
    }
    
    .sidebar {
        width: 250px;
    }
    
    .media-panel {
        width: 300px;
    }
    
    .video-container {
        flex-direction: row;
        gap: 10px;
    }
    
    .video-player {
        flex: 1;
        aspect-ratio: 16/9;
    }
}

/* 触摸优化 */
.action-button,
.control-button,
.send-button,
.copy-button {
    min-height: 44px; /* iOS推荐的最小触摸目标 */
    min-width: 44px;
    touch-action: manipulation; /* 防止双击缩放 */
}

/* 滚动优化 */
.chat-messages {
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--primary-color) transparent; /* Firefox */
}

/* Webkit浏览器的滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 3px;
}

/* 键盘弹出时的优化 */
@media screen and (max-height: 500px) {
    .sidebar.active,
    .media-panel.active {
        height: 100vh;
        overflow-y: auto;
    }
    
    .video-container {
        display: none; /* 键盘弹出时隐藏视频 */
    }
}

/* 暗色模式适配 */
@media (prefers-color-scheme: dark) {
    .qr-container {
        background-color: #2f3136;
        color: var(--text-color);
    }
    
    .qr-container h3 {
        color: var(--text-color);
    }
}

/* 减少动画以提高性能 */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .media-panel {
        transition: none;
    }
    
    .control-button,
    .action-button {
        transition: none;
    }
}

/* 网络慢时的优化 */
/* 网络慢时的优化 */
@media (prefers-reduced-motion: reduce) {
    .video-player video {
        /* poster 属性应该在HTML中设置，而不是CSS */
    }
}