/**
 * K-Tech WooCommerce Add to Cart Popup Styles
 * - Mobile: Bottom Sheet pinned to bottom, 100% width, rounded top corners
 * - PC: Centered Modal Dialog
 *
 * @package Flatsome Child
 */

/* =====================================================
   POPUP BACKDROP & OVERLAY
   ===================================================== */
.ktech-cart-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 9999999;
    display: flex;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    box-sizing: border-box;
}

.ktech-cart-popup.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.ktech-cart-popup__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    cursor: pointer;
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}

/* =====================================================
   MODAL DIALOG BASE STYLES
   ===================================================== */
.ktech-cart-popup__dialog {
    position: relative;
    z-index: 2;
    background: #ffffff;
    box-sizing: border-box;
    overflow: hidden;
}

.ktech-cart-popup__content {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    box-sizing: border-box;
    width: 100%;
}

/* =====================================================
   HEADER: LIGHT GREEN BACKGROUND + CHECKMARK + CLOSE
   ===================================================== */
.ktech-cart-popup__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f2f9f4;
    border-bottom: 1px solid #e5f2e8;
    box-sizing: border-box;
}

.ktech-cart-popup__title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ktech-cart-popup__icon-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.ktech-cart-popup__icon-check svg {
    width: 19px;
    height: 19px;
    display: block;
}

.ktech-cart-popup__title-text {
    font-size: 15px;
    font-weight: 600;
    color: #28a745;
    line-height: 1.25;
    letter-spacing: -0.2px;
}

.ktech-cart-popup__close-btn {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #777777;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    transition: color 0.15s ease, background-color 0.15s ease;
    outline: none;
    box-shadow: none !important;
}

.ktech-cart-popup__close-btn:hover {
    color: #222222;
    background: rgba(0, 0, 0, 0.05) !important;
}

.ktech-cart-popup__close-btn svg {
    display: block;
}

/* =====================================================
   PRODUCT ROW: THUMBNAIL + TITLE + VARIATION
   ===================================================== */
.ktech-cart-popup__product {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 15px 16px;
    border-bottom: 1px solid #f0f0f0;
    box-sizing: border-box;
    background: #ffffff;
}

.ktech-cart-popup__product-thumb {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 4px;
    border: 1px solid #f2f2f2;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    box-sizing: border-box;
}

.ktech-cart-popup__product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.ktech-cart-popup__product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ktech-cart-popup__product-name {
    font-size: 13.5px;
    line-height: 1.45;
    color: #2c2c2c;
    margin: 0 0 5px 0;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.ktech-cart-popup__product-meta {
    font-size: 13px;
    color: #8c8c8c;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1.3;
    letter-spacing: 0.2px;
}

/* =====================================================
   CART SUMMARY: "Giỏ hàng hiện có" + PRICE & QUANTITY
   ===================================================== */
.ktech-cart-popup__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    box-sizing: border-box;
    background: #ffffff;
}

.ktech-cart-popup__summary-label {
    font-size: 14px;
    color: #333333;
    font-weight: 400;
    line-height: 1.3;
}

.ktech-cart-popup__summary-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.ktech-cart-popup__summary-price,
.ktech-cart-popup__summary-price .woocommerce-Price-amount,
.ktech-cart-popup__summary-price .woocommerce-Price-currencySymbol {
    font-size: 15.5px !important;
    font-weight: 700 !important;
    color: var(--primary-color) !important;
    line-height: 1.25;
}

.ktech-cart-popup__summary-count {
    font-size: 13px;
    color: #777777;
    line-height: 1.3;
    margin-top: 3px;
    font-weight: 400;
}

/* =====================================================
   FOOTER BUTTONS: "Thanh toán" & "Xem giỏ hàng"
   ===================================================== */
.ktech-cart-popup__footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 16px 18px;
    background: #ffffff;
    box-sizing: border-box;
}

.ktech-cart-popup__btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 14px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    box-sizing: border-box;
    white-space: nowrap;
    outline: none;
    box-shadow: none !important;
}

