/* ========================================
   响应式设计 - 手机和平板适配
   Mobile: < 768px
   Tablet: 768px - 1024px
   Desktop: > 1024px
   
   注意：所有样式都在媒体查询内，不影响电脑端
======================================== */

/* ========================================
   移动端菜单按钮（默认隐藏）
======================================== */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    order: -1;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #333;
    transition: all 0.3s;
    border-radius: 2px;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* 移动端导航菜单（默认隐藏） */
.mobile-nav {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    z-index: 999;
    overflow-y: auto;
    padding: 0;
}

.mobile-nav.show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.mobile-nav a {
    display: block;
    padding: 1rem 1.25rem;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.95rem;
}

.mobile-nav a:hover,
.mobile-nav a.active {
    color: #0066cc;
    background: #f8f9fa;
}

/* 移动端分类栏滚动条隐藏 */
.mobile-category-bar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.mobile-category-bar::-webkit-scrollbar {
    display: none;
}

/* ========================================
   平板适配 (768px - 1024px)
======================================== */
@media (max-width: 1024px) {
    /* 隐藏首页分类侧边栏 */
    .category-sidebar {
        display: none !important;
    }
    
    /* 首页Hero区域改为单列 */
    section[style*="linear-gradient"] > .container-wide > div[style*="grid-template-columns: 280px"] {
        display: block !important;
    }
    
    /* 产品网格调整 */
    .grid-5 { grid-template-columns: repeat(4, 1fr) !important; }
    .grid-4 { grid-template-columns: repeat(3, 1fr) !important; }
    
    /* 侧边栏布局改为单列 */
    div[style*="grid-template-columns: 280px 1fr"],
    div[style*="grid-template-columns: 250px 1fr"] {
        display: block !important;
    }
    
    /* 隐藏侧边栏筛选 */
    aside[style*="position: sticky"] {
        display: none !important;
    }
}

