/* 移动端优化样式 */

/* 基础移动端适配 */
@media (max-width: 768px) {
    /* 导航栏优化 */
    .navbar-nav .nav-link {
        padding: 0.5rem 1rem;
    }
    
    /* 卡片优化 */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-deck .card {
        margin-bottom: 15px;
    }
    
    /* 按钮优化 */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    /* 表单优化 */
    .form-control {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    /* 标题优化 */
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
    
    /* 间距优化 */
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .my-5 {
        margin-top: 2rem !important;
        margin-bottom: 2rem !important;
    }
}

/* 小屏幕设备优化 */
@media (max-width: 576px) {
    /* 进一步缩小元素 */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .display-4 {
        font-size: 2.5rem;
    }
    
    .display-5 {
        font-size: 2rem;
    }
    
    /* 图片优化 */
    .img-fluid {
        max-width: 100%;
        height: auto;
    }
    
    /* 表格优化 */
    .table-responsive {
        font-size: 0.875rem;
    }
    
    /* 模态框优化 */
    .modal-dialog {
        margin: 10px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大触摸目标 */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* 减少悬停效果依赖 */
    .card:hover {
        transform: none;
    }
    
    /* 优化滚动 */
    .overflow-auto {
        -webkit-overflow-scrolling: touch;
    }
}

/* 横屏模式优化 */
@media (max-width: 992px) and (orientation: landscape) {
    /* 调整布局适应横屏 */
    .hero-section {
        padding: 2rem 0;
    }
    
    .section {
        padding: 2rem 0;
    }
    
    /* 优化导航栏 */
    .navbar-collapse {
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* 优化图片显示质量 */
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    /* 优化图标显示 */
    .fa, .fas, .far, .fal, .fad, .fab {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --bs-dark: #1a1a1a;
        --bs-light: #2d2d2d;
    }
    
    body {
        background-color: var(--bs-dark);
        color: #e0e0e0;
    }
    
    .card {
        background-color: var(--bs-light);
        border-color: #404040;
    }
    
    .bg-light {
        background-color: #2d2d2d !important;
    }
    
    .text-muted {
        color: #a0a0a0 !important;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .animate-in {
        animation: none;
    }
    
    .hover-effect {
        transform: none !important;
    }
}

/* 打印样式优化 */
@media print {
    .navbar,
    .btn,
    .form-control,
    .no-print {
        display: none !important;
    }
    
    .card {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: black;
        background: white;
    }
}

/* iOS Safari优化 */
@supports (-webkit-touch-callout: none) {
    /* 修复iOS Safari的弹性滚动问题 */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* 优化输入框在iOS上的表现 */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea {
        -webkit-appearance: none;
        border-radius: 4px;
    }
}

/* Android Chrome优化 */
@supports selector(:autofill) {
    /* 处理自动填充样式 */
    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus,
    textarea:-webkit-autofill,
    textarea:-webkit-autofill:hover,
    textarea:-webkit-autofill:focus,
    select:-webkit-autofill,
    select:-webkit-autofill:hover,
    select:-webkit-autofill:focus {
        -webkit-box-shadow: 0 0 0px 1000px white inset;
        transition: background-color 5000s ease-in-out 0s;
    }
}

/* 无障碍访问优化 */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 焦点可见性增强 */
*:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .btn-outline-primary {
        border-width: 2px;
    }
    
    .card {
        border-width: 2px;
    }
    
    a {
        text-decoration-thickness: 2px;
    }
}

/* 低对比度模式支持 */
@media (prefers-contrast: low) {
    .text-muted {
        opacity: 0.8;
    }
    
    .btn-outline-secondary {
        border-color: #adb5bd;
        color: #6c757d;
    }
}