/* ==========================================================================
   [DPS CUSTOM FIX] - 2026-10-15 - Dev: DPS
   Mục đích: Bộ giao diện chuẩn Giỏ Hàng Kamereo & Bách Hóa Xanh v3.0
             - Flexbox co giãn tự nhiên, không bao giờ vỡ chữ thành 1 ký tự
             - Ép padding 0 !important trên input để số lượng hiển thị rõ nét
             - Nút xóa thùng rác Lucide trash-2 độc lập (loại bỏ (x))
             - Loại bỏ hoàn toàn lỗi lặp đơn vị tính
             - Ẩn triệt để header desktop trên mobile (<= 768px)
             - Thanh Sticky Bottom Bar bám chặt chân màn hình Mobile
             - 100% Lucide SVG Icons - Tuyệt đối không emoji
   ========================================================================== */

/* 1. Reset & Khung tổng thể trang giỏ hàng */
.woocommerce-cart .site-content {
    background-color: #f8fafc !important;
    padding-top: 16px !important;
    padding-bottom: 40px !important;
}

.woocommerce-cart .freshio-breadcrumb,
.woocommerce-cart .entry-header {
    display: none !important;
}

.ksf-cart-container {
    max-width: 1200px !important;
    margin: 0 auto;
    padding: 0 16px !important;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* 2. Header giỏ hàng */
.ksf-cart-top-bar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 4px 0;
}

.ksf-cart-title-wrap {
    display: flex !important;
    align-items: center;
    gap: 10px;
}

.ksf-cart-main-title {
    font-size: 20px !important;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    display: flex !important;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.3px;
}

.ksf-cart-count-badge {
    background: #e6f4ea;
    color: #008848;
    font-size: 13px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
}

.ksf-cart-clear-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #ef4444 !important;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    background: #fef2f2 !important;
    border: 1px solid #fee2e2 !important;
    transition: all 0.2s ease !important;
}

.ksf-cart-clear-btn:hover {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fca5a5 !important;
}

/* 3. Layout 2 cột Desktop 70/30 */
.ksf-cart-layout-grid {
    display: flex !important;
    flex-direction: row !important;
    gap: 24px !important;
    align-items: flex-start;
}

.ksf-cart-col-left {
    flex: 1 1 68% !important;
    min-width: 0 !important;
}

.ksf-cart-col-right {
    flex: 0 0 32% !important;
    min-width: 320px !important;
    max-width: 380px !important;
    position: sticky !important;
    top: 90px !important;
    z-index: 10 !important;
}

/* 4. Form giỏ hàng & Danh sách sản phẩm phẳng */
.woocommerce-cart-form {
    width: 100% !important;
    margin: 0 !important;
}

.ksf-cart-items-list {
    width: 100% !important;
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

/* 5. Thẻ sản phẩm phẳng Desktop (Flexbox Kamereo) */
.ksf-cart-item-card {
    width: 100% !important;
    background: #ffffff;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 16px 20px !important;
    display: flex !important;
    flex-direction: row;
    align-items: center !important;
    justify-content: space-between;
    gap: 18px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
    box-sizing: border-box;
}

.ksf-cart-item-card:hover {
    border-color: #cbd5e1 !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05) !important;
}

/* 5.1. Thumbnail 72x72px */
.ksf-cart-item-thumb {
    flex: 0 0 72px;
    width: 72px !important;
    height: 72px !important;
    border-radius: 8px;
    overflow: hidden !important;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.ksf-cart-item-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    display: block !important;
}

/* 5.2. Cột thông tin chi tiết */
.ksf-cart-item-details {
    flex: 1 1 auto;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column;
    gap: 4px;
}

.ksf-cart-item-title-row {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
}

.ksf-cart-item-name {
    font-size: 15px !important;
    font-weight: 700;
    color: #1e293b !important;
    line-height: 1.4 !important;
    margin: 0;
    text-decoration: none;
    display: block !important;
    word-break: break-word;
    white-space: normal;
    transition: color 0.15s ease !important;
}

.ksf-cart-item-name:hover {
    color: #008848 !important;
}

.ksf-cart-item-meta-row {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 2px !important;
}

.ksf-cart-item-unit-price {
    font-size: 13.5px;
    font-weight: 600;
    color: #475569;
}

.ksf-cart-deal-badge {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    background: #fff7ed;
    border: 1px solid #ffedd5;
    color: #c2410c;
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
}

.ksf-cart-preorder-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    background: #eff6ff !important;
    border: 1px solid #dbeafe !important;
    color: #1d4ed8 !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    padding: 2px 7px !important;
    border-radius: 5px !important;
}

