/* 移动端响应式样式 */

/* 基础移动端优化 */
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    -webkit-touch-callout: none;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 移动端导航菜单 */
.mobile-menu {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu.active {
    display: block;
    opacity: 1;
}

.mobile-menu-content {
    background: white;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.mobile-menu.active .mobile-menu-content {
    transform: translateY(0);
}

.dark .mobile-menu-content {
    background: #0f172a;
}

.mobile-menu-item {
    display: block;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    color: #1e293b;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.dark .mobile-menu-item {
    color: #cbd5e1;
    border-bottom-color: #334155;
}

.mobile-menu-item:active {
    background: #f1f5f9;
}

.dark .mobile-menu-item:active {
    background: #1e293b;
}

/* 汉堡菜单图标动画 */
.hamburger {
    width: 24px;
    height: 24px;
    position: relative;
    cursor: pointer;
}

.hamburger span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: currentColor;
    border-radius: 2px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: .25s ease-in-out;
}

.hamburger span:nth-child(1) {
    top: 4px;
}

.hamburger span:nth-child(2),
.hamburger span:nth-child(3) {
    top: 11px;
}

.hamburger span:nth-child(4) {
    top: 18px;
}

.hamburger.active span:nth-child(1),
.hamburger.active span:nth-child(4) {
    top: 11px;
    width: 0%;
    left: 50%;
}

.hamburger.active span:nth-child(2) {
    transform: rotate(45deg);
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg);
}

/* 移动端表格优化 */
@media (max-width: 768px) {
    /* 表格横向滚动 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* 卡片式表格布局 */
    .table-card-view {
        display: block;
    }
    
    .table-card-view thead {
        display: none;
    }
    
    .table-card-view tbody {
        display: block;
    }
    
    .table-card-view tr {
        display: block;
        margin-bottom: 1rem;
        background: white;
        border-radius: 0.5rem;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .dark .table-card-view tr {
        background: #1e293b;
    }
    
    .table-card-view td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .dark .table-card-view td {
        border-bottom-color: #334155;
    }
    
    .table-card-view td:last-child {
        border-bottom: none;
    }
    
    .table-card-view td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
    }
    
    /* 表单优化 */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    /* 按钮触摸优化 */
    button,
    .btn,
    a.button {
        min-height: 44px; /* iOS推荐最小触摸目标 */
        min-width: 44px;
    }
    
    /* 间距调整 */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* 文字大小调整 */
    h1 {
        font-size: 1.875rem; /* 30px */
    }
    
    h2 {
        font-size: 1.5rem; /* 24px */
    }
    
    h3 {
        font-size: 1.25rem; /* 20px */
    }
    
    /* 图片优化 */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* 隐藏桌面端元素 */
    .hide-mobile {
        display: none !important;
    }
}

/* 平板端优化 */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    /* 隐藏移动端元素 */
    .show-mobile {
        display: none !important;
    }
}

