/* Shop Page Styles - Based on spudcrunch.com/shop/ */

/* 防止横向滚动和空白区域 */
html, body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

* {
    box-sizing: border-box;
}

/* 确保页面内容区域有正确的padding-top，避免被固定头部遮挡 */
.content-area {
    padding-top: 90px; /* 头部高度 */
}

/* Breadcrumb */
.breadcrumb-nav {
    padding: 15px 0;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
}

.breadcrumb-nav .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.breadcrumb-nav a {
    color: #666;
    text-decoration: none;
}

.breadcrumb-nav a:hover {
    color: var(--fs-color-primary);
}

.breadcrumb-nav span {
    color: #333;
}

/* Shop Header */
.shop-header {
    padding: 20px 0;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
}

.shop-header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.shop-header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.shop-result-count {
    display: none; /* 隐藏结果计数，让排序框居中 */
}

.shop-result-count {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.shop-ordering {
    margin: 0;
}

.orderby {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    min-width: 200px;
}

.orderby:focus {
    outline: none;
    border-color: var(--fs-color-primary);
}

/* Shop Content */
.shop-content {
    padding: 30px 0;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.shop-content .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

.shop-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

/* Sidebar */
.shop-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: #f9f9f9;
    padding: 20px;
    border-radius: 4px;
}

.sidebar-header-mobile {
    display: none;
}

.sidebar-title-desktop {
    display: block;
}

.sidebar-close-mobile {
    display: none;
}

.filter-overlay {
    display: none;
}

.widget-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 20px 0;
    color: #4a4a4a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.price-filter {
    margin: 0;
}

/* 价格范围滑块容器 */
.price-range-slider-wrapper {
    margin-bottom: 20px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    min-height: 40px !important;
    position: relative !important;
}

.price-range-slider {
    position: relative !important;
    height: 40px !important;
    margin: 20px 0 !important;
    width: 100% !important;
    display: block !important;
    visibility: visible !important;
}

.price-range-track {
    position: absolute !important;
    top: 50% !important;
    left: 0 !important;
    right: 0 !important;
    height: 6px !important;
    background: #e0e0e0 !important;
    border-radius: 3px !important;
    transform: translateY(-50%) !important;
    z-index: 1 !important;
    display: block !important;
    visibility: visible !important;
}

.price-range-progress {
    position: absolute !important;
    height: 6px !important;
    background: #4a4a4a !important;
    border-radius: 3px !important;
    left: 0% !important;
    right: 0% !important;
    transition: all 0.1s ease !important;
    z-index: 1 !important;
    display: block !important;
    visibility: visible !important;
}

.price-range-input {
    position: absolute !important;
    top: 50% !important;
    width: 100% !important;
    height: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    outline: none !important;
    cursor: pointer !important;
    transform: translateY(-50%) !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    z-index: 2 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    border: none !important;
}

.price-range-input::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 18px !important;
    height: 18px !important;
    background: #4a4a4a !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    border: 2px solid #fff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.2s ease !important;
    margin-top: -6px !important;
}

.price-range-input::-webkit-slider-thumb:hover {
    background: #333 !important;
    transform: scale(1.1) !important;
}

.price-range-input::-moz-range-thumb {
    width: 18px !important;
    height: 18px !important;
    background: #4a4a4a !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    border: 2px solid #fff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.2s ease !important;
}

.price-range-input::-moz-range-thumb:hover {
    background: #333 !important;
    transform: scale(1.1) !important;
}

.price-range-input::-ms-thumb {
    width: 18px !important;
    height: 18px !important;
    background: #4a4a4a !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    border: 2px solid #fff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

.price-range-input::-webkit-slider-runnable-track {
    height: 6px !important;
    background: transparent !important;
    border: none !important;
    -webkit-appearance: none !important;
}

.price-range-input::-moz-range-track {
    height: 6px !important;
    background: transparent !important;
    border: none !important;
    -moz-appearance: none !important;
}

.price-range-input::-ms-track {
    height: 6px !important;
    background: transparent !important;
    border-color: transparent !important;
    color: transparent !important;
    -ms-appearance: none !important;
}

/* 确保滑块在移动端也可见 */
@media (max-width: 768px) {
    .price-range-slider-wrapper {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        margin-bottom: 20px !important;
    }
    
    .price-range-slider {
        height: 40px !important;
        margin: 20px 0 !important;
    }
    
    .price-range-input {
        height: 40px !important;
        z-index: 10 !important;
    }
}

.price-filter-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}

.price-filter-button {
    padding: 10px 20px;
    background: #4a4a4a;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.3s;
    white-space: nowrap;
}

.price-filter-button:hover {
    background: #333;
}

.price-filter-result {
    margin: 0;
    padding: 0;
    font-size: 14px;
    color: #4a4a4a;
    font-weight: 500;
}

/* Products Grid */
.shop-products {
    flex: 1;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.products {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
    align-items: start;
}

.products.columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.product {
    margin: 0;
    padding: 0;
}

.product-small.box {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    transition: none !important;
    height: auto !important;
    min-height: auto !important; /* 改为auto，允许高度自适应 */
    display: flex;
    flex-direction: column;
    box-shadow: none !important;
}

.product-small.box:hover {
    box-shadow: none !important;
    transform: none !important;
}

.box-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
}