.ksf-cart-item-extra-meta {
    font-size: 12px !important;
    color: #059669 !important;
    font-weight: 600 !important;
    margin-top: 2px !important;
    line-height: 1.4 !important;
}

.ksf-cart-item-extra-meta p {
    margin: 2px 0 !important;
}

/* 5.3. Cụm Actions bên phải */
.ksf-cart-item-actions-cluster {
    display: flex !important;
    align-items: center !important;
    gap: 16px;
    flex-shrink: 0;
}

/* Bộ nút chọn số lượng Kamereo */
.ksf-cart-qty-control {
    display: inline-flex !important;
    align-items: center;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden !important;
    height: 34px !important;
    box-sizing: border-box;
}

.ksf-cart-qty-btn {
    width: 32px !important;
    height: 34px !important;
    border: none !important;
    background: #f8fafc !important;
    color: #334155 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease !important;
    padding: 0;
    margin: 0;
    outline: none !important;
    box-shadow: none;
}

.ksf-cart-qty-btn:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

/* INPUT SỐ LƯỢNG - ÉP PADDING = 0 ĐỂ HIỂN THỊ CHÍNH XÁC SỐ */
input.ksf-cart-qty-input,
.woocommerce-cart input.ksf-cart-qty-input,
.woocommerce-cart-form input.ksf-cart-qty-input,
.ksf-cart-qty-control input.qty {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 34px !important;
    line-height: 34px;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-left: 1px solid #e5e7eb !important;
    border-right: 1px solid #e5e7eb !important;
    text-align: center !important;
    font-size: 14.5px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    background: #ffffff !important;
    box-shadow: none;
    outline: none !important;
    display: inline-block !important;
    vertical-align: middle;
    -webkit-appearance: none !important;
    -moz-appearance: textfield !important;
    box-sizing: border-box;
}

input.ksf-cart-qty-input::-webkit-outer-spin-button,
input.ksf-cart-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Cột Thành tiền */
.ksf-cart-item-subtotal {
    min-width: 95px !important;
    text-align: right;
    font-size: 16px !important;
    font-weight: 700;
    color: #008848;
    white-space: nowrap;
}

/* NÚT XÓA - DÙNG CLASS ĐỘC LẬP TRÁNH BỊ THEME ĐÈ (x) */
.ksf-cart-remove-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px;
    background: #fef2f2 !important;
    border: 1px solid #fee2e2 !important;
    color: #ef4444 !important;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease !important;
    padding: 0;
    margin: 0;
    font-size: 0;
}

.ksf-cart-remove-btn:hover {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fca5a5 !important;
    transform: scale(1.05) !important;
}

.ksf-cart-remove-btn svg {
    display: block !important;
    width: 15px !important;
    height: 15px !important;
    stroke: currentColor;
    pointer-events: none !important;
}

.ksf-cart-remove-btn::before,
.ksf-cart-remove-btn::after {
    display: none !important;
    content: none;
}

.ksf-cart-remove-btn-mobile {
    display: none !important;
}
.ksf-cart-remove-btn-desktop {
    display: inline-flex !important;
}

/* Chân danh sách sản phẩm */
.ksf-cart-left-footer {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding: 6px 2px;
}

.ksf-continue-shopping-link {
    display: inline-flex !important;
    align-items: center;
    gap: 6px !important;
    font-size: 14px;
    font-weight: 600;
    color: #008848 !important;
    text-decoration: none;
    transition: gap 0.2s ease, color 0.2s ease !important;
}

.ksf-continue-shopping-link:hover {
    color: #006634 !important;
    gap: 9px !important;
}

/* 6. Cột phải: Voucher & Tóm tắt đơn hàng */
.cart-collaterals {
    width: 100% !important;
    float: none !important;
}

.cart-collaterals .cross-sells {
    display: none !important;
}

/* 7. Sticky Bottom Bar trên Mobile (<= 768px) */
.ksf-mobile-cart-sticky-bar {
    display: none !important;
}

@media (min-width: 769px) {
    .ksf-mobile-cart-sticky-bar {
        display: none !important;
    }
}

@media (max-width: 991px) {
    .ksf-cart-layout-grid {
        flex-direction: column;
        gap: 16px;
    }
    .ksf-cart-col-left,
    .ksf-cart-col-right {
        flex: 1 1 100%;
        max-width: 100% !important;
        width: 100% !important;
        position: static !important;
    }
}