/* 桌面端 */
@media (min-width: 1024px) {
    /* 隐藏移动端元素 */
    .show-mobile {
        display: none !important;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-menu-content {
        max-height: calc(100vh - 56px);
    }
    
    /* 减少垂直间距 */
    section {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
}

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
    /* 移除悬停效果，使用激活状态 */
    .hover\\:scale-105:hover {
        transform: none;
    }
    
    .hover\\:scale-105:active {
        transform: scale(0.98);
    }
    
    /* 按钮反馈 */
    button:active,
    .btn:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* 安全区域适配 (iPhone X+) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    footer {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* 产品网格优化 */
@media (max-width: 640px) {
    .product-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 640px) and (max-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 搜索框优化 */
@media (max-width: 768px) {
    .search-container {
        width: 100%;
    }
    
    .search-filters {
        flex-direction: column;
    }
    
    .search-filters > * {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* 质保查询表单优化 */
@media (max-width: 640px) {
    .warranty-form {
        padding: 1rem;
    }
    
    .warranty-form input {
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    .warranty-form button {
        width: 100%;
    }
}

/* 卡片布局优化 */
@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
}

/* Modal/弹窗优化 */
@media (max-width: 768px) {
    .modal {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
    
    .modal-content {
        border-radius: 0.75rem;
    }
}

/* Footer优化 */
@media (max-width: 768px) {
    footer .grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    footer .col-span-1 {
        text-align: center;
    }
    
    footer .flex {
        justify-content: center;
    }
}

/* 加载动画优化 */
@media (max-width: 768px) {
    .spinner {
        width: 32px;
        height: 32px;
        border-width: 2px;
    }
}

/* 图片轮播优化 */
@media (max-width: 768px) {
    .carousel {
        touch-action: pan-y pinch-zoom;
    }
    
    .carousel-controls {
        display: none; /* 移动端使用滑动手势 */
    }
}

/* 表单验证提示优化 */
@media (max-width: 768px) {
    .validation-message {
        font-size: 0.875rem;
        margin-top: 0.25rem;
    }
}

/* 导航固定优化 */
@media (max-width: 768px) {
    .sticky-header {
        position: sticky;
        top: 0;
        z-index: 50;
    }
}

/* 性能优化 */
@media (max-width: 768px) {
    /* 减少动画以提高性能 */
    .reduce-motion {
        animation: none !important;
        transition: none !important;
    }
}

/* 打印样式 */
@media print {
    .no-print {
        display: none !important;
    }
    
    header,
    footer,
    nav,
    .mobile-menu {
        display: none !important;
    }
}

/* 自定义滚动条（仅桌面端） */
@media (min-width: 1024px) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    
    ::-webkit-scrollbar-track {
        background: #f1f5f9;
    }
    
    ::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }
    
    .dark ::-webkit-scrollbar-track {
        background: #1e293b;
    }
    
    .dark ::-webkit-scrollbar-thumb {
        background: #475569;
    }
    
    .dark ::-webkit-scrollbar-thumb:hover {
        background: #64748b;
    }
}

/* 辅助功能 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus可见性 */
@media (prefers-reduced-motion: no-preference) {
    :focus-visible {
        outline: 2px solid #1173d4;
        outline-offset: 2px;
    }
}

/* 社交媒体二维码移动端优化 */
@media (max-width: 768px) {
    /* 二维码弹窗定位调整 */
    .qrcode-popup {
        position: fixed !important;
        bottom: auto !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 9999 !important;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
    }
    
    /* 二维码箭头在移动端隐藏 */
    .qrcode-popup .arrow {
        display: none !important;
    }
    
    /* 社交媒体图标增大触摸区域 */
    .social-qrcode-container a[data-social] {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        padding: 8px;
    }
    
    /* 二维码弹窗内容优化 */
    .qrcode-popup {
        min-width: 200px !important;
        max-width: 90vw;
    }
    
    /* 添加遮罩层效果 */
    .qrcode-popup:not(.hidden)::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
        backdrop-filter: blur(2px);
    }
    
    /* 二维码图片容器优化 */
    .qrcode-image-container {
        padding: 1rem;
    }
    
    /* 二维码图片大小调整 */
    .qrcode-image-container img {
        width: 180px !important;
        height: 180px !important;
        max-width: calc(100vw - 4rem);
        max-height: calc(100vw - 4rem);
    }
    
    .qrcode-image-container p {
        width: auto !important;
        max-width: 180px;
    }
    
    /* 触摸反馈 */
    .social-qrcode-container a[data-social]:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* 小屏手机优化 */
@media (max-width: 375px) {
    .qrcode-popup {
        min-width: 180px !important;
    }
    
    .qrcode-image-container img {
        width: 150px !important;
        height: 150px !important;
    }
    
    .qrcode-image-container p {
        max-width: 150px;
        font-size: 0.75rem !important;
    }
}

