/* ----------------------------------------------------------------
   styles.css - 基础布局、头部、侧边栏、商品列表
---------------------------------------------------------------- */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* 🛡️ 全局禁止图片选中 (User Select None) */
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
    padding-bottom: 70px; /* 为底部购物车栏留出空间 */
}

/* 🛡️ 保护所有图片不被选中 (Anti-Selection) */
img, canvas {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none; /* iOS Safari 禁止长按弹出菜单 */
}

html, body {
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

/* --- 顶部搜索栏 --- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: white;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 10px 15px;
    padding-top: max(10px, env(safe-area-inset-top));
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-container {
    flex: 1;
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #333;
    border-radius: 24px;
    padding: 6px 12px;
    transition: all 0.3s ease;
}

.search-container:focus-within {
    border-color: #ff6b35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.search-icon {
    color: #333;
    flex-shrink: 0;
    margin-right: 8px;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    background: transparent;
    padding: 2px 0;
    color: #333;
    width: 100%;
}

/* --- 语言切换 --- */
.language-wrapper {
    position: relative;
    display: inline-block;
}

.lang-toggle {
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
}

.lang-toggle:active, 
.lang-toggle:hover {
    background: #f0f0f0;
}

.lang-dropdown {
    display: none;
    position: absolute;
    top: 115%;
    right: 0; 
    background-color: white;
    width: auto; 
    min-width: 130px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border-radius: 10px;
    padding: 6px 0;
    z-index: 2000;
    border: 1px solid #f0f0f0;
}

.lang-dropdown.show {
    display: block;
    animation: menuFadeIn 0.2s ease-out;
}

.lang-option {
    padding: 10px 16px; 
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-align: left;
    border-left: 3px solid transparent; 
}

.lang-option:hover {
    background-color: #f5f5f5; 
}

.lang-option.active {
    background-color: #f0f8ff; 
    color: #333; 
    font-weight: 600; 
    border-left-color: transparent; 
}

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

/* --- 主布局 --- */
.main-container {
    display: flex;
    margin-top: 70px;
    height: calc(100vh - 140px); /* 减去头部和可能的底部空间 */
}

.category-nav {
    width: 85px;
    background: white;
    overflow-y: auto;
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
    padding-bottom: 20px;
    z-index: 90;
    flex-shrink: 0;
}

.category-item {
    padding: 15px 5px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    border-bottom: 1px solid #f5f5f5;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    line-height: 1.2;
}

.category-item.active {
    background: #ff6b35;
    color: white;
    font-weight: bold;
}

/* --- 骨架屏样式 --- */
@keyframes skeleton-loading {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.skeleton-bg {
    background: linear-gradient(90deg, #f0f0f0 25%, #e6e6e6 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
}

.category-skeleton {
    width: 60px;
    height: 30px;
    margin: 15px auto;
    border-radius: 4px;
    background: #f0f0f0;
}

.skeleton-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
    height: 100%; 
}
.skeleton-image {
    width: 100%;
    padding-top: 100%;
    background: #e0e0e0; 
    position: relative;
    overflow: hidden;
}
.skeleton-image::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0) 100%);
    transform: translateX(-100%);
    animation: shimmer 1.5s infinite;
}
.skeleton-text {
    height: 14px;
    margin: 10px;
    border-radius: 4px;
    background: #f0f0f0;
}
.skeleton-text.short { width: 60%; }
.skeleton-text.price { width: 40%; height: 18px; margin-top: 15px; }

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

/* --- 商品列表与卡片 --- */
.product-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    padding-bottom: 80px;
    -webkit-overflow-scrolling: touch;
    background: #f5f5f5;
}

.subcategory-section {
    margin-bottom: 25px;
}

.subcategory-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 12px;
    padding: 0 5px;
    color: #333;
}

.subcategory-tabs {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 5px 5px 15px 5px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.subcategory-tabs::-webkit-scrollbar { display: none; }

.sub-tab {
    -webkit-appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    min-width: fit-content;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 20px;
    background: white;
    color: #999;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.sub-tab:active { transform: scale(0.98); }

.sub-tab.active {
    background: #ff6b35;
    color: #fff;
    border-color: transparent;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(255, 107, 53, 0.3);
}

.subcategory-title .page-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    margin-top: 10px;
    padding-bottom: 5px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
}
.subcategory-title .page-tabs::-webkit-scrollbar { 
    display: none;
}

.page-tab {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    min-width: 60px;
    max-width: 150px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 16px;
    background: white;
    color: #666;
    border: 1px solid #eee;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
}

.page-tab.active {
    background: #ff6b35;
    color: #fff;
    border-color: #ff6b35;
    box-shadow: 0 2px 6px rgba(255, 107, 53, 0.2);
    font-weight: 600;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    align-items: stretch; 
}

.product-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    height: 100%; 
    justify-content: space-between;
}
.product-card:active { transform: scale(0.98); }

.product-image {
    width: 100%;
    padding-top: 100%;
    height: 0;
    background: #f9f9f9;
    position: relative;
    overflow: hidden;
    flex-shrink: 0; 
    /* 🛡️ 禁止右键和拖拽的辅助 */
    pointer-events: auto; 
}

/* === 🛡️ 列表页 CSS 水印效果 (已更新为大 LOGO 风格) === */
.product-image::after {
    content: "";
    
    position: absolute;
    inset: 0; 
    pointer-events: none; 
    z-index: 2;

    /* 1. 改为单个不重复 */
    background-repeat: no-repeat;
    background-position: center;

    /* 2. 调整大小：手机端单个封面较小，设置为 110px 比较合适 */
    background-size: 110px 110px;

    /* 3. 透明度 */
    opacity: 0.16;

    /* 4. 使用大号字体的 SVG (font-size='22') 以匹配弹窗风格 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Ctext x='50%25' y='50%25' dy='.35em' text-anchor='middle' font-family='Arial, sans-serif' font-weight='bold' font-size='22' transform='rotate(-45 50 50)' fill='%23000000'%3E NGH %3C/text%3E%3C/svg%3E");
}

.product-image img {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease-in;
    z-index: 1;
    /* 🛡️ 确保图片不能被拖拽 */
    pointer-events: none;
}
.product-image img.loaded {
    opacity: 1;
}

.product-info {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 14px;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 36px;
}

.product-spec {
    font-size: 11px;
    color: #999;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 16px;
}

.product-price {
    font-size: 18px;
    color: #ff6b35;
    font-weight: 800;
    margin-bottom: 8px;
    line-height: 1;
    letter-spacing: -0.5px;
}

.product-variant-wrapper {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; 
}

.product-variant-wrapper:empty {
    margin-bottom: 0;
    display: none;
}

.variant-selector { 
    width: 100%;
}

.variant-label { display: none; } 

.variant-options { 
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.variant-option {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    background-color: #f9f9f9;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.variant-option.selected {
    border-color: #ff6b35;
    background-color: #fff0eb; 
    color: #ff6b35;
    font-weight: 600;
}

.cart-control-container {
    margin-top: auto;
    width: 100%;
}

/* --- 桌面端/平板端 适配 --- */
@media (min-width: 1024px) {
    .header-inner {
        max-width: 1200px;
        margin: 0 auto;
    }
    .main-container {
        max-width: 1200px;
        margin: 70px auto 0;
        height: calc(100vh - 70px); 
    }
    body {
        padding-bottom: 0;
    }
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    /* 电脑端 (Desktop): 封面大水印尺寸调整 */
    .product-image::after {
        background-size: 160px 160px;
    }
}