/* 移动端遮罩滑动修复样式 */

/* 防止背景滚动 */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* 模态框基础样式优化 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    background-color: rgba(23, 43, 77, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow-y: auto;
    overflow-x: hidden;
    /* 防止iOS Safari的弹性滚动 */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 模态框内容优化 */
.modal-content {
    position: relative;
    background-color: #ffffff;
    border-radius: 16px;
    width: 90%;
    max-width: 420px;
    max-height: 90vh;
    margin: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
    /* 防止内容溢出 */
    display: flex;
    flex-direction: column;
}

/* 模态框动画 */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }
}

@keyframes modalSlideUp {
    from {
        transform: translateY(50px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* 模态框头部 */
.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: linear-gradient(135deg, #fafbfc 0%, #ffffff 100%);
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.3;
}

/* 关闭按钮优化 */
.modal-close,
.close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: #95a5a6;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover,
.close:hover {
    background-color: #f8f9fa;
    color: #e74c3c;
    transform: scale(1.1);
}

/* 模态框主体 */
.modal-body {
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* 移动端特殊优化 */
@media (max-width: 768px) {
    .modal {
        padding: 16px;
        align-items: flex-start;
        padding-top: 10vh;
    }
    
    .modal-content {
        width: 100%;
        max-width: none;
        margin: 0;
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
        position: relative;
        bottom: 0;
    }
    
    .modal-header {
        padding: 24px 20px 16px;
        text-align: center;
        position: relative;
    }
    
    .modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background-color: #e0e0e0;
        border-radius: 2px;
    }
    
    .modal-body {
        padding: 20px;
        max-height: calc(85vh - 80px);
    }
    
    .modal-close,
    .close {
        top: 20px;
        right: 20px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .modal {
        padding: 8px;
        padding-top: 5vh;
    }
    
    .modal-content {
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
    }
    
    .modal-header {
        padding: 20px 16px 12px;
    }
    
    .modal-body {
        padding: 16px;
        max-height: calc(90vh - 70px);
    }
    
    .modal-close,
    .close {
        top: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
}

/* 防止页面跳动 */
@media (max-width: 768px) {
    html {
        scroll-behavior: smooth;
    }
    
    body {
        -webkit-text-size-adjust: 100%;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* 防止iOS Safari地址栏变化导致的高度问题 */
    .modal {
        height: 100vh;
        height: -webkit-fill-available;
    }
}

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
    .modal-close:hover,
    .close:hover {
        background-color: transparent;
        transform: none;
    }
    
    .modal-close:active,
    .close:active {
        background-color: #f8f9fa;
        transform: scale(0.95);
    }
}