/*
 * Site-wide progressive enhancements.
 * Loaded after the legacy stylesheet so older templates remain compatible.
 */

:root {
    --site-accent: #d71920;
    --site-accent-dark: #ad1016;
    --site-link: #1d73b7;
    --site-text: #252525;
    --site-muted: #666;
    --site-border: #e2e5e9;
    --site-surface: #fff;
    --site-surface-soft: #f7f8fa;
    --site-radius: 8px;
    --site-shadow: 0 6px 24px rgba(0, 0, 0, .08);
}

html {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    color: var(--site-text);
    overflow-x: hidden;
    overflow-wrap: break-word;
}

.site-main {
    min-width: 0;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 100000000;
    padding: 10px 14px;
    color: #fff;
    background: #111;
    border-radius: 4px;
    transform: translateY(-160%);
    transition: transform .15s ease;
}

.skip-link:focus {
    color: #fff;
    transform: translateY(0);
}

/* Keyboard accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid rgba(29, 115, 183, .45);
    outline-offset: 2px;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
    touch-action: manipulation;
}

/* Media defaults: keep editorial content inside the viewport. */
.article-detail img,
.article-detail picture,
.prd-description img,
.product-tabs__pane img,
.seo-content-image,
.main-content .content img,
.main-content .description img {
    display: block;
    max-width: 100% !important;
    height: auto !important;
    margin-right: auto;
    margin-left: auto;
}

.article-detail iframe,
.article-detail video,
.article-detail embed,
.article-detail object,
.prd-description iframe,
.product-tabs__pane iframe,
.footer iframe {
    max-width: 100% !important;
}

.article-detail iframe[src*="youtube"],
.article-detail iframe[src*="youtu.be"],
.article-detail iframe[src*="vimeo"],
.product-tabs__pane iframe[src*="youtube"],
.product-tabs__pane iframe[src*="youtu.be"],
.product-tabs__pane iframe[src*="vimeo"] {
    width: 100% !important;
    aspect-ratio: 16 / 9;
    height: auto !important;
    min-height: 240px;
}

.footer .content iframe {
    width: 100% !important;
    min-height: 280px;
    border: 0;
}

/* Tables are wrapped automatically by site-enhancements.js. */
.responsive-table {
    width: 100%;
    max-width: 100%;
    margin: 16px 0;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--site-border);
    border-radius: var(--site-radius);
    background: var(--site-surface);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.responsive-table:focus {
    outline: 3px solid rgba(29, 115, 183, .35);
    outline-offset: 2px;
}

.responsive-table table,
table.seo-content-table {
    width: 100% !important;
    min-width: 640px;
    margin: 0 !important;
    border-collapse: collapse;
    border-spacing: 0;
    background: var(--site-surface);
}

.responsive-table th,
.responsive-table td,
table.seo-content-table th,
table.seo-content-table td {
    padding: 10px 12px;
    vertical-align: top;
    border: 1px solid var(--site-border);
    white-space: normal;
}

.responsive-table th,
table.seo-content-table th {
    font-weight: 700;
    text-align: left;
    background: var(--site-surface-soft);
}

.responsive-table tr:nth-child(even) td,
table.seo-content-table tr:nth-child(even) td {
    background: #fcfcfd;
}

.table-scroll-hint {
    display: none;
    padding: 7px 10px;
    color: var(--site-muted);
    font-size: 12px;
    line-height: 1.4;
    background: var(--site-surface-soft);
    border-bottom: 1px solid var(--site-border);
}

/* Article and product editorial typography. */
.article-detail .article,
.product-tabs__pane,
.prd-description {
    line-height: 1.7;
}

.article-detail .article p,
.product-tabs__pane p,
.prd-description p {
    margin: 0 0 14px;
}

.article-detail .article h2,
.article-detail .article h3,
.product-tabs__pane h2,
.product-tabs__pane h3 {
    margin-top: 26px;
    margin-bottom: 12px;
    line-height: 1.35;
}

.article-detail .article ul,
.article-detail .article ol,
.product-tabs__pane ul,
.product-tabs__pane ol {
    padding-left: 24px;
}

.article-detail .article blockquote,
.product-tabs__pane blockquote {
    margin: 18px 0;
    padding: 14px 18px;
    color: #444;
    border-left: 4px solid var(--site-accent);
    background: var(--site-surface-soft);
}

/* Product cards: clearer hierarchy, consistent height and touch targets. */
.list-product > li {
    min-width: 0;
}

