
/* ==========================================================================
   1. GLOBAL MULTI-DEVICE FOUNDATION & ZERO HORIZONTAL OVERFLOW
   ========================================================================== */
html {
    max-width: 100% !important;
    overflow-x: clip !important;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}
body {
    max-width: 100% !important;
    overflow-x: clip !important;
    background-color: #eef2f7 !important;
    background-image: none !important;
}
#wrapper {
    width: 100% !important;
    max-width: 1220px !important;
    margin: 0 auto !important;
    overflow-x: clip !important;
    background: #ffffff !important;
    box-shadow: 0 0 36px rgba(15, 23, 42, 0.08);
}
.container {
    max-width: 100% !important;
    box-sizing: border-box !important;
}
/* Universal CSS Grid / Flex Blowout Guard */
#content,
#primary,
#secondary,
#sidebar,
.site-content,
.site-main,
.entry-content,
.post-info,
article,
.tta-box-card,
.tta-sec,
.tta-cr-consult-box > *,
.tta-hub-wrap,
.tta-hub-hero > *,
.tta-hub-cluster-card,
.tta-hub-mb-card,
.tta-hub-mb-info,
.tta-bk-card,
.tta-bk-body,
.tta-grid-2 > *,
.tta-grid-3 > *,
.tta-grid-4 > * {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Fix Bootstrap .row (-15px) causing +5px overflow on Phone & iPad Portrait */
@media (max-width: 1024px) {
    .container {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }
    .top-header .row,
    .mid-header .row,
    #header .row,
    #footer .row,
    #main .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .top-header [class*="col-"],
    .mid-header [class*="col-"],
    #header [class*="col-"] {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }
    #main > .container > .row > [class*="col-"] {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* ==========================================================================
   2. CRITICAL FIX FOR ALL 5,500+ SINGLE BLOG POSTS (DESKTOP, IPAD & PHONE)
   Theme benhvienthanhan sets `.post-info { display: table }` which stretches
   to 880px+ and clips titles, metadata, images & text off the right edge!
   ========================================================================== */
.post-info,
.single .post-info,
article .post-info,
.post-fullwidth .post-info,
.archive .post-info,
.search .post-info {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    float: none !important;
    box-sizing: border-box !important;
}
.single article,
.single .site-content,
.single .entry-content {
    max-width: 100% !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
}
.single h1.post-title,
.single h1.title,
h1.post-title {
    font-size: clamp(20px, 2.3vw, 27px) !important;
    line-height: 1.38 !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    max-width: 100% !important;
}
.single .post-meta,
.single .post-cat {
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    line-height: 1.55 !important;
}
.entry-content img,
.tta-single-post-hero-cover,
.tta-single-post-hero-cover img,
.site-content img,
article img {
    max-width: 100% !important;
    height: auto !important;
}
.entry-content figure,
.wp-caption {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}
.entry-content iframe,
.entry-content video,
.entry-content embed,
.entry-content object {
    max-width: 100% !important;
}
.entry-content p,
.entry-content li {
    font-size: clamp(15px, 1.05vw, 16.5px);
    line-height: 1.75;
}

/* Responsive Scrollable Tables & KaTeX/MathJax Formula Protection */
.tta-resp-table-scroll,
.tta-table-wrap,
.tta-kw-table-wrap {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin: 14px 0 20px !important;
    box-sizing: border-box !important;
}
.tta-resp-table-scroll > table,
.tta-table-wrap > table,
.tta-kw-table-wrap > table {
    margin: 0 !important;
    min-width: 520px;
}
.tta-math-block,
.katex-display,
.MathJax_Display,
mjx-container[display="true"] {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 6px 2px !important;
}
.katex .hide-tail,
.katex svg {
    max-width: 100% !important;
}
#MathJax_Message {
    display: none !important;
}

/* ==========================================================================
   3. HEADER & NAVIGATION — DESKTOP, IPAD LANDSCAPE, IPAD PORTRAIT & PHONE
   ========================================================================== */
.mid-header {
    padding: 8px 0 !important;
}
.mid-header .right-header p {
    margin: 0 !important;
}
.mid-header .right-header img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* Desktop & iPad Landscape (>= 992px): Compact Header + Guaranteed 1-Row Nav */
@media (min-width: 992px) {
    .mid-header .row {
        display: flex !important;
        align-items: center !important;
    }
    .mid-header .logo img {
        max-height: 86px !important;
        width: auto !important;
        display: block !important;
    }
    .mid-header .right-header img {
        max-height: 108px !important;
        width: auto !important;
        margin-left: auto !important;
    }
    #menu-main.tta-ux-menu-upgraded {
        flex-wrap: nowrap !important;
    }
}
@media (min-width: 992px) and (max-width: 1199px) {
    #menu-main > li > a {
        padding-left: 9px !important;
        padding-right: 9px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
    }
}

