/*
 * modern-ui.css — lớp tinh chỉnh giao diện chung cho frontend (nạp sau cùng trong layouts/default).
 * Mục tiêu: header dính, top bar gọn trên điện thoại, không tràn ngang, thẻ khoá học/blog đồng nhất,
 * bộ lọc khoá học thu gọn trên mobile, tab và phân trang cuộn được trên màn hình hẹp.
 */

:root {
    --mu-radius: 16px;
    --mu-line: #e8ebf3;
    --mu-ink: #141c2f;
    --mu-muted: #6b7385;
    --mu-primary: #2f57ef;
    --mu-grad: linear-gradient(90deg, #2f57ef 0%, #c664ff 100%);
    --mu-shadow: 0 10px 30px rgba(20, 28, 47, .08);
    --mu-header-h: 72px;
}

/* ---------- Nền tảng ---------- */
html,
body {
    overflow-x: clip; /* khác "hidden": không phá position: sticky */
}
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
html {
    scroll-padding-top: calc(var(--mu-header-h) + 12px);
}
img,
video,
iframe {
    max-width: 100%;
}
:focus-visible {
    outline: 2px solid var(--mu-primary);
    outline-offset: 2px;
}
@media (max-width: 575.98px) {
    .container,
    .container-fluid {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* ---------- Header dính, nền mờ ---------- */
.header-area {
    position: sticky;
    top: 0;
    z-index: 1020;
    background-color: transparent;
    border-bottom: 1px solid rgba(232, 235, 243, .8);
    transition: box-shadow .25s ease, padding .25s ease;
}
/* Nền mờ đặt ở lớp giả: backdrop-filter trên chính .header-area sẽ biến nó thành khung chứa
   của các phần tử position: fixed bên trong (menu offcanvas trên điện thoại) và cắt menu mất */
.header-area::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-color: rgba(255, 255, 255, .9);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    pointer-events: none;
}
.header-area:has(.offcanvas.show),
.header-area:has(.offcanvas.showing),
.header-area:has(.offcanvas.hiding) {
    z-index: 1046; /* trên lớp nền mờ của Bootstrap (1040) khi menu đang mở */
}
.header-area.mu-scrolled {
    box-shadow: 0 6px 24px rgba(20, 28, 47, .08);
}
.header-area .logo-image img {
    max-width: 170px;
}

/* ---------- Căn thẳng hàng các phần tử header (logo, menu, tìm kiếm, profile) ---------- */
.header-area > .container > .row {
    align-items: center;
    row-gap: 0;
}
.header-area .logo-image,
.header-area .logo-image > a {
    display: flex;
    align-items: center;
}
.header-area .logo-image img {
    display: block;
}
.header-area .header-menu {
    margin-top: 0 !important;
    padding-top: 0 !important;
    align-items: center;
}
.header-area .primary-end {
    min-height: 44px;
}
.header-area .primary-end .Userprofile,
.header-area .primary-end > .eBtn,
.header-area .primary-end .toggle-bar,
.header-area .floating-searchbar > button {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}
.header-area .us-btn {
    height: 44px;
    padding: 2px 10px 2px 2px !important;
    align-items: center;
}

/* ---------- Tìm kiếm trên điện thoại: nút rõ ràng + thanh tìm kiếm trải ngang dưới header ---------- */
@media (max-width: 575.98px) {
    .header-area .floating-searchbar {
        position: static;
    }
    .header-area .floating-searchbar > button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 12px;
        background: #f1f3f9 !important;
        color: var(--mu-ink) !important;
        font-size: 17px;
        transition: background .2s, color .2s;
    }
    .header-area .floating-searchbar > button i {
        color: inherit !important;
    }
    .header-area .floating-searchbar > button.is-active {
        background: var(--mu-grad) !important;
        color: #fff !important;
    }
    .header-area .floating-searchbar > form {
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        width: auto;
        margin: 0 !important;
        padding: 12px 16px 14px;
        gap: 8px;
        background: #fff;
        border-bottom: 1px solid var(--mu-line);
        box-shadow: 0 14px 28px rgba(20, 28, 47, .12);
        transform: translateY(-6px);
        transition: opacity .2s ease, transform .2s ease, visibility .2s;
    }
    .header-area .floating-searchbar > form.show {
        transform: none;
    }
    .header-area .floating-searchbar > form .form-control {
        flex: 1;
        min-width: 0;
        height: 46px;
        padding: 0 16px;
        border: 1px solid var(--mu-line);
        border-radius: 12px;
        background: #f6f7fb;
        color: var(--mu-ink);
        box-shadow: none;
    }
    .header-area .floating-searchbar > form .form-control:focus {
        border-color: var(--mu-primary);
        background: #fff;
        box-shadow: 0 0 0 3px rgba(47, 87, 239, .12);
    }
    .header-area .floating-searchbar > form > button {
        flex: none;
        width: 46px;
        height: 46px;
        margin: 0 !important;
        border-radius: 12px;
        background: var(--mu-grad) !important;
        color: #fff !important;
    }
    .header-area .floating-searchbar > form > button i {
        color: #fff !important;
    }
}

/* ---------- Top bar ---------- */
.sub-header .store-badge {
    width: auto !important;
    min-width: 116px;
    padding: 0 12px !important;
}
@media (max-width: 767.98px) {
    .sub-header {
        padding: 6px 0;
    }
    .sub-header > .container > .row {
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
    }
    .sub-header > .container > .row > [class*="col-"] {
        width: auto;
        flex: 0 1 auto;
    }
    /* Địa chỉ và nút tải app chiếm 2 dòng thừa trên điện thoại */
    .sub-header .tb-static,
    .sub-header .sub-header-left:not(.right-sub) li:nth-child(2),
    .sub-header .app-download-cta {
        display: none !important;
    }
    .sub-header .sub-header-left ul {
        justify-content: flex-start;
        margin: 0;
        gap: 10px;
    }
    .sub-header .right-sub ul {
        justify-content: flex-end;
        gap: 6px;
    }
    .sub-header .sub-header-left ul li a {
        font-size: 13px;
    }
}

/* ---------- Tiêu đề trang (breadcrumb hero) ---------- */
@media (max-width: 767.98px) {
    .bread-crumb h1,
    .bread-crumb .title,
    .eNtry-breadcum h3,
    .eNtry-breadcum .title {
        font-size: 28px !important;
        line-height: 1.25 !important;
    }
}

/* ---------- Thẻ khoá học (trang danh sách) ---------- */
.Ecard.eBar-card {
    border: 1px solid var(--mu-line);
    border-radius: var(--mu-radius);
    overflow: hidden;
    height: 100%;
    transition: transform .25s ease, box-shadow .25s ease;
}
.Ecard.eBar-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--mu-shadow);
}
.Ecard.eBar-card .courses-img {
    aspect-ratio: 16 / 9;
    overflow: hidden;
}
.Ecard.eBar-card .courses-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.Ecard.eBar-card .cText h4 {
    font-size: 18px;
    line-height: 1.3;
    font-weight: 700;
}
.Ecard.eBar-card .cText h4 del {
    font-size: 12px;
    font-weight: 500;
    opacity: .85;
}
.Ecard.eBar-card .entry-title h3 {
    font-size: 16px;
    line-height: 1.45;
    font-weight: 600;
    min-height: 2.9em;
}
.Ecard.eBar-card .entry-details > ul {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 8px;
}
.Ecard.eBar-card .entry-details > ul li {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-size: 14px;
}
.Ecard.eBar-card .entry-details > ul li img {
    width: 26px;
    height: 26px;
}
.Ecard.eBar-card .creator img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}
.list-courses > [class*="col-"] {
    display: flex;
    flex-direction: column;
}
.list-courses > [class*="col-"] > .Ecard {
    flex: 1;
}