.box-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-small.box:hover .box-image img {
    transform: scale(1.05);
}

.quick-view-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.product-small.box:hover .quick-view-wrapper {
    opacity: 1;
}

.quick-view-button {
    background: #fff;
    color: #333;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.quick-view-button:hover {
    background: var(--fs-color-primary);
    color: white;
}

.box-text-products {
    padding: 15px 0 !important;
    flex: 0 0 auto !important; /* 改为不扩展，只占据需要的高度 */
    display: flex;
    flex-direction: column;
    gap: 8px !important; /* 增加间距，防止标题和价格重叠 */
    background: transparent !important;
    min-height: auto;
}

.title-wrapper {
    margin-bottom: 0 !important; /* 移除底部margin，使用gap统一间距 */
    flex: 0 0 auto !important; /* 改为不扩展 */
    min-height: 0; /* 允许flex子元素缩小 */
    overflow: hidden; /* 防止内容溢出 */
}

.product-description {
    margin: 0 !important; /* 移除所有margin，使用gap统一间距 */
    padding: 0;
    flex: 0 0 auto !important; /* 改为不扩展 */
    min-height: 0; /* 允许flex子元素缩小 */
}

.product-desc-text {
    font-size: 13px;
    color: #666;
    line-height: 1.6;
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.product-cat {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    margin: 0 0 5px 0;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.product-title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    line-height: 1.3 !important; /* 减小行高，让内容更紧凑 */
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    overflow-wrap: break-word;
    /* 限制标题高度，超出部分用省略号 */
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important; /* 最多显示2行 */
    line-clamp: 2 !important; /* 标准属性 */
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-height: calc(14px * 1.3 * 2) !important; /* 2行的高度：14px * 1.3行高 * 2行 = 36.4px */
    min-height: calc(14px * 1.3) !important; /* 最小高度：至少1行 = 18.2px */
    flex-shrink: 0 !important; /* 防止被压缩 */
    position: relative !important; /* 确保定位上下文 */
    z-index: 1 !important; /* 确保在价格上方 */
    width: 100% !important; /* 确保宽度100% */
    box-sizing: border-box !important;
}

.product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s;
}

.product-title a:hover {
    color: var(--fs-color-primary);
}

.product-title-text,
.name {
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    overflow-wrap: break-word;
    margin: 0 !important;
    padding: 0;
    line-height: 1.3 !important; /* 确保行高一致 */
    display: block; /* 确保是块级元素 */
}

.price-wrapper {
    margin-top: 0 !important; /* 移除顶部margin，使用gap统一间距 */
    margin-bottom: 0 !important; /* 移除底部margin */
    flex: 0 0 auto !important; /* 改为不扩展 */
    min-height: 24px !important; /* 确保价格区域有足够高度，防止被挤压 */
    display: flex !important;
    align-items: center !important; /* 垂直居中对齐价格 */
    position: relative !important; /* 确保定位上下文 */
    z-index: 2 !important; /* 确保在标题下方 */
    clear: both !important; /* 清除浮动 */
}

.price {
    display: inline-flex;
    align-items: baseline; /* 基线对齐，确保原价和现价在同一行 */
    flex-wrap: wrap; /* 如果空间不足，允许换行 */
    gap: 5px; /* 原价和现价之间的间距 */
    line-height: 1.2; /* 确保行高足够 */
}

.price del {
    color: #999;
    text-decoration: line-through;
    font-size: 13px;
    margin-right: 0; /* 移除margin，使用gap */
    flex-shrink: 0; /* 防止被压缩 */
}

.price ins {
    text-decoration: none;
    color: #333;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0; /* 防止被压缩 */
}

/* Pagination */
.woocommerce-pagination {
    margin-top: 40px;
    text-align: center;
}

