/* =============================================================
   HKBallet — Cart Popup  (hkb-cart-popup.css)
   ============================================================= */

/* ── Overlay ────────────────────────────────────────────────── */
.hkb-cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.hkb-cart-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* ── Panel ──────────────────────────────────────────────────── */
.hkb-cart-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 430px;
    background: white;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: var(--transition);
    overflow: hidden;
    padding: 20px;
}

/* Flexbox order: header → confirm → body → footer */
.hkb-cart__header {
    order: 1;
    flex-shrink: 0;
}

.hkb-cart-confirm {
    order: 2;
    flex-shrink: 0;
}

.hkb-cart__body {
    order: 3;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--clr-neutral-15) transparent;
}

.hkb-cart__body::-webkit-scrollbar {
    width: 4px;
}

.hkb-cart__body::-webkit-scrollbar-track {
    background: transparent;
}

.hkb-cart__body::-webkit-scrollbar-thumb {
    background-color: var(--clr-neutral-15);
    border-radius: 4px;
}

.hkb-cart__footer {
    order: 4;
    flex-shrink: 0;
}

.hkb-cart-panel.is-open {
    transform: translateX(0);
}

/* ── Header ─────────────────────────────────────────────────── */
.hkb-cart__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--clr-neutral-15);
    padding-bottom: 19px;
    flex-shrink: 0;
}

.hkb-cart__title {
    font-size: var(--fs-26);
    color: var(--clr-blue-100);
    line-height: var(--lh-35);
    margin: 0;
}

.hkb-cart__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: transparent !important;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
}

/* ── Body (scrollable items list) ───────────────────────────── */
.hkb-cart__body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Loading state */
.hkb-cart__body.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Empty state */
.hkb-cart__empty {
    text-align: center;
    color: var(--clr-blue-100);
    font-size: var(--fs-16);
    margin: 0;
}

/* ── Cart Item ───────────────────────────────────────────────── */
.hkb-cart__item {
    display: flex;
    gap: 24px;
}

.hkb-cart__item.is-updating {
    opacity: 0.5;
    pointer-events: none;
}

.hkb-cart__item-img {
    flex-shrink: 0;
    aspect-ratio: 2 / 2.66;
    width: 127px;
    border-radius: 2px;
    border: 1px solid var(--clr-neutral-05);
    overflow: hidden;
}

.hkb-cart__item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: all 0.5s;
}

.hkb-cart__item-name:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.hkb-cart__item-img:hover img {
    transform: scale(1.2);
}

.hkb-cart__item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
}

.hkb-cart__item-price .woocommerce-Price-amount {
    font-weight: 500;
}

/* Item actions row: qty + delete */
.hkb-cart__item-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Qty control */
.hkb-cart__qty-ctrl {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-large);
    gap: 0;
}

.hkb-cart__qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none !important;
    border: none;
    cursor: pointer;
    color: var(--clr-blue-100);
    transition: var(--transition);
    flex-shrink: 0;
    padding: 6px;
    border: 1px solid var(--clr-blue-60);
    border-radius: var(--radius-large);
}

/*.hkb-cart__qty-btn:focus-within{
    box-shadow: 0px 0px 0px 3px var(--clr-purple-50);
}*/

.hkb-cart__qty-btn:hover {
    background: var(--clr-neutral-05) !important;
}

.hkb-cart__qty-btn[disabled]{
    border: 1px solid var(--clr-neutral-60);
    pointer-events: none;
}

.hkb-cart__qty-btn[disabled] svg path{
    fill: var(--clr-neutral-60);
}

.hkb-cart__qty-num {
    min-width: 42px;
    text-align: center;
    font-size: var(--fs-16);
    line-height: var(--lh-26);
    color: var(--clr-blue-100);
    user-select: none;
}

/* Remove button */
.hkb-cart__remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background-color: transparent !important;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
    padding: 0;
}


/* ── Footer ─────────────────────────────────────────────────── */
.hkb-cart__footer {
    padding: 20px 0 0 0;
    border-top: 1px solid var(--clr-neutral-15);
    flex-shrink: 0;
    background: white;
}

.hkb-cart__shipping-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.hkb-cart__shipping-label,
.hkb-cart__shipping-val {
    font-size: var(--fs-16);
    line-height: var(--lh-26);
    color: var(--clr-blue-100);
}

.hkb-cart__shipping-note {
    font-size: var(--fs-12);
    line-height: var(--lh-168);
    font-weight: 300;
    color: var(--clr-blue-100);
    margin: 0;
}

.hkb-cart__total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-18);
    line-height: var(--lh-252);
    color: var(--clr-blue-100);
    padding-top: 20px;
}

/* Checkout button */
.hkb-cart__checkout {
    display: block;
    width: 100%;
    padding: 10px 28px;
    background: var(--clr-blue-100);
    color: white !important;
    border: none;
    border-radius: 100px;
    font-size: var(--fs-18);
    line-height: var(--lh-252);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 40px;
}

