/* ============================================================================
   产品列表页（Products/SmartTourismProducts.cshtml）移动端专项优化
   ============================================================================ */

/* 安全区域适配（支持刘海屏）*/
@media (max-width: 768px) {
    .hero-section {
        padding-top: calc(60px + env(safe-area-inset-top));
    }

    .product-filter {
        top: calc(70px + env(safe-area-inset-top));
    }
}

/* 超小屏优化（< 640px）*/
@media (max-width: 639px) {
    /* Hero区域 */
    .hero-section {
        padding: 60px 0 50px;
        background-attachment: scroll; /* 禁用视差效果提升性能 */
    }

    .hero-title {
        font-size: clamp(1.75rem, 6vw, 2.5rem);
        line-height: 1.2;
    }

    .hero-subtitle {
        font-size: 0.95rem;
        max-width: 100%;
        padding: 0 1rem;
    }

    /* Hero features */
    .hero-features {
        gap: 1.5rem;
        flex-direction: column;
        padding: 0 1rem;
    }

    .hero-feature {
        width: 100%;
    }

    .hero-feature-icon {
        width: 48px;
        height: 48px;
        font-size: 1.1rem;
    }

    .hero-feature h4 {
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }

    .hero-feature p {
        font-size: 0.85rem;
    }

    /* 产品筛选器 */
    .product-filter {
        top: 70px; /* Header高度补偿 */
        position: relative;
        box-shadow: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .filter-tabs {
        gap: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0.5rem 0;
        scroll-snap-type: x mandatory;
    }

    .filter-tabs::-webkit-scrollbar {
        display: none;
    }

    .filter-tab {
        padding: 0.6rem 1.25rem;
        font-size: 0.9rem;
        white-space: nowrap;
        flex-shrink: 0;
        scroll-snap-align: start;
    }

    /* 硬件筛选 */
    #hardware-filter {
        display: none !important; /* 移动端完全隐藏二级筛选 */
    }

    .secondary-filter {
        display: none !important;
    }

    /* 产品分类 */
    .categories-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        margin-bottom: 1rem;
    }

    .category-products {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }

    .category-section {
        padding: 1.25rem;
        border-radius: 12px;
    }

    .category-header {
        margin-bottom: 1rem;
        text-align: left;
    }

    .category-icon {
        width: 52px;
        height: 52px;
        font-size: 1.3rem;
    }

    .category-icon svg {
        width: 24px;
        height: 24px;
    }

    .category-title {
        font-size: 1.15rem;
        text-align: left;
    }

    .category-description {
        font-size: 0.9rem;
        max-width: 100%;
        text-align: left;
    }

    /* 产品卡片 */
    .product-card {
        padding: 1.125rem;
        border-radius: 10px;
        min-height: auto;
        position: relative;
        overflow: hidden;
    }

    .product-name {
        font-size: 1rem;
        margin-bottom: 0.5rem;
        line-height: 1.4;
    }

    .product-description {
        font-size: 0.85rem;
        margin-bottom: 1rem;
        line-height: 1.5;
    }

    .product-link {
        width: 100%;
        display: flex;
        justify-content: center;
        padding: 0.5rem 0;
        min-height: 44px; /* 触摸友好 */
        align-items: center;
    }

    /* Ecosystem section */
    .ecosystem-section {
        padding: 2.5rem 0;
    }

    .ecosystem-container {
        padding: 0 1rem;
    }

    .ecosystem-title {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }

    .ecosystem-subtitle {
        font-size: 0.95rem;
        margin-bottom: 2rem;
        padding: 0 0.5rem;
    }

    /* Workflow demo */
    .workflow-demo {
        padding: 1.5rem;
        border-radius: 12px;
    }

    .workflow-steps {
        gap: 1.5rem;
    }

    .workflow-step {
        text-align: left;
        padding: 0;
    }

    .step-icon {
        width: 52px;
        height: 52px;
        font-size: 1.3rem;
        margin-bottom: 0.75rem;
    }

    .step-title {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        text-align: left;
    }

    .step-description {
        font-size: 0.85rem;
        line-height: 1.6;
        text-align: left;
    }

    .workflow-arrow {
        display: none; /* 移动端隐藏箭头 */
    }

    /* CTA section */
    .cta-section {
        padding: 2.5rem 0;
        padding-bottom: calc(2.5rem + env(safe-area-inset-bottom));
    }

    .cta-content {
        padding: 0 1rem;
    }

    .cta-title {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
        line-height: 1.3;
    }

    .cta-description {
        font-size: 0.95rem;
        line-height: 1.6;
        margin-bottom: 2rem;
    }

    .cta-buttons {
        flex-direction: column;
        gap: 0.875rem;
    }

    .btn-cta {
        width: 100%;
        max-width: 100%;
        padding: 14px 24px;
        font-size: 1rem;
        min-height: 48px;
    }

    /* Breadcrumb */
    .breadcrumb {
        padding: 1rem;
        font-size: 0.85rem;
    }

    .breadcrumb-item {
        padding: 0.25rem 0.5rem;
    }

    /* 容器padding统一 */
    .container,
    .categories-container,
    .ecosystem-container {
        padding: 0 1rem;
    }

    /* 产品卡片触摸反馈 */
    .product-card:active::after {
        content: '';
        position: absolute;
        inset: 0;
        background: var(--primary-color);
        opacity: 0.1;
        animation: ripple 0.6s ease-out;
    }
}

