/* ============================================================
   FIX NỘI DUNG CKEDITOR 5 TRONG THEME STYLE2025
   Thêm vào file: themes/style2025/css/custom.css
   ============================================================ */

/* ── Vùng nội dung bài viết ────────────────────────────────── */
#news-bodyhtml,
.bodytext,
.hometext {
    line-height: 1.8;
    font-size: 15px;
    color: #333;
    word-break: break-word;
}

/* ── Tiêu đề (h1–h6) ────────────────────────────────────────
   Theme reset toàn bộ → phải khai báo lại kích thước & khoảng cách
   ─────────────────────────────────────────────────────────── */
#news-bodyhtml h1,
#news-bodyhtml h2,
#news-bodyhtml h3,
#news-bodyhtml h4,
#news-bodyhtml h5,
#news-bodyhtml h6,
.bodytext h1,
.bodytext h2,
.bodytext h3,
.bodytext h4,
.bodytext h5,
.bodytext h6 {
    font-weight: 700;
    margin-top: 1.2em;
    margin-bottom: 0.6em;
    line-height: 1.4;
    color: #111;
}
#news-bodyhtml h1, .bodytext h1 { font-size: 2em; }
#news-bodyhtml h2, .bodytext h2 { font-size: 1.6em; }
#news-bodyhtml h3, .bodytext h3 { font-size: 1.35em; }
#news-bodyhtml h4, .bodytext h4 { font-size: 1.15em; }
#news-bodyhtml h5, .bodytext h5 { font-size: 1em; }
#news-bodyhtml h6, .bodytext h6 { font-size: 0.9em; color: #555; }

/* ── Đoạn văn & khoảng cách ────────────────────────────────── */
#news-bodyhtml p,
.bodytext p {
    margin-bottom: 1em;
}

/* ── Danh sách (ul / ol) ────────────────────────────────────
   Theme reset list-style: none → phải khôi phục lại
   ─────────────────────────────────────────────────────────── */
#news-bodyhtml ul,
.bodytext ul {
    list-style: disc;
    padding-left: 1.8em;
    margin-bottom: 1em;
}
#news-bodyhtml ol,
.bodytext ol {
    list-style: decimal;
    padding-left: 1.8em;
    margin-bottom: 1em;
}
#news-bodyhtml ul li,
#news-bodyhtml ol li,
.bodytext ul li,
.bodytext ol li {
    list-style: inherit;
    padding: 0;
    margin: 0 0 0.3em 0;
    display: list-item;
}
/* Danh sách lồng nhau */
#news-bodyhtml ul ul,
.bodytext ul ul {
    list-style: circle;
    margin-bottom: 0;
}
#news-bodyhtml ul ul ul,
.bodytext ul ul ul {
    list-style: square;
}
#news-bodyhtml ol ol,
.bodytext ol ol {
    list-style: lower-alpha;
    margin-bottom: 0;
}

/* ── Hình ảnh ───────────────────────────────────────────────── */
#news-bodyhtml img,
.bodytext img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1em auto;
    border-radius: 4px;
}
/* Hình inline (CKEditor thêm class này) */
#news-bodyhtml img.image-style-side,
.bodytext img.image-style-side {
    float: right;
    margin: 0.5em 0 1em 1.5em;
    max-width: 50%;
}
#news-bodyhtml .image,
.bodytext .image {
    text-align: center;
    margin: 1.5em 0;
}
#news-bodyhtml .image > figcaption,
.bodytext .image > figcaption {
    font-size: 13px;
    color: #777;
    text-align: center;
    margin-top: 0.4em;
    font-style: italic;
}

/* ── Blockquote ─────────────────────────────────────────────── */
#news-bodyhtml blockquote,
.bodytext blockquote {
    border-left: 4px solid #ff6700;
    margin: 1.5em 0;
    padding: 0.8em 1.2em;
    background: #fff8f5;
    color: #555;
    font-style: italic;
    border-radius: 0 4px 4px 0;
}
#news-bodyhtml blockquote p,
.bodytext blockquote p {
    margin-bottom: 0;
}