/* iPad Portrait (768px - 991px): Side-by-Side Compact Header (cuts height 557px -> ~240px!) */
@media (min-width: 768px) and (max-width: 991px) {
    .mid-header {
        padding: 10px 0 !important;
    }
    .mid-header .row {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 14px !important;
        flex-wrap: nowrap !important;
    }
    .mid-header .row > .col-md-3,
    .mid-header .row > [class*="col-"]:first-child {
        flex: 0 0 138px !important;
        width: 138px !important;
        max-width: 138px !important;
        text-align: left !important;
    }
    .mid-header .row > .col-md-9,
    .mid-header .row > [class*="col-"]:last-child {
        flex: 1 1 auto !important;
        width: auto !important;
        min-width: 0 !important;
    }
    .mid-header .logo img {
        max-height: 70px !important;
        width: auto !important;
        margin: 0 !important;
    }
    .mid-header .right-header img {
        max-height: 86px !important;
        width: auto !important;
        max-width: 100% !important;
        margin-left: auto !important;
        object-fit: contain !important;
    }
    /* Full-width content column on iPad Portrait so articles & hubs breathe */
    #main .col-md-9,
    #main .col-md-3,
    #main #content,
    #main #sidebar {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        float: none !important;
    }
}

/* Phone (<= 767px): Compact Header, Touch-Friendly Menu & Search */
@media (max-width: 767px) {
    .top-header {
        padding: 4px 0 !important;
    }
    .top-header .top-menu {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 4px 10px !important;
        margin: 0 !important;
        padding: 2px 0 !important;
    }
    .top-header .top-menu li a {
        font-size: 12.5px !important;
        padding: 3px 6px !important;
    }
    .mid-header {
        padding: 6px 0 !important;
    }
    .mid-header .logo {
        display: inline-block !important;
        margin: 0 auto !important;
    }
    .mid-header .logo img {
        max-height: 52px !important;
        width: auto !important;
    }
    .mid-header .right-header {
        display: none !important;
    }
    nav.main-menu .mobile-menu {
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
    #menu-main {
        border-radius: 0 0 12px 12px !important;
        box-shadow: 0 16px 32px rgba(15, 23, 42, 0.25) !important;
        overflow: hidden !important;
    }
    #menu-main > li > a {
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
    /* Quick search bar: prevent iOS zoom (16px font) & smooth horizontal chips */
    #tta-quick-search-bar {
        padding: 8px 0 !important;
    }
    #tta-quick-search-bar input[type="search"],
    #tta-quick-search-bar input[type="text"] {
        font-size: 16px !important;
        min-height: 42px !important;
    }
    .tta-qsearch-chips {
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none;
        padding-bottom: 2px !important;
    }
    .tta-qsearch-chips::-webkit-scrollbar {
        display: none;
    }
    /* Hide legacy giant slider inside header on internal tool pages like de-test-45-phut on mobile */
    body:not(.home) #header .main-slider {
        display: none !important;
    }
    /* Clear bottom sticky bar */
    body {
        padding-bottom: 58px !important;
    }
}

/* ==========================================================================
   4. BOOK CARDS, /SACH/ BREADCRUMB & /KHOA-HOC/ REGISTER GRID FIX
   ========================================================================== */
.tta-bk-specs {
    flex-wrap: wrap !important;
    gap: 4px 10px !important;
}
.tta-bk-specs span {
    white-space: normal !important;
    overflow-wrap: break-word !important;
    max-width: 100% !important;
}
.tta-bk-readers {
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    flex-basis: 100% !important;
    max-width: 100% !important;
}
/* Fix duplicate » separator ONLY on /sach/ breadcrumbs that already have inline <span>/</span> */
.breadcrumbs li:has(> span)::after,
ul.breadcrumbs li:has(> span)::after,
.tta-bk-top-bar .breadcrumbs li::after {
    content: none !important;
    display: none !important;
}
/* Fix /khoa-hoc/ consult box grid blowout (+115px on Phone) */
#tta-cr-register-box.tta-cr-consult-box,
.tta-cr-consult-box {
    max-width: 100% !important;
    box-sizing: border-box !important;
}
@media (max-width: 900px) {
    #tta-cr-register-box.tta-cr-consult-box,
    .tta-cr-consult-box {
        grid-template-columns: minmax(0, 1fr) !important;
        padding: 20px 16px !important;
        gap: 18px !important;
    }
    .tta-cr-lead-form,
    #tta-cr-hub-lead-form,
    #tta-cr-hub-lead-form input,
    #tta-cr-hub-lead-form select,
    #tta-cr-hub-lead-form textarea,
    #tta-cr-hub-lead-form button {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        font-size: 16px !important;
    }
}
@media (min-width: 901px) {
    #tta-cr-register-box.tta-cr-consult-box,
    .tta-cr-consult-box {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    }
}