/* 小屏优化（640px - 767px）*/
@media (min-width: 640px) and (max-width: 767px) {
    .hero-features {
        flex-wrap: wrap;
        gap: 1.5rem;
    }

    .categories-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .category-products {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .ecosystem-container {
        padding: 0 2rem;
    }
}

/* 平板优化（768px - 1023px）*/
@media (min-width: 768px) and (max-width: 1023px) {
    .hero-features {
        gap: 2rem;
    }

    .filter-tabs {
        gap: 1rem;
    }

    .filter-tab {
        padding: 1rem 2rem;
        font-size: 1rem;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .category-section {
        padding: 1.5rem;
    }

    .category-products {
        grid-template-columns: 1fr 1fr;
    }
}

/* 横屏优化 */
@media (max-width: 1024px) and (orientation: landscape) {
    .hero-section {
        padding: 40px 0;
    }

    .cta-section {
        padding: 30px 0;
    }

    .product-categories,
    .ecosystem-section {
        padding: 1.5rem 0;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大触摸目标 */
    .filter-tab,
    .product-card,
    .btn-cta,
    .category-section {
        min-height: 48px;
        min-width: 48px;
        cursor: pointer;
    }

    .filter-tab:active,
    .product-card:active,
    .btn-cta:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    /* 移除hover效果，改用active */
    .product-card:hover {
        transform: none;
        border-color: #e2e8f0;
    }

    .product-card:active,
    .product-card:focus-within {
        transform: translateX(-3px);
        border-color: var(--primary-color);
        box-shadow: var(--shadow-medium);
    }

    /* 按钮触摸反馈 */
    .btn-cta:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(255, 255, 255, 0.2);
    }
}

/* 动画优化（移动端禁用复杂动画）*/
@media (max-width: 767px) {
    .scroll-animate {
        opacity: 1;
        transform: none;
    }

    .animate-fadeInUp,
    .animate-slideInLeft,
    .animate-slideInRight,
    .animate-pulse {
        animation: none !important;
    }

    /* 禁用视差效果 */
    .hero-section {
        background-attachment: scroll !important;
    }
}

/* 加载状态优化 */
@media (max-width: 767px) {
    .category-section:not(.visible),
    .product-card:not(.visible) {
        background: #f0f0f0;
    }

    .category-section.visible,
    .product-card.visible {
        animation: fadeIn 0.3s ease;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ripple {
    0% {
        opacity: 0.6;
        transform: scale(0.8);
    }
    100% {
        opacity: 0;
        transform: scale(1);
    }
}

/* Hero背景优化 */
@media (max-width: 767px) {
    .hero-section {
        background-position: center 70%;
        background-size: cover;
    }
}

/* 隐藏硬件筛选（移动端不使用）*/
@media (max-width: 1023px) {
    .secondary-filter {
        display: none !important;
    }
}

/* 按钮间距优化 */
@media (max-width: 480px) {
    .cta-buttons {
        gap: 0.75rem;
    }

    .btn-cta {
        padding: 12px 20px;
    }
}

/* 字体加载优化 */
.font-loading .hero-title,
.font-loading .category-title,
.font-loading .cta-title {
    font-family: system-ui, -apple-system, sans-serif;
}

/* 减少动画模式（尊重用户偏好）*/
@media (prefers-reduced-motion: reduce) {
    .animate-fadeInUp,
    .animate-slideInLeft,
    .animate-slideInRight,
    .animate-pulse,
    @keyframes fadeIn,
    @keyframes ripple {
        animation-duration: 0.01ms !important;
    }

    .product-card,
    .category-section,
    .btn-cta {
        transition: none !important;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000FF;
        --text-primary: #000000;
        --bg-light: #FFFFFF;
    }

    .product-card {
        border-width: 2px;
    }

    .btn-cta {
        border-width: 2px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .product-card {
        background: #1f2937;
        border-color: #374151;
    }

    .category-section {
        background: #1f2937;
        border-color: #374151;
    }

    .product-name,
    .category-title,
    .ecosystem-title,
    .cta-title {
        color: #f9fafb;
    }

    .product-description,
    .category-description,
    .ecosystem-subtitle,
    .cta-description {
        color: #d1d5db;
    }
}

/* 打印样式 */
@media print {
    .hero-section,
    .product-filter,
    .cta-section {
        page-break-after: always;
    }

    .ecosystem-section,
    .category-section {
        break-inside: avoid;
    }

    .workflow-demo {
        display: none; /* 打印时不显示交互式demo */
    }

    .product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* 性能优化：硬件加速 */
@media (max-width: 767px) {
    .product-card,
    .category-section,
    .workflow-step,
    .btn-cta {
        will-change: transform;
        transform: translateZ(0);
    }
}

/* 文本选择优化 */
@media (max-width: 767px) {
    .product-card,
    .btn-cta,
    .filter-tab {
        -webkit-user-select: none;
        user-select: none;
    }

    .product-description,
    .category-description,
    .step-description {
        -webkit-user-select: text;
        user-select: text;
    }
}

/* 焦点样式（键盘导航）*/
@media (max-width: 767px) {
    .filter-tab:focus,
    .product-card:focus,
    .btn-cta:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

    .filter-tab:focus:not(:focus-visible),
    .product-card:focus:not(:focus-visible),
    .btn-cta:focus:not(:focus-visible) {
        outline: none;
    }
}
