﻿/* 移动端优化全局样式 */

/* 防止双击放大和内容溢出 */
html, body {
    overflow-x: hidden !important;
    -webkit-text-size-adjust: 100% !important;
    -ms-text-size-adjust: 100% !important;
    touch-action: manipulation !important;
    -webkit-overflow-scrolling: touch !important;
    -webkit-tap-highlight-color: transparent !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative;
}

/* 防止内容溢出屏幕 */
* {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 图片和媒体元素优化 */
img, video, canvas, iframe {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
}

/* 表格和代码块优化 */
table, pre, code {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 容器和布局优化 */
.app-container,
.container,
.main-content,
.benchmark-app,
.benchmark-page {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
}

/* 输入框优化 */
input, textarea, select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0;
    font-size: 16px; /* 防止iOS缩放 */
    transform: scale(1); /* 防止意外缩放 */
    outline: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: text;
    user-select: text;
}

/* 内容可编辑元素优化 */
[contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* 按钮优化 */
button, .btn, .action-btn, .search-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    cursor: pointer;
}

/* 防止文本选择（非输入元素） */
.app-container,
.container,
.main-content,
.header,
.navigation,
.card,
.btn,
button {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* 允许特定元素的文本选择 */
p, span, div[contenteditable], input, textarea {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* 滚动优化 */
.scroll-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* 防止橡皮筋效果 */
body {
    overscroll-behavior: none;
    overscroll-behavior-y: none;
    -webkit-overscroll-behavior: none;
    -webkit-overscroll-behavior-y: none;
}

/* 确保底部导航栏始终固定在视口底部 */
html, body {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.app-container {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
}

/* 特殊元素优化 */
.keyword-tag,
.note-title,
.content-area,
.search-input-wrapper,
.card,
.btn,
.action-btn,
.publish-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* 图像处理优化 */
.image-container,
.image-preview,
.enhanced-image {
    overflow: hidden;
    position: relative;
}

.image-container img,
.image-preview img,
.enhanced-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

/* 防止长按菜单 */
img, video {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 移动端特定媒体查询 */
@media screen and (max-width: 768px) {
    /* 确保所有元素都不会超出屏幕 */
    * {
        max-width: 100vw !important;
    }
    
    /* 防止横向滚动 */
    body, html {
        overflow-x: hidden !important;
    }
    
    /* 优化触摸目标大小 */
    .btn, button, .keyword-tag, .action-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* 输入框字体大小防止缩放 */
    input, textarea, select {
        font-size: 16px !important;
    }
}

/* 横屏适配 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .main-content {
        padding-top: 10px;
        padding-bottom: 10px;
    }
}

/* 高DPI屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* 确保在高DPI屏幕上的清晰度 */
    .app-container {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}