/* ── Bảng (table) ───────────────────────────────────────────── */
#news-bodyhtml table,
.bodytext table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 14px;
    overflow-x: auto;
    display: block;
}
#news-bodyhtml table th,
#news-bodyhtml table td,
.bodytext table th,
.bodytext table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}
#news-bodyhtml table th,
.bodytext table th {
    background: #f5f5f5;
    font-weight: 700;
    color: #333;
}
#news-bodyhtml table tr:hover,
.bodytext table tr:hover {
    background: #fafafa;
}

/* ── Code & Pre ─────────────────────────────────────────────── */
#news-bodyhtml pre,
.bodytext pre {
    background: #f4f4f4;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1em;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    margin: 1em 0;
}
#news-bodyhtml code,
.bodytext code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    color: #c7254e;
}
#news-bodyhtml pre code,
.bodytext pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* ── Đường kẻ ngang (hr) ────────────────────────────────────── */
#news-bodyhtml hr,
.bodytext hr {
    border: none;
    border-top: 2px solid #eee;
    margin: 2em 0;
}

/* ── Link trong nội dung ────────────────────────────────────── */
#news-bodyhtml a,
.bodytext a {
    color: #ff6700;
    text-decoration: underline;
}
#news-bodyhtml a:hover,
.bodytext a:hover {
    color: #cc5200;
    text-decoration: none;
}

/* ── Strong / Em / Mark ─────────────────────────────────────── */
#news-bodyhtml strong, .bodytext strong { font-weight: 700; }
#news-bodyhtml em,     .bodytext em     { font-style: italic; }
#news-bodyhtml mark,   .bodytext mark   { background: #fff3cd; padding: 0 3px; border-radius: 2px; }
#news-bodyhtml u,      .bodytext u      { text-decoration: underline; }
#news-bodyhtml s,      .bodytext s      { text-decoration: line-through; }
#news-bodyhtml sub,    .bodytext sub    { vertical-align: sub; font-size: 0.8em; }
#news-bodyhtml sup,    .bodytext sup    { vertical-align: super; font-size: 0.8em; }

/* ── CKEditor 5 – class đặc trưng ───────────────────────────── */
/* Media embed (YouTube, v.v.) */
#news-bodyhtml .media,
.bodytext .media {
    margin: 1.5em 0;
}
#news-bodyhtml .media > div,
.bodytext .media > div {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
}
#news-bodyhtml .media iframe,
.bodytext .media iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
}