/* .hkb-cart__checkout:hover {
    background: var(--clr-blue-80);
} */

/*.hkb-cart__checkout:focus-within {
    box-shadow: 0px 0px 0px 3px var(--clr-purple-50) !important;
}*/

/* ── Cart count badge (for header icon) ─────────────────────── */

/* ── Prevent body scroll when panel open ────────────────────── */
body.hkb-cart-open {
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════
   CART BUTTON — layout: <a> text "Cart" + badge inline
   ══════════════════════════════════════════════════════════════ */

/* Wrapper .top-header-cta — không sửa nếu theme đã có style */
.top-header-cta {
    display: flex;
    align-items: center;
}

/* Button <a> */
a.hkb-cart-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    /* khoảng cách giữa "Cart" và badge */
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    /* Giữ nguyên style .cta-have-bg / .btn-bg-effect của theme */
}

/* Badge — nằm INLINE bên phải chữ "Cart", không absolute */
.hkb-cart-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #fff;
    /* màu trắng trên nền navy button */
    color: var(--hkb-navy, #1a1f5e);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.15s ease;
    transform-origin: center;
    vertical-align: middle;
}

/* Ẩn badge khi = 0 */
/*.hkb-cart-badge.is-zero {
    transform: scale(0);
    opacity: 0;
    width: 0;
    padding: 0;
    min-width: 0;
    overflow: hidden;
}*/

/* Pop animation khi số tăng */
.hkb-cart-badge.pop {
    animation: hkbBadgePop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes hkbBadgePop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.5);
    }

    100% {
        transform: scale(1);
    }
}


/* ── Typography ────────────────────────────────────────────── */
.hkb-cart__item-name {
    font-size: var(--fs-20);
    line-height: var(--lh-26);
    color: var(--clr-blue-100);
    margin: 0 0 8px;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    display: block;
}

.hkb-cart__item-price,
.hkb-cart__item-variation {
    font-size: var(--fs-14);
    line-height: var(--lh-26);
    color: var(--clr-blue-100);
}

.hkb-cart__item-variation {
    margin: 0 0 8px;
}

.hkb-cart__item-price .woocommerce-Price-amount {
    font-weight: 400;
}

/* ── Badge format (4) ───────────────────────────────────────── */
.hkb-cart-badge {
    font-size: inherit;
    font-weight: inherit;
    background: none;
    color: inherit;
    border-radius: 0;
    min-width: auto;
    height: auto;
    padding: 0;
    line-height: inherit;
}

/*.hkb-cart-badge.is-zero {
    display: none;
}*/

/* ── Icons img ──────────────────────────────────────────────── */

.hkb-cart__qty-btn img,
.hkb-cart__remove img {
    display: block;
    pointer-events: none;
}

/* ── Confirm dialog — sau header, trước items ───────────────── */
.hkb-cart-confirm {
    display: none;
    padding: 20px;
    background: var(--clr-neutral-05);
    order: 2;
}

.hkb-cart-confirm.is-open {
    display: block;
    margin-top: 20px;
}

.hkb-cart-confirm__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--hkb-gray-400, #999);
    margin: 0 0 12px;
}

.hkb-cart-confirm__text {
    font-size: 14px !important;
    color: var(--clr-blue-100);
    line-height: var(--lh-168);
    margin: 0 0 16px;
    text-align: center;
}

.hkb-cart-confirm__actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.hkb-cart-confirm__keep,
.hkb-cart-confirm__remove {
    padding: 6px 14px;
    border-radius: 100px;
    font-size: var(--fs-12);
    line-height: var(--lh-168);
    cursor: pointer;
    transition: var(--transition);
    width: auto;
}

.hkb-cart-confirm__keep {
    background: white !important;
    color: var(--clr-blue-100) !important;
    border: 1px solid var(--clr-blue-60);
}

.hkb-cart-confirm__remove {
    border: none !important;
    background-color: var(--clr-blue-100) !important;
    color: white !important;
}

/*.hkb-cart-confirm__keep:focus-within,
.hkb-cart-confirm__remove:focus-within {
    box-shadow: 0px 0px 0px 3px var(--clr-purple-50) !important;
}*/

/* Ẩn qty native WC */
.hkb-sp__wc-atc .quantity {
    display: none !important;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768) {
    .hkb-cart__item-name {
        --fs-20: 16px;
        --lh-26: 23px;
    }

    .hkb-cart__item-price,
    .hkb-cart__item-variation {
        --fs-14: 12px;
        --fs-16: 14px;
        --lh-26: 21px;
    }

    .hkb-cart__item-img {
        width: 98px;
    }

    .hkb-cart__shipping-label,
    .hkb-cart__shipping-val {
        --fs-16: 14px;
        --lh-26: 21px;
    }
}

@media (max-width: 430px) {
    .hkb-cart-panel {
        width: 100%;
    }
}