.page-numbers {
    list-style: none;
    margin: 0;
    padding: 0;
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.page-numbers li {
    margin: 0;
    padding: 0;
}

.page-numbers a,
.page-numbers span {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    min-width: 40px;
    text-align: center;
    transition: all 0.3s;
}

.page-numbers a:hover {
    background: var(--fs-color-primary);
    color: white;
    border-color: var(--fs-color-primary);
}

.page-numbers .current {
    background: var(--fs-color-primary);
    color: white;
    border-color: var(--fs-color-primary);
}

.page-numbers .dots {
    border: none;
    cursor: default;
}

/* Responsive */
@media (max-width: 1024px) {
    .products.columns-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .shop-layout {
        flex-direction: column;
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .shop-sidebar {
        width: 100%;
        display: none; /* 默认隐藏侧边栏 */
    }
    
    .shop-sidebar.active {
        display: block; /* 点击筛选按钮时显示 */
    }
    
    .shop-products {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .products.columns-3 {
        grid-template-columns: repeat(2, 1fr) !important; /* 手机端2列网格 */
        gap: 15px;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .shop-header-content {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        width: 100%;
    }
    
    .shop-ordering {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .orderby {
        width: 100%;
        max-width: 300px;
    }
    
    .shop-result-count {
        display: block; /* 手机端显示结果计数 */
        text-align: center;
        width: 100%;
    }
    
    /* 手机端筛选按钮 - 无边框样式 */
    .mobile-filter-toggle {
        display: flex !important;
        align-items: center;
        gap: 8px;
        padding: 8px 0;
        background: transparent !important;
        border: none !important;
        border-radius: 0;
        font-size: 14px;
        font-weight: 600;
        color: #333;
        cursor: pointer;
        margin-bottom: 10px;
        width: 100%;
        justify-content: center;
        box-shadow: none !important;
    }
    
    .mobile-filter-toggle .filter-icon {
        width: 18px;
        height: 14px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        position: relative;
    }
    
    .mobile-filter-toggle .filter-icon span {
        height: 2px;
        background: #333;
        border-radius: 1px;
        display: block;
    }
    
    .mobile-filter-toggle .filter-icon span:nth-child(1) {
        width: 60%;
    }
    
    .mobile-filter-toggle .filter-icon span:nth-child(2) {
        width: 100%;
    }
    
    .mobile-filter-toggle .filter-icon span:nth-child(3) {
        width: 80%;
    }
    
    /* 手机端侧边栏样式 */
    .shop-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px !important;
        height: 100vh;
        z-index: 10000;
        background: #fff;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease;
        overflow-y: auto;
        padding: 20px;
    }
    
    .shop-sidebar.active {
        left: 0;
    }
    
    .sidebar-header-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .sidebar-title-desktop {
        display: none !important;
    }
    
    .sidebar-close-mobile {
        display: block;
        background: none;
        border: none;
        font-size: 24px;
        color: #666;
        cursor: pointer;
        padding: 0;
        width: 30px;
        height: 30px;
        line-height: 30px;
        text-align: center;
    }
    
    .filter-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
    }
    
    .filter-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* 商品卡片手机端优化 */
    .product-small.box {
        border-radius: 0 !important;
    }
    
    .box-image {
        border-radius: 0 !important;
    }
    
    .box-text-products {
        padding: 12px 0 !important;
        gap: 8px !important; /* 确保移动端也有间距 */
    }
    
    .product-cat {
        font-size: 10px;
        margin-bottom: 0 !important; /* 移除底部margin，使用gap统一间距 */
    }
    
    .product-title {
        font-size: 13px !important;
        line-height: 1.3 !important;
        margin-bottom: 0 !important; /* 移除底部margin，使用gap统一间距 */
        max-height: calc(13px * 1.3 * 2) !important; /* 2行的高度 */
        min-height: calc(13px * 1.3) !important; /* 最小高度：至少1行 */
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        flex-shrink: 0 !important;
    }
    
    .price-wrapper {
        margin-top: 0 !important;
        min-height: 24px !important;
    }
    
    .product-description {
        margin: 8px 0;
    }
    
    .product-desc-text {
        font-size: 12px;
    }
    
    .price {
        gap: 6px;
    }
    
    .price del {
        font-size: 11px;
    }
    
    .price ins {
        font-size: 14px;
    }
    
    /* 隐藏Quick View按钮在手机端 */
    .quick-view-wrapper {
        display: none;
    }
    
    /* 面包屑导航手机端 */
    .breadcrumb-nav {
        padding: 10px 0;
        font-size: 12px;
        text-align: center;
    }
    
    .breadcrumb-nav .container {
        text-align: center;
    }
    
    /* 结果计数手机端 */
    .shop-result-count {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .products.columns-3 {
        grid-template-columns: repeat(2, 1fr); /* 保持2列 */
        gap: 12px;
    }
    
    .shop-content {
        padding: 15px 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    .shop-content .container {
        padding: 0 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        box-sizing: border-box !important;
    }
    
    .shop-layout {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .shop-products {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .products.columns-3 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .product-title {
        font-size: 12px !important;
        word-wrap: break-word;
        word-break: break-word;
        white-space: normal;
        overflow-wrap: break-word;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-height: calc(12px * 1.3 * 2) !important; /* 2行的高度 */
        min-height: calc(12px * 1.3) !important; /* 最小高度：至少1行 */
        flex-shrink: 0 !important;
    }
    
    .box-text-products {
        gap: 8px !important; /* 确保小屏也有间距 */
    }
    
    .price-wrapper {
        margin-top: 0 !important;
        min-height: 24px !important;
    }
    
    .mobile-filter-toggle {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .shop-result-count {
        font-size: 11px;
    }
    
    .orderby {
        font-size: 13px;
        padding: 7px 10px;
    }
}

/* PC端隐藏筛选按钮 */
@media (min-width: 769px) {
    .mobile-filter-toggle {
        display: none !important;
    }
    
    .shop-sidebar {
        position: static !important;
        left: auto !important;
        height: auto !important;
        box-shadow: none !important;
    }
    
    .sidebar-header-mobile {
        display: none !important;
    }
    
    .filter-overlay {
        display: none !important;
    }
}
