/* ========== 基础样式 & 全局变量 ========== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&family=Noto+Sans+SC:wght@400;500;700&display=swap');

/* 防闪屏：立即应用背景色（与渐变起始色一致） */
html {
    background-color: #f5f7fc;
    height: 100%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', 'Noto Sans SC', system-ui, sans-serif;
    background: linear-gradient(135deg, #f5f7fc 0%, #eef2f6 100%);
    color: #1f2937;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    opacity: 1;
    margin: 0;
    padding: 0;
    transition: background 0.1s ease;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

main {
    flex: 1;
}

/* 多语言文本初始隐藏，防止未翻译内容闪现 */
[data-i18n] {
    visibility: hidden;
}
body.loaded [data-i18n] {
    visibility: visible;
}

/* 产品容器最小高度，避免骨架屏加载时布局跳动 */
#products-container {
    min-height: 300px;
}

/* 骨架屏样式优化（无渐变背景，改用脉冲动画） */
.skeleton-card {
    background: #f0f0f0;
    border-radius: 1rem;
    overflow: hidden;
    animation: skeleton-pulse 1.2s ease-in-out infinite;
}

.skeleton-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #e0e0e0;
}

.skeleton-text {
    height: 1rem;
    background: #e0e0e0;
    margin: 0.5rem;
    border-radius: 4px;
}

@keyframes skeleton-pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* 产品卡片 - 更紧凑 */
.product-card {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05);
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -8px rgba(0,0,0,0.1);
}

.product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background-color: #f3f4f6;
    cursor: pointer;
}

/* 卡片内容区域的内边距减小 */
.product-card .p-3 {
    padding: 0.5rem !important;
}

/* 产品名称字体缩小 */
.product-card h3 {
    font-size: 0.85rem !important;
    font-weight: 600;
    margin-bottom: 0.2rem;
    line-height: 1.3;
}

/* 产品描述字体缩小、行数减少 */
.product-card .text-gray-500 {
    font-size: 0.7rem !important;
    line-height: 1.3;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 价格区域 */
.product-price {
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

/* 查看详情 + 加入购物车 区域 */
.product-card .mt-3 {
    margin-top: 0.5rem !important;
}
.product-card .text-blue-600,
.product-card .add-to-cart-quick {
    font-size: 0.7rem !important;
}
.product-card .add-to-cart-quick i {
    font-size: 0.65rem;
}

/* 产品网格布局 - 移动端默认2列 */
#products-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
}

/* 平板及以上改为3列，让卡片变小 */
@media (min-width: 768px) {
    #products-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.8rem;
    }
}

/* 桌面大屏幕改为4列，进一步缩小卡片尺寸 */
@media (min-width: 1024px) {
    #products-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
}

/* 超大屏幕改为5列（可选） */
@media (min-width: 1440px) {
    #products-container {
        grid-template-columns: repeat(5, 1fr);
        gap: 1rem;
    }
}

/* 分类滚动容器 */
.category-scroll-container {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}
.category-scroll-container::-webkit-scrollbar {
    height: 4px;
}
.filter-btn {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: 1rem;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #334155;
    transition: all 0.2s;
    cursor: pointer;
    font-weight: 500;
}
.filter-btn.active {
    background: #2563eb;
    color: white;
}
/* 修复：激活状态下图标不变白，仅文字变色 */
.filter-btn.active .category-icon-wrapper i,
.filter-btn.active .category-icon-wrapper img {
    /* 移除滤镜，保持原图标颜色 */
    filter: none;
}
.category-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
}
.category-icon-wrapper i {
    font-size: 42px;
}

/* 搜索框 */
.search-wrapper {
    position: relative;
    display: inline-block;
}
.search-input {
    border: 1px solid #e2e8f0;
    border-radius: 2.5rem;
    padding: 0.6rem 2rem 0.6rem 1.2rem;
    width: 100%;
    max-width: 280px;
    background: white;
    transition: all 0.2s;
    font-family: inherit;
}
.search-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1rem;
    display: none;
}
.search-clear:hover {
    color: #ef4444;
}

/* 购物车侧边栏 */
.inquiry-sidebar {
    position: fixed;
    right: -400px;
    top: 0;
    width: 380px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transition: right 0.3s;
    z-index: 1001;
    display: flex;
    flex-direction: column;
}
.inquiry-sidebar.open {
    right: 0;
}
.inquiry-header {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
}
.inquiry-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}
.inquiry-item {
    margin-bottom: 1rem;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 0.5rem;
}
.inquiry-footer {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
}
.float-inquiry-btn {
    position: fixed;
    bottom: 200px;
    right: 24px;
    background: #f59e0b;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    z-index: 1000;
}
.badge-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mobile-cart-bar {
    background: white;
    border-top: 1px solid #e5e7eb;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
@media (max-width: 768px) {
    .float-inquiry-btn { display: none; }
    .inquiry-sidebar { width: 100%; right: -100%; }
    .mobile-cart-bar { display: flex; }
}
@media (min-width: 769px) {
    .mobile-cart-bar { display: none; }
}

/* 模态框 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}
.modal-content {
    background: white;
    border-radius: 1.5rem;
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    position: relative;
}
#image-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
#modal-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 1rem;
}

/* 授权弹窗按钮组样式 */
#auth-modal .modal-content .flex {
    gap: 0.75rem;
}
#auth-modal button {
    font-weight: 500;
    transition: all 0.2s;
}
#auth-modal button:hover {
    transform: translateY(-1px);
    filter: brightness(0.95);
}

/* 面包屑 */
.breadcrumb {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 1.5rem;
}
.breadcrumb a {
    color: #3b82f6;
    text-decoration: none;
}
.animate-spin {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 悬浮按钮 */
.floating-buttons {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}
.floating-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.2s;
}
.floating-btn.whatsapp { background: #25D366; color: white; }
.floating-btn.backtotop { background: #2563eb; color: white; }

/* SKU表格样式优化 */
.sku-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    table-layout: auto;
}
.sku-table th, .sku-table td {
    border: 1px solid #e5e7eb;
    padding: 0.75rem;
    text-align: left;
    vertical-align: middle;
}
.sku-table th {
    background-color: #f8fafc;
    font-weight: 600;
    white-space: nowrap;
}
@media (max-width: 768px) {
    .sku-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: normal;
    }
    .sku-table tbody {
        display: table;
        width: 100%;
    }
    .sku-table th, .sku-table td {
        white-space: normal;
        word-break: normal;
        word-wrap: break-word;
        min-width: 80px;
    }
    .sku-qty {
        width: 50px !important;
    }
    .add-to-cart-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }
}
.hidden-sku-section {
    display: none !important;
}
.quantity-input {
    width: 70px;
    padding: 0.3rem;
    text-align: center;
}
.add-to-cart-btn {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: opacity 0.2s;
}
.add-to-cart-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.gallery-thumb {
    transition: all 0.2s ease;
    cursor: pointer;
    border: 2px solid transparent;
}
.gallery-thumb:hover {
    transform: scale(1.02);
    border-color: #3b82f6;
}
.gallery-thumb.active {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.3);
}
@media (max-width: 768px) {
    .mobile-cart-bar { display: flex; }
}
@media (min-width: 769px) {
    .mobile-cart-bar { display: none; }
}