/* 主要样式文件 */

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

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f5f5f5;
    line-height: 1.6;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 0;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* 搜索区域 */
.search-container {
    background: white;
    padding: 20px;
    margin: 20px auto;
    max-width: 1200px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.search-box {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 16px; /* 防止iOS缩放 */
    outline: none;
    transition: border-color 0.3s;
    -webkit-appearance: none; /* 移除iOS默认样式 */
    -webkit-tap-highlight-color: transparent; /* 移除点击高亮 */
    touch-action: manipulation; /* 优化触摸响应 */
}

.search-input:focus {
    border-color: #667eea;
}

.search-btn {
    padding: 12px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s;
}

.search-btn:hover {
    transform: translateY(-2px);
}

/* 商品容器 */
.products-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

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

/* 商品卡片 */
.product-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s forwards;
}

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

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* 保持1:1比例 */
    overflow: hidden;
}

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

.product-card:hover .product-image {
    transform: scale(1.05);
}

.product-brand-overlay {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 2;
}

.product-time-overlay {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    padding: 4px 10px;
    font-size: 11px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 2;
}

.product-info {
    padding: 10px;
}

.product-title {
    font-size: 16px;
    color: #333;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.price-live {
    color: #e74c3c;
    font-size: 13px;
    font-weight: bold;
}

.commission {
    background: #f39c12;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.product-id {
    color: #666;
    font-size: 12px;
    margin-bottom: 10px;
}

.product-shop {
    color: #888;
    font-size: 12px;
    margin-bottom: 15px;
}

.shop-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.shop-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* 跨店铺搜索开关样式 */
.search-options {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
}

.search-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.product-shop {
    color: #888;
    font-size: 12px;
    margin-bottom: 15px;
}

.shop-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.shop-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* 跨店铺搜索开关样式 */
.search-options {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
}

.search-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.product-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.copy-id-btn {
    background: #f39c12;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
    flex: 1;
    text-align: center;
}

.copy-id-btn:hover {
    background: #e67e22;
    transform: translateY(-2px);
}

.product-link {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    text-decoration: none;
    transition: transform 0.2s;
    font-size: 14px;
    flex: 1;
    text-align: center;
}

.product-link:hover {
    transform: translateY(-2px);
}

/* 提示消息样式 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 无更多数据提示 */
.no-more {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s;
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2em;
    }

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

    .search-container {
        margin: 15px;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .products-container {
        padding: 0 10px;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .search-box {
        flex-direction: row;
        gap: 10px;
    }

    .search-input {
        flex: 1;
        margin-bottom: 0;
        font-size: 16px; /* 防止iOS自动缩放 */
        min-height: 44px; /* iOS推荐的最小触摸目标 */
        -webkit-user-select: text; /* 确保可以选择文本 */
        user-select: text;
    }

    .search-btn {
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* 手机端商品卡片优化 */
    .product-card {
        margin: 0;
    }

    .product-title {
        font-size: 12px;
        line-height: 1.3;
        height: 3.1em; /* 限制为3行 */
        overflow: hidden;
    }

    .product-price {
        font-size: 11px;
        margin: 8px 0;
    }

    .product-id {
        font-size: 10px;
        margin-bottom: 8px;
    }

    .product-shop {
        font-size: 10px;
        margin-bottom: 8px;
    }

    .product-actions {
        gap: 5px;
    }

    .copy-id-btn, .product-link {
        padding: 6px 10px;
        font-size: 11px;
    }

    .product-brand-overlay {
        font-size: 10px;
        padding: 3px 8px;
    }

    .product-time-overlay {
        font-size: 9px;
        padding: 2px 6px;
    }
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* 图片懒加载效果 */
.product-image {
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
                linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* 搜索建议样式 */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-suggestion-item {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.search-suggestion-item:hover {
    background-color: #f8f9fa;
}

.search-suggestion-item:last-child {
    border-bottom: none;
}

/* 商品卡片悬停效果增强 */
.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.product-card:hover::before {
    opacity: 1;
}

/* 价格闪烁效果 */
@keyframes priceGlow {
    0%, 100% { text-shadow: 0 0 5px rgba(231, 76, 60, 0.5); }
    50% { text-shadow: 0 0 20px rgba(231, 76, 60, 0.8); }
}

.price-live:hover {
    animation: priceGlow 2s infinite;
}

/* 加载骨架屏 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.skeleton-image {
    width: 100%;
    height: 250px;
}

.skeleton-content {
    padding: 20px;
}

.skeleton-line {
    height: 16px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.medium {
    width: 80%;
}

.skeleton-line.long {
    width: 100%;
}

/* 错误状态样式 */
.error-message {
    text-align: center;
    padding: 40px;
    color: #e74c3c;
    background: #fdf2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    margin: 20px;
}

.error-message h3 {
    margin-bottom: 10px;
    font-size: 18px;
}

.error-message p {
    margin-bottom: 15px;
}

.retry-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.retry-btn:hover {
    background: #c0392b;
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state img {
    width: 120px;
    height: 120px;
    opacity: 0.5;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #333;
}

.empty-state p {
    font-size: 16px;
    line-height: 1.6;
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s;
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}



/* 移动端优化 */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .product-card {
        border: 2px solid #000;
    }
    
    .search-input {
        border: 2px solid #000;
    }
    
    .product-link {
        background: #000;
        color: #fff;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