/* ========================================
   手机适配 (< 768px)
======================================== */
@media (max-width: 768px) {
    /* 显示移动端菜单按钮 */
    .mobile-menu-btn {
        display: flex !important;
    }
    
    /* ===== Header ===== */
    .hd-wrap {
        padding: 0 12px !important;
        height: 56px !important;
        gap: 10px !important;
    }
    
    .hd-logo {
        font-size: 18px !important;
        flex: 1;
    }
    
    .hd-logo img {
        height: 28px !important;
        max-width: 100px !important;
    }
    
    /* 隐藏桌面导航 */
    .hd-nav {
        display: none !important;
    }
    
    /* 隐藏header内的搜索框（滚动时显示的那个） */
    .hd-search {
        display: none !important;
    }
    
    /* 隐藏语言和货币选择器 */
    .hd-right .hd-select {
        display: none !important;
    }
    
    /* 隐藏登录链接，保留按钮 */
    .hd-right .hd-link {
        display: none !important;
    }
    
    /* 注册按钮简化 */
    .hd-right .hd-btn {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
    
    /* 客服按钮简化 */
    .hd-cs-btn {
        padding: 6px 10px !important;
        font-size: 0 !important;
        min-width: 36px;
    }
    .hd-cs-btn::before {
        content: "💬";
        font-size: 16px;
    }
    
    /* ===== 搜索栏 ===== */
    .search-bar {
        padding: 10px 0 !important;
    }
    
    .search-wrap {
        padding: 0 12px !important;
    }
    
    .search-box {
        flex-wrap: wrap !important;
        border-radius: 8px !important;
        padding: 8px !important;
    }
    
    /* 隐藏分类下拉 */
    .search-cat {
        display: none !important;
    }
    
    .search-input {
        flex: 1 !important;
        min-width: 0 !important;
        padding: 8px 12px !important;
        font-size: 14px !important;
        border: none !important;
    }
    
    /* 搜索按钮区域 */
    .search-btns,
    .search-box > div[style*="display:flex"][style*="padding:4px"] {
        width: auto !important;
        margin-top: 0 !important;
        flex-shrink: 0 !important;
    }
    
    /* 图片搜索按钮 - 只显示图标 */
    .search-box button[title*="图片"],
    .search-box button[onclick*="openImgSearch"] {
        padding: 0 10px !important;
        min-width: 40px !important;
    }
    .search-box button[title*="图片"] span,
    .search-box button[onclick*="openImgSearch"] span {
        display: none !important;
    }
    
    /* 搜索按钮 */
    .search-box button[onclick*="doSearch"],
    .search-box button[style*="letter-spacing"] {
        padding: 0 16px !important;
        letter-spacing: 0 !important;
        font-size: 14px !important;
    }
    
    /* 热门搜索 */
    .hot-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        margin-top: 10px !important;
    }
    
    .hot-left {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    
    .hot-right {
        display: none !important;
    }
    
    .hot-tag {
        padding: 4px 10px !important;
        font-size: 12px !important;
    }
    
    .hot-label {
        font-size: 12px !important;
    }
    
    /* ===== 首页 Hero ===== */
    /* Banner容器 */
    .hero-carousel,
    div[style*="height: 600px"][style*="position: relative"] {
        height: 220px !important;
    }
    
    /* 轮播箭头 */
    .carousel-prev,
    .carousel-next,
    button[class*="carousel-prev"],
    button[class*="carousel-next"] {
        width: 36px !important;
        height: 36px !important;
        font-size: 18px !important;
    }
    
    /* Banner文字 */
    div[style*="font-size: 3rem"],
    div[style*="font-size: 2.5rem"],
    h1[style*="font-size: 3rem"],
    h2[style*="font-size: 2.5rem"] {
        font-size: 1.25rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    div[style*="font-size: 1.25rem"]:not(strong) {
        font-size: 0.875rem !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    /* Banner内的按钮 */
    div[style*="display: flex"][style*="gap: 1rem"] .btn {
        padding: 8px 16px !important;
        font-size: 12px !important;
    }
    
    /* ===== 统计数据 ===== */
    div[style*="grid-template-columns: repeat(4, 1fr)"][style*="text-align: center"][style*="color: white"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
        padding: 1rem 0 !important;
    }
    
    div[style*="font-size: 2.5rem"][style*="font-weight: 700"] {
        font-size: 1.5rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    /* ===== Section ===== */
    .section {
        padding: 1.5rem 0 !important;
    }
    
    .section-title,
    h2[style*="font-size: 2rem"] {
        font-size: 1.25rem !important;
    }
    
    /* Section header */
    div[style*="display: flex"][style*="justify-content: space-between"][style*="margin-bottom: 2rem"] {
        flex-direction: column !important;
        gap: 0.75rem !important;
        margin-bottom: 1rem !important;
    }
    
    /* ===== 产品网格 ===== */
    .grid-5,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .grid-3,
    .grid-2 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    /* ===== 产品卡片 ===== */
    .card {
        border-radius: 8px !important;
    }
    
    .card-img {
        height: 140px !important;
    }
    
    .card-body {
        padding: 10px !important;
    }
    
    .card-title {
        font-size: 0.8rem !important;
        margin-bottom: 0.25rem !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .card-text {
        display: none !important;
    }
    
    /* 卡片内供应商信息 */
    .card-body > div[style*="margin: 0.75rem"] {
        margin: 0.5rem 0 !important;
        font-size: 0.75rem !important;
    }
    
    .card-body > div[style*="margin: 0.75rem"] > div {
        display: none !important;
    }
    .card-body > div[style*="margin: 0.75rem"] > div:first-child {
        display: block !important;
    }
    
    .card-footer {
        flex-direction: column !important;
        gap: 8px !important;
        align-items: stretch !important;
        padding-top: 8px !important;
        margin-top: 8px !important;
    }
    
    .card-footer strong {
        font-size: 1rem !important;
    }
    
    .card-footer .btn {
        width: 100% !important;
        text-align: center !important;
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    
    /* ===== 广告Banner ===== */
    div[style*="height: 200px"][style*="border-radius: 12px"][style*="overflow: hidden"] {
        height: 120px !important;
        border-radius: 8px !important;
    }
    
    div[style*="height: 200px"] h2,
    div[style*="height: 200px"] h3 {
        font-size: 1rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    div[style*="height: 200px"] p {
        font-size: 0.75rem !important;
        margin-bottom: 0.5rem !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    /* ===== 分类专区 ===== */
    div[style*="margin-bottom: 3rem"] {
        margin-bottom: 1.5rem !important;
    }
    
    /* 子分类标签 */
    div[style*="display: flex"][style*="flex-wrap: wrap"][style*="gap: 0.5rem"][style*="margin-bottom: 1.5rem"] {
        gap: 6px !important;
        margin-bottom: 1rem !important;
    }
    
    div[style*="display: flex"][style*="flex-wrap: wrap"][style*="gap: 0.5rem"] a[style*="border-radius: 20px"] {
        padding: 4px 10px !important;
        font-size: 11px !important;
    }
    
    /* 分类专区内的广告卡片 */
    .grid-5 > div[style*="min-height: 280px"] {
        display: none !important;
    }
    
    /* ===== 按钮 ===== */
    .btn {
        padding: 8px 16px !important;
        font-size: 13px !important;
    }
    
    .btn-large {
        padding: 10px 20px !important;
        font-size: 14px !important;
    }
    
    .btn-small {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
    
    .btn-outline {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
    
    /* ===== 面包屑 ===== */
    .breadcrumb {
        font-size: 12px !important;
        padding: 10px 0 !important;
        flex-wrap: wrap;
    }
    
    /* ===== 分页 ===== */
    .pagination {
        flex-wrap: wrap;
        gap: 4px !important;
    }
    
    .pagination a,
    .pagination span {
        min-width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
        padding: 0 8px !important;
    }
    
    /* ===== 图片搜索弹窗 ===== */
    .img-search-modal > div {
        margin: 1rem !important;
        padding: 1.25rem !important;
        max-width: calc(100% - 2rem) !important;
    }
    
    .img-search-box h3 {
        font-size: 1.125rem !important;
    }
    
    .img-upload-area {
        padding: 24px 16px !important;
    }
    
    /* ===== 浮动组件 ===== */
    #chat-widget,
    div[id*="chat"][style*="position: fixed"] {
        bottom: 10px !important;
        right: 10px !important;
    }
    
    #compare-bar {
        bottom: 60px !important;
        right: 10px !important;
        min-width: 150px !important;
        padding: 10px !important;
        font-size: 12px !important;
    }
    
    /* ===== 用户菜单 ===== */
    .hd-menu {
        right: 0 !important;
        min-width: 150px !important;
    }
    
    .hd-avatar {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }
    
    /* ===== 语言提示 ===== */
    .lang-notice {
        padding: 10px 12px !important;
        font-size: 12px !important;
    }
    
    .lang-notice-content {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .lang-notice-actions {
        width: 100%;
        justify-content: center;
    }
    
    /* ===== 产品详情页 ===== */
    div[style*="grid-template-columns: 1fr 1fr"][style*="gap: 2rem"],
    div[style*="grid-template-columns: 1fr 1fr"][style*="gap: 3rem"] {
        display: block !important;
    }
    
    /* ===== 供应商详情 ===== */
    div[style*="grid-template-columns: 1fr 320px"],
    div[style*="grid-template-columns: 2fr 1fr"] {
        display: block !important;
    }
}

/* ========================================
   超小屏幕 (< 480px)
======================================== */
@media (max-width: 480px) {
    .container-wide {
        padding: 0 10px !important;
    }
    
    /* 产品网格保持2列 */
    .grid-5,
    .grid-4,
    .grid-3 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    .grid-2 {
        grid-template-columns: 1fr !important;
    }
    
    /* 卡片图片更小 */
    .card-img {
        height: 120px !important;
    }
    
    /* Banner更小 */
    .hero-carousel,
    div[style*="height: 600px"] {
        height: 180px !important;
    }
    
    /* 统计数字 */
    div[style*="font-size: 2.5rem"][style*="font-weight: 700"],
    div[style*="font-size: 1.5rem"][style*="font-weight: 700"] {
        font-size: 1.25rem !important;
    }
}

/* ========================================
   横屏手机
======================================== */
@media (max-width: 896px) and (orientation: landscape) {
    .hero-carousel,
    div[style*="height: 600px"] {
        height: 200px !important;
    }
    
    .grid-5,
    .grid-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .mobile-nav {
        top: 50px !important;
    }
}

/* ========================================
   触摸设备优化
======================================== */
@media (hover: none) and (pointer: coarse) {
    /* 增大点击区域 */
    .btn,
    .mobile-nav a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 禁用hover效果 */
    .card:hover {
        transform: none !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    }
    
    .btn:hover {
        transform: none !important;
    }
    
    /* 分类弹出菜单在触摸设备隐藏 */
    .category-flyout {
        display: none !important;
    }
}

/* ========================================
   打印样式
======================================== */
@media print {
    .hd,
    .search-bar,
    .footer,
    .site-footer,
    #chat-widget,
    #compare-bar,
    .mobile-menu-btn,
    .mobile-nav,
    .mobile-category-bar,
    .mobile-filter-bar {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        color: #000;
        background: #fff;
    }
}

/* ========================================
   减少动画（无障碍）
======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