/* ---------- Bộ lọc khoá học: thu gọn trên điện thoại ---------- */
.course-filter .cf-toggle {
    display: none;
}
@media (max-width: 767.98px) {
    .course-filter {
        margin-bottom: 24px;
    }
    .course-filter .cf-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        margin-left: auto;
        padding: 6px 12px;
        border: 1px solid var(--mu-line);
        border-radius: 999px;
        background: #fff;
        color: var(--mu-ink);
        font-size: 13px;
        font-weight: 600;
    }
    .course-filter .cf-toggle i {
        transition: transform .2s;
    }
    .course-filter.is-open .cf-toggle i {
        transform: rotate(180deg);
    }
    .course-filter:not(.is-open) .cf-section {
        display: none;
    }
    .course-filter .cf-header {
        gap: 8px;
    }
    .course-filter .cf-toggle {
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
        font-size: 0; /* chỉ hiện mũi tên, chữ "Filter" đã có ở tiêu đề */
    }
    .course-filter .cf-toggle i {
        font-size: 14px;
    }

}

/* ---------- Phân trang: xuống dòng thay vì tràn ---------- */
.pagination {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}
@media (max-width: 575.98px) {
    .pagination .page-link {
        min-width: 36px;
        height: 36px;
        padding: 0 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
    }
}

