/* ========== 购物车【专属独立样式】完全隔离，不与其他文件冲突 ==========
   关键原则：
   1. 不写 #mainPanel-cart 容器规则 → 让全局 <style> 块的 position: fixed 接管
   2. 所有规则都用 #homeCartList 前缀限定 → 不会污染其他面板
   3. 类名匹配 JS 实际渲染的 cart- 前缀
   4. 不使用 !important → 避免和全局规则冲突
   ================================================================ */

/* 核心滚动容器：绝对定位，100%滚动生效 */
#homeCartList {
    position: absolute;
    top: 0;                  /* 购物车面板无顶部顶栏，从 0 开始 */
    left: 0;
    right: 0;
    bottom: 106px;            /* 留出工具栏空间：56(Tab栏) + 50(工具栏) = 106 */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    background: #f5f5f5;
    -webkit-overflow-scrolling: touch;
}

/* 滚动条美化 */
#homeCartList::-webkit-scrollbar {
    width: 5px;
}
#homeCartList::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
#homeCartList::-webkit-scrollbar-track {
    background: transparent;
}

/* ========== 店铺分组 ========== */
#homeCartList .cart-shop-group {
    background: #fff;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}
#homeCartList .cart-shop-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #fafafa;
    border-bottom: 1px solid #eee;
}
#homeCartList .cart-shop-check {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
#homeCartList .cart-shop-name {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    margin: 0;
}

/* ========== 购物车单项布局（左右两列） ========== */
#homeCartList .cart-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #eee;
}
#homeCartList .cart-item:last-child {
    border-bottom: none;
}

/* ========== 列1：商品图片区（选择框+图片+原价+小计，纵向堆叠） ========== */
#homeCartList .cart-col1 {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 0 0 90px;
    flex-shrink: 0;
}
#homeCartList .cart-col1-top {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}
#homeCartList .cart-check {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
}
#homeCartList .cart-img-wrap {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    overflow: hidden;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}
#homeCartList .cart-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
#homeCartList .cart-original-price {
    font-size: 11px;
    color: #999;
    text-decoration: line-through;
    margin: 0;
    text-align: center;
}
#homeCartList .cart-subtotal {
    font-size: 16px;
    font-weight: 600;
    color: #e63946;
    margin: 0;
    text-align: center;
}

/* ========== 列2：右侧信息区（名称+删除+规格+促销+库存数量+备注） ========== */
#homeCartList .cart-col2 {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
#homeCartList .cart-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
#homeCartList .cart-row-name {
    justify-content: space-between;
    align-items: flex-start;
}
#homeCartList .cart-goods-name {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
    min-width: 0;
    margin: 0;
    word-break: break-all;
}
#homeCartList .cart-del-btn {
    background: #ff4d4f;
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
#homeCartList .cart-del-btn:hover {
    background: #ff7875;
}

/* 规格/促销/限购/库存 标签 */
#homeCartList .cart-spec-tag,
#homeCartList .cart-promo-tag,
#homeCartList .cart-limit-tag,
#homeCartList .cart-stock-tag {
    font-size: 12px;
    color: #888;
    margin: 0;
}
#homeCartList .cart-promo-tag {
    color: #ff6b35;
}
#homeCartList .cart-limit-tag {
    color: #ff9800;
}
#homeCartList .cart-stock-tag {
    color: #666;
}

/* 数量输入框 */
#homeCartList .cart-quantity-input {
    width: 70px;
    padding: 6px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}
#homeCartList .cart-quantity-input:focus {
    border-color: #0088ff;
}

/* 备注输入框 */
#homeCartList .cart-remark-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
    outline: none;
    box-sizing: border-box;
}
#homeCartList .cart-remark-input:focus {
    border-color: #0088ff;
}

/* 空购物车 */
#homeCartList .cart-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}

/* ========== 底部工具栏：全选 + 合计 + 去付款（一排） ========== */
#mainPanel-cart .cart-toolbar {
    position: absolute;     /* 相对 #mainPanel-cart 定位（购物车面板是 fixed 全屏） */
    left: 0;
    right: 0;
    bottom: 56px;           /* 避开底部 Tab 栏（Tab 栏 56px 高） */
    height: 50px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    padding: 0 12px;
    gap: 8px;
    z-index: 1000 !important;   /* 必须高于底部 Tab 栏的 900！ */
    box-shadow: 0 -2px 6px rgba(0,0,0,0.06);
    box-sizing: border-box;
}
#mainPanel-cart .cart-toolbar .check-all-btn {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto !important;   /* 不缩、不撑开、固定大小 */
    width: auto !important;
    max-width: none !important;
    transition: all 0.2s;
}
#mainPanel-cart .cart-toolbar .check-all-btn:hover {
    border-color: #0088ff;
    color: #0088ff;
}
#mainPanel-cart .cart-toolbar .total-price {
    flex: 1 1 0 !important;       /* 撑开剩余空间 */
    min-width: 0;
    font-size: 15px;
    color: #333;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}
#mainPanel-cart .cart-toolbar .total-price .total-amount {
    color: #e63946;
    font-size: 18px;
    font-weight: 600;
    margin-left: 4px;
}
#mainPanel-cart .cart-toolbar .pay-btn {
    background: #e63946;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 22px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto !important;   /* 不缩、不撑开、固定大小 */
    width: auto !important;
    max-width: none !important;
    transition: background 0.2s;
}
#mainPanel-cart .cart-toolbar .pay-btn:hover {
    background: #d63031;
}
#mainPanel-cart .cart-toolbar .pay-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ========== 移动端适配（≤767px） ========== */
@media (max-width: 767px) {
    #homeCartList {
        padding: 8px;
        top: 0;            /* 紧贴顶部 */
        bottom: 106px;     /* 留出工具栏空间 */
    }
    #homeCartList .cart-shop-group {
        margin-bottom: 8px;
    }
    #homeCartList .cart-shop-header {
        padding: 10px;
    }
    /* 手机端：单列堆叠（图片+信息上下排列） */
    #homeCartList .cart-item {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }
    #homeCartList .cart-col1 {
        flex-direction: row;
        align-items: center;
        width: 100%;
        flex: none;
        gap: 10px;
    }
    #homeCartList .cart-col1-top {
        width: auto;
    }
    #homeCartList .cart-img-wrap {
        width: 70px;
        height: 70px;
    }
    #homeCartList .cart-original-price,
    #homeCartList .cart-subtotal {
        text-align: left;
    }
    #homeCartList .cart-col2 {
        width: 100%;
        flex: none;
    }
    #homeCartList .cart-remark-input {
        padding: 8px;
        font-size: 13px;
    }
    #homeCartList .cart-quantity-input {
        width: 60px;
        padding: 8px;
        font-size: 16px;
    }
    #homeCartList .cart-del-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
}
