/**
 * Cart popup (Figma-aligned). Separate file loads after Porto checkout CSS for reliable cascade.
 */

.modal-popup.cart-popup-modal .modal-inner-wrap {
    width: 624px;
    max-width: 100% !important;
    border-radius: 0 !important;
    overflow: visible !important;
    position: relative !important;
}

.modal-popup.cart-popup-modal .modal-header,
.modal-popup.cart-popup-modal .modal-footer {
    display: none;
}

.modal-popup.cart-popup-modal .modal-content {
    padding: 0;
}

.modal-popup.cart-popup-modal .modal-content [data-role="content"] {
    padding: 0;
}

/**
 * Root is moved into modal — jQuery .show() forces display:block inline; keep flex on inner shell instead.
 */
#cart-popup.cart-popup {
    box-sizing: border-box;
    font-family: 'Montserrat', Helvetica, Arial, sans-serif;
    color: #33312e;
    background: #fff;
}

#cart-popup.cart-popup *,
#cart-popup.cart-popup *::before,
#cart-popup.cart-popup *::after {
    box-sizing: border-box;
}

.cart-popup-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 85vh;
}

/* Header */
.cart-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px 20px;
    flex-shrink: 0;
}

.cart-popup-title {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif;
    font-weight: 700;
    font-size: 18px;
    line-height: 1.4;
    color: #33312e;
    margin: 0;
}

.cart-popup-close {
    position: absolute !important;
    top: -16px !important;
    right: -16px !important;
    border: 1px solid #fff !important;
    background: #33312e !important;
    box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.25) !important;
    border-radius: 0 !important;
    transform: unset !important;
    padding: 0 !important;
    width: 34px !important;
    height: 34px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17' viewBox='0 0 17 17' fill='none'%3E%3Cpath d='M8.16667 8.16667L1.5 1.5M8.16667 8.16667L14.8333 14.8333M8.16667 8.16667L14.8333 1.5M8.16667 8.16667L1.5 14.8333' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
    background-size: 17px !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    z-index: 10 !important;
}

.cart-popup-close svg {
    display: none !important;
}

.cart-popup-close::before,
.cart-popup-close::after {
    display: none !important;
}

.cart-popup-close:hover {
    background-color: #6a1712 !important;
    opacity: 1 !important;
}

/* Items wrapper */
.cart-popup-items-wrapper {
    padding: 0 28px;
    overflow-y: auto;
    max-height: 440px;
    flex: 1 1 auto;
    min-height: 180px;
}

/* Single cart item */
.cart-popup-item {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.cart-popup-item:last-child {
    margin-bottom: 0;
}

.cart-popup-item-image {
    width: 150px;
    height: 180px;
    flex-shrink: 0;
    overflow: hidden;
}

.cart-popup-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cart-popup-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.cart-popup-item-brand {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif;
    font-weight: 500;
    font-size: 10px;
    line-height: 14px;
    color: #33312e;
    margin: 0;
}

.cart-popup-item-name-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 32px;
}

.cart-popup-item-name {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif;
    font-weight: 700;
    font-size: 15px;
    line-height: 24px;
    color: #33312e;
    margin: 0;
    flex: 1;
    min-width: 0;
}

.cart-popup-item-price {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif;
    font-weight: 700;
    font-size: 15px;
    line-height: 24px;
    color: #33312e;
    margin: 0;
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}

.cart-popup-item-attrs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-popup-item-attr {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 24px;
}

.cart-popup-attr-label {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif;
    font-weight: 700;
    font-size: 12px;
    line-height: 1.6;
    color: #33312e;
    white-space: nowrap;
    flex-shrink: 0;
}

.cart-popup-attr-value {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif;
    font-weight: 500;
    font-size: 12px;
    line-height: 1.6;
    color: #33312e;
}

/* Dáng + Màu combined row */
.cart-popup-color-size-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: nowrap;
}

