/* Khối SP đầu bài tin tức + thanh "Mua ngay" cố định đáy (mobile)
   Nạp ở news-view của cả 3 bộ (desktop, mobile, tablet). Chỉ dùng biến màu có sẵn (style guide). */
.news-top-products {
    margin: 16px 0;
    padding: 12px;
    border: 1px solid var(--gray);
    border-radius: 4px;
    background: var(--light);
}

.news-top-products-title {
    margin-bottom: 10px;
    color: var(--dark);
    font-size: 16px;
    font-weight: bold;
    line-height: 22px;
}

.news-top-products-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.news-top-products-item {
    display: flex;
    flex-direction: column;
    padding: 8px;
    border-radius: 4px;
    background: var(--white);
}

.news-top-products-img {
    display: block;
    text-align: center;
}

.news-top-products-img img {
    display: block;
    margin: 0 auto;
    width: 120px;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

.news-top-products-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 40px;
    margin: 6px 0 4px;
    color: var(--dark);
    font-size: 14px;
    line-height: 20px;
}

.news-top-products-name:hover,
.news-top-products-name:focus {
    color: var(--primary);
}

.news-top-products-price {
    margin-bottom: 8px;
    line-height: 20px;
}

.news-top-products-newprice {
    color: var(--price);
    font-size: 16px;
    font-weight: bold;
}

.news-top-products-oldprice {
    margin-left: 4px;
    color: var(--silver);
    font-size: 13px;
    text-decoration: line-through;
}

.news-top-products .news-top-products-btn {
    box-sizing: border-box;
    width: 100%;
    margin-top: auto;
    text-align: center;
    padding: 4px 8px;
    font-size: 14px;
    line-height: 24px;
}

/* Thanh "Mua ngay" cố định đáy: chỉ view mobile có markup này */
.news-top-sticky,
.news-top-sticky[hidden] {
    display: none;
}

.news-top-sticky.is-visible {
    display: flex;
    align-items: center;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    padding: 6px 4px 6px 8px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--gray);
    background: var(--white);
    box-shadow: 0 -2px 6px var(--shadow);
}

.news-top-sticky-inner {
    display: flex;
    flex: 1;
    align-items: center;
    min-width: 0;
}

.news-top-sticky-img {
    flex: 0 0 48px;
}

.news-top-sticky-img img {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.news-top-sticky-info {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    padding: 0 8px;
}

.news-top-sticky-name {
    overflow: hidden;
    color: var(--dark);
    font-size: 14px;
    line-height: 20px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.news-top-sticky-price {
    color: var(--price);
    font-size: 15px;
    font-weight: bold;
    line-height: 20px;
}

.news-top-sticky .news-top-sticky-btn {
    flex: 0 0 auto;
    padding: 4px 12px;
    font-size: 14px;
    line-height: 28px !important;
}

.news-top-sticky-close {
    flex: 0 0 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--silver);
    font-size: 22px;
    line-height: 32px;
}

body.news-top-sticky-on {
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
}

body.news-top-sticky-on .shortcut-chat-mb {
    bottom: calc(72px + env(safe-area-inset-bottom));
}

body.quick-cart-open .news-top-sticky.is-visible {
    display: none;
}

@media (max-width: 767px) {
    .news-top-products {
        margin: 12px 0;
        padding: 10px;
    }

    .news-top-products-list {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .news-top-products-item {
        flex: 0 0 42%;
        scroll-snap-align: start;
    }

    .news-top-products-img img {
        width: 96px;
    }

    .news-top-products-list .news-top-products-item:only-child {
        flex-basis: 100%;
    }
}
