/* Add to cart popup + modal mua nhanh (port từ hithean, xem custom-functions/woocommerce/products/add-to-cart-popup.php) */

html.atc-popup-open {
    overflow: hidden;
}

/* <dialog> full viewport trong suốt; panel bên trong là hộp hiển thị. */
dialog.atc-popup {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    overflow: hidden;
}

dialog.atc-popup[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

dialog.atc-popup:not([open]) {
    display: none;
}

dialog.atc-popup::backdrop {
    background: transparent;
}

.atc-popup__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
}

.atc-popup__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: calc(100% - 32px);
    max-width: 480px;
    max-height: 85vh;
    padding: 24px;
    background: var(--default-color-white);
    border-radius: 8px;
    outline: none;
}

.atc-popup__close {
    position: absolute;
    top: 8px;
    right: 12px;
    padding: 0;
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: var(--default-color-black);
    cursor: pointer;
}

.atc-popup__state {
    display: none;
    flex-direction: column;
    min-height: 0;
}

.atc-popup[data-state="success"] .atc-popup__state--success,
.atc-popup[data-state="error"] .atc-popup__state--error {
    display: flex;
}

.atc-popup__title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 24px 16px 0;
    font-size: 18px;
}

.atc-popup__check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #07876a;
    color: var(--default-color-white);
    font-size: 14px;
}

.atc-popup__cart {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.atc-popup__items {
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-y: auto;
    border-top: 1px solid var(--default-color-grey);
}

.atc-popup__item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid var(--default-color-grey);
}

.atc-popup__item.is-added {
    background: var(--default-color-beige);
}

.atc-popup__thumb {
    flex-shrink: 0;
    width: 56px;
}

.atc-popup__thumb img {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
}

.atc-popup__info {
    flex: 1;
    min-width: 0;
    font-size: 14px;
}

.atc-popup__name {
    margin: 0 0 4px;
    font-weight: 600;
    line-height: 1.35;
}

.atc-popup__name a {
    color: inherit;
    text-decoration: none;
}

.atc-popup__info .variation {
    margin: 0 0 4px;
    font-size: 13px;
    color: #666;
}

.atc-popup__info .variation dt,
.atc-popup__info .variation dd,
.atc-popup__info .variation p {
    display: inline;
    margin: 0;
}

.atc-popup__qty {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.atc-popup__line-total {
    flex-shrink: 0;
    font-weight: 600;
    font-size: 14px;
}

.atc-popup__subtotal {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 12px 0 0;
}

.atc-popup__subtotal strong {
    font-size: 18px;
    color: var(--default-color-red);
}

.atc-popup__actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* Nitro: toast "đã thêm vào giỏ" sau AJAX add-to-cart trong product list — popup thay thế. Toast lỗi giữ nguyên. */
.wr-notice-cart-outer:not(.error) {
    display: none !important;
}

/* Selector 4 class + !important để thắng style .button / .button.alt của Nitro (theme cha). */
.atc-popup .atc-popup__actions .button.atc-popup__continue,
.atc-popup .atc-popup__actions .button.atc-popup__checkout {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 45px;
    margin: 0 !important;
    padding: 0 12px;
    border: 2px solid;
    border-radius: 0;
    box-shadow: var(--md-shadow-1);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

/* Secondary — như .button--white (css/custom.css). */
.atc-popup .atc-popup__actions .button.atc-popup__continue {
    background: var(--default-color-white) !important;
    border-color: var(--default-color-black) !important;
    color: var(--default-color-black) !important;
}

.atc-popup .atc-popup__actions .button.atc-popup__continue:hover {
    background: var(--default-color-grey) !important;
}

/* Primary — như .button--pink. */
.atc-popup .atc-popup__actions .button.atc-popup__checkout {
    background: var(--default-color-pink) !important;
    border-color: var(--default-color-pink) !important;
    color: var(--default-color-white) !important;
}

.atc-popup .atc-popup__actions .button.atc-popup__continue:hover,
.atc-popup .atc-popup__actions .button.atc-popup__checkout:hover {
    box-shadow: var(--md-shadow-2);
}

.atc-popup__state--error .atc-popup__actions .button {
    flex: 1;
    margin: 0 !important;
}

.atc-popup__view-cart {
    align-self: center;
    margin-top: 12px;
    font-size: 14px;
    text-decoration: underline;
}

.atc-popup__error-msg {
    margin: 0;
}

/* Modal mua nhanh (product list, sản phẩm variable) */
.atc-quick-buy__panel {
    max-width: 560px;
    max-height: min(88vh, 720px);
    overflow-y: auto;
}

.atc-quick-buy__head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 28px 16px 0;
}

.atc-quick-buy__thumb:empty {
    display: none;
}

.atc-quick-buy__thumb img {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 6px;
}

.atc-quick-buy__title {
    margin: 0 0 4px;
    color: var(--default-color-navy-blue);
    font-size: 20px;
}

.atc-quick-buy__price {
    margin: 0;
    color: var(--default-color-pink);
    font-size: 18px;
    font-weight: 700;
}

.atc-quick-buy__loading {
    display: none;
    margin: 0;
}

.atc-quick-buy.is-loading .atc-quick-buy__loading {
    display: block;
}

.atc-quick-buy__form .p-single-action {
    border: 0;
    padding-bottom: 0;
}

@media (max-width: 480px) {
    dialog.atc-popup[open] {
        align-items: flex-end;
    }

    .atc-popup__panel {
        width: 100%;
        max-height: 90vh;
        padding: 20px 16px;
        border-radius: 12px 12px 0 0;
    }

    .atc-popup__actions {
        flex-direction: column-reverse;
        flex-shrink: 0;
    }

    /* Cột dọc: flex-basis 0 sẽ áp lên chiều cao và làm nút co về 0 → giữ height 45px. */
    .atc-popup .atc-popup__actions .button.atc-popup__continue,
    .atc-popup .atc-popup__actions .button.atc-popup__checkout,
    .atc-popup__state--error .atc-popup__actions .button {
        flex: 0 0 auto;
        width: 100%;
    }
}