.cart-popup-text-attr-col {
    display: flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.cart-popup-color-col,
.cart-popup-size-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Color swatches */
.cart-popup-color-swatches {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.cart-popup-color-swatch {
    width: 40px;
    height: 28px;
    border: 2px solid #fff;
    outline: 2px solid #ecebea;
    cursor: pointer;
    padding: 0;
    background-color: #ccc;
    background-size: cover;
    background-position: center;
    transition: outline-color 0.15s;
    flex-shrink: 0;
    border-radius: 0;
    box-sizing: border-box;
    display: block;
}

.cart-popup-color-swatch.active {
    outline-color: #7b1b15;
}

.cart-popup-color-swatch:hover {
    outline-color: #33312e;
}

/* Size buttons */
.cart-popup-size-btns {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.cart-popup-size-btn {
    border: 2px solid #33312e;
    background: #fff;
    color: #33312e;
    font-family: 'Montserrat', Helvetica, Arial, sans-serif;
    font-weight: 500;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    min-width: 36px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    border-radius: 0;
    box-sizing: border-box;
}

.cart-popup-size-btn.active {
    background: #7b1b15;
    color: #fff;
    border-color: #7b1b15;
}

.cart-popup-size-btn:hover:not(.active) {
    background: #f5f5f5;
}

/* Text attribute (Dáng) */
.cart-popup-text-btns {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.cart-popup-text-btn {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif;
    font-weight: 500;
    font-size: 12px;
    line-height: 1.6;
    color: #33312e;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.cart-popup-text-btn.active {
    color: #33312e;
    font-weight: 700;
    text-decoration: underline;
}

.cart-popup-text-btn:hover {
    opacity: 0.7;
}

.cart-popup-item-qty-row {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    margin-top: 8px !important;
}

.cart-popup-qty-label {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    color: #33312e !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.cart-popup-qty-right {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 1 !important;
}

.cart-popup-qty-inner {
    display: inline-flex !important;
    align-items: center !important;
    border: 1.5px solid #d1d1d1 !important;
    border-radius: 6px !important;
    overflow: hidden !important;
    height: 34px !important;
}

.cart-popup-qty-btn {
    background: #f5f5f5 !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 16px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    color: #33312e !important;
    padding: 0 !important;
    width: 32px !important;
    height: 34px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: background 0.15s !important;
}

.cart-popup-qty-btn:hover {
    background: #ebebeb !important;
}

.cart-popup-qty-value {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif !important;
    font-weight: 500 !important;
    font-size: 13px !important;
    color: #33312e !important;
    text-align: center !important;
    min-width: 30px !important;
    border-left: 1.5px solid #d1d1d1 !important;
    border-right: 1.5px solid #d1d1d1 !important;
    height: 34px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.cart-popup-delete-btn {
    background: none !important;
    border: 1.5px solid #d1d1d1 !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 34px !important;
    height: 34px !important;
    flex-shrink: 0 !important;
    color: #888 !important;
    transition: border-color 0.15s, color 0.15s !important;
}

.cart-popup-delete-btn:hover {
    border-color: #c0392b !important;
    color: #c0392b !important;
}

.cart-popup-empty {
    padding: 14px 20px !important;
    text-align: center !important;
    color: #7a3b3b !important;
    font-family: 'Montserrat', Helvetica, Arial, sans-serif !important;
    font-size: 13px !important;
    background: #F8E6E5 !important;
    border-radius: 6px !important;
    margin: 0 !important;
}

.cart-popup-footer {
    padding: 16px 28px 28px;
    flex-shrink: 0;
}

.cart-popup-divider {
    height: 1px;
    background: #ecebea;
    margin-bottom: 16px;
}

.cart-popup-totals {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
}

/**
 * Totals: avoid inline-span glue when flex is weakened by theme CSS — use explicit flex + nowrap value cell.
 */
.modal-popup.cart-popup-modal .cart-popup-total-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 32px !important;
    width: 100% !important;
    font-family: 'Montserrat', Helvetica, Arial, sans-serif !important;
    font-weight: 500 !important;
    font-size: 15px !important;
    line-height: 24px !important;
    color: #949089 !important;
}

.modal-popup.cart-popup-modal .cart-popup-total-grand {
    font-weight: 700 !important;
    color: #33312e !important;
}

.cart-popup-total-label {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    margin: 0 !important;
}

.cart-popup-total-value {
    flex: 0 0 auto !important;
    text-align: right !important;
    white-space: nowrap !important;
    margin: 0 !important;
}

.cart-popup-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cart-popup-terms {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif;
    font-weight: 500;
    font-size: 12px;
    line-height: 16.8px;
    color: #33312e;
}

.cart-popup-terms p {
    margin: 0 0 2px;
}

.cart-popup-terms a {
    color: #0088ff;
    text-decoration: underline;
}

/* Checkout CTA — Porto checkout often resets button styles inside modals */
.modal-popup.cart-popup-modal button.cart-popup-checkout-btn {
    width: 100% !important;
    height: 56px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #7b1b15 !important;
    background-color: #7b1b15 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.modal-popup.cart-popup-modal button.cart-popup-checkout-btn span {
    font-family: 'Montserrat', Helvetica, Arial, sans-serif !important;
    font-weight: 700 !important;
    font-size: 15px !important;
    line-height: 24px !important;
    color: #fff !important;
    letter-spacing: 0.05em !important;
}

.modal-popup.cart-popup-modal button.cart-popup-checkout-btn:hover {
    background-color: #6a1712 !important;
    background: #6a1712 !important;
}

.modal-popup.cart-popup-modal button.cart-popup-checkout-btn.disabled,
.modal-popup.cart-popup-modal button.cart-popup-checkout-btn:disabled {
    background: #ccc !important;
    background-color: #ccc !important;
    cursor: not-allowed !important;
}

@media (max-width: 767px) {
    .modal-popup.cart-popup-modal,
    .modal-slide.cart-popup-modal {
        overflow-y: auto !important;
        padding: 20px 12px !important;
        left: 0 !important;
        right: 0 !important;
    }

    .modal-popup.cart-popup-modal .modal-inner-wrap,
    .modal-slide.cart-popup-modal .modal-inner-wrap {
        width: 100% !important;
        max-width: 100% !important;
        margin: auto !important;
        max-height: 90vh !important;
        border-radius: 4px !important;
        min-height: auto !important;
        transform: none !important;
        position: relative !important;
    }

    .cart-popup-shell {
        max-height: 90vh !important;
    }

    .cart-popup-header {
        padding: 16px 16px 12px !important;
    }

    .cart-popup-items-wrapper {
        padding: 0 16px !important;
        max-height: 45vh !important;
        min-height: 100px !important;
    }

    .cart-popup-item {
        gap: 12px !important;
    }

    .cart-popup-item-image {
        width: 80px !important;
        height: 100px !important;
    }

    .cart-popup-item-name-row {
        flex-direction: column !important;
        gap: 4px !important;
    }

    .cart-popup-footer {
        padding: 12px 16px 20px !important;
    }

    .cart-popup-close {
        top: -12px !important;
        right: -12px !important;
        width: 30px !important;
        height: 30px !important;
        background-size: 13px !important;
    }

    .cart-popup-color-size-row {
        gap: 8px !important;
        flex-wrap: wrap !important;
    }

    .cart-popup-title {
        font-size: 16px !important;
    }

    .modal-popup.cart-popup-modal button.cart-popup-checkout-btn {
        height: 48px !important;
    }
}