/* ==========================================================================
   5. HIGH-CONVERTING SEO LANDING PAGES (6 PAGES + REVIEW-2)
   Eliminates +131px to +196px overflow on Phone & optimizes iPad grid
   ========================================================================== */
.tta-kw-hub-wrap,
#tta-high-converting-seo-ads-app {
    max-width: 100% !important;
    overflow-x: clip !important;
    box-sizing: border-box !important;
}
.tta-nav-tabs-wrap {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
}
.tta-box-card,
.tta-sec,
#hoc-phi.tta-box-card {
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    box-sizing: border-box !important;
}
.tta-box-card code,
.tta-box-card pre,
.tta-box-card h3,
.tta-box-card li,
.tta-box-card a,
.tta-btn-primary,
.tta-checklist li {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
@media (max-width: 767px) {
    .tta-grid-2,
    .tta-grid-3,
    .tta-grid-4 {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 14px !important;
    }
    .tta-box-card {
        padding: 16px 14px !important;
    }
    .tta-btn-primary {
        width: 100% !important;
        padding: 13px 16px !important;
        font-size: 15px !important;
        line-height: 1.4 !important;
    }
    /* Make review-2 (inside default page template) clean full-width without cramped side walls */
    body.page-id-24111 #main > .container,
    body.tta-has-kw-hub #main > .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    body.page-id-24111 #content,
    body.tta-has-kw-hub #content {
        width: 100% !important;
        padding: 0 !important;
    }
    body.page-id-24111 #sidebar,
    body.tta-has-kw-hub #sidebar {
        display: none !important;
    }
}
@media (min-width: 768px) and (max-width: 1024px) {
    .tta-grid-3,
    .tta-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    .tta-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* ==========================================================================
   6. PILLAR HUB PAGES (TOÁN 12 THỰC TẾ, TOÁN 10 CHUYÊN, TỦ SÁCH 50 KIỆT TÁC)
   Expands full-width canvas & prevents 84px-144px squished cards on iPad/Desktop
   ========================================================================== */
body.tta-is-hub-page #content,
body:has(.tta-hub-wrap) #content,
body.page-id-24524 #content,
body.page-id-24525 #content,
body.page-id-24526 #content {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    float: none !important;
}
body.tta-is-hub-page #sidebar,
body:has(.tta-hub-wrap) #sidebar,
body.page-id-24524 #sidebar,
body.page-id-24525 #sidebar,
body.page-id-24526 #sidebar {
    display: none !important;
}
.tta-hub-wrap {
    width: 100% !important;
    max-width: 100% !important;
}
@media (max-width: 860px) {
    .tta-hub-hero {
        grid-template-columns: minmax(0, 1fr) !important;
        padding: 22px 18px !important;
        gap: 20px !important;
    }
    .tta-hub-h1 {
        font-size: clamp(22px, 5.5vw, 28px) !important;
        line-height: 1.3 !important;
    }
    .tta-hub-clusters,
    .tta-hub-cluster-grid,
    .tta-hub-mb-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}
@media (min-width: 861px) {
    .tta-hub-hero {
        grid-template-columns: minmax(0, 1.35fr) minmax(260px, 320px) !important;
        gap: 28px !important;
    }
    .tta-hub-clusters,
    .tta-hub-cluster-grid {
        grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)) !important;
    }
    .tta-hub-mb-grid {
        grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)) !important;
    }
}
.tta-hub-mb-card {
    display: flex !important;
    gap: 14px !important;
    align-items: flex-start !important;
}
.tta-hub-mb-info {
    flex: 1 1 160px !important;
    min-width: 0 !important;
}

/* ==========================================================================
   7. FLOATING STICKY BARS, BACK-TO-TOP & ZERO FIXED COLLISIONS
   ========================================================================== */