/* Left button: Thanh toán */
.ktech-cart-popup__btn-checkout {
    background: #ffffff !important;
    color: var(--primary-color) !important;
    border: 1px solid var(--primary-color) !important;
}

.ktech-cart-popup__btn-checkout:hover,
.ktech-cart-popup__btn-checkout:focus {
    background: var(--primary-color) !important;
    color: #ffffff !important;
    border-color: var(--primary-color) !important;
}

/* Right button: Xem giỏ hàng */
.ktech-cart-popup__btn-viewcart {
    background: var(--primary-color) !important;
    color: #ffffff !important;
    border: 1px solid var(--primary-color) !important;
}

.ktech-cart-popup__btn-viewcart:hover,
.ktech-cart-popup__btn-viewcart:focus {
    background: var(--primary-color) !important;
    color: #ffffff !important;
    border-color: var(--primary-color) !important;
}

/* =====================================================
   BODY SCROLL LOCK
   ===================================================== */
body.ktech-cart-popup-open {
    overflow: hidden !important;
}

/* =====================================================
   PC / DESKTOP (min-width: 768px): CENTERED MODAL
   ===================================================== */
@media (min-width: 768px) {
    .ktech-cart-popup {
        align-items: center;
        justify-content: center;
    }

    .ktech-cart-popup__dialog {
        width: 450px;
        max-width: calc(100vw - 32px);
        border-radius: 8px;
        box-shadow: 0 10px 35px rgba(0, 0, 0, 0.22);
        border: 1px solid rgba(0, 0, 0, 0.04);
        transform: translateY(16px) scale(0.98);
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .ktech-cart-popup.is-open .ktech-cart-popup__dialog {
        transform: translateY(0) scale(1);
    }

    .ktech-cart-popup__header {
        padding: 13px 18px;
    }

    .ktech-cart-popup__product {
        padding: 16px 18px;
    }

    .ktech-cart-popup__summary {
        padding: 14px 18px;
    }

    .ktech-cart-popup__footer {
        padding: 15px 18px 18px;
    }
}

/* =====================================================
   MOBILE (max-width: 767px): BOTTOM SHEET (ĐÚNG THEO ẢNH)
   ===================================================== */
@media (max-width: 767px) {
    .ktech-cart-popup {
        align-items: flex-end;
        /* Ghim sát đáy màn hình */
        justify-content: center;
        padding: 0;
    }

    .ktech-cart-popup__dialog {
        width: 100%;
        max-width: 100%;
        border-radius: 5px 5px 0 0;
        /* Bo tròn 2 góc trên, 2 góc dưới vuông phẳng */
        border: none;
        box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.2);
        transform: translateY(100%);
        /* Trượt từ dưới lên */
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
        margin: 0;
    }

    .ktech-cart-popup.is-open .ktech-cart-popup__dialog {
        transform: translateY(0);
        /* Xuất hiện ở đáy màn hình */
    }

    .ktech-cart-popup__header {
        padding: 12px 16px;
    }

    .ktech-cart-popup__title-text {
        font-size: 14.5px;
    }

    .ktech-cart-popup__product {
        padding: 14px 16px;
        gap: 12px;
    }

    .ktech-cart-popup__product-thumb {
        width: 68px;
        height: 68px;
    }

    .ktech-cart-popup__product-name {
        font-size: 13.5px;
        line-height: 1.42;
    }

    .ktech-cart-popup__product-meta {
        font-size: 12.5px;
    }

    .ktech-cart-popup__summary {
        padding: 13px 16px;
    }

    .ktech-cart-popup__summary-label {
        font-size: 13.5px;
    }

    .ktech-cart-popup__summary-price,
    .ktech-cart-popup__summary-price .woocommerce-Price-amount {
        font-size: 15px !important;
    }

    .ktech-cart-popup__summary-count {
        font-size: 12.5px;
    }

    .ktech-cart-popup__footer {
        padding: 14px 16px max(18px, env(safe-area-inset-bottom, 18px));
        gap: 10px;
    }

    .ktech-cart-popup__btn {
        height: 40px;
        font-size: 13.5px;
        padding: 0 10px;
    }
}