/* Căn chỉnh hình CKEditor */
#news-bodyhtml .image.image_resized,
.bodytext .image.image_resized {
    display: block;
    box-sizing: border-box;
}
#news-bodyhtml .image.image-style-align-left,
.bodytext .image.image-style-align-left {
    float: left;
    margin-right: 1.5em;
    margin-bottom: 0.5em;
}
#news-bodyhtml .image.image-style-align-right,
.bodytext .image.image-style-align-right {
    float: right;
    margin-left: 1.5em;
    margin-bottom: 0.5em;
}
#news-bodyhtml .image.image-style-align-center,
.bodytext .image.image-style-align-center {
    margin-left: auto;
    margin-right: auto;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 576px) {
    #news-bodyhtml,
    .bodytext {
        font-size: 14px;
    }
    #news-bodyhtml h1, .bodytext h1 { font-size: 1.6em; }
    #news-bodyhtml h2, .bodytext h2 { font-size: 1.35em; }
    #news-bodyhtml h3, .bodytext h3 { font-size: 1.15em; }
    #news-bodyhtml table,
    .bodytext table {
        font-size: 12px;
    }
    #news-bodyhtml table th,
    #news-bodyhtml table td,
    .bodytext table th,
    .bodytext table td {
        padding: 6px 8px;
    }
    #news-bodyhtml .image.image-style-align-left,
    #news-bodyhtml .image.image-style-align-right,
    .bodytext .image.image-style-align-left,
    .bodytext .image.image-style-align-right {
        float: none;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ═══════════════════════════════════════════════════════
   DETAIL PAGE — TABS + GALLERY + BODYTEXT FIX
   Thêm vào cuối custom.css (load cuối, override được hết)
   ═══════════════════════════════════════════════════════ */

/* ── 1. TABS ──────────────────────────────────────────── */
.b2b-tabs-section {
    margin-top: 28px;
    border: 1px solid #e0e6ef;
    border-radius: 8px;
    overflow: hidden;
}

.b2b-tabs {
    display: flex !important;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e6ef;
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: nowrap;
}
.b2b-tabs::-webkit-scrollbar { display: none; }

.b2b-tabs__btn {
    display: inline-block !important;
    padding: 13px 22px;
    border: none;
    background: none;
    font-size: 13.5px;
    font-weight: 600;
    color: #526070;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color .18s, background .18s;
    font-family: inherit;
    line-height: 1;
}
.b2b-tabs__btn:hover {
    color: #0D2B5B;
    background: rgba(13,43,91,.04);
}
.b2b-tabs__btn.active {
    color: #0D2B5B;
    background: #fff;
    border-bottom-color: #F57C00;
}

/* Tab panes — ẩn hết trừ .active */
.b2b-tab-pane {
    display: none !important;
    padding: 24px;
}
.b2b-tab-pane.active {
    display: block !important;
}

/* ── 2. BODYTEXT trong tab ────────────────────────────── */
.b2b-detail__bodytext {
    font-size: 14.5px !important;
    line-height: 1.85 !important;
    color: #333 !important;
    word-break: break-word;
}
.b2b-detail__bodytext h1,
.b2b-detail__bodytext h2,
.b2b-detail__bodytext h3,
.b2b-detail__bodytext h4,
.b2b-detail__bodytext h5,
.b2b-detail__bodytext h6 {
    font-weight: 700 !important;
    margin-top: 1.2em !important;
    margin-bottom: 0.6em !important;
    line-height: 1.4;
    color: #111 !important;
}
.b2b-detail__bodytext h2 { font-size: 1.4em !important; color: #0D2B5B !important; }
.b2b-detail__bodytext h3 { font-size: 1.2em !important; }
.b2b-detail__bodytext p  { margin-bottom: 1em !important; }
.b2b-detail__bodytext ul,
.b2b-detail__bodytext ol {
    padding-left: 22px !important;
    margin-bottom: 1em !important;
}
.b2b-detail__bodytext ul { list-style: disc !important; }
.b2b-detail__bodytext ol { list-style: decimal !important; }
.b2b-detail__bodytext li { margin-bottom: 5px !important; }
.b2b-detail__bodytext img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 4px;
}
.b2b-detail__bodytext table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    font-size: 13.5px;
}
.b2b-detail__bodytext table td,
.b2b-detail__bodytext table th {
    border: 1px solid #dee2e6 !important;
    padding: 8px 12px !important;
    text-align: left;
}
.b2b-detail__bodytext table th {
    background: #f8f9fa !important;
    font-weight: 700;
    color: #0D2B5B;
}

/* ── 3. GALLERY HEIGHT FIX ────────────────────────────── */
.gallery-top {
    height: 420px !important;
    overflow: hidden;
    background: #fff;
}
.gallery-top .swiper-wrapper { height: 100% !important; }
.gallery-top .swiper-slide {
    height: 420px !important;
    padding-bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #fff;
}
.gallery-top .swiper-slide img {
    position: static !important;
    transform: none !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 420px !important;
    object-fit: contain;
    display: block !important;
    margin: 0 auto;
}
.gallery-thumbs .swiper-slide {
    height: 72px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.gallery-thumbs .swiper-slide .p-100 {
    padding-bottom: 0 !important;
    height: 72px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100%;
}
.gallery-thumbs .swiper-slide img,
.gallery-thumbs .swiper-slide .p-100 img {
    position: static !important;
    transform: none !important;
    left: auto !important;
    top: auto !important;
    max-width: 100% !important;
    max-height: 66px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    display: block !important;
}

/* ── 4. SPECS TABLE ───────────────────────────────────── */
.b2b-specs-wrap { overflow-x: auto; }
.b2b-specs-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.b2b-specs-table th, .b2b-specs-table td {
    padding: 9px 14px;
    border: 1px solid #e0e6ef;
    text-align: left;
    vertical-align: top;
}
.b2b-specs-table th {
    background: #f0f4f8;
    font-weight: 700;
    color: #0D2B5B;
    width: 38%;
    white-space: nowrap;
}
.b2b-specs-table tr:nth-child(even) td { background: #f8f9fa; }

@media (max-width: 768px) {
    .gallery-top { height: 280px !important; }
    .gallery-top .swiper-slide { height: 280px !important; }
    .gallery-top .swiper-slide img { max-height: 280px !important; }
    .b2b-tabs__btn { padding: 10px 14px; font-size: 12.5px; }
    .b2b-tab-pane { padding: 16px; }
}


/* ═══════════════════════════════════════════════════════
   PAGINATION — b2b-pagination (viewgrid, viewcat)
   ═══════════════════════════════════════════════════════ */
.b2b-pagination {
    display: flex;
    justify-content: center;
    padding: 24px 0 8px;
    width: 100%;
}

/* Bootstrap pagination override cho B2B theme */
.b2b-pagination .pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.b2b-pagination .pagination .page-item { list-style: none; }

.b2b-pagination .pagination .page-link,
.b2b-pagination .pagination li a,
.b2b-pagination .pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #d0d7e3;
    border-radius: 6px;
    background: #fff;
    color: #0D2B5B;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    transition: all .18s;
    line-height: 1;
}

.b2b-pagination .pagination .page-link:hover,
.b2b-pagination .pagination li a:hover {
    background: #EBF5FB;
    border-color: #0D2B5B;
    color: #0D2B5B;
}

/* Trang đang active */
.b2b-pagination .pagination .page-item.active .page-link,
.b2b-pagination .pagination li.active a,
.b2b-pagination .pagination li.active span {
    background: #0D2B5B !important;
    border-color: #0D2B5B !important;
    color: #fff !important;
    font-weight: 700;
    pointer-events: none;
}

/* Disabled (prev/next ở trang đầu/cuối) */
.b2b-pagination .pagination .page-item.disabled .page-link,
.b2b-pagination .pagination li.disabled a,
.b2b-pagination .pagination li.disabled span {
    background: #f8f9fa;
    border-color: #e0e6ef;
    color: #adb5bd;
    pointer-events: none;
}

/* Prev / Next text */
.b2b-pagination .pagination li:first-child a::before { content: '‹ '; }
.b2b-pagination .pagination li:last-child a::after  { content: ' ›'; }

@media (max-width: 576px) {
    .b2b-pagination .pagination .page-link,
    .b2b-pagination .pagination li a,
    .b2b-pagination .pagination li span {
        min-width: 32px;
        height: 32px;
        font-size: 12.5px;
        padding: 0 8px;
    }
}


/* ═══════════════════════════════════════════════════════
   MEGA MENU FIX — z-index + overflow
   ═══════════════════════════════════════════════════════ */

/* Nav bar cần position:relative để mega-menu absolute tính đúng */
.b2b-nav,
.b2b-navbar {
    position: relative;
    z-index: 900;
}

/* Override conflicting sidebar CSS - force correct positioning */
#mega-menu .nav-item-xiaomi .mega-menu {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    width: auto !important;
    min-width: 600px !important;
    max-width: 1000px !important;
    display: none !important;
    z-index: 9999 !important;
    flex-wrap: wrap !important;
    gap: 20px !important;
    padding: 20px !important;
    background: #fff !important;
    border-top: 3px solid var(--b2b-red) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,.15) !important;
}

#mega-menu .nav-item-xiaomi:hover .mega-menu {
    display: flex !important;
}

/* Ensure columns don't overlap */
#mega-menu .nav-item-xiaomi .mega-menu-column {
    flex: 1 1 160px !important;
    min-width: 150px !important;
    max-width: 250px !important;
    padding: 0 12px !important;
}

/* Prevent hero from showing through */
.b2b-nav ~ *,
.b2b-navbar ~ * {
    position: relative;
    z-index: 1;
}


/* ═══════════════════════════════════════════════════════
   MEGA MENU Z-INDEX FIX v2
   Header overflow:visible để mega menu không bị clip
   ═══════════════════════════════════════════════════════ */
.b2b-header,
.b2b-nav,
header {
    overflow: visible !important;
}

/* Hero section phải thấp hơn mega menu */
.b2b-hero,
.b2b-hero *,
.b2b-slider,
[class*="swiper"] {
    z-index: auto;
}

/* Mega menu phải cao nhất */
#mega-menu .nav-item-xiaomi {
    position: relative;
    overflow: visible !important;
}

#mega-menu .nav-item-xiaomi .mega-menu {
    z-index: 99999 !important;
}
