/* 移动端专用样式 */

/* 基础重置和优化 */
* {
    -webkit-tap-highlight-color: transparent; /* 移除点击高亮 */
    -webkit-touch-callout: none; /* 防止长按出现上下文菜单 */
    -webkit-text-size-adjust: 100%; /* 防止iOS Safari字体变化 */
}

/* 特定元素才应用用户选择禁用 */
input, textarea {
    -webkit-user-select: none; /* 防止文字被选中 */
}

body {
    -webkit-overflow-scrolling: touch; /* 启用原生滚动 */
}

/* 确保图标可见 */
i, .fa, .fab, .fas, .far {
    -webkit-user-select: auto;
    -webkit-touch-callout: default;
    font-family: "Font Awesome 6 Brands", "Font Awesome 6 Free";
}

/* 移动端按钮优化 */
.btn {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* 导航栏优化 */
.navbar-toggler {
    border: none;
    padding: 0.5rem 0.75rem;
}

.navbar-collapse {
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

.navbar-brand {
    padding: 0.5rem 0;
}

.navbar-brand img {
    max-width: 100px;
    height: auto;
}

/* 产品卡片移动端优化 */
.product-card {
    margin-bottom: 1.5rem;
}

.product-card .card-img-top {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.product-card .card-body {
    padding: 0.75rem;
}

.product-card .card-title {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.product-card .card-text {
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

/* 表单控件移动端优化 */
.form-control {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 1rem;
    min-height: 46px;
}

.form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* 卡片优化 */
.card {
    border: none;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* 优化移动端滚动体验 */
.scroll-container {
    -webkit-overflow-scrolling: touch;
}

/* 移动端字体优化 */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
}

/* 图片优化 */
img {
    max-width: 100%;
    height: auto;
    -webkit-user-drag: none;
}

/* 优化列表显示 */
.list-group-item {
    padding: 0.75rem 1rem;
}

/* 优化移动端触摸目标 */
.clickable-area {
    min-height: 44px; /* iOS推荐的最小触摸目标 */
    min-width: 44px;
    padding: 10px 15px;
}

/* 移动端加载指示器 */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 移动端友好间距 */
.pt-mobile {
    padding-top: 1rem !important;
}

.pb-mobile {
    padding-bottom: 1rem !important;
}

.mt-mobile {
    margin-top: 1rem !important;
}

.mb-mobile {
    margin-bottom: 1rem !important;
}

/* 针对小屏幕的特殊优化 */
@media (max-width: 480px) {
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    .display-4 {
        font-size: 1.75rem;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.3rem;
    }

    /* 优化移动端按钮组 */
    .btn-group,
    .btn-group-vertical {
        gap: 0.5rem;
    }

    /* 优化移动端表格显示 */
    .table-responsive {
        font-size: 0.875rem;
    }

    /* 优化移动端导航 */
    .navbar-brand {
        font-size: 1.25rem;
    }

    .nav-link {
        padding: 0.75rem 1rem !important;
    }
}

/* 针对大屏手机的优化 */
@media (min-width: 576px) and (max-width: 768px) {
    .container {
        max-width: 100%;
        padding-left: 15px;
        padding-right: 15px;
    }

    .row {
        margin-left: -12px;
        margin-right: -12px;
    }

    [class*="col-"] {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* 触摸反馈 */
.touch-feedback:active {
    background-color: rgba(0, 0, 0, 0.1) !important;
    transition: background-color 0.2s;
}

/* 移动端隐藏元素 */
.mobile-hide {
    display: block;
}

.desktop-hide {
    display: none;
}

@media (max-width: 768px) {
    .mobile-hide {
        display: none;
    }

    .desktop-hide {
        display: block;
    }
}

/* 优化移动端表单输入体验 */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
textarea {
    -webkit-autofill: -webkit-autofill; /* 解决iOS Safari自动填充背景色问题 */
    transition: background-color 5000s ease-in-out 0s; /* 解决自动填充背景色问题 */
}

/* 修复iOS Safari固定定位问题 */
.fixed-top-ios {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
}

/* 针对iPhone X等设备的安全区域 */
@supports(padding: env(safe-area-inset)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}