/* ===== 分類頁面手機版優化 ===== */

/* 手機版分類頁面佈局 */
@media (max-width: 768px) {

    /* 禁用 body 滾動，只保留內部滾輪 */
    html, body {
        overflow: hidden !important;
        height: 100vh;
        position: fixed;
        width: 100%;
    }

    /* 移除原有的標題區域 */
    .category-header {
        display: none;
    }

    /* 主要容器 - 使用彈性計算避免與公告重疊 */
    .category-mobile-container {
        display: flex;
        overflow: hidden;
        position: fixed;
        /* 
         * 手機版高度計算:
         * - Header: 15px (padding-top) + 40px (content) + 15px (padding-bottom) = 70px
         * - Announcement: 10px (padding-top) + 28px (content) + 10px (padding-bottom) + 2px (border) = 50px
         * - 總計: 120px（但 Announcement 已隱藏，實際只需 70px）
         * - 底部導航欄: 60px
         */
        top: 70px;
        left: 0;
        right: 0;
        bottom: 60px;
        background: white;
        z-index: 50;
    }

    /* 左側分類列表 */
    .category-sidebar {
        width: 90px;
        background: #f8f8f8;
        border-right: 1px solid #eee;
        overflow-y: auto;
        overflow-x: hidden;
        flex-shrink: 0;
        -webkit-overflow-scrolling: touch;
    }

    .category-list {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .category-list-item {
        padding: 16px 8px;
        text-align: center;
        cursor: pointer;
        border-bottom: 1px solid #eee;
        transition: all 0.2s;
        position: relative;
        background: #f8f8f8;
    }

    .category-list-item:active {
        background: #f0f0f0;
    }

    .category-list-item.active {
        background: white;
        color: var(--primary-color);
        font-weight: 600;
    }

    .category-list-item.active::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 3px;
        background: var(--primary-color);
    }

    .category-icon {
        font-size: 22px;
        margin-bottom: 6px;
        display: block;
    }

    .category-name {
        font-size: 11px;
        display: block;
        word-break: keep-all;
        line-height: 1.3;
    }

    /* 右側商品列表 */
    .category-products {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        background: white;
        -webkit-overflow-scrolling: touch;
    }

    /* 商品列表項 */
    .product-list-mobile {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .product-list-item {
        display: flex;
        padding: 12px;
        border-bottom: 1px solid #f0f0f0;
        cursor: pointer;
        transition: background 0.2s;
        background: white;
    }

    .product-list-item:active {
        background: #f8f8f8;
    }

    /* 商品圖片 */
    .product-image-wrapper {
        width: 95px;
        height: 95px;
        flex-shrink: 0;
        margin-right: 12px;
        border-radius: 8px;
        overflow: hidden;
        background: #f5f5f5;
        border: 1px solid #f0f0f0;
    }

    .product-image-wrapper img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* 商品資訊 */
    .product-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-width: 0;
        padding: 2px 0;
    }

    .product-title {
        font-size: 14px;
        font-weight: 500;
        color: var(--text-primary);
        margin-bottom: 6px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-height: 1.4;
    }

    .product-tags {
        display: flex;
        gap: 5px;
        margin-bottom: 8px;
        flex-wrap: wrap;
    }

    .product-tag {
        font-size: 10px;
        padding: 2px 8px;
/*        background: var(--bg-primary-lightest);*/
        color: var(--primary-color);
        border-radius: 4px;
        font-weight: 500;
    }

    .product-tag .origin-tag {
        font-size: 10px;
        padding: 2px 8px;
        border-radius: 4px;
        font-weight: 500;
    }
    
    .product-tag .origin-tag.overseas {
        background: #eddaf1;
        color: #9C27B0;
    }
    
    .product-tag .origin-tag.domestic {
        background: var(--bg-primary-lightest);
        color: var(--primary-color);
    }

    .product-bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: auto;
    }

    .product-price {
        display: flex;
        align-items: baseline;
        gap: 6px;
        flex-wrap: wrap;
    }

    .price-current {
        font-size: 18px;
        font-weight: 700;
        color: #f44336;
    }

    .price-original {
        font-size: 12px;
        color: var(--text-tertiary);
        text-decoration: line-through;
    }

    .product-add-btn {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: var(--primary-color);
        border: none;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s;
        flex-shrink: 0;
        box-shadow: var(--shadow-primary);
    }

    .product-add-btn:active {
        transform: scale(0.92);
        background: var(--primary-hover);
    }

    .product-add-btn i {
        font-size: 16px;
    }

    /* 載入中狀態 */
    .loading-mobile {
        text-align: center;
        padding: 50px 20px;
        color: var(--text-tertiary);
    }

    .loading-mobile i {
        font-size: 36px;
        margin-bottom: 12px;
        display: block;
        color: var(--primary-color);
    }

    .loading-mobile div {
        font-size: 14px;
    }

    /* 空狀態 */
    .empty-mobile {
        text-align: center;
        padding: 80px 20px;
        color: var(--text-tertiary);
    }

    .empty-mobile i {
        font-size: 56px;
        margin-bottom: 16px;
        display: block;
        color: #ddd;
    }

    .empty-mobile h3 {
        font-size: 16px;
        margin-bottom: 8px;
        color: var(--text-secondary);
        font-weight: 600;
    }

    .empty-mobile p {
        font-size: 14px;
        color: var(--text-tertiary);
    }

    /* 隱藏桌面版元素 */
    .results-header,
    .pagination,
    .product-grid,
    .category-products-section {
        display: none !important;
    }

    /* 調整主容器 */
    .category-container {
        padding: 0 !important;
    }
}

/* 桌面版隱藏手機版元素 */
@media (min-width: 769px) {
    .category-mobile-container {
        display: none !important;
    }
}

/* 滾動條樣式（針對手機版分類側邊欄） */
@media (max-width: 768px) {
    .category-sidebar::-webkit-scrollbar {
        width: 3px;
    }

    .category-sidebar::-webkit-scrollbar-track {
        background: #f8f8f8;
    }

    .category-sidebar::-webkit-scrollbar-thumb {
        background: #ddd;
        border-radius: 3px;
    }

    .category-products::-webkit-scrollbar {
        width: 4px;
    }

    .category-products::-webkit-scrollbar-track {
        background: #fafafa;
    }

    .category-products::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 4px;
    }
}