/* ---------- Tab chi tiết khoá học: cuộn ngang trên mobile ---------- */
@media (max-width: 767.98px) {
    .nav.nav-bordered {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .nav.nav-bordered::-webkit-scrollbar {
        display: none;
    }
    .nav.nav-bordered .nav-item {
        flex: none;
    }
    .nav.nav-bordered .nav-link {
        white-space: nowrap;
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* ---------- Thẻ blog ---------- */
.b-card .card-head {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: linear-gradient(135deg, #eef1ff, #f6edff);
}
.b-card .card-head img {
    width: 100%;
    height: 100% !important;
    object-fit: cover;
}

/* ---------- Biểu mẫu: chữ ≥16px để iOS không tự phóng to ---------- */
@media (max-width: 767.98px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ---------- Trang chủ (.ady-home) trên điện thoại ---------- */
@media (max-width: 767.98px) {
    .ady-home .section-padding {
        padding-top: 52px;
    }
    /* Tiêu đề section + nút "Xem tất cả" nằm cùng hàng */
    .ady-home .res-control {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: flex-end !important;
        justify-content: space-between !important;
        gap: 12px;
    }
    .ady-home .res-control > :last-child {
        align-self: flex-end;
        margin-bottom: 4px;
    }
    .ady-home .res-control .section-title {
        min-width: 0;
        text-align: left !important;
    }
    .ady-home .res-control .eBtn {
        flex: none;
        padding: 8px 14px;
        font-size: 13px;
        line-height: 1.3;
        border-radius: 999px;
        white-space: nowrap;
    }
    .ady-home .title {
        font-size: 24px;
        line-height: 1.3;
    }
    /* Danh mục: lưới 2 cột gọn thay vì 13 thẻ xếp chồng */
    .ady-home .category-wrapper .row.justify-content-center > [class*="col-"] {
        width: 50%;
        flex: 0 0 50%;
        padding-left: 6px;
        padding-right: 6px;
        margin-bottom: 0 !important;
    }
    .ady-home .category-wrapper .row.justify-content-center {
        margin-left: -6px;
        margin-right: -6px;
        row-gap: 12px;
    }
    .ady-home .category-wrapper .single-category {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
        height: 100%;
        padding: 14px;
        margin-bottom: 0 !important;
    }
    .ady-home .category-wrapper .single-category h4 {
        font-size: 14px;
        line-height: 1.35;
    }
    .ady-home .category-wrapper .single-category p {
        font-size: 12px;
    }
    .ady-home .single-category-arrow {
        display: none !important;
    }
    /* Thẻ "Tại sao chọn" gọn hơn */
    .ady-home .ps-border + .ps-border {
        margin-top: 0;
    }
    .ady-home .performance-wrapper .ps-border {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
    .ady-home .ps-single-wrap {
        margin-bottom: 12px !important;
    }
}
@media (max-width: 380px) {
    .ady-hero h1 {
        font-size: 30px;
    }
}

/* ---------- Trợ lý AI: không che nội dung trên điện thoại ---------- */
@media (max-width: 575.98px) {
    /* Bong bóng chào + linh vật che nội dung; nút tròn trợ lý vẫn luôn hiển thị */
    .aia-greet {
        display: none !important;
    }
}

/* ---------- Đăng nhập / đăng ký: form lên trước, ảnh minh hoạ nhỏ lại ---------- */
@media (max-width: 767.98px) {
    .login-area {
        padding-top: 24px !important;
    }
    .login-area .login-img {
        text-align: center;
        margin-bottom: 8px;
    }
    .login-area .login-img img {
        display: block;
        max-height: 180px;
        width: auto;
        margin: 0 auto;
    }
}

/* ---------- Footer ---------- */
.footer-area .footer-content img {
    height: 40px;
}
.header-area .logo-image img {
    height: 40px;
    object-fit: contain !important;
    border-radius: 0 !important;
}

/* Tablet: thương hiệu bên trái, liên hệ bên phải; 4 cột link chia đều */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .footer-area .footer-content {
        display: grid;
        grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
        column-gap: 40px;
        align-items: start;
    }
    .footer-area .footer-content > img,
    .footer-area .footer-content > .description {
        grid-column: 1;
    }
    .footer-area .footer-content > .footer-contact,
    .footer-area .footer-content > .f-socials {
        grid-column: 2;
    }
    .footer-area .footer-content > .footer-contact {
        grid-row: 1 / span 2;
        margin: 0;
    }
}

/* Điện thoại: các nhóm link thành accordion, bản tin và nút tải app gọn lại */
@media (max-width: 767.98px) {
    .footer-area {
        padding-top: 48px !important;
    }
    .footer-area > .container > .row.gy-5 {
        --bs-gutter-y: 0;
    }
    .footer-area .footer-content {
        padding-bottom: 24px;
        margin-bottom: 8px;
        border-bottom: 1px solid rgba(255, 255, 255, .08);
    }
    .footer-area .footer-content > img {
        margin-bottom: 14px;
    }
    .footer-area .footer-content .description {
        font-size: 14px;
        margin-bottom: 16px;
    }
    .footer-area .footer-contact li {
        margin-bottom: 10px;
    }
    .footer-area .footer-contact a,
    .footer-area .footer-contact span {
        word-break: break-word;
    }

    /* 4 nhóm link: mỗi nhóm một hàng, bấm tiêu đề để mở */
    .footer-area > .container > .row.gy-5 > .col-6 {
        width: 100%;
        flex: 0 0 100%;
    }
    .footer-area .footer-widget:not(.newslater-bottom) {
        border-bottom: 1px solid rgba(255, 255, 255, .08);
    }
    .footer-area .footer-widget:not(.newslater-bottom) > h4 {
        position: relative;
        margin: 0 !important;
        padding: 15px 40px 15px 0;
        font-size: 15px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }
    .footer-area .footer-widget:not(.newslater-bottom) > h4::after {
        content: "\f078";
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        position: absolute;
        right: 0;
        top: 50%;
        width: 28px;
        height: 28px;
        line-height: 28px;
        text-align: center;
        border-radius: 8px;
        background: rgba(255, 255, 255, .08);
        font-size: 11px;
        transform: translateY(-50%);
        transition: transform .25s ease;
    }
    .footer-area .footer-widget.is-open > h4::after {
        transform: translateY(-50%) rotate(180deg);
    }
    .footer-area .footer-widget:not(.newslater-bottom) > ul {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 2px 16px;
        max-height: 0;
        overflow: hidden;
        margin: 0;
        transition: max-height .3s ease, padding .3s ease;
    }
    .footer-area .footer-widget.is-open > ul {
        max-height: 600px;
        padding-bottom: 14px;
    }
    .footer-area .footer-widget:not(.newslater-bottom) > ul li {
        margin-bottom: 0 !important;
    }
    .footer-area .footer-widget:not(.newslater-bottom) > ul li a {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 0;
        font-size: 14px;
        line-height: 1.35;
    }

    /* Bản tin */
    .footer-area .footer-subscribe {
        margin-top: 28px !important;
    }
    .footer-area .footer-subscribe .newslater-bottom {
        display: block !important;
        padding: 20px 18px !important;
    }
    .footer-area .newslater-bottom > h4 {
        margin-bottom: 4px;
    }
    .footer-area .newslater-bottom > p {
        margin-bottom: 14px !important;
    }
    .footer-area .newslater-form {
        display: flex;
    }
    .footer-area .newslater-form .form-control {
        min-width: 0;
        flex: 1;
    }
    .footer-area .newslater-form .eBtn {
        flex: none;
    }
    .footer-area .download-app {
        display: block !important;
        margin-top: 20px !important;
        padding-top: 18px;
        border-top: 1px solid rgba(255, 255, 255, .08);
    }
    .footer-area .download-app h4 {
        margin-bottom: 10px !important;
    }
    .footer-area .download-app .d-flex {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .footer-area .app-badge {
        min-width: 0 !important;
        padding: 0 10px !important;
        gap: 8px !important;
    }
    .footer-area .app-badge span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 13px;
    }

    /* Dòng cuối */
    .footer-area .footer-bottom {
        margin-top: 28px;
        padding: 18px 0 calc(18px + env(safe-area-inset-bottom));
    }
    .footer-area .footer-policy {
        flex-wrap: wrap;
        gap: 6px 18px;
    }
    .footer-area .copyright-text p {
        font-size: 13px;
        margin: 0;
    }
    /* Chừa chỗ cho nút tròn trợ lý AI để không che dòng bản quyền */
    .footer-area .footer-bottom {
        padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important;
    }
    .footer-area .footer-subscribe {
        margin-top: 24px !important;
    }
    .footer-area .footer-content .f-socials {
        margin-bottom: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .Ecard.eBar-card,
    .header-area {
        transition: none;
    }
    .Ecard.eBar-card:hover {
        transform: none;
    }
}
