/*
 * Chống vỡ giao diện với nội dung admin nhập trong các trình sửa (trang theo khối, header, footer):
 * chữ dài / từ liền không dấu cách, danh sách nhiều mục hơn thiết kế gốc. Nạp sau cùng (head-assets).
 */

/* 1) Từ quá dài tự xuống dòng thay vì tràn khỏi thẻ (anywhere: phần tử flex/grid co lại được) */
:where([data-page-sections], #aladdin-about-reference, .cc-footer-wrapper, .av-header, .cc-mobile-wireframe-header, .desktop-category-rail)
    :where(h1, h2, h3, h4, h5, h6, p, li, span, strong, em, b, a, small, label, button, blockquote, figcaption, dt, dd, div) {
    overflow-wrap: anywhere;
}
:where([data-page-sections], #aladdin-about-reference, .cc-footer-wrapper) :where(td, th) {
    overflow-wrap: break-word;
}

/* 2) Thanh thông tin trên cùng (một dòng): co lại và cắt "…" thay vì đẩy tràn ngang */
.av-topbar-row { min-width: 0; }
.av-topbar-group { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.av-topbar-item { flex: 0 1 auto; min-width: 0; overflow: hidden; }
.av-topbar-icon-wrap { flex: none; }
.av-topbar-addr-link { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; }
.av-topbar-item .av-topbar-label,
.av-topbar-item .av-topbar-addr-val,
.av-topbar-item .av-topbar-phone {
    display: inline-block;
    min-width: 0;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: normal;
}
.av-topbar-item .av-topbar-phone { max-width: 170px; }
.av-topbar-item .av-topbar-chip {
    display: inline-block !important;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 20px !important;
}
.av-topbar-right { flex: 0 1 auto; min-width: 0; max-width: 280px; }
.av-topbar-pill-btn { max-width: 100%; min-width: 0; overflow: hidden; }
.av-topbar-pill-btn > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }

/* 3) Menu chính: luôn một hàng. Tên mục dài / nhiều mục thì từng mục co lại và cắt "…" (title hiện tên đầy đủ) */
.av-nav { flex: 0 1 auto; min-width: 0; }
.av-nav > a.cc-nav-link,
.av-nav > .cc-nav-item-dropdown { flex: 0 1 auto; min-width: 44px; }
.av-nav .cc-nav-item-dropdown > .cc-nav-link { max-width: 100%; }
.av-nav .cc-nav-link { min-width: 0; max-width: 180px; white-space: nowrap; }
.av-nav .cc-nav-label { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }
.cc-nav-mini-dropdown a { white-space: normal; }

/* 4) Header điện thoại: chữ nút chat dài thì cắt "…" */
.cc-m-hdr-btn > span { display: block; max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }

/* 5) Footer: cột co được, chữ dài xuống dòng, thẻ hotline / mạng xã hội không bị bóp méo */
.cc-footer-columns-row > .cc-footer-column { min-width: 0; }
.cc-commitment-card, .cc-commitment-label { min-width: 0; white-space: normal; }
.cc-hotline-card { flex-wrap: wrap; row-gap: 6px; }
.cc-hotline-card-info { flex: 1 1 140px; min-width: 0; }
.cc-hotline-card-label { display: block; white-space: normal; }
.cc-social-card { min-width: 0; max-width: 100%; }
.cc-social-name { min-width: 0; white-space: normal; }
.cc-footer-link-list a { white-space: normal; }

/* 6) Trang Đối tác: 2 dòng tiêu đề ảnh bìa vốn ép một dòng — chữ admin dài thì cho xuống dòng */
.b2b-page .b2b-hero h1 > span { white-space: normal; }

/* 7) Chỗ bản gốc ép một dòng (nút, nhãn, tiêu đề thẻ): chữ ngắn vẫn một dòng, chữ admin quá dài thì xuống dòng */
.b2b-page .b2b-submit-btn,
.b2b-page .b2b-hero .b2b-btn-primary,
.b2b-page .b2b-hero .b2b-btn-secondary { white-space: normal !important; text-align: center; }
.av-about .av-distribution h3,
.av-distribution-benefits li,
.av-distribution-logo span,
.av-distribution-logo--label,
#aladdin-about-reference .ar-section-head a { white-space: normal !important; }
.ac-map-card__heading { flex-wrap: wrap; }
.ac-map-card__heading > * { min-width: 0; }
.ac-map-link { white-space: normal; }
#aladdin-about-reference .av-about-button,
#aladdin-about-reference .av-cta-m-btn { white-space: normal !important; text-align: center; }
/* Cột lưới không được phình theo nội dung dài nhất (mặc định min-width:auto) */
#aladdin-about-reference :where(.av-about-experience, .av-about-hero, .av-about-brands-grid, .av-about-cta-mobile-card) > * { min-width: 0; }

/* 8) Tiêu đề khối trang chủ: tiêu đề chiếm phần còn lại, nút "Xem tất cả" tối đa 40vw (không dùng % vì tiêu đề mobile là grid) và cắt "…" */
:is(.desktop-exclusive-deals__header, .desktop-best-sellers__header, .desktop-catalog-section > header,
    .desktop-brand-showcase__header, .desktop-news-section__header, .desktop-voucher-strip__header, .desktop-brands-strip__header) {
    min-width: 0;
}
:is(.desktop-exclusive-deals__header, .desktop-best-sellers__header, .desktop-catalog-section > header,
    .desktop-brand-showcase__header, .desktop-news-section__header, .desktop-voucher-strip__header, .desktop-brands-strip__header) > :first-child {
    flex: 1 1 auto;
    min-width: 0;
}
:is(.desktop-exclusive-deals__header, .desktop-best-sellers__header, .desktop-catalog-section > header,
    .desktop-brand-showcase__header, .desktop-news-section__header, .desktop-voucher-strip__header, .desktop-brands-strip__header) > a:last-child {
    flex: 0 0 auto;
    min-width: 0;
    max-width: 40vw;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow-wrap: normal;
}
:is(.desktop-exclusive-deals__header, .desktop-best-sellers__header, .desktop-catalog-section > header,
    .desktop-brand-showcase__header, .desktop-news-section__header, .desktop-voucher-strip__header, .desktop-brands-strip__header) > a:last-child span {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow-wrap: normal;
}

/* 9) Chữ trong huy hiệu tròn (HACCP, GMP…): không bẻ giữa từ — ô nhập đã giới hạn 8 ký tự */
.b2b-cert-badge { overflow-wrap: normal; }
