/* Mobile layout fixes */
@media (max-width: 640px) {
    /* Tránh header che nội dung khi cuộn trên điện thoại */
    .site-header {
        position: relative;
        top: auto;
    }

    .section-head {
        margin-bottom: 36px;
    }

    /* Căn 4 lợi ích thành lưới 2 cột đều nhau */
    .hero-trust {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px 20px;
        width: 100%;
        margin-top: 30px;
    }

    .hero-trust span {
        min-width: 0;
        align-items: center;
        line-height: 1.45;
    }

    /* Hệ sinh thái FBO: giữ cảm giác desktop nhưng ưu tiên không đè logo */
    .orbit-system {
        width: 100%;
        min-height: 455px;
        margin: 24px 0 0;
        transform: none;
        overflow: visible;
    }

    .orbit-core {
        width: 136px;
        height: 136px;
    }

    .orbit-core img {
        width: 104px;
    }

    .orbit-ring {
        width: min(300px, 84vw);
        height: 180px;
    }

    .orbit-ring::before {
        inset: 28px -24px;
    }

    .orbit-chip {
        min-width: 0;
        width: 122px;
        min-height: 44px;
        padding: 9px 8px;
        justify-content: center;
        text-align: center;
        font-size: 10px;
        line-height: 1.2;
        white-space: nowrap;
    }

    /* Hai ô giữa ngắn hơn để chừa khoảng trống rõ ràng cho logo */
    .oc6,
    .oc3 {
        width: 104px;
        min-width: 104px;
        min-height: 48px;
        padding: 8px 6px;
        gap: 5px;
        font-size: 9.5px;
        white-space: normal;
    }

    /* Hàng trên */
    .oc1 {
        top: 42px;
        left: 14px;
    }

    .oc2 {
        top: 42px;
        right: 14px;
    }

    /* Hàng giữa: đẩy ra sát hai mép để tuyệt đối không chạm logo */
    .oc6 {
        top: 50%;
        left: -10px;
        transform: translateY(-50%);
    }

    .oc3 {
        top: 50%;
        right: -10px;
        transform: translateY(-50%);
    }

    /* Hàng dưới */
    .oc5 {
        bottom: 42px;
        left: 14px;
    }

    .oc4 {
        bottom: 42px;
        right: 14px;
    }

    /* Đối tác: FBO - liên kết - Viettel nằm cùng một hàng và căn giữa */
    .partner-card {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        align-items: center;
        justify-items: center;
        padding: 24px 16px;
        gap: 10px;
    }

    .partner-brand {
        width: 100%;
        min-width: 0;
        min-height: 96px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .partner-brand img {
        width: auto;
        max-width: 128px;
        max-height: 62px;
        object-fit: contain;
    }

    .partner-link {
        font-size: 24px;
        margin: 0;
        transform: none;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .partner-viettel {
        font-size: 36px;
        line-height: 1;
        white-space: nowrap;
        text-align: center;
    }

    .partner-note {
        margin-top: 18px;
        line-height: 1.7;
    }

    /* Dành chỗ cho thanh điều hướng kiểu app ở cuối màn hình */
    body {
        padding-bottom: calc(82px + env(safe-area-inset-bottom));
    }

    .mobile-app-nav {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(8px + env(safe-area-inset-bottom));
        z-index: 1200;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: end;
        min-height: 68px;
        padding: 8px 6px 7px;
        border: 1px solid rgba(255, 255, 255, .10);
        border-radius: 22px;
        background: rgba(5, 17, 35, .94);
        box-shadow: 0 16px 40px rgba(0, 0, 0, .36);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    .mobile-app-nav__item {
        position: relative;
        min-width: 0;
        min-height: 52px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        color: #9ca9bc;
        text-decoration: none;
        font-size: 10px;
        font-weight: 700;
        line-height: 1;
        transition: color .2s ease, transform .2s ease;
    }

    .mobile-app-nav__item > i {
        font-size: 18px;
    }

    .mobile-app-nav__item.active {
        color: #f1c35c;
    }

    .mobile-app-nav__item--primary {
        padding-top: 2px;
    }

    .mobile-app-nav__primary-icon {
        width: 44px;
        height: 44px;
        margin-top: -22px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: linear-gradient(135deg, #f6d06d, #d9a43b);
        color: #071526;
        border: 5px solid #071526;
        box-shadow: 0 8px 22px rgba(218, 168, 67, .32);
        font-size: 17px;
    }

    .mobile-app-nav__item--primary.active .mobile-app-nav__primary-icon {
        box-shadow: 0 0 0 2px rgba(246, 208, 109, .30), 0 8px 22px rgba(218, 168, 67, .38);
    }

    /* Đẩy các nút Zalo/Gọi lên trên thanh bottom-nav để không bị che */
    .floating-contact {
        bottom: calc(96px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 390px) {
    .orbit-system {
        min-height: 430px;
    }

    .orbit-core {
        width: 116px;
        height: 116px;
    }

    .orbit-core img {
        width: 90px;
    }

    .orbit-ring {
        width: min(282px, 82vw);
        height: 170px;
    }

    .orbit-chip {
        width: 112px;
        min-height: 42px;
        padding: 8px 6px;
        font-size: 10px;
    }

    .oc6,
    .oc3 {
        width: 94px;
        min-width: 94px;
        min-height: 46px;
        padding: 7px 5px;
        font-size: 9px;
    }

    .oc1 { left: 8px; }
    .oc2 { right: 8px; }
    .oc5 { left: 8px; }
    .oc4 { right: 8px; }
    .oc6 { left: -8px; }
    .oc3 { right: -8px; }

    .partner-card {
        padding: 22px 12px;
        gap: 7px;
    }

    .partner-brand {
        min-height: 82px;
    }

    .partner-brand img {
        max-width: 105px;
        max-height: 54px;
    }

    .partner-link {
        font-size: 20px;
    }

    .partner-viettel {
        font-size: 31px;
    }

    .mobile-app-nav {
        left: 6px;
        right: 6px;
        border-radius: 19px;
        padding-left: 3px;
        padding-right: 3px;
    }

    .mobile-app-nav__item {
        font-size: 9px;
    }
}

/* Tất cả thiết bị: cuộn xuống thì ẩn header, cuộn lên thì hiện lại */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    transform: translateY(0);
    transition: transform .28s ease, box-shadow .28s ease;
    will-change: transform;
}

.site-header.header-hidden {
    transform: translateY(-105%);
}

.site-header.header-visible {
    transform: translateY(0);
}

body.mobile-menu-open .site-header {
    transform: translateY(0) !important;
}

/* Bottom nav chỉ xuất hiện trên điện thoại */
.mobile-app-nav {
    display: none;
}

@media (max-width: 640px) {
    .mobile-app-nav {
        display: grid;
    }
}