@media (max-width: 767px) {
    .tta-sticky-bar {
        display: flex !important;
        align-items: stretch !important;
        justify-content: space-between !important;
        gap: 5px !important;
        padding: 6px 6px max(6px, env(safe-area-inset-bottom)) 6px !important;
        box-sizing: border-box !important;
    }
    .tta-sticky-bar a {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        padding: 9px 4px !important;
        font-size: 11.5px !important;
        letter-spacing: -0.25px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: clip !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
    }
    .tta-sticky-bar a.tta-sb-call {
        flex: 1.18 1 0% !important;
    }
    #tta-back-top {
        bottom: 66px !important;
        right: 12px !important;
        width: 40px !important;
        height: 40px !important;
        z-index: 9990 !important;
    }
    #tta-cro-sticky-bar.tta-cro-sticky-bar:not(.is-visible) {
        bottom: 0 !important;
        transform: translateY(150%) !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
    #tta-cro-sticky-bar.tta-cro-sticky-bar.is-visible {
        bottom: 50px !important;
        transform: translateY(0) !important;
        visibility: visible !important;
        pointer-events: auto !important;
        z-index: 9985 !important;
    }
}
@media (min-width: 768px) {
    /* Lift back-to-top cleanly above the bottom-right Zalo/Call stack (85px tall + bottom 18px) */
    #tta-back-top {
        bottom: 116px !important;
        right: 20px !important;
        z-index: 9990 !important;
    }
}

/* ==========================================================================
   8. FOOTER & LEGACY TEMPLATES (AFFILIATE, THI-ONLINE, TAI-LIEU, AUTH FORMS)
   ========================================================================== */
/* Fix invisible white-on-white Facebook link in footer when FB SDK is blocked */
.tta-ft-fb-card,
.tta-ft-fb-card blockquote,
.tta-ft-fb-card blockquote a,
.tta-ft-fb-card a {
    color: #1877f2 !important;
    font-weight: 700 !important;
    text-decoration: none !important;
}
.tta-ft-fb-card blockquote {
    margin: 0 !important;
    padding: 10px 14px !important;
    border: none !important;
    background: transparent !important;
    text-align: center !important;
}

/* Fix /affiliate/ invisible hero on Mobile/iPad/Desktop */
#affiliate-content #header-aff {
    background: linear-gradient(135deg, #0f172a 0%, #960606 100%) !important;
    color: #ffffff !important;
    padding: clamp(32px, 6vw, 68px) 16px !important;
    height: auto !important;
    min-height: 0 !important;
    text-align: center !important;
}
#affiliate-content #header-aff .slogan h1 {
    color: #ffffff !important;
    font-size: clamp(22px, 3.2vw, 34px) !important;
    line-height: 1.35 !important;
    margin: 0 0 14px !important;
    font-weight: 800 !important;
}
#affiliate-content #header-aff .intro {
    color: #fde68a !important;
    font-size: clamp(15px, 1.8vw, 19px) !important;
    margin: 0 0 22px !important;
    font-weight: 600 !important;
}
#affiliate-content #header-aff .more a {
    display: inline-block !important;
    background: #f59e0b !important;
    color: #0f172a !important;
    font-weight: 800 !important;
    padding: 12px 28px !important;
    border-radius: 999px !important;
    text-decoration: none !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25) !important;
}

#affiliate-content iframe {
    width: 100% !important;
    max-width: 640px !important;
    aspect-ratio: 16 / 9;
    height: auto !important;
    display: block !important;
    margin: 0 auto !important;
    border-radius: 10px !important;
}

/* Fix /thi-online/ & /tai-lieu-mien-phi/ legacy templates */
.item-services img,
.item-services a img {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 10;
    object-fit: cover !important;
    object-position: left center !important;
    border-radius: 8px !important;
    display: block !important;
}
#main h2:empty,
.title-box h2:empty {
    display: none !important;
}

/* Touch-friendly Auth & Account Forms (prevent iOS Safari auto-zoom) */
.page-template-login input[type="text"],
.page-template-login input[type="password"],
.page-template-login input[type="email"],
.page-template-register-user input[type="text"],
.page-template-register-user input[type="password"],
.page-template-register-user input[type="email"],
.page-template-template-taikhoan input,
.page-template-nap-tien input,
.page-template-template-formpay input,
.page-template-template-formpay select {
    min-height: 44px !important;
    font-size: 16px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 8px !important;
}
.page-template-login button,
.page-template-login input[type="submit"],
.page-template-register-user button,
.page-template-register-user input[type="submit"] {
    min-height: 44px !important;
    padding: 10px 22px !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
}