.main-product {
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--site-border);
    border-radius: var(--site-radius);
    background: var(--site-surface);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.main-product:hover,
.main-product:focus-within {
    border-color: #ccd2d9;
    box-shadow: var(--site-shadow);
    transform: translateY(-2px);
}

.main-product .thumb {
    overflow: hidden;
    background: #fff;
}

.main-product .thumb img {
    max-width: 100%;
    height: auto;
    transition: transform .22s ease;
}

.main-product:hover .thumb img {
    transform: scale(1.025);
}

.main-product .infor {
    display: flex;
    min-height: 190px;
    flex-direction: column;
}

.main-product .title {
    display: -webkit-box;
    min-height: 44px;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 1.45;
}

.main-product .wrap-price,
.main-product .notprice {
    margin-top: auto;
}

.main-product .viewmore {
    min-height: 38px;
    padding: 8px 12px;
    text-align: center;
    border-radius: 4px;
}

/* Search suggestions are easier to use on desktop and mobile. */
.header-search .searchResult,
.mobile-search .searchResult {
    max-height: min(70vh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.header-search .searchResult[aria-busy="true"],
.mobile-search .searchResult[aria-busy="true"] {
    min-height: 42px;
}

.header-search .searchResult[aria-busy="true"]::before,
.mobile-search .searchResult[aria-busy="true"]::before {
    display: block;
    padding: 10px;
    color: var(--site-muted);
    content: "Đang tìm kiếm…";
}

/* Keep the mobile action bar clear of device safe areas. */
.modile-show {
    padding-bottom: env(safe-area-inset-bottom);
}

.modile-show .bar-item a,
.modile-show .bar-item {
    min-height: 44px;
}

/* Existing back-to-top control, enhanced by JS. */
#goTop {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}

#goTop.is-visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Prevent very long URLs or product codes from widening the page. */
.article-detail a,
.product-tabs__pane a,
.footer a,
.breadcrumb a {
    overflow-wrap: anywhere;
}

/* Navigation and buttons should have comfortable tap targets. */
.mobile-header a,
.mobile-header button,
.offcanvas a,
.pagination a,
.pagination span {
    min-height: 40px;
}

@media (max-width: 767px) {
    .responsive-table table,
    table.seo-content-table {
        min-width: 680px;
    }

    .table-scroll-hint {
        display: block;
    }

    .article-detail iframe[src*="youtube"],
    .article-detail iframe[src*="youtu.be"],
    .article-detail iframe[src*="vimeo"],
    .product-tabs__pane iframe[src*="youtube"],
    .product-tabs__pane iframe[src*="youtu.be"],
    .product-tabs__pane iframe[src*="vimeo"] {
        min-height: 190px;
    }

    .main-product .infor {
        min-height: 176px;
    }

    .main-product .viewmore {
        display: block;
        width: 100%;
    }

    .article-detail .article,
    .product-tabs__pane,
    .prd-description {
        font-size: 16px;
        line-height: 1.72;
    }
}

@media (max-width: 480px) {
    .responsive-table {
        margin-right: -4px;
        margin-left: -4px;
        width: calc(100% + 8px);
    }

    .responsive-table th,
    .responsive-table td,
    table.seo-content-table th,
    table.seo-content-table td {
        padding: 9px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

/* V2.1 product-card hotfix: square media, full image visibility, no artificial gap. */
.list-product > li {
    display: flex;
}

.main-product {
    display: flex;
    width: 100%;
    flex-direction: column;
}

.main-product .thumb {
    width: 100%;
    margin: 0 0 10px;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #fff;
}

.main-product .image {
    display: flex;
    width: 100%;
    height: 100% !important;
    aspect-ratio: 1 / 1;
    align-items: center;
    justify-content: center;
}

.main-product .thumb img {
    display: block;
    width: 100%;
    height: 100% !important;
    object-fit: contain;
    object-position: center;
}

.main-product .infor {
    display: flex;
    min-height: 0 !important;
    flex: 1 1 auto;
    flex-direction: column;
}

.main-product .title {
    min-height: 42px;
    margin: 0 0 7px;
}

.main-product .wrap-price,
.main-product .notprice {
    margin-top: 0;
}

.main-product .km {
    min-height: 40px;
    margin-top: 4px;
    line-height: 20px;
}

.main-product .viewmore {
    margin-top: auto;
}

@media (max-width: 567px) {
    .main-product .image {
        height: 100% !important;
    }

    .main-product .title {
        min-height: 38px;
    }
}