@media (max-width: 768px) {
    /* ẨN TRIỆT ĐỂ HEADER DESKTOP TRÊN MOBILE */
    header#ksfSiteHeader,
    .ksf-site-header {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* ĐẨY NÚT LIÊN HỆ LÊN TRÊN THANH CHECKOUT ĐỂ TRÁNH CHE MẤT NÚT ĐẶT HÀNG */
    .woocommerce-cart .wacu-widget {
        bottom: 74px !important;
        z-index: 9999 !important;
    }

    .woocommerce-cart .site-content {
        padding-bottom: 95px !important;
    }

    .ksf-cart-container {
        padding: 0 10px;
    }

    .ksf-cart-main-title {
        font-size: 17px;
    }

    /* Thẻ sản phẩm trên Mobile: Grid 64px 1fr 2 tầng */
    .ksf-cart-item-card {
        padding: 12px 14px;
        display: grid !important;
        grid-template-columns: 64px 1fr;
        gap: 8px 12px;
        align-items: start;
        border-radius: 10px;
    }

    .ksf-cart-item-thumb {
        grid-column: 1;
        grid-row: 1;
        width: 64px !important;
        height: 64px !important;
    }

    .ksf-cart-item-details {
        grid-column: 2;
        grid-row: 1;
        min-width: 0 !important;
    }

    .ksf-cart-item-title-row {
        display: flex !important;
        align-items: flex-start;
        justify-content: space-between;
        gap: 8px;
    }

    .ksf-cart-item-name {
        font-size: 14px;
        line-height: 1.35;
        flex: 1 1 auto;
        min-width: 0 !important;
    }

    .ksf-cart-remove-btn-mobile {
        display: inline-flex !important;
        flex-shrink: 0;
        width: 28px !important;
        height: 28px !important;
    }

    .ksf-cart-remove-btn-desktop {
        display: none !important;
    }

    .ksf-cart-item-meta-row {
        margin-top: 4px;
        font-size: 13px;
    }

    /* Tầng 2 trên Mobile: Bộ số lượng bên trái, Thành tiền bên phải */
    .ksf-cart-item-actions-cluster {
        grid-column: 1 / 3;
        grid-row: 2;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        width: 100% !important;
        margin-top: 4px;
        padding-top: 8px;
        border-top: 1px dashed #f1f5f9;
    }

    .ksf-cart-item-subtotal {
        font-size: 15.5px;
    }

    /* Thanh Sticky Bottom Bar chân màn hình */
    #ksfMobileCartStickyBar,
    .ksf-mobile-cart-sticky-bar {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 62px !important;
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
        padding: 0 16px;
        z-index: 999999 !important;
        box-sizing: border-box;
    }

    .ksf-mobile-sticky-total-wrap {
        display: flex !important;
        flex-direction: column;
    }

    .ksf-mobile-sticky-label {
        font-size: 11px;
        color: #64748b;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

    .ksf-mobile-sticky-amount {
        font-size: 17px;
        font-weight: 700;
        color: #008848;
        line-height: 1.2;
    }

    .ksf-mobile-sticky-checkout-btn {
        height: 42px !important;
        line-height: 42px;
        padding: 0 20px;
        background: #008848 !important;
        color: #ffffff !important;
        font-size: 14px;
        font-weight: 700;
        border-radius: 8px;
        text-decoration: none;
        display: inline-flex !important;
        align-items: center;
        gap: 6px;
        box-shadow: 0 3px 8px rgba(0, 136, 72, 0.3);
    }

    .ksf-mobile-sticky-checkout-btn:active {
        background: #006634 !important;
    }
}

/* 8. Giao diện Giỏ Hàng Trống (Cart Empty) */
.ksf-cart-empty-container {
    max-width: 520px !important;
    margin: 40px auto !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 16px !important;
    padding: 40px 24px !important;
    text-align: center !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03) !important;
}

.ksf-cart-empty-icon-wrap {
    width: 80px !important;
    height: 80px !important;
    border-radius: 50% !important;
    background: #f1f5f9 !important;
    color: #94a3b8 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-bottom: 20px !important;
}

.ksf-cart-empty-title {
    font-size: 20px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin: 0 0 8px 0 !important;
}

.ksf-cart-empty-subtitle {
    font-size: 14px !important;
    color: #64748b !important;
    line-height: 1.5 !important;
    margin: 0 0 24px 0 !important;
}

.ksf-cart-empty-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    background: #008848 !important;
    color: #ffffff !important;
    font-size: 14.5px !important;
    font-weight: 700 !important;
    padding: 12px 28px !important;
    border-radius: 10px !important;
    text-decoration: none !important;
    box-shadow: 0 4px 12px rgba(0, 136, 72, 0.25) !important;
    transition: all 0.2s ease !important;
}

.ksf-cart-empty-btn:hover {
    background: #006634 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 16px rgba(0, 136, 72, 0.35) !important;
}
