/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
}

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

/* 头部样式 */
.header {
    background-color: #2c3e50;
    color: white;
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    font-size: 2rem;
    font-weight: bold;
}

/* 导航菜单 */
.nav-menu {
    background-color: #ecf0f1;
    position: sticky;
    top: 80px; /* 头部高度 */
    z-index: 999;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-items {
    display: flex;
}

.nav-item {
    display: inline-block;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-item.active {
    background-color: #3498db;
    color: white;
    font-weight: bold;
}

/* 搜索切换按钮 */
.toggle-filters-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
    margin: 0;
}

.toggle-filters-btn:hover {
    background-color: #2980b9;
}

/* 主体内容 */
.main {
    min-height: calc(100vh - 160px); /* 减去头部和底部高度 */
}

/* 搜索和筛选区域 - 固定在顶部 */
.filters {
    background-color: white;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky; /* Changed back to sticky */
    top: 140px; /* Adjusted to account for header and nav heights */
    z-index: 998;
    margin: 20px 0;
    border-radius: 8px;
    display: none; /* 默认隐藏 */
}

.filters.show {
    display: block; /* 显示搜索区域 */
}

.search-box {
    display: flex;
    margin-bottom: 15px;
}

.search-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    font-size: 1rem;
}

.search-btn {
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-size: 1rem;
}

.search-btn:hover {
    background-color: #2980b9;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.category-filter, .price-filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-select, .price-input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.filter-btn {
    padding: 8px 15px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.filter-btn:hover {
    background-color: #219653;
}

/* 商品列表 */
.products-container {
    padding: 20px 0;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.product-card {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    background: white;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: contain;
}

.product-info {
    padding: 15px;
}

.product-name {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 1rem;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.product-price {
    font-size: 1.1rem;
    color: #e74c3c;
    font-weight: bold;
}

.favorite-btn-list-inline {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #bdc3c7;
}

.favorite-btn-list-inline.favorited {
    color: #e74c3c;
}

.product-category {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* 加载更多 */
.load-more {
    text-align: center;
    margin-top: 30px;
}

.load-more-btn {
    padding: 12px 30px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.load-more-btn:hover {
    background-color: #2980b9;
}

.loading, .no-products {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

/* 商品详情 */
.breadcrumb {
    padding: 20px 0;
}

.back-button {
    padding: 10px 15px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.back-button:hover {
    background-color: #2980b9;
}

.product-detail {
    display: flex;
    gap: 30px;
    padding: 20px 0;
    flex-wrap: wrap;
}

.product-image-section {
    flex: 1;
    min-width: 300px;
}

.product-detail-image {
    width: 100%;
    border-radius: 8px;
    cursor: pointer;
}

.product-info-section {
    flex: 1;
    min-width: 300px;
}

.product-info-section .product-name {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.product-category {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #7f8c8d;
}

.product-price {
    font-size: 1.3rem;
    color: #e74c3c;
    margin-bottom: 20px;
}

.product-description h3, .product-keywords h3 {
    margin: 20px 0 10px 0;
    font-size: 1.1rem;
}

.keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.keyword-tag {
    background-color: #ecf0f1;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.product-actions {
    margin-top: 30px;
}

.favorite-btn {
    padding: 12px 25px;
    font-size: 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-color: #ecf0f1;
}

.favorite-btn.favorited {
    background-color: #e74c3c;
    color: white;
}

/* 我的收藏 */
.favorites-container {
    padding: 20px 0;
}

.favorites-container h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.favorite-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #eee;
    gap: 15px;
    transition: background-color 0.3s;
}

.favorite-item:hover {
    background-color: #f9f9f9;
}

.favorite-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    cursor: pointer;
}

.favorite-info {
    flex: 1;
    cursor: pointer;
}

.favorite-name {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 1rem;
}

.favorite-price {
    color: #e74c3c;
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.favorite-category {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.remove-favorite-btn {
    background: none;
    border: 1px solid #e74c3c;
    color: #e74c3c;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.remove-favorite-btn:hover {
    background: #e74c3c;
    color: white;
}

.no-favorites {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

/* 图片模态框 */
.modal {
    display: block;
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
}

.modal-content {
    display: block;
    margin: auto;
    max-width: 90%;
    max-height: 90%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #bbb;
}

/* 底部 */
.footer {
    background-color: #34495e;
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
    
    .header {
        padding: 15px 0;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .nav-menu {
        top: 70px;
    }
    
    .nav-container {
        flex-direction: row;
    }
    
    .nav-items {
        flex: 1;
    }
    
    .toggle-filters-btn {
        margin-left: 10px;
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .filters {
        top: 125px; /* Adjusted for mobile */
        padding: 15px;
        margin: 15px 0;
    }
    
    .filter-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .search-box {
        margin-bottom: 10px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .product-image {
        height: 150px;
    }
    
    .product-detail {
        flex-direction: column;
    }
    
    .product-info-section .product-name {
        font-size: 1.3rem;
    }
    
    .product-price {
        font-size: 1.2rem;
    }
    
    .favorites-container h2 {
        font-size: 1.3rem;
    }
}

/* Add specific styles for small screens to handle price filter better */
@media (max-width: 480px) {
    .filter-row {
        gap: 10px;
    }
    
    .category-filter, .price-filter {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    
    .category-select, .price-input {
        width: 100%;
    }
    
    .filter-btn {
        width: 100%;
    }
    
    .price-filter {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .price-input {
        flex: 1;
        min-width: 80px;
    